From 44624fdb4829c161cc54a0b4fcd0dbba663ba6d8 Mon Sep 17 00:00:00 2001 From: Wangjunqi123 Date: Fri, 7 Jun 2024 14:30:16 +0800 Subject: [PATCH] elk/elasticclient: add elastic client --- elk/elasticClient/client.go | 50 +- elk/go.mod | 1 + elk/go.sum | 2 + elk/main.go | 6 + .../elastic/go-elasticsearch/v7/.codecov.yml | 8 + .../elastic/go-elasticsearch/v7/.dockerignore | 2 + .../elastic/go-elasticsearch/v7/.gitignore | 5 + .../elastic/go-elasticsearch/v7/CHANGELOG.md | 294 ++++++ .../elastic/go-elasticsearch/v7/LICENSE | 201 ++++ .../elastic/go-elasticsearch/v7/Makefile | 480 +++++++++ .../elastic/go-elasticsearch/v7/README.md | 379 +++++++ .../elastic/go-elasticsearch/v7/doc.go | 67 ++ .../go-elasticsearch/v7/elasticsearch.go | 465 ++++++++ .../go-elasticsearch/v7/esapi/api._.go | 989 ++++++++++++++++++ .../go-elasticsearch/v7/esapi/api.bulk.go | 334 ++++++ .../v7/esapi/api.cat.aliases.go | 288 +++++ .../v7/esapi/api.cat.allocation.go | 301 ++++++ .../v7/esapi/api.cat.count.go | 264 +++++ .../v7/esapi/api.cat.fielddata.go | 280 +++++ .../v7/esapi/api.cat.health.go | 272 +++++ .../go-elasticsearch/v7/esapi/api.cat.help.go | 212 ++++ .../v7/esapi/api.cat.indices.go | 361 +++++++ .../v7/esapi/api.cat.master.go | 273 +++++ .../v7/esapi/api.cat.nodeattrs.go | 273 +++++ .../v7/esapi/api.cat.nodes.go | 321 ++++++ .../v7/esapi/api.cat.pending_tasks.go | 285 +++++ .../v7/esapi/api.cat.plugins.go | 285 +++++ .../v7/esapi/api.cat.recovery.go | 316 ++++++ .../v7/esapi/api.cat.repositories.go | 273 +++++ .../v7/esapi/api.cat.segments.go | 276 +++++ .../v7/esapi/api.cat.shards.go | 313 ++++++ .../v7/esapi/api.cat.snapshots.go | 301 ++++++ .../v7/esapi/api.cat.tasks.go | 308 ++++++ .../v7/esapi/api.cat.templates.go | 289 +++++ .../v7/esapi/api.cat.thread_pool.go | 302 ++++++ .../v7/esapi/api.clear_scroll.go | 216 ++++ .../esapi/api.cluster.allocation_explain.go | 226 ++++ .../api.cluster.delete_component_template.go | 217 ++++ ...cluster.delete_voting_config_exclusions.go | 200 ++++ .../api.cluster.exists_component_template.go | 218 ++++ .../api.cluster.get_component_template.go | 227 ++++ .../v7/esapi/api.cluster.get_settings.go | 237 +++++ .../v7/esapi/api.cluster.health.go | 337 ++++++ .../v7/esapi/api.cluster.pending_tasks.go | 214 ++++ ...i.cluster.post_voting_config_exclusions.go | 224 ++++ .../api.cluster.put_component_template.go | 237 +++++ .../v7/esapi/api.cluster.put_settings.go | 232 ++++ .../v7/esapi/api.cluster.remote_info.go | 186 ++++ .../v7/esapi/api.cluster.reroute.go | 275 +++++ .../v7/esapi/api.cluster.state.go | 314 ++++++ .../v7/esapi/api.cluster.stats.go | 231 ++++ .../go-elasticsearch/v7/esapi/api.count.go | 396 +++++++ .../go-elasticsearch/v7/esapi/api.create.go | 306 ++++++ ....dangling_indices.delete_dangling_index.go | 230 ++++ ....dangling_indices.import_dangling_index.go | 230 ++++ ....dangling_indices.list_dangling_indices.go | 186 ++++ .../go-elasticsearch/v7/esapi/api.delete.go | 307 ++++++ .../v7/esapi/api.delete_by_query.go | 579 ++++++++++ .../esapi/api.delete_by_query_rethrottle.go | 207 ++++ .../v7/esapi/api.delete_script.go | 217 ++++ .../go-elasticsearch/v7/esapi/api.exists.go | 330 ++++++ .../v7/esapi/api.exists_source.go | 316 ++++++ .../go-elasticsearch/v7/esapi/api.explain.go | 370 +++++++ .../v7/esapi/api.features.get_features.go | 200 ++++ .../v7/esapi/api.features.reset_features.go | 188 ++++ .../v7/esapi/api.field_caps.go | 276 +++++ .../v7/esapi/api.fleet.global_checkpoints.go | 244 +++++ .../v7/esapi/api.fleet.msearch.go | 209 ++++ .../v7/esapi/api.fleet.search.go | 246 +++++ .../go-elasticsearch/v7/esapi/api.get.go | 330 ++++++ .../v7/esapi/api.get_script.go | 205 ++++ .../v7/esapi/api.get_script_context.go | 186 ++++ .../v7/esapi/api.get_script_languages.go | 186 ++++ .../v7/esapi/api.get_source.go | 320 ++++++ .../go-elasticsearch/v7/esapi/api.index.go | 363 +++++++ .../v7/esapi/api.indices.add_block.go | 263 +++++ .../v7/esapi/api.indices.analyze.go | 218 ++++ .../v7/esapi/api.indices.clear_cache.go | 292 ++++++ .../v7/esapi/api.indices.clone.go | 247 +++++ .../v7/esapi/api.indices.close.go | 271 +++++ .../v7/esapi/api.indices.create.go | 254 +++++ .../v7/esapi/api.indices.delete.go | 257 +++++ .../v7/esapi/api.indices.delete_alias.go | 229 ++++ .../api.indices.delete_index_template.go | 217 ++++ .../v7/esapi/api.indices.delete_template.go | 217 ++++ .../v7/esapi/api.indices.disk_usage.go | 255 +++++ .../v7/esapi/api.indices.exists.go | 268 +++++ .../v7/esapi/api.indices.exists_alias.go | 259 +++++ .../api.indices.exists_index_template.go | 230 ++++ .../v7/esapi/api.indices.exists_template.go | 235 +++++ .../v7/esapi/api.indices.exists_type.go | 259 +++++ .../v7/esapi/api.indices.field_usage_stats.go | 243 +++++ .../v7/esapi/api.indices.flush.go | 262 +++++ .../v7/esapi/api.indices.flush_synced.go | 240 +++++ .../v7/esapi/api.indices.forcemerge.go | 274 +++++ .../v7/esapi/api.indices.get.go | 293 ++++++ .../v7/esapi/api.indices.get_alias.go | 263 +++++ .../v7/esapi/api.indices.get_field_mapping.go | 297 ++++++ .../esapi/api.indices.get_index_template.go | 239 +++++ .../v7/esapi/api.indices.get_mapping.go | 287 +++++ .../v7/esapi/api.indices.get_settings.go | 300 ++++++ .../v7/esapi/api.indices.get_template.go | 251 +++++ .../v7/esapi/api.indices.get_upgrade.go | 238 +++++ .../esapi/api.indices.modify_data_stream.go | 193 ++++ .../v7/esapi/api.indices.open.go | 271 +++++ .../v7/esapi/api.indices.put_alias.go | 240 +++++ .../esapi/api.indices.put_index_template.go | 237 +++++ .../v7/esapi/api.indices.put_mapping.go | 306 ++++++ .../v7/esapi/api.indices.put_settings.go | 294 ++++++ .../v7/esapi/api.indices.put_template.go | 249 +++++ .../v7/esapi/api.indices.recovery.go | 226 ++++ .../v7/esapi/api.indices.refresh.go | 238 +++++ .../v7/esapi/api.indices.resolve_index.go | 211 ++++ .../v7/esapi/api.indices.rollover.go | 281 +++++ .../v7/esapi/api.indices.segments.go | 250 +++++ .../v7/esapi/api.indices.shard_stores.go | 250 +++++ .../v7/esapi/api.indices.shrink.go | 260 +++++ .../api.indices.simulate_index_template.go | 246 +++++ .../v7/esapi/api.indices.simulate_template.go | 255 +++++ .../v7/esapi/api.indices.split.go | 260 +++++ .../v7/esapi/api.indices.stats.go | 335 ++++++ .../v7/esapi/api.indices.update_aliases.go | 219 ++++ .../v7/esapi/api.indices.upgrade.go | 262 +++++ .../v7/esapi/api.indices.validate_query.go | 374 +++++++ .../go-elasticsearch/v7/esapi/api.info.go | 179 ++++ .../v7/esapi/api.ingest.delete_pipeline.go | 219 ++++ .../v7/esapi/api.ingest.geo_ip_stats.go | 186 ++++ .../v7/esapi/api.ingest.get_pipeline.go | 229 ++++ .../v7/esapi/api.ingest.processor_grok.go | 186 ++++ .../v7/esapi/api.ingest.put_pipeline.go | 239 +++++ .../v7/esapi/api.ingest.simulate.go | 225 ++++ .../go-elasticsearch/v7/esapi/api.mget.go | 317 ++++++ .../go-elasticsearch/v7/esapi/api.msearch.go | 305 ++++++ .../v7/esapi/api.msearch_template.go | 283 +++++ .../v7/esapi/api.mtermvectors.go | 372 +++++++ .../esapi/api.nodes.clear_metering_archive.go | 209 ++++ ...des.clear_repositories_metering_archive.go | 207 ++++ .../v7/esapi/api.nodes.get_metering_info.go | 205 ++++ ...pi.nodes.get_repositories_metering_info.go | 200 ++++ .../v7/esapi/api.nodes.hot_threads.go | 291 ++++++ .../v7/esapi/api.nodes.info.go | 239 +++++ .../esapi/api.nodes.reload_secure_settings.go | 230 ++++ .../v7/esapi/api.nodes.stats.go | 337 ++++++ .../v7/esapi/api.nodes.usage.go | 228 ++++ .../go-elasticsearch/v7/esapi/api.ping.go | 186 ++++ .../v7/esapi/api.put_script.go | 241 +++++ .../v7/esapi/api.rank_eval.go | 257 +++++ .../go-elasticsearch/v7/esapi/api.reindex.go | 295 ++++++ .../v7/esapi/api.reindex_rethrottle.go | 207 ++++ .../v7/esapi/api.render_search_template.go | 216 ++++ .../v7/esapi/api.scripts_painless_execute.go | 202 ++++ .../go-elasticsearch/v7/esapi/api.scroll.go | 240 +++++ .../go-elasticsearch/v7/esapi/api.search.go | 746 +++++++++++++ .../v7/esapi/api.search_mvt.go | 309 ++++++ .../v7/esapi/api.search_shards.go | 274 +++++ .../v7/esapi/api.search_template.go | 380 +++++++ .../v7/esapi/api.shutdown.delete_node.go | 193 ++++ .../v7/esapi/api.shutdown.get_node.go | 202 ++++ .../v7/esapi/api.shutdown.put_node.go | 200 ++++ .../esapi/api.snapshot.cleanup_repository.go | 219 ++++ .../v7/esapi/api.snapshot.clone.go | 220 ++++ .../v7/esapi/api.snapshot.create.go | 235 +++++ .../esapi/api.snapshot.create_repository.go | 237 +++++ .../v7/esapi/api.snapshot.delete.go | 208 ++++ .../esapi/api.snapshot.delete_repository.go | 222 ++++ .../v7/esapi/api.snapshot.get.go | 347 ++++++ .../v7/esapi/api.snapshot.get_repository.go | 227 ++++ .../esapi/api.snapshot.repository_analyze.go | 328 ++++++ .../v7/esapi/api.snapshot.restore.go | 237 +++++ .../v7/esapi/api.snapshot.status.go | 241 +++++ .../esapi/api.snapshot.verify_repository.go | 219 ++++ .../v7/esapi/api.tasks.cancel.go | 254 +++++ .../v7/esapi/api.tasks.get.go | 220 ++++ .../v7/esapi/api.tasks.list.go | 275 +++++ .../v7/esapi/api.terms_enum.go | 210 ++++ .../v7/esapi/api.termvectors.go | 367 +++++++ .../go-elasticsearch/v7/esapi/api.update.go | 364 +++++++ .../v7/esapi/api.update_by_query.go | 611 +++++++++++ .../esapi/api.update_by_query_rethrottle.go | 207 ++++ .../v7/esapi/api.xpack.async_search.delete.go | 191 ++++ .../v7/esapi/api.xpack.async_search.get.go | 230 ++++ .../v7/esapi/api.xpack.async_search.status.go | 193 ++++ .../v7/esapi/api.xpack.async_search.submit.go | 709 +++++++++++++ ...k.autoscaling.delete_autoscaling_policy.go | 193 ++++ ...ck.autoscaling.get_autoscaling_capacity.go | 186 ++++ ...ck.autoscaling.get_autoscaling_decision.go | 198 ++++ ...pack.autoscaling.get_autoscaling_policy.go | 193 ++++ ...pack.autoscaling.put_autoscaling_policy.go | 200 ++++ .../api.xpack.cat.ml_data_frame_analytics.go | 304 ++++++ .../v7/esapi/api.xpack.cat.ml_datafeeds.go | 302 ++++++ .../v7/esapi/api.xpack.cat.ml_jobs.go | 314 ++++++ .../esapi/api.xpack.cat.ml_trained_models.go | 326 ++++++ .../v7/esapi/api.xpack.cat.transforms.go | 312 ++++++ ...pi.xpack.ccr.delete_auto_follow_pattern.go | 193 ++++ .../v7/esapi/api.xpack.ccr.follow.go | 213 ++++ .../v7/esapi/api.xpack.ccr.follow_info.go | 198 ++++ .../v7/esapi/api.xpack.ccr.follow_stats.go | 198 ++++ .../v7/esapi/api.xpack.ccr.forget_follower.go | 200 ++++ .../api.xpack.ccr.get_auto_follow_pattern.go | 202 ++++ ...api.xpack.ccr.pause_auto_follow_pattern.go | 195 ++++ .../v7/esapi/api.xpack.ccr.pause_follow.go | 193 ++++ .../api.xpack.ccr.put_auto_follow_pattern.go | 200 ++++ ...pi.xpack.ccr.resume_auto_follow_pattern.go | 195 ++++ .../v7/esapi/api.xpack.ccr.resume_follow.go | 207 ++++ .../v7/esapi/api.xpack.ccr.stats.go | 186 ++++ .../v7/esapi/api.xpack.ccr.unfollow.go | 193 ++++ .../v7/esapi/api.xpack.close_point_in_time.go | 200 ++++ ...e_transform_deprecated.delete_transform.go | 209 ++++ ...rame_transform_deprecated.get_transform.go | 254 +++++ ...ransform_deprecated.get_transform_stats.go | 235 +++++ ..._transform_deprecated.preview_transform.go | 195 ++++ ...rame_transform_deprecated.put_transform.go | 216 ++++ ...me_transform_deprecated.start_transform.go | 211 ++++ ...ame_transform_deprecated.stop_transform.go | 236 +++++ ...e_transform_deprecated.update_transform.go | 218 ++++ .../esapi/api.xpack.enrich.delete_policy.go | 193 ++++ .../esapi/api.xpack.enrich.execute_policy.go | 209 ++++ .../v7/esapi/api.xpack.enrich.get_policy.go | 202 ++++ .../v7/esapi/api.xpack.enrich.put_policy.go | 200 ++++ .../v7/esapi/api.xpack.enrich.stats.go | 186 ++++ .../v7/esapi/api.xpack.eql.delete.go | 193 ++++ .../v7/esapi/api.xpack.eql.get.go | 219 ++++ .../v7/esapi/api.xpack.eql.get_status.go | 195 ++++ .../v7/esapi/api.xpack.eql.search.go | 239 +++++ .../v7/esapi/api.xpack.graph.explore.go | 250 +++++ .../esapi/api.xpack.ilm.delete_lifecycle.go | 193 ++++ .../esapi/api.xpack.ilm.explain_lifecycle.go | 219 ++++ .../v7/esapi/api.xpack.ilm.get_lifecycle.go | 202 ++++ .../v7/esapi/api.xpack.ilm.get_status.go | 186 ++++ .../api.xpack.ilm.migrate_to_data_tiers.go | 214 ++++ .../v7/esapi/api.xpack.ilm.move_to_step.go | 207 ++++ .../v7/esapi/api.xpack.ilm.put_lifecycle.go | 207 ++++ .../v7/esapi/api.xpack.ilm.remove_policy.go | 193 ++++ .../v7/esapi/api.xpack.ilm.retry.go | 193 ++++ .../v7/esapi/api.xpack.ilm.start.go | 186 ++++ .../v7/esapi/api.xpack.ilm.stop.go | 186 ++++ .../api.xpack.indices.create_data_stream.go | 191 ++++ .../api.xpack.indices.data_streams_stats.go | 202 ++++ .../api.xpack.indices.delete_data_stream.go | 209 ++++ .../v7/esapi/api.xpack.indices.freeze.go | 266 +++++ .../api.xpack.indices.get_data_stream.go | 213 ++++ ...pi.xpack.indices.migrate_to_data_stream.go | 193 ++++ .../api.xpack.indices.promote_data_stream.go | 193 ++++ ...i.xpack.indices.reload_search_analyzers.go | 234 +++++ .../v7/esapi/api.xpack.indices.unfreeze.go | 266 +++++ .../v7/esapi/api.xpack.license.delete.go | 186 ++++ .../v7/esapi/api.xpack.license.get.go | 212 ++++ .../api.xpack.license.get_basic_status.go | 186 ++++ .../api.xpack.license.get_trial_status.go | 186 ++++ .../v7/esapi/api.xpack.license.post.go | 214 ++++ .../api.xpack.license.post_start_basic.go | 200 ++++ .../api.xpack.license.post_start_trial.go | 212 ++++ .../api.xpack.logstash.delete_pipeline.go | 193 ++++ .../esapi/api.xpack.logstash.get_pipeline.go | 193 ++++ .../esapi/api.xpack.logstash.put_pipeline.go | 200 ++++ .../esapi/api.xpack.migration.deprecations.go | 202 ++++ ...ck.migration.get_feature_upgrade_status.go | 186 ++++ ...pi.xpack.migration.post_feature_upgrade.go | 186 ++++ .../v7/esapi/api.xpack.ml.close_job.go | 260 +++++ .../v7/esapi/api.xpack.ml.delete_calendar.go | 193 ++++ .../api.xpack.ml.delete_calendar_event.go | 198 ++++ .../esapi/api.xpack.ml.delete_calendar_job.go | 198 ++++ ...pi.xpack.ml.delete_data_frame_analytics.go | 222 ++++ .../v7/esapi/api.xpack.ml.delete_datafeed.go | 207 ++++ .../esapi/api.xpack.ml.delete_expired_data.go | 243 +++++ .../v7/esapi/api.xpack.ml.delete_filter.go | 193 ++++ .../v7/esapi/api.xpack.ml.delete_forecast.go | 234 +++++ .../v7/esapi/api.xpack.ml.delete_job.go | 219 ++++ .../api.xpack.ml.delete_model_snapshot.go | 198 ++++ .../api.xpack.ml.delete_trained_model.go | 193 ++++ ...api.xpack.ml.delete_trained_model_alias.go | 198 ++++ .../api.xpack.ml.estimate_model_memory.go | 193 ++++ .../esapi/api.xpack.ml.evaluate_data_frame.go | 193 ++++ ...i.xpack.ml.explain_data_frame_analytics.go | 220 ++++ .../esapi/api.xpack.ml.find_file_structure.go | 366 +++++++ .../v7/esapi/api.xpack.ml.flush_job.go | 271 +++++ .../v7/esapi/api.xpack.ml.forecast.go | 247 +++++ .../v7/esapi/api.xpack.ml.get_buckets.go | 334 ++++++ .../esapi/api.xpack.ml.get_calendar_events.go | 258 +++++ .../v7/esapi/api.xpack.ml.get_calendars.go | 242 +++++ .../v7/esapi/api.xpack.ml.get_categories.go | 263 +++++ .../api.xpack.ml.get_data_frame_analytics.go | 254 +++++ ...xpack.ml.get_data_frame_analytics_stats.go | 256 +++++ .../esapi/api.xpack.ml.get_datafeed_stats.go | 230 ++++ .../v7/esapi/api.xpack.ml.get_datafeeds.go | 240 +++++ .../v7/esapi/api.xpack.ml.get_filters.go | 228 ++++ .../v7/esapi/api.xpack.ml.get_influencers.go | 310 ++++++ .../v7/esapi/api.xpack.ml.get_job_stats.go | 230 ++++ .../v7/esapi/api.xpack.ml.get_jobs.go | 240 +++++ ...ack.ml.get_model_snapshot_upgrade_stats.go | 216 ++++ .../esapi/api.xpack.ml.get_model_snapshots.go | 296 ++++++ .../esapi/api.xpack.ml.get_overall_buckets.go | 310 ++++++ .../v7/esapi/api.xpack.ml.get_records.go | 310 ++++++ .../esapi/api.xpack.ml.get_trained_models.go | 300 ++++++ .../api.xpack.ml.get_trained_models_stats.go | 242 +++++ .../v7/esapi/api.xpack.ml.info.go | 186 ++++ .../v7/esapi/api.xpack.ml.open_job.go | 209 ++++ .../api.xpack.ml.post_calendar_events.go | 202 ++++ .../v7/esapi/api.xpack.ml.post_data.go | 227 ++++ ...i.xpack.ml.preview_data_frame_analytics.go | 220 ++++ .../v7/esapi/api.xpack.ml.preview_datafeed.go | 218 ++++ .../v7/esapi/api.xpack.ml.put_calendar.go | 207 ++++ .../v7/esapi/api.xpack.ml.put_calendar_job.go | 198 ++++ .../api.xpack.ml.put_data_frame_analytics.go | 202 ++++ .../v7/esapi/api.xpack.ml.put_datafeed.go | 250 +++++ .../v7/esapi/api.xpack.ml.put_filter.go | 200 ++++ .../v7/esapi/api.xpack.ml.put_job.go | 250 +++++ .../esapi/api.xpack.ml.put_trained_model.go | 214 ++++ .../api.xpack.ml.put_trained_model_alias.go | 212 ++++ .../v7/esapi/api.xpack.ml.reset_job.go | 209 ++++ .../api.xpack.ml.revert_model_snapshot.go | 228 ++++ .../v7/esapi/api.xpack.ml.set_upgrade_mode.go | 213 ++++ ...api.xpack.ml.start_data_frame_analytics.go | 225 ++++ .../v7/esapi/api.xpack.ml.start_datafeed.go | 247 +++++ .../api.xpack.ml.stop_data_frame_analytics.go | 250 +++++ .../v7/esapi/api.xpack.ml.stop_datafeed.go | 260 +++++ ...pi.xpack.ml.update_data_frame_analytics.go | 204 ++++ .../v7/esapi/api.xpack.ml.update_datafeed.go | 252 +++++ .../v7/esapi/api.xpack.ml.update_filter.go | 202 ++++ .../v7/esapi/api.xpack.ml.update_job.go | 202 ++++ .../api.xpack.ml.update_model_snapshot.go | 207 ++++ .../api.xpack.ml.upgrade_job_snapshot.go | 227 ++++ .../v7/esapi/api.xpack.ml.validate.go | 193 ++++ .../esapi/api.xpack.ml.validate_detector.go | 193 ++++ .../v7/esapi/api.xpack.monitoring.bulk.go | 246 +++++ .../v7/esapi/api.xpack.open_point_in_time.go | 258 +++++ .../v7/esapi/api.xpack.rollup.delete_job.go | 195 ++++ .../v7/esapi/api.xpack.rollup.get_jobs.go | 204 ++++ .../esapi/api.xpack.rollup.get_rollup_caps.go | 204 ++++ .../api.xpack.rollup.get_rollup_index_caps.go | 195 ++++ .../v7/esapi/api.xpack.rollup.put_job.go | 202 ++++ .../v7/esapi/api.xpack.rollup.rollup.go | 204 ++++ .../esapi/api.xpack.rollup.rollup_search.go | 243 +++++ .../v7/esapi/api.xpack.rollup.start_job.go | 197 ++++ .../v7/esapi/api.xpack.rollup.stop_job.go | 224 ++++ ....xpack.searchable_snapshots.cache_stats.go | 206 ++++ ....xpack.searchable_snapshots.clear_cache.go | 248 +++++ .../api.xpack.searchable_snapshots.mount.go | 242 +++++ ...k.searchable_snapshots.repository_stats.go | 195 ++++ .../api.xpack.searchable_snapshots.stats.go | 215 ++++ .../esapi/api.xpack.security.authenticate.go | 186 ++++ .../api.xpack.security.change_password.go | 224 ++++ .../api.xpack.security.clear_api_key_cache.go | 200 ++++ ....xpack.security.clear_cached_privileges.go | 200 ++++ .../api.xpack.security.clear_cached_realms.go | 213 ++++ .../api.xpack.security.clear_cached_roles.go | 200 ++++ ...ck.security.clear_cached_service_tokens.go | 210 ++++ .../api.xpack.security.create_api_key.go | 206 ++++ ...api.xpack.security.create_service_token.go | 225 ++++ .../api.xpack.security.delete_privileges.go | 209 ++++ .../esapi/api.xpack.security.delete_role.go | 206 ++++ .../api.xpack.security.delete_role_mapping.go | 206 ++++ ...api.xpack.security.delete_service_token.go | 216 ++++ .../esapi/api.xpack.security.delete_user.go | 206 ++++ .../esapi/api.xpack.security.disable_user.go | 208 ++++ .../esapi/api.xpack.security.enable_user.go | 208 ++++ .../esapi/api.xpack.security.get_api_key.go | 248 +++++ ...i.xpack.security.get_builtin_privileges.go | 186 ++++ .../api.xpack.security.get_privileges.go | 214 ++++ .../v7/esapi/api.xpack.security.get_role.go | 202 ++++ .../api.xpack.security.get_role_mapping.go | 202 ++++ ...api.xpack.security.get_service_accounts.go | 214 ++++ ....xpack.security.get_service_credentials.go | 198 ++++ .../v7/esapi/api.xpack.security.get_token.go | 193 ++++ .../v7/esapi/api.xpack.security.get_user.go | 202 ++++ .../api.xpack.security.get_user_privileges.go | 186 ++++ .../esapi/api.xpack.security.grant_api_key.go | 206 ++++ .../api.xpack.security.has_privileges.go | 211 ++++ .../api.xpack.security.invalidate_api_key.go | 193 ++++ .../api.xpack.security.invalidate_token.go | 193 ++++ .../api.xpack.security.put_privileges.go | 206 ++++ .../v7/esapi/api.xpack.security.put_role.go | 213 ++++ .../api.xpack.security.put_role_mapping.go | 213 ++++ .../v7/esapi/api.xpack.security.put_user.go | 213 ++++ .../api.xpack.security.query_api_keys.go | 200 ++++ .../api.xpack.security.saml_authenticate.go | 193 ++++ ...api.xpack.security.saml_complete_logout.go | 193 ++++ .../api.xpack.security.saml_invalidate.go | 193 ++++ .../esapi/api.xpack.security.saml_logout.go | 193 ++++ ...ck.security.saml_prepare_authentication.go | 193 ++++ ...security.saml_service_provider_metadata.go | 195 ++++ .../esapi/api.xpack.slm.delete_lifecycle.go | 193 ++++ .../esapi/api.xpack.slm.execute_lifecycle.go | 195 ++++ .../esapi/api.xpack.slm.execute_retention.go | 186 ++++ .../v7/esapi/api.xpack.slm.get_lifecycle.go | 202 ++++ .../v7/esapi/api.xpack.slm.get_stats.go | 186 ++++ .../v7/esapi/api.xpack.slm.get_status.go | 186 ++++ .../v7/esapi/api.xpack.slm.put_lifecycle.go | 207 ++++ .../v7/esapi/api.xpack.slm.start.go | 186 ++++ .../v7/esapi/api.xpack.slm.stop.go | 186 ++++ .../v7/esapi/api.xpack.sql.clear_cursor.go | 193 ++++ .../v7/esapi/api.xpack.sql.delete_async.go | 195 ++++ .../v7/esapi/api.xpack.sql.get_async.go | 243 +++++ .../esapi/api.xpack.sql.get_async_status.go | 195 ++++ .../v7/esapi/api.xpack.sql.query.go | 206 ++++ .../v7/esapi/api.xpack.sql.translate.go | 193 ++++ .../v7/esapi/api.xpack.ssl.certificates.go | 186 ++++ ...api.xpack.text_structure.find_structure.go | 364 +++++++ .../api.xpack.transform.delete_transform.go | 218 ++++ .../api.xpack.transform.get_transform.go | 250 +++++ ...api.xpack.transform.get_transform_stats.go | 231 ++++ .../api.xpack.transform.preview_transform.go | 230 ++++ .../api.xpack.transform.put_transform.go | 225 ++++ .../api.xpack.transform.start_transform.go | 207 ++++ .../api.xpack.transform.stop_transform.go | 256 +++++ .../api.xpack.transform.update_transform.go | 227 ++++ .../api.xpack.transform.upgrade_transforms.go | 213 ++++ .../v7/esapi/api.xpack.watcher.ack_watch.go | 207 ++++ .../esapi/api.xpack.watcher.activate_watch.go | 195 ++++ .../api.xpack.watcher.deactivate_watch.go | 195 ++++ .../esapi/api.xpack.watcher.delete_watch.go | 193 ++++ .../esapi/api.xpack.watcher.execute_watch.go | 232 ++++ .../v7/esapi/api.xpack.watcher.get_watch.go | 193 ++++ .../v7/esapi/api.xpack.watcher.put_watch.go | 257 +++++ .../esapi/api.xpack.watcher.query_watches.go | 200 ++++ .../v7/esapi/api.xpack.watcher.start.go | 186 ++++ .../v7/esapi/api.xpack.watcher.stats.go | 220 ++++ .../v7/esapi/api.xpack.watcher.stop.go | 186 ++++ .../v7/esapi/api.xpack.xpack.info.go | 212 ++++ .../v7/esapi/api.xpack.xpack.usage.go | 200 ++++ .../elastic/go-elasticsearch/v7/esapi/doc.go | 112 ++ .../go-elasticsearch/v7/esapi/esapi.go | 62 ++ .../v7/esapi/esapi.request.go | 44 + .../v7/esapi/esapi.response.go | 105 ++ .../v7/estransport/connection.go | 335 ++++++ .../v7/estransport/discovery.go | 218 ++++ .../go-elasticsearch/v7/estransport/doc.go | 51 + .../v7/estransport/estransport.go | 600 +++++++++++ .../go-elasticsearch/v7/estransport/logger.go | 457 ++++++++ .../v7/estransport/metaheader.go | 81 ++ .../v7/estransport/metrics.go | 198 ++++ .../v7/internal/version/version.go | 21 + elk/vendor/modules.txt | 6 + 433 files changed, 101474 insertions(+), 1 deletion(-) create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/.codecov.yml create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/.dockerignore create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/.gitignore create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/CHANGELOG.md create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/LICENSE create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/Makefile create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/README.md create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/doc.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/elasticsearch.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api._.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.bulk.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.aliases.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.allocation.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.count.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.fielddata.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.health.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.help.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.indices.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.master.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.nodeattrs.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.nodes.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.pending_tasks.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.plugins.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.recovery.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.repositories.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.segments.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.shards.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.snapshots.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.tasks.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.templates.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.thread_pool.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.clear_scroll.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.allocation_explain.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.delete_component_template.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.delete_voting_config_exclusions.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.exists_component_template.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.get_component_template.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.get_settings.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.health.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.pending_tasks.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.post_voting_config_exclusions.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.put_component_template.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.put_settings.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.remote_info.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.reroute.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.state.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.stats.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.count.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.create.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.dangling_indices.delete_dangling_index.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.dangling_indices.import_dangling_index.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.dangling_indices.list_dangling_indices.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.delete.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.delete_by_query.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.delete_by_query_rethrottle.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.delete_script.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.exists.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.exists_source.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.explain.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.features.get_features.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.features.reset_features.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.field_caps.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.fleet.global_checkpoints.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.fleet.msearch.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.fleet.search.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.get.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.get_script.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.get_script_context.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.get_script_languages.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.get_source.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.index.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.add_block.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.analyze.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.clear_cache.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.clone.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.close.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.create.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.delete.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.delete_alias.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.delete_index_template.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.delete_template.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.disk_usage.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.exists.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.exists_alias.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.exists_index_template.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.exists_template.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.exists_type.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.field_usage_stats.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.flush.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.flush_synced.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.forcemerge.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.get.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.get_alias.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.get_field_mapping.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.get_index_template.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.get_mapping.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.get_settings.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.get_template.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.get_upgrade.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.modify_data_stream.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.open.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.put_alias.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.put_index_template.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.put_mapping.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.put_settings.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.put_template.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.recovery.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.refresh.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.resolve_index.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.rollover.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.segments.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.shard_stores.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.shrink.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.simulate_index_template.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.simulate_template.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.split.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.stats.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.update_aliases.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.upgrade.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.validate_query.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.info.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.ingest.delete_pipeline.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.ingest.geo_ip_stats.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.ingest.get_pipeline.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.ingest.processor_grok.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.ingest.put_pipeline.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.ingest.simulate.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.mget.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.msearch.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.msearch_template.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.mtermvectors.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.nodes.clear_metering_archive.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.nodes.clear_repositories_metering_archive.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.nodes.get_metering_info.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.nodes.get_repositories_metering_info.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.nodes.hot_threads.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.nodes.info.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.nodes.reload_secure_settings.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.nodes.stats.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.nodes.usage.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.ping.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.put_script.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.rank_eval.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.reindex.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.reindex_rethrottle.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.render_search_template.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.scripts_painless_execute.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.scroll.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.search.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.search_mvt.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.search_shards.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.search_template.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.shutdown.delete_node.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.shutdown.get_node.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.shutdown.put_node.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.snapshot.cleanup_repository.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.snapshot.clone.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.snapshot.create.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.snapshot.create_repository.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.snapshot.delete.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.snapshot.delete_repository.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.snapshot.get.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.snapshot.get_repository.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.snapshot.repository_analyze.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.snapshot.restore.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.snapshot.status.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.snapshot.verify_repository.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.tasks.cancel.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.tasks.get.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.tasks.list.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.terms_enum.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.termvectors.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.update.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.update_by_query.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.update_by_query_rethrottle.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.async_search.delete.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.async_search.get.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.async_search.status.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.async_search.submit.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.autoscaling.delete_autoscaling_policy.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.autoscaling.get_autoscaling_capacity.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.autoscaling.get_autoscaling_decision.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.autoscaling.get_autoscaling_policy.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.autoscaling.put_autoscaling_policy.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.cat.ml_data_frame_analytics.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.cat.ml_datafeeds.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.cat.ml_jobs.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.cat.ml_trained_models.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.cat.transforms.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.delete_auto_follow_pattern.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.follow.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.follow_info.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.follow_stats.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.forget_follower.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.get_auto_follow_pattern.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.pause_auto_follow_pattern.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.pause_follow.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.put_auto_follow_pattern.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.resume_auto_follow_pattern.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.resume_follow.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.stats.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.unfollow.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.close_point_in_time.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.data_frame_transform_deprecated.delete_transform.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.data_frame_transform_deprecated.get_transform.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.data_frame_transform_deprecated.get_transform_stats.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.data_frame_transform_deprecated.preview_transform.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.data_frame_transform_deprecated.put_transform.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.data_frame_transform_deprecated.start_transform.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.data_frame_transform_deprecated.stop_transform.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.data_frame_transform_deprecated.update_transform.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.enrich.delete_policy.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.enrich.execute_policy.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.enrich.get_policy.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.enrich.put_policy.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.enrich.stats.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.eql.delete.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.eql.get.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.eql.get_status.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.eql.search.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.graph.explore.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ilm.delete_lifecycle.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ilm.explain_lifecycle.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ilm.get_lifecycle.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ilm.get_status.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ilm.migrate_to_data_tiers.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ilm.move_to_step.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ilm.put_lifecycle.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ilm.remove_policy.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ilm.retry.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ilm.start.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ilm.stop.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.indices.create_data_stream.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.indices.data_streams_stats.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.indices.delete_data_stream.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.indices.freeze.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.indices.get_data_stream.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.indices.migrate_to_data_stream.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.indices.promote_data_stream.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.indices.reload_search_analyzers.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.indices.unfreeze.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.license.delete.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.license.get.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.license.get_basic_status.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.license.get_trial_status.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.license.post.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.license.post_start_basic.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.license.post_start_trial.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.logstash.delete_pipeline.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.logstash.get_pipeline.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.logstash.put_pipeline.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.migration.deprecations.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.migration.get_feature_upgrade_status.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.migration.post_feature_upgrade.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.close_job.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.delete_calendar.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.delete_calendar_event.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.delete_calendar_job.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.delete_data_frame_analytics.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.delete_datafeed.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.delete_expired_data.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.delete_filter.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.delete_forecast.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.delete_job.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.delete_model_snapshot.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.delete_trained_model.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.delete_trained_model_alias.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.estimate_model_memory.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.evaluate_data_frame.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.explain_data_frame_analytics.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.find_file_structure.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.flush_job.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.forecast.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_buckets.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_calendar_events.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_calendars.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_categories.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_data_frame_analytics.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_data_frame_analytics_stats.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_datafeed_stats.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_datafeeds.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_filters.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_influencers.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_job_stats.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_jobs.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_model_snapshot_upgrade_stats.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_model_snapshots.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_overall_buckets.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_records.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_trained_models.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_trained_models_stats.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.info.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.open_job.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.post_calendar_events.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.post_data.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.preview_data_frame_analytics.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.preview_datafeed.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.put_calendar.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.put_calendar_job.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.put_data_frame_analytics.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.put_datafeed.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.put_filter.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.put_job.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.put_trained_model.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.put_trained_model_alias.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.reset_job.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.revert_model_snapshot.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.set_upgrade_mode.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.start_data_frame_analytics.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.start_datafeed.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.stop_data_frame_analytics.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.stop_datafeed.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.update_data_frame_analytics.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.update_datafeed.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.update_filter.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.update_job.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.update_model_snapshot.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.upgrade_job_snapshot.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.validate.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.validate_detector.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.monitoring.bulk.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.open_point_in_time.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.rollup.delete_job.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.rollup.get_jobs.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.rollup.get_rollup_caps.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.rollup.get_rollup_index_caps.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.rollup.put_job.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.rollup.rollup.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.rollup.rollup_search.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.rollup.start_job.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.rollup.stop_job.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.searchable_snapshots.cache_stats.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.searchable_snapshots.clear_cache.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.searchable_snapshots.mount.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.searchable_snapshots.repository_stats.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.searchable_snapshots.stats.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.authenticate.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.change_password.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.clear_api_key_cache.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.clear_cached_privileges.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.clear_cached_realms.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.clear_cached_roles.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.clear_cached_service_tokens.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.create_api_key.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.create_service_token.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.delete_privileges.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.delete_role.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.delete_role_mapping.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.delete_service_token.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.delete_user.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.disable_user.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.enable_user.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.get_api_key.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.get_builtin_privileges.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.get_privileges.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.get_role.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.get_role_mapping.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.get_service_accounts.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.get_service_credentials.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.get_token.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.get_user.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.get_user_privileges.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.grant_api_key.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.has_privileges.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.invalidate_api_key.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.invalidate_token.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.put_privileges.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.put_role.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.put_role_mapping.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.put_user.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.query_api_keys.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.saml_authenticate.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.saml_complete_logout.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.saml_invalidate.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.saml_logout.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.saml_prepare_authentication.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.saml_service_provider_metadata.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.slm.delete_lifecycle.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.slm.execute_lifecycle.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.slm.execute_retention.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.slm.get_lifecycle.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.slm.get_stats.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.slm.get_status.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.slm.put_lifecycle.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.slm.start.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.slm.stop.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.sql.clear_cursor.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.sql.delete_async.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.sql.get_async.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.sql.get_async_status.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.sql.query.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.sql.translate.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ssl.certificates.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.text_structure.find_structure.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.transform.delete_transform.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.transform.get_transform.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.transform.get_transform_stats.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.transform.preview_transform.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.transform.put_transform.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.transform.start_transform.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.transform.stop_transform.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.transform.update_transform.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.transform.upgrade_transforms.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.watcher.ack_watch.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.watcher.activate_watch.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.watcher.deactivate_watch.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.watcher.delete_watch.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.watcher.execute_watch.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.watcher.get_watch.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.watcher.put_watch.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.watcher.query_watches.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.watcher.start.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.watcher.stats.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.watcher.stop.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.xpack.info.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.xpack.usage.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/doc.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/esapi.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/esapi.request.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/esapi.response.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/estransport/connection.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/estransport/discovery.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/estransport/doc.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/estransport/estransport.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/estransport/logger.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/estransport/metaheader.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/estransport/metrics.go create mode 100644 elk/vendor/github.com/elastic/go-elasticsearch/v7/internal/version/version.go diff --git a/elk/elasticClient/client.go b/elk/elasticClient/client.go index 742d3e7d..d90c6c77 100644 --- a/elk/elasticClient/client.go +++ b/elk/elasticClient/client.go @@ -1 +1,49 @@ -package elasticClient \ No newline at end of file +package elasticClient + +import ( + "context" + "errors" + "fmt" + "net" + "net/http" + "time" + + "gitee.com/openeuler/PilotGo-plugin-elk/conf" + "gitee.com/openeuler/PilotGo-plugin-elk/errormanager" + "gitee.com/openeuler/PilotGo-plugin-elk/pluginclient" + elastic "github.com/elastic/go-elasticsearch/v7" +) + +var Global_elastic *ElasticClient_v7 + +type ElasticClient_v7 struct { + Client *elastic.Client + Ctx context.Context +} + +func InitElasticClient() { + cfg := elastic.Config{ + Addresses: []string{ + fmt.Sprintf("http://%s", conf.Global_Config.Elasticsearch.Addr), + }, + Username: conf.Global_Config.Elasticsearch.Username, + Password: conf.Global_Config.Elasticsearch.Password, + Transport: &http.Transport{ + MaxIdleConnsPerHost: 10, + ResponseHeaderTimeout: time.Second, + DialContext: (&net.Dialer{Timeout: time.Second}).DialContext, + }, + } + + es_client, err := elastic.NewClient(cfg) + if err != nil { + err = errors.New("failed to init kibana client **errstackfatal**0") // err top + errormanager.ErrorTransmit(pluginclient.Global_Context, err, true) + return + } + + Global_elastic = &ElasticClient_v7{ + Client: es_client, + Ctx: context.Background(), + } +} diff --git a/elk/go.mod b/elk/go.mod index 412798b8..ea75426d 100644 --- a/elk/go.mod +++ b/elk/go.mod @@ -5,6 +5,7 @@ go 1.20 require ( gitee.com/openeuler/PilotGo/sdk v0.0.0-20240516011326-59b5a9af0526 github.com/elastic/elastic-agent-libs v0.9.8 + github.com/elastic/go-elasticsearch/v7 v7.17.10 github.com/gin-contrib/timeout v1.0.1 github.com/gin-gonic/gin v1.9.1 github.com/pkg/errors v0.9.1 diff --git a/elk/go.sum b/elk/go.sum index e660bb98..83396bd4 100644 --- a/elk/go.sum +++ b/elk/go.sum @@ -19,6 +19,8 @@ github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4 github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/elastic/elastic-agent-libs v0.9.8 h1:fwl3hp0gNmKkuERcUQTwe4cyIK6M0jJkv16EIsB6Apw= github.com/elastic/elastic-agent-libs v0.9.8/go.mod h1:xhHF9jeWhPzKPtEHN+epKjdiZi0bCbACLxwkp1aHMpc= +github.com/elastic/go-elasticsearch/v7 v7.17.10 h1:TCQ8i4PmIJuBunvBS6bwT2ybzVFxxUhhltAs3Gyu1yo= +github.com/elastic/go-elasticsearch/v7 v7.17.10/go.mod h1:OJ4wdbtDNk5g503kvlHLyErCgQwwzmDtaFC4XyOxXA4= github.com/elastic/go-licenser v0.4.0 h1:jLq6A5SilDS/Iz1ABRkO6BHy91B9jBora8FwGRsDqUI= github.com/elastic/go-licenser v0.4.0/go.mod h1:V56wHMpmdURfibNBggaSBfqgPxyT1Tldns1i87iTEvU= github.com/elastic/go-sysinfo v1.7.1/go.mod h1:i1ZYdU10oLNfRzq4vq62BEwD2fH8KaWh6eh0ikPT9F0= diff --git a/elk/main.go b/elk/main.go index 926abc0a..acbb48cf 100644 --- a/elk/main.go +++ b/elk/main.go @@ -3,6 +3,7 @@ package main import ( "gitee.com/openeuler/PilotGo-plugin-elk/conf" "gitee.com/openeuler/PilotGo-plugin-elk/db" + "gitee.com/openeuler/PilotGo-plugin-elk/elasticClient" "gitee.com/openeuler/PilotGo-plugin-elk/errormanager" "gitee.com/openeuler/PilotGo-plugin-elk/handler" kibanaclient "gitee.com/openeuler/PilotGo-plugin-elk/kibanaClient/7_17_16" @@ -43,6 +44,11 @@ func main() { */ db.InitDB() + /* + init elasticsearch client + */ + elasticClient.InitElasticClient() + /* init kibana client */ diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/.codecov.yml b/elk/vendor/github.com/elastic/go-elasticsearch/v7/.codecov.yml new file mode 100644 index 00000000..e6210f88 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/.codecov.yml @@ -0,0 +1,8 @@ +comment: off + +coverage: + status: + patch: off + +ignore: + - "esapi/api.*.go" diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/.dockerignore b/elk/vendor/github.com/elastic/go-elasticsearch/v7/.dockerignore new file mode 100644 index 00000000..4c8512b0 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/.dockerignore @@ -0,0 +1,2 @@ +.git/ +tmp/ diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/.gitignore b/elk/vendor/github.com/elastic/go-elasticsearch/v7/.gitignore new file mode 100644 index 00000000..7a915a03 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/.gitignore @@ -0,0 +1,5 @@ +tmp/ +*.test + +#jetBrains editors +.idea \ No newline at end of file diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/CHANGELOG.md b/elk/vendor/github.com/elastic/go-elasticsearch/v7/CHANGELOG.md new file mode 100644 index 00000000..becf380f --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/CHANGELOG.md @@ -0,0 +1,294 @@ +# v7.17.10 + +## Transport + +* Fixed an issue with subdirectory in url during retry. (#657) +* Fixed a deadlock in transport (#603 & #640) + +# v7.17.7 + +## Client + +* Added the option to override the `Content-Type` to enable usage of alternative serialization. ([#542](https://github.com/elastic/go-elasticsearch/pull/542)) +* API is compatible with Elasticsearch 7.17.7 + +# v7.17.1 + +## Client + +* Fixed serialisation of the `routing` parameter for the `BulkIndexerItem` routing property. + +# v7.17.0 + +## Client + +* Fixed a race condition on metrics in transport [#397](https://github.com/elastic/go-elasticsearch/pull/397), thanks @mainliufeng ! +* The client will now return an error if a required arguments is passed as a nil value. [#201](https://github.com/elastic/go-elasticsearch/issues/201) +* API is compatible with Elasticsearch 7.17.0 + +# v8.0.0-alpha + +## Client + +### Elastic Transport +* This is the first release using the all new `elastictransport` which now lives in the [elastic-transport-go](https://github.com/elastic/elastic-transport-go/) repository. The goal is to allow for reuse between this and future Go clients. +### API +* Changed the `Body` parameter for `BulkIndexerItem` in favor of `io.ReadSeeker` to lower memory consumption when using the `esutil.BulkIndexer`. +* Replaced the `Config` option `RetryOnTimeout` in favor of a new `RetryOnError` function which allows to dynamically chose what error should be retried." + +# v7.16.0 + +# Client +* Adds versioning and routing options to the `BulkIndexer`. Thanks to @mehran-prs and @munkyboy ! + +* Adds CA fingerprinting. You can configure the client to only trust certificates that are signed by a specific CA certificate (CA certificate pinning) by providing a ca_fingerprint option. This will verify that the fingerprint of the CA certificate that has signed the certificate of the server matches the supplied value: +```go +elasticsearch.NewClient(Config{ +Addresses: []string{\"https://elastic:changeme@localhost:9200\"}, +CertificateFingerprint: \"A6FB224A4386...\" +}) +``` +# API + +* New APIs: + * ModifyDataStream, [documentation](https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html) + * TransformUpgradeTransforms, [documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/upgrade-transforms.html) + * Migration.GetFeatureUpgradeStatus, [documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/migration-api-feature-upgrade.html) + * Migration.PostFeatureUpgrade, [documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/migration-api-feature-upgrade.html) + + +* New **Experimental** API: + + * FleetSearch, [documentation](https://www.elastic.co/guide/en/elasticsearch/reference/7.16/fleet-search.html) + * FleetMsearch, [documentation](https://www.elastic.co/guide/en/elasticsearch/reference/7.16/fleet-multi-search.html) + + +* Changes: + * DeleteByQuery + * Removed _source, _source_excludes, _source_includes parameters. + * UpdateByQuery + * Removed _source, _source_excludes, _source_includes parameters. + * OpenPointInTime + * The parameter keep_alive is now required. + * SearchMvt + * Added TrackTotalHits, Indicate if the number of documents that match the query should be tracked. A number can also be specified, to accurately track the total hit count up to the number. + * IngestPutPipeline + * Added WithIfVersion, required version for optimistic concurrency control for pipeline updates. + * IndicesGetIndexTemplate + * WithName, a pattern that returned template names must match. + * NodesHotThreads + * WithSort, the sort order for 'cpu' type (default: total). + * MLPutTrainedModel + * WithDeferDefinitionDecompression, if set to `true` and a `compressed_definition` is provided, the request defers definition decompression and skips relevant validations. + * TransformDeleteTransform + * WithTimeout, controls the time to wait for the transform deletion. + * TransformPutTransform + * WithTimeout, controls the time to wait for the transform to start. + * TransformUpdateTransform + * WithTimeout, controls the time to wait for the update. + +* Promoted to stable: + * FleetGlobalCheckpoints + * GetScriptContext + * GetScriptLanguages + * IndicesResolveIndex + * MonitoringBulk + * RankEval + * SearchableSnapshotsMount + * SearchableSnapshotsStats + * SecurityClearCachedServiceTokens + * SecurityCreateServiceToken + * SecurityDeleteServiceToken + * SecurityGetServiceAccounts + * SecurityGetServiceCredentials + * ShutdownDeleteNode + * ShutdownGetNode + * ShutdownPutNode + * TermsEnum" + +# v7.15.1 + +# Client + * Allow User-Agent override via the `userAgentHeader` header. Credit goes to @aleksmaus! " + +# v7.15.0 + +# Client + * Body compression can now be enabled in the client via the `CompressRequestBody` config option. Thank you @bschofield for this contribution ! + * # API + + * New APIs: + * Security + * QueryAPIKeys [documentation](https://www.elastic.co/guide/en/elasticsearch/reference/7.15/security-api-query-api-key.html) + + * New **Experimental** API: + * Indices + * DiskUsage [documentation](https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-disk-usage.html) + * FieldUsageStats [documentation](https://www.elastic.co/guide/en/elasticsearch/reference/master/field-usage-stats.html) + * Nodes + * ClearRepositoriesMeteringArchive [documentation](https://www.elastic.co/guide/en/elasticsearch/reference/7.15/clear-repositories-metering-archive-api.html) + * GetRepositoriesMeteringInfo [documentation](https://www.elastic.co/guide/en/elasticsearch/reference/7.15/get-repositories-metering-api.html) + * SearchMvt [documentation](https://www.elastic.co/guide/en/elasticsearch/reference/master/search-vector-tile-api.html)" + +# v7.14.0 + +# Client +Starting in v7.14.0 the client performs a required product check before the first API call is executed. This product check allows the client to establish that it’s communicating with a supported Elasticsearch cluster. + +The product check requires a single HTTP request to the `info` API. In most cases this request will succeed quickly and then no further product check HTTP requests will be sent. + +# API +* New APIs: + * ILM + * MigrateToDataTiers + * ML + * ResetJob + * SAML + * SamlAuthenticate + * SamlCompleteLogout + * SamlInvalidate + * SamlLogout + * SamlPrepareAuthentication + * SamlServiceProviderMetadata + * SQL + * DeleteAsync + * GetAsync + * GetAsyncStatus + +* New **Beta** API: + * TermsEnum, [see documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-terms-enum.html) + + +# v7.13.1 + +# X-Pack +* New API: + * `SnapshotRepositoryAnalyze`" + +# v7.13.0 + +# Client +* Adds support for compatibility header for Elasticsearch. If the environment variable 'ELASTIC_CLIENT_APIVERSIONING' is set to true or 1, the client will send the headers Accept and Content-Type with the following value: application/vnd.elasticsearch+json;compatible-with=7. +* Favor `POST` method when only `GET` & `POST` method are available to prevent goroutine leak. https://github.com/elastic/go-elasticsearch/issues/250 +* Filter master only nodes in discovery. https://github.com/elastic/go-elasticsearch/issues/256 + +# API + +* New APIs: + * `FeaturesResetFeatures` + * `IngestGeoIPStats` + +* New experimental APIs: + * `ShutdownGetNode` + * `ShutdownPutNode` + * `ShutdownDeleteNode` + +# X-Pack + +* New APIs: + * `MLDeleteTrainedModelAlias` + * `MLPreviewDataFrameAnalytics` + * `MLPutTrainedModelAlias` + +* APIs promoted to stable: + * `TextStructureFindStructure` + * `MLDeleteDataFrameAnalytics` + * `MLDeleteTrainedModel` + * `MLEvaluateDataFrame` + * `MLExplainDataFrameAnalytics` + * `MLGetDataFrameAnalytics` + * `MLGetDataFrameAnalyticsStats` + * `MLGetTrainedModels` + * `MLGetTrainedModelsStats` + * `MLPutDataFrameAnalytics` + * `MLPutTrainedModel` + * `MLStartDataFrameAnalytics` + * `MLStopDataFrameAnalytics` + * `MLUpdateDataFrameAnalytics` + +* New Beta APIs: + * `SecurityCreateServiceToken` + * `SecurityClearCachedServiceTokens` + * `SecurityDeleteServiceToken` + * `SecurityGetServiceAccounts` + * `SecurityGetServiceCredentials` + +* New experimental APIs: + * `SearchableSnapshotsCacheStats` + +# v7.12.0 + +# Transport +* Added the `X-Elastic-Client-Meta` HTTP header (#240) +* Fixed of by one error in the retry mechanism of the client (#242) + +# API +## New +* `GetFeatures` within `Snapshot.GetFeatures` & `FeaturesGetFeatures` + +## Added +* `Search` with `MinCompatibleShardNode` - the minimum compatible version that all shards involved in search should have for this request to be successful. + +# X-Pack +## New +* `EqlGetStatus` - Returns the status of a previously submitted async or stored Event Query Language (EQL) search +* `Logstash` with `LogstashGetPipeline` `LogstashPutPipeline` and `LogstashDeletePipeline` [More info](https://www.elastic.co/guide/en/elasticsearch/reference/current/logstash-apis.html) +* `TextStructureFindStructure` - Finds the structure of a text file. The text file must contain data that is suitable to be ingested into Elasticsearch. +* `AutoscalingGetAutoscalingPolicy`, `AutoscalingPutAutoscalingPolicy`, `AutoscalingDeleteAutoscalingPolicy` and `AutoscalingGetAutoscalingCapacity` are promoted `stable` + +## Added +* `SearchableSnapshotsStats` with `WithLevel` - return stats aggregated at cluster, index or shard level. +* `SearchableSnapshotsMount` with `WithStorage` - selects the kind of local storage used to accelerate searches. experimental, and defaults to `full_copy`. + + +# v7.11.0 + +* Updated APIs for Elasticsearch 7.11" + +# v7.10.0 + +* Updated APIs for Elasticsearch 7.10 +* Fixed capitalization of UUID values" + +# v7.9.0 + +* Updated APIs for Elasticsearch 7.9 +* Util: Reinstate item.Body after it is consumed in BulkIndexer +* Transport: Fix memory leak when retrying 5xx responses +* Fixes and improvements to the test generator + +# v7.8.0 + +* Updated APIs for Elasticsearch 7.8.0 + +# v7.7.0 + +* API: Add convenience method for accessing the deprecation warnings in the response headers +* Transport: Add the CACert global configuration option +* Transport: Add support for global request headers +* Util: Add the BulkIndexer helper; see [example](https://github.com/elastic/go-elasticsearch/tree/master/_examples/bulk#indexergo) +* Examples: Add examples and benchmarks for the BulkIndexer helper +* CI: Add workflows for Github Actions +* CI: Remove Travis CI +* Generator: Tests: Fixes and improvements +* Generator: Source: Updates and improvements" + +# v7.6.0 + +* Ignore the ELASTICSEARCH_URL variable when address is passed in configuration +* Retry on EOF errors" + +# v6.8.5 + +* Support for Elasticsearch 6.8.5 APIs +* Add support for request retries +* Add connection state management +* Add support for node discovery in client + +# v7.5.0 + +* Support for Elasticsearch 7.5 APIs +* Add support for request retries +* Add connection state management +* Add support for node discovery in client + diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/LICENSE b/elk/vendor/github.com/elastic/go-elasticsearch/v7/LICENSE new file mode 100644 index 00000000..b1a731fb --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2018 Elasticsearch BV + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/Makefile b/elk/vendor/github.com/elastic/go-elasticsearch/v7/Makefile new file mode 100644 index 00000000..75870bb2 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/Makefile @@ -0,0 +1,480 @@ +SHELL := /bin/bash + +ELASTICSEARCH_DEFAULT_BUILD_VERSION = "7.17.10-SNAPSHOT" + +##@ Test +test-unit: ## Run unit tests + @printf "\033[2m→ Running unit tests...\033[0m\n" +ifdef race + $(eval testunitargs += "-race") +endif + $(eval testunitargs += "-cover" "-coverprofile=tmp/unit.cov" "./...") + @mkdir -p tmp + @if which gotestsum > /dev/null 2>&1 ; then \ + echo "gotestsum --format=short-verbose --junitfile=tmp/unit-report.xml --" $(testunitargs); \ + gotestsum --format=short-verbose --junitfile=tmp/unit-report.xml -- $(testunitargs); \ + else \ + echo "go test -v" $(testunitargs); \ + go test -v $(testunitargs); \ + fi; +test: test-unit + +test-integ: ## Run integration tests + @printf "\033[2m→ Running integration tests...\033[0m\n" + $(eval testintegtags += "integration") +ifdef multinode + $(eval testintegtags += "multinode") +endif +ifdef race + $(eval testintegargs += "-race") +endif + $(eval testintegargs += "-cover" "-coverprofile=tmp/integration-client.cov" "-tags='$(testintegtags)'" "-timeout=1h") + @mkdir -p tmp + @if which gotestsum > /dev/null 2>&1 ; then \ + echo "gotestsum --format=short-verbose --junitfile=tmp/integration-report.xml --" $(testintegargs); \ + gotestsum --format=short-verbose --junitfile=tmp/integration-report.xml -- $(testintegargs) "."; \ + gotestsum --format=short-verbose --junitfile=tmp/integration-report.xml -- $(testintegargs) "./estransport" "./esapi" "./esutil"; \ + else \ + echo "go test -v" $(testintegargs) "."; \ + go test -v $(testintegargs) "./estransport" "./esapi" "./esutil"; \ + fi; + +test-api: ## Run generated API integration tests + @mkdir -p tmp +ifdef race + $(eval testapiargs += "-race") +endif + $(eval testapiargs += "-cover" "-coverpkg=github.com/elastic/go-elasticsearch/v7/esapi" "-coverprofile=$(PWD)/tmp/integration-api.cov" "-tags='integration'" "-timeout=1h") +ifdef flavor +else + $(eval flavor='free') +endif + @printf "\033[2m→ Running API integration tests for [$(flavor)]...\033[0m\n" +ifeq ($(flavor), platinum) + @{ \ + set -e ; \ + trap "test -d .git && git checkout --quiet $(PWD)/esapi/test/go.mod" INT TERM EXIT; \ + export ELASTICSEARCH_URL='https://elastic:elastic@localhost:9200' && \ + if which gotestsum > /dev/null 2>&1 ; then \ + cd esapi/test && \ + go mod download && \ + gotestsum --format=short-verbose --junitfile=$(PWD)/tmp/integration-api-report.xml -- $(testapiargs) $(PWD)/esapi/test/xpack/*_test.go && \ + gotestsum --format=short-verbose --junitfile=$(PWD)/tmp/integration-api-report.xml -- $(testapiargs) $(PWD)/esapi/test/xpack/ml/*_test.go && \ + gotestsum --format=short-verbose --junitfile=$(PWD)/tmp/integration-api-report.xml -- $(testapiargs) $(PWD)/esapi/test/xpack/ml-crud/*_test.go; \ + else \ + echo "go test -v" $(testapiargs); \ + cd esapi/test && \ + go mod download && \ + go test -v $(testapiargs) $(PWD)/esapi/test/xpack/*_test.go && \ + go test -v $(testapiargs) $(PWD)/esapi/test/xpack/ml/*_test.go && \ + go test -v $(testapiargs) $(PWD)/esapi/test/xpack/ml-crud/*_test.go; \ + fi; \ + } +else + $(eval testapiargs += $(PWD)/esapi/test/*_test.go) + @{ \ + set -e ; \ + trap "test -d .git && git checkout --quiet $(PWD)/esapi/test/go.mod" INT TERM EXIT; \ + if which gotestsum > /dev/null 2>&1 ; then \ + cd esapi/test && \ + go mod download && \ + gotestsum --format=short-verbose --junitfile=$(PWD)/tmp/integration-api-report.xml -- $(testapiargs); \ + else \ + echo "go test -v" $(testapiargs); \ + cd esapi/test && \ + go mod download && \ + go test -v $(testapiargs); \ + fi; \ + } +endif + +test-bench: ## Run benchmarks + @printf "\033[2m→ Running benchmarks...\033[0m\n" + go test -run=none -bench=. -benchmem ./... + +test-examples: ## Execute the _examples + @printf "\033[2m→ Testing the examples...\033[0m\n" + @{ \ + set -e ; \ + trap "test -d .git && git checkout --quiet _examples/**/go.mod" INT TERM EXIT; \ + for d in _examples/*/; do \ + printf "\033[2m────────────────────────────────────────────────────────────────────────────────\n"; \ + printf "\033[1mUpdating dependencies for $$d\033[0m\n"; \ + printf "\033[2m────────────────────────────────────────────────────────────────────────────────\033[0m\n"; \ + (cd $$d && go mod download && make setup) || \ + ( \ + printf "\033[31m────────────────────────────────────────────────────────────────────────────────\033[0m\n"; \ + printf "\033[31;1m⨯ ERROR\033[0m\n"; \ + false; \ + ); \ + done; \ + \ + for f in _examples/*.go; do \ + printf "\033[2m────────────────────────────────────────────────────────────────────────────────\n"; \ + printf "\033[1m$$f\033[0m\n"; \ + printf "\033[2m────────────────────────────────────────────────────────────────────────────────\033[0m\n"; \ + (go run $$f && true) || \ + ( \ + printf "\033[31m────────────────────────────────────────────────────────────────────────────────\033[0m\n"; \ + printf "\033[31;1m⨯ ERROR\033[0m\n"; \ + false; \ + ); \ + done; \ + \ + for f in _examples/*/; do \ + printf "\033[2m────────────────────────────────────────────────────────────────────────────────\033[0m\n"; \ + printf "\033[1m$$f\033[0m\n"; \ + printf "\033[2m────────────────────────────────────────────────────────────────────────────────\033[0m\n"; \ + (cd $$f && make test && true) || \ + ( \ + printf "\033[31m────────────────────────────────────────────────────────────────────────────────\033[0m\n"; \ + printf "\033[31;1m⨯ ERROR\033[0m\n"; \ + false; \ + ); \ + done; \ + printf "\033[32m────────────────────────────────────────────────────────────────────────────────\033[0m\n"; \ + \ + printf "\033[32;1mSUCCESS\033[0m\n"; \ + } + +test-coverage: ## Generate test coverage report + @printf "\033[2m→ Generating test coverage report...\033[0m\n" + @go tool cover -html=tmp/unit.cov -o tmp/coverage.html + @go tool cover -func=tmp/unit.cov | 'grep' -v 'esapi/api\.' | sed 's/github.com\/elastic\/go-elasticsearch\///g' + @printf "\033[0m--------------------------------------------------------------------------------\nopen tmp/coverage.html\n\n\033[0m" + +##@ Development +lint: ## Run lint on the package + @printf "\033[2m→ Running lint...\033[0m\n" + go vet github.com/elastic/go-elasticsearch/... + go list github.com/elastic/go-elasticsearch/... | 'grep' -v internal | xargs golint -set_exit_status + @{ \ + set -e ; \ + trap "test -d ../../../.git && git checkout --quiet go.mod" INT TERM EXIT; \ + echo "cd internal/build/ && go vet ./..."; \ + cd "internal/build/" && go mod tidy && go mod download && go vet ./...; \ + } + + +apidiff: ## Display API incompabilities + @if ! command -v apidiff > /dev/null; then \ + printf "\033[31;1mERROR: apidiff not installed\033[0m\n"; \ + printf "go get -u github.com/go-modules-by-example/apidiff\n"; \ + printf "\033[2m→ https://github.com/go-modules-by-example/index/blob/master/019_apidiff/README.md\033[0m\n\n"; \ + false; \ + fi; + @rm -rf tmp/apidiff-OLD tmp/apidiff-NEW + @git clone --quiet --local .git/ tmp/apidiff-OLD + @mkdir -p tmp/apidiff-NEW + @tar -c --exclude .git --exclude tmp --exclude cmd . | tar -x -C tmp/apidiff-NEW + @printf "\033[2m→ Running apidiff...\033[0m\n" + @pritnf "tmp/apidiff-OLD/esapi tmp/apidiff-NEW/esapi\n" + @{ \ + set -e ; \ + output=$$(apidiff tmp/apidiff-OLD/esapi tmp/apidiff-NEW/esapi); \ + printf "\n$$output\n\n"; \ + if echo $$output | grep -i -e 'incompatible' - > /dev/null 2>&1; then \ + printf "\n\033[31;1mFAILURE\033[0m\n\n"; \ + false; \ + else \ + printf "\033[32;1mSUCCESS\033[0m\n"; \ + fi; \ + } + +backport: ## Backport one or more commits from master into version branches +ifeq ($(origin commits), undefined) + @echo "Missing commit(s), exiting..." + @exit 2 +endif +ifndef branches + $(eval branches_list = '7.17' '6.x' '5.x') +else + $(eval branches_list = $(shell echo $(branches) | tr ',' ' ') ) +endif + $(eval commits_list = $(shell echo $(commits) | tr ',' ' ')) + @printf "\033[2m→ Backporting commits [$(commits)]\033[0m\n" + @{ \ + set -e -o pipefail; \ + for commit in $(commits_list); do \ + git show --pretty='%h | %s' --no-patch $$commit; \ + done; \ + echo ""; \ + for branch in $(branches_list); do \ + printf "\033[2m→ $$branch\033[0m\n"; \ + git checkout $$branch; \ + for commit in $(commits_list); do \ + git cherry-pick -x $$commit; \ + done; \ + git status --short --branch; \ + echo ""; \ + done; \ + printf "\033[2m→ Push updates to Github:\033[0m\n"; \ + for branch in $(branches_list); do \ + echo "git push --verbose origin $$branch"; \ + done; \ + } + +release: ## Release a new version to Github + $(eval branch = $(shell git rev-parse --abbrev-ref HEAD)) + $(eval current_version = $(shell cat internal/version/version.go | sed -Ee 's/const Client = "(.*)"/\1/' | tail -1)) + @printf "\033[2m→ [$(branch)] Current version: $(current_version)...\033[0m\n" +ifndef version + @printf "\033[31m[!] Missing version argument, exiting...\033[0m\n" + @exit 2 +endif +ifeq ($(version), "") + @printf "\033[31m[!] Empty version argument, exiting...\033[0m\n" + @exit 2 +endif + @printf "\033[2m→ [$(branch)] Creating version $(version)...\033[0m\n" + @{ \ + set -e -o pipefail; \ + cp internal/version/version.go internal/version/version.go.OLD && \ + cat internal/version/version.go.OLD | sed -e 's/Client = ".*"/Client = "$(version)"/' > internal/version/version.go && \ + go vet internal/version/version.go && \ + go fmt internal/version/version.go && \ + git diff --color-words internal/version/version.go | tail -n 1; \ + } + @{ \ + set -e -o pipefail; \ + printf "\033[2m→ Commit and create Git tag? (y/n): \033[0m\c"; \ + read continue; \ + if [[ $$continue == "y" ]]; then \ + git add internal/version/version.go && \ + git commit --no-status --quiet --message "Release $(version)" && \ + git tag --annotate v$(version) --message 'Release $(version)'; \ + printf "\033[2m→ Push `git show --pretty='%h (%s)' --no-patch HEAD` to Github:\033[0m\n\n"; \ + printf "\033[1m git push origin HEAD && git push origin v$(version)\033[0m\n\n"; \ + mv internal/version/version.go.OLD internal/version/version.go && \ + git add internal/version/version.go && \ + original_version=`cat internal/version/version.go | sed -ne 's;^const Client = "\(.*\)"$$;\1;p'` && \ + git commit --no-status --quiet --message "Update version to $$original_version"; \ + printf "\033[2m→ Version updated to [$$original_version].\033[0m\n\n"; \ + else \ + echo "Aborting..."; \ + rm internal/version/version.go.OLD; \ + exit 1; \ + fi; \ + } + +godoc: ## Display documentation for the package + @printf "\033[2m→ Generating documentation...\033[0m\n" + @echo "* http://localhost:6060/pkg/github.com/elastic/go-elasticsearch/v7" + @echo "* http://localhost:6060/pkg/github.com/elastic/go-elasticsearch/v7/esapi" + @echo "* http://localhost:6060/pkg/github.com/elastic/go-elasticsearch/v7/estransport" + @echo "* http://localhost:6060/pkg/github.com/elastic/go-elasticsearch/v7/esutil" + @printf "\n" + godoc --http=localhost:6060 --play + +cluster: ## Launch an Elasticsearch cluster with Docker + $(eval version ?= "elasticsearch:7.17-SNAPSHOT") + $(eval flavor ?= "core") + $(eval elasticsearch_url = "http://es1:9200") + +ifdef ELASTICSEARCH_BUILD_VERSION + $(eval version ?= "elasticsearch:"${ELASTICSEARCH_BUILD_VERSION}) +else + $(eval version ?= "elasticsearch:"${ELASTICSEARCH_DEFAULT_BUILD_VERSION}) +endif + +ifeq ($(origin nodes), undefined) + $(eval nodes = 1) +endif + @printf "\033[2m→ Launching %d node(s) of %s...\033[0m\n" $(nodes) $(version) +ifeq ($(shell test $(nodes) && test $(nodes) -gt 1; echo $$?),0) + $(eval detach ?= "true") +else + $(eval detach ?= "false") +endif + +ifeq ($(flavor), platinum) + $(eval elasticsearch_url = "https://elastic:elastic@es1:9200") + $(eval xpack_env += --env "ELASTIC_PASSWORD=elastic") + $(eval xpack_env += --env "xpack.license.self_generated.type=trial") + $(eval xpack_env += --env "xpack.security.enabled=true") + $(eval xpack_env += --env "xpack.security.http.ssl.enabled=true") + $(eval xpack_env += --env "xpack.security.http.ssl.key=certs/testnode.key") + $(eval xpack_env += --env "xpack.security.http.ssl.certificate=certs/testnode.crt") + $(eval xpack_env += --env "xpack.security.http.ssl.certificate_authorities=certs/ca.crt") + $(eval xpack_env += --env "xpack.security.transport.ssl.enabled=true") + $(eval xpack_env += --env "xpack.security.transport.ssl.verification_mode=certificate") + $(eval xpack_env += --env "xpack.security.transport.ssl.key=certs/testnode.key") + $(eval xpack_env += --env "xpack.security.transport.ssl.certificate=certs/testnode.crt") + $(eval xpack_env += --env "xpack.security.transport.ssl.certificate_authorities=certs/ca.crt") + $(eval xpack_volumes += --volume "$(PWD)/.ci/certs/testnode.crt:/usr/share/elasticsearch/config/certs/testnode.crt") + $(eval xpack_volumes += --volume "$(PWD)/.ci/certs/testnode.key:/usr/share/elasticsearch/config/certs/testnode.key") + $(eval xpack_volumes += --volume "$(PWD)/.ci/certs/ca.crt:/usr/share/elasticsearch/config/certs/ca.crt") +endif + @docker network inspect elasticsearch > /dev/null 2>&1 || docker network create elasticsearch; + @{ \ + for n in `seq 1 $(nodes)`; do \ + if [[ -z "$$port" ]]; then \ + hostport=$$((9199+$$n)); \ + else \ + hostport=$$port; \ + fi; \ + docker run \ + --name "es$$n" \ + --network elasticsearch \ + --env "node.name=es$$n" \ + --env "cluster.name=go-elasticsearch" \ + --env "cluster.initial_master_nodes=es1" \ + --env "discovery.seed_hosts=es1" \ + --env "cluster.routing.allocation.disk.threshold_enabled=false" \ + --env "bootstrap.memory_lock=true" \ + --env "node.attr.testattr=test" \ + --env "path.repo=/tmp" \ + --env "repositories.url.allowed_urls=http://snapshot.test*" \ + --env ES_JAVA_OPTS="-Xms1g -Xmx1g" \ + $(xpack_env) \ + --volume `echo $(version) | tr -C "[:alnum:]" '-'`-node-$$n-data:/usr/share/elasticsearch/data \ + $(xpack_volumes) \ + --publish $$hostport:9200 \ + --ulimit nofile=65536:65536 \ + --ulimit memlock=-1:-1 \ + --detach=$(detach) \ + --rm \ + docker.elastic.co/elasticsearch/$(version); \ + done \ + } +ifdef detach + @{ \ + printf "\033[2m→ Waiting for the cluster on $(elasticsearch_url)...\033[0m\n"; \ + docker run --network elasticsearch --rm appropriate/curl --max-time 120 --retry 120 --retry-delay 1 --retry-connrefused --show-error --silent --insecure $(elasticsearch_url); \ + output="\033[2m→ Cluster ready; to remove containers:"; \ + output="$$output docker rm -f"; \ + for n in `seq 1 $(nodes)`; do \ + output="$$output es$$n"; \ + done; \ + printf "$$output\033[0m\n"; \ + } +endif + +cluster-update: ## Update the Docker image +ifdef ELASTICSEARCH_BUILD_VERSION + $(eval version ?= "elasticsearch:"${ELASTICSEARCH_BUILD_VERSION}) +else + $(eval version ?= "elasticsearch:"${ELASTICSEARCH_DEFAULT_BUILD_VERSION}) +endif + @printf "\033[2m→ Updating the Docker image...\033[0m\n" + @docker pull docker.elastic.co/elasticsearch/$(version); + +cluster-clean: ## Remove unused Docker volumes and networks + @printf "\033[2m→ Cleaning up Docker assets...\033[0m\n" + docker volume prune --force + docker network prune --force + +docker: ## Build the Docker image and run it + docker build --file .ci/Dockerfile --tag elastic/go-elasticsearch . + docker run -it --network elasticsearch --volume $(PWD)/tmp:/tmp:rw,delegated --rm elastic/go-elasticsearch + +##@ Generator +gen-api: ## Generate the API package from the JSON specification + $(eval input ?= tmp/rest-api-spec) + $(eval output ?= esapi) +ifdef debug + $(eval args += --debug) +endif +ifdef ELASTICSEARCH_BUILD_VERSION + $(eval version = $(ELASTICSEARCH_BUILD_VERSION)) +else + $(eval version = $(ELASTICSEARCH_DEFAULT_BUILD_VERSION)) +endif +ifdef ELASTICSEARCH_BUILD_HASH + $(eval build_hash = $(ELASTICSEARCH_BUILD_HASH)) +else + $(eval build_hash = $(shell cat tmp/elasticsearch.json | jq ".projects.elasticsearch.commit_hash")) +endif + @printf "\033[2m→ Generating API package from specification ($(version):$(build_hash))...\033[0m\n" + @{ \ + set -e; \ + trap "test -d .git && git checkout --quiet $(PWD)/internal/build/go.mod" INT TERM EXIT; \ + export ELASTICSEARCH_BUILD_VERSION=$(version) && \ + export ELASTICSEARCH_BUILD_HASH=$(build_hash) && \ + cd internal/build && \ + go run main.go apisource --input '$(PWD)/$(input)/api/*.json' --output '$(PWD)/$(output)' $(args) && \ + go run main.go apistruct --output '$(PWD)/$(output)'; \ + } + +gen-tests: ## Generate the API tests from the YAML specification + $(eval input ?= tmp/rest-api-spec) + $(eval output ?= esapi/test) +ifdef debug + $(eval args += --debug) +endif +ifdef ELASTICSEARCH_BUILD_VERSION + $(eval version = $(ELASTICSEARCH_BUILD_VERSION)) +else + $(eval version = $(ELASTICSEARCH_DEFAULT_BUILD_VERSION)) +endif +ifdef ELASTICSEARCH_BUILD_HASH + $(eval build_hash = $(ELASTICSEARCH_BUILD_HASH)) +else + $(eval build_hash = $(shell cat tmp/elasticsearch.json | jq ".projects.elasticsearch.commit_hash")) +endif + @printf "\033[2m→ Generating API tests from specification ($(version):$(build_hash))...\033[0m\n" + @{ \ + set -e; \ + trap "test -d .git && git checkout --quiet $(PWD)/internal/cmd/generate/go.mod" INT TERM EXIT; \ + export ELASTICSEARCH_BUILD_VERSION=$(version) && \ + export ELASTICSEARCH_BUILD_HASH=$(build_hash) && \ + rm -rf $(output)/*_test.go && \ + rm -rf $(output)/xpack && \ + cd internal/build && \ + go get golang.org/x/tools/cmd/goimports && \ + go generate ./... && \ + go run main.go apitests --input '$(PWD)/$(input)/test/free/**/*.y*ml' --output '$(PWD)/$(output)' $(args) && \ + go run main.go apitests --input '$(PWD)/$(input)/test/platinum/**/*.yml' --output '$(PWD)/$(output)/xpack' $(args) && \ + mkdir -p '$(PWD)/esapi/test/xpack/ml' && \ + mkdir -p '$(PWD)/esapi/test/xpack/ml-crud' && \ + mv $(PWD)/esapi/test/xpack/xpack_ml* $(PWD)/esapi/test/xpack/ml/ && \ + mv $(PWD)/esapi/test/xpack/ml/xpack_ml__jobs_crud_test.go $(PWD)/esapi/test/xpack/ml-crud/; \ + } + +gen-docs: ## Generate the skeleton of documentation examples + $(eval input ?= tmp/alternatives_report.json) + $(eval update ?= no) + @{ \ + set -e; \ + trap "test -d .git && git checkout --quiet $(PWD)/internal/cmd/generate/go.mod" INT TERM EXIT; \ + if [[ $(update) == 'yes' ]]; then \ + printf "\033[2m→ Updating the alternatives_report.json file\033[0m\n" && \ + curl -s https://raw.githubusercontent.com/elastic/built-docs/master/raw/en/elasticsearch/reference/master/alternatives_report.json > tmp/alternatives_report.json; \ + fi; \ + printf "\033[2m→ Generating Go source files from Console input in [$(input)]\033[0m\n" && \ + ( cd '$(PWD)/internal/cmd/generate' && \ + go run main.go examples src --debug --input='$(PWD)/$(input)' --output='$(PWD)/.doc/examples/' \ + ) && \ + ( cd '$(PWD)/.doc/examples/src' && \ + if which gotestsum > /dev/null 2>&1 ; then \ + gotestsum --format=short-verbose; \ + else \ + go test -v $(testunitargs); \ + fi; \ + ) && \ + printf "\n\033[2m→ Generating ASCIIDoc files from Go source\033[0m\n" && \ + ( cd '$(PWD)/internal/build' && \ + go run main.go examples doc --debug --input='$(PWD)/.doc/examples/src/' --output='$(PWD)/.doc/examples/' \ + ) \ + } + +download-specs: ## Download the latest specs for the specified Elasticsearch version + $(eval output ?= tmp) + @mkdir -p tmp + @{ \ + set -e; \ + printf "\n\033[2m→ Downloading latest Elasticsearch specs for version [$(ELASTICSEARCH_DEFAULT_BUILD_VERSION)]\033[0m\n" && \ + rm -rf $(output)/rest-api-spec && \ + rm -rf $(output)/elasticsearch.json && \ + cd internal/build && \ + go run main.go download-spec --output '$(PWD)/$(output)'; \ + } + +##@ Other +#------------------------------------------------------------------------------ +help: ## Display help + @awk 'BEGIN {FS = ":.*##"; printf "Usage:\n make \033[36m\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) +#------------- -------------- + +.DEFAULT_GOAL := help +.PHONY: help apidiff backport cluster cluster-clean cluster-update coverage docker examples gen-api gen-tests godoc lint release test test-api test-bench test-integ test-unit diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/README.md b/elk/vendor/github.com/elastic/go-elasticsearch/v7/README.md new file mode 100644 index 00000000..533b3d5e --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/README.md @@ -0,0 +1,379 @@ +# go-elasticsearch + +The official Go client for [Elasticsearch](https://www.elastic.co/products/elasticsearch). + +[![GoDoc](https://godoc.org/github.com/elastic/go-elasticsearch?status.svg)](https://pkg.go.dev/github.com/elastic/go-elasticsearch/v7) +[![Go Report Card](https://goreportcard.com/badge/github.com/elastic/go-elasticsearch)](https://goreportcard.com/report/github.com/elastic/go-elasticsearch) +[![codecov.io](https://codecov.io/github/elastic/go-elasticsearch/coverage.svg?branch=main)](https://codecov.io/gh/elastic/go-elasticsearch?branch=main) +[![Build](https://github.com/elastic/go-elasticsearch/workflows/Build/badge.svg)](https://github.com/elastic/go-elasticsearch/actions?query=branch%3Amain) +[![Unit](https://github.com/elastic/go-elasticsearch/workflows/Unit/badge.svg)](https://github.com/elastic/go-elasticsearch/actions?query=branch%3Amain) +[![Integration](https://github.com/elastic/go-elasticsearch/workflows/Integration/badge.svg)](https://github.com/elastic/go-elasticsearch/actions?query=branch%3Amain) +[![API](https://github.com/elastic/go-elasticsearch/workflows/API/badge.svg)](https://github.com/elastic/go-elasticsearch/actions?query=branch%3Amain) + +## Compatibility + +Language clients are forward compatible; meaning that clients support communicating with greater or equal minor versions of Elasticsearch. +Elasticsearch language clients are only backwards compatible with default distributions and without guarantees made. + +When using Go modules, include the version in the import path, and specify either an explicit version or a branch: + + require github.com/elastic/go-elasticsearch/v7 7.16 + require github.com/elastic/go-elasticsearch/v7 7.0.0 + +It's possible to use multiple versions of the client in a single project: + + // go.mod + github.com/elastic/go-elasticsearch/v6 6.x + github.com/elastic/go-elasticsearch/v7 7.16 + + // main.go + import ( + elasticsearch6 "github.com/elastic/go-elasticsearch/v6" + elasticsearch7 "github.com/elastic/go-elasticsearch/v7" + ) + // ... + es6, _ := elasticsearch6.NewDefaultClient() + es7, _ := elasticsearch7.NewDefaultClient() + +The `main` branch of the client is compatible with the current `master` branch of Elasticsearch. + + + +## Installation + +Add the package to your `go.mod` file: + + require github.com/elastic/go-elasticsearch/v8 main + +Or, clone the repository: + + git clone --branch main https://github.com/elastic/go-elasticsearch.git $GOPATH/src/github.com/elastic/go-elasticsearch + +A complete example: + +```bash +mkdir my-elasticsearch-app && cd my-elasticsearch-app + +cat > go.mod <<-END + module my-elasticsearch-app + + require github.com/elastic/go-elasticsearch/v8 main +END + +cat > main.go <<-END + package main + + import ( + "log" + + "github.com/elastic/go-elasticsearch/v7" + ) + + func main() { + es, _ := elasticsearch.NewDefaultClient() + log.Println(elasticsearch.Version) + log.Println(es.Info()) + } +END + +go run main.go +``` + + + + +## Usage + +The `elasticsearch` package ties together two separate packages for calling the Elasticsearch APIs and transferring data over HTTP: `esapi` and `estransport`, respectively. + +Use the `elasticsearch.NewDefaultClient()` function to create the client with the default settings. + +```golang +es, err := elasticsearch.NewDefaultClient() +if err != nil { + log.Fatalf("Error creating the client: %s", err) +} + +res, err := es.Info() +if err != nil { + log.Fatalf("Error getting response: %s", err) +} + +defer res.Body.Close() +log.Println(res) + +// [200 OK] { +// "name" : "node-1", +// "cluster_name" : "go-elasticsearch" +// ... +``` + +> NOTE: It is _critical_ to both close the response body _and_ to consume it, in order to re-use persistent TCP connections in the default HTTP transport. If you're not interested in the response body, call `io.Copy(ioutil.Discard, res.Body)`. + +When you export the `ELASTICSEARCH_URL` environment variable, +it will be used to set the cluster endpoint(s). Separate multiple adresses by a comma. + +To set the cluster endpoint(s) programatically, pass a configuration object +to the `elasticsearch.NewClient()` function. + +```golang +cfg := elasticsearch.Config{ + Addresses: []string{ + "http://localhost:9200", + "http://localhost:9201", + }, + // ... +} +es, err := elasticsearch.NewClient(cfg) +``` + +To set the username and password, include them in the endpoint URL, +or use the corresponding configuration options. + +```golang +cfg := elasticsearch.Config{ + // ... + Username: "foo", + Password: "bar", +} +``` + +To set a custom certificate authority used to sign the certificates of cluster nodes, +use the `CACert` configuration option. + +```golang +cert, _ := ioutil.ReadFile(*cacert) + +cfg := elasticsearch.Config{ + // ... + CACert: cert, +} +``` + +To configure other HTTP settings, pass an [`http.Transport`](https://golang.org/pkg/net/http/#Transport) +object in the configuration object. + +```golang +cfg := elasticsearch.Config{ + Transport: &http.Transport{ + MaxIdleConnsPerHost: 10, + ResponseHeaderTimeout: time.Second, + TLSClientConfig: &tls.Config{ + MinVersion: tls.VersionTLS12, + // ... + }, + // ... + }, +} +``` + +See the [`_examples/configuration.go`](_examples/configuration.go) and +[`_examples/customization.go`](_examples/customization.go) files for +more examples of configuration and customization of the client. +See the [`_examples/security`](_examples/security) for an example of a security configuration. + +The following example demonstrates a more complex usage. It fetches the Elasticsearch version from the cluster, indexes a couple of documents concurrently, and prints the search results, using a lightweight wrapper around the response body. + +```golang +// $ go run _examples/main.go + +package main + +import ( + "bytes" + "context" + "encoding/json" + "log" + "strconv" + "strings" + "sync" + "bytes" + + "github.com/elastic/go-elasticsearch/v7" + "github.com/elastic/go-elasticsearch/v7/esapi" +) + +func main() { + log.SetFlags(0) + + var ( + r map[string]interface{} + wg sync.WaitGroup + ) + + // Initialize a client with the default settings. + // + // An `ELASTICSEARCH_URL` environment variable will be used when exported. + // + es, err := elasticsearch.NewDefaultClient() + if err != nil { + log.Fatalf("Error creating the client: %s", err) + } + + // 1. Get cluster info + // + res, err := es.Info() + if err != nil { + log.Fatalf("Error getting response: %s", err) + } + defer res.Body.Close() + // Check response status + if res.IsError() { + log.Fatalf("Error: %s", res.String()) + } + // Deserialize the response into a map. + if err := json.NewDecoder(res.Body).Decode(&r); err != nil { + log.Fatalf("Error parsing the response body: %s", err) + } + // Print client and server version numbers. + log.Printf("Client: %s", elasticsearch.Version) + log.Printf("Server: %s", r["version"].(map[string]interface{})["number"]) + log.Println(strings.Repeat("~", 37)) + + // 2. Index documents concurrently + // + for i, title := range []string{"Test One", "Test Two"} { + wg.Add(1) + + go func(i int, title string) { + defer wg.Done() + + // Build the request body. + data, err := json.Marshal(struct{ Title string }{Title: title}) + if err != nil { + log.Fatalf("Error marshaling document: %s", err) + } + + // Set up the request object. + req := esapi.IndexRequest{ + Index: "test", + DocumentID: strconv.Itoa(i + 1), + Body: bytes.NewReader(data), + Refresh: "true", + } + + // Perform the request with the client. + res, err := req.Do(context.Background(), es) + if err != nil { + log.Fatalf("Error getting response: %s", err) + } + defer res.Body.Close() + + if res.IsError() { + log.Printf("[%s] Error indexing document ID=%d", res.Status(), i+1) + } else { + // Deserialize the response into a map. + var r map[string]interface{} + if err := json.NewDecoder(res.Body).Decode(&r); err != nil { + log.Printf("Error parsing the response body: %s", err) + } else { + // Print the response status and indexed document version. + log.Printf("[%s] %s; version=%d", res.Status(), r["result"], int(r["_version"].(float64))) + } + } + }(i, title) + } + wg.Wait() + + log.Println(strings.Repeat("-", 37)) + + // 3. Search for the indexed documents + // + // Build the request body. + var buf bytes.Buffer + query := map[string]interface{}{ + "query": map[string]interface{}{ + "match": map[string]interface{}{ + "title": "test", + }, + }, + } + if err := json.NewEncoder(&buf).Encode(query); err != nil { + log.Fatalf("Error encoding query: %s", err) + } + + // Perform the search request. + res, err = es.Search( + es.Search.WithContext(context.Background()), + es.Search.WithIndex("test"), + es.Search.WithBody(&buf), + es.Search.WithTrackTotalHits(true), + es.Search.WithPretty(), + ) + if err != nil { + log.Fatalf("Error getting response: %s", err) + } + defer res.Body.Close() + + if res.IsError() { + var e map[string]interface{} + if err := json.NewDecoder(res.Body).Decode(&e); err != nil { + log.Fatalf("Error parsing the response body: %s", err) + } else { + // Print the response status and error information. + log.Fatalf("[%s] %s: %s", + res.Status(), + e["error"].(map[string]interface{})["type"], + e["error"].(map[string]interface{})["reason"], + ) + } + } + + if err := json.NewDecoder(res.Body).Decode(&r); err != nil { + log.Fatalf("Error parsing the response body: %s", err) + } + // Print the response status, number of results, and request duration. + log.Printf( + "[%s] %d hits; took: %dms", + res.Status(), + int(r["hits"].(map[string]interface{})["total"].(map[string]interface{})["value"].(float64)), + int(r["took"].(float64)), + ) + // Print the ID and document source for each hit. + for _, hit := range r["hits"].(map[string]interface{})["hits"].([]interface{}) { + log.Printf(" * ID=%s, %s", hit.(map[string]interface{})["_id"], hit.(map[string]interface{})["_source"]) + } + + log.Println(strings.Repeat("=", 37)) +} + +// Client: 7.0.0-SNAPSHOT +// Server: 7.0.0-SNAPSHOT +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// [201 Created] updated; version=1 +// [201 Created] updated; version=1 +// ------------------------------------- +// [200 OK] 2 hits; took: 5ms +// * ID=1, map[title:Test One] +// * ID=2, map[title:Test Two] +// ===================================== +``` + +As you see in the example above, the `esapi` package allows to call the Elasticsearch APIs in two distinct ways: either by creating a struct, such as `IndexRequest`, and calling its `Do()` method by passing it a context and the client, or by calling the `Search()` function on the client directly, using the option functions such as `WithIndex()`. See more information and examples in the +[package documentation](https://godoc.org/github.com/elastic/go-elasticsearch/esapi). + +The `estransport` package handles the transfer of data to and from Elasticsearch, including retrying failed requests, keeping a connection pool, discovering cluster nodes and logging. + +Read more about the client internals and usage in the following blog posts: + +* https://www.elastic.co/blog/the-go-client-for-elasticsearch-introduction +* https://www.elastic.co/blog/the-go-client-for-elasticsearch-configuration-and-customization +* https://www.elastic.co/blog/the-go-client-for-elasticsearch-working-with-data + + + +## Helpers + +The `esutil` package provides convenience helpers for working with the client. At the moment, it provides the `esutil.JSONReader()` and the `esutil.BulkIndexer` helpers. + + + +## Examples + +The **[`_examples`](./_examples)** folder contains a number of recipes and comprehensive examples to get you started with the client, including configuration and customization of the client, using a custom certificate authority (CA) for security (TLS), mocking the transport for unit tests, embedding the client in a custom type, building queries, performing requests individually and in bulk, and parsing the responses. + + + +## License + +(c) 2019 Elasticsearch. Licensed under the Apache License, Version 2.0. diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/doc.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/doc.go new file mode 100644 index 00000000..f24fc7af --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/doc.go @@ -0,0 +1,67 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +/* +Package elasticsearch provides a Go client for Elasticsearch. + +Create the client with the NewDefaultClient function: + + elasticsearch.NewDefaultClient() + +The ELASTICSEARCH_URL environment variable is used instead of the default URL, when set. +Use a comma to separate multiple URLs. + +To configure the client, pass a Config object to the NewClient function: + + cfg := elasticsearch.Config{ + Addresses: []string{ + "http://localhost:9200", + "http://localhost:9201", + }, + Username: "foo", + Password: "bar", + Transport: &http.Transport{ + MaxIdleConnsPerHost: 10, + ResponseHeaderTimeout: time.Second, + DialContext: (&net.Dialer{Timeout: time.Second}).DialContext, + TLSClientConfig: &tls.Config{ + MinVersion: tls.VersionTLS12, + }, + }, + } + + elasticsearch.NewClient(cfg) + +When using the Elastic Service (https://elastic.co/cloud), you can use CloudID instead of Addresses. +When either Addresses or CloudID is set, the ELASTICSEARCH_URL environment variable is ignored. + +See the elasticsearch_integration_test.go file and the _examples folder for more information. + +Call the Elasticsearch APIs by invoking the corresponding methods on the client: + + res, err := es.Info() + if err != nil { + log.Fatalf("Error getting response: %s", err) + } + + log.Println(res) + +See the github.com/elastic/go-elasticsearch/esapi package for more information about using the API. + +See the github.com/elastic/go-elasticsearch/estransport package for more information about configuring the transport. +*/ +package elasticsearch diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/elasticsearch.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/elasticsearch.go new file mode 100644 index 00000000..db204011 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/elasticsearch.go @@ -0,0 +1,465 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package elasticsearch + +import ( + "context" + "encoding/base64" + "encoding/json" + "errors" + "fmt" + "io" + "io/ioutil" + "net/http" + "net/url" + "os" + "regexp" + "strconv" + "strings" + "sync" + "time" + + "github.com/elastic/go-elasticsearch/v7/esapi" + "github.com/elastic/go-elasticsearch/v7/estransport" + "github.com/elastic/go-elasticsearch/v7/internal/version" +) + +var ( + reVersion *regexp.Regexp +) + +func init() { + versionPattern := `^([0-9]+)\.([0-9]+)\.([0-9]+)` + reVersion = regexp.MustCompile(versionPattern) +} + +const ( + defaultURL = "http://localhost:9200" + tagline = "You Know, for Search" + unknownProduct = "the client noticed that the server is not Elasticsearch and we do not support this unknown product" + unsupportedProduct = "the client noticed that the server is not a supported distribution of Elasticsearch" +) + +// Version returns the package version as a string. +// +const Version = version.Client + +// Config represents the client configuration. +// +type Config struct { + Addresses []string // A list of Elasticsearch nodes to use. + Username string // Username for HTTP Basic Authentication. + Password string // Password for HTTP Basic Authentication. + + CloudID string // Endpoint for the Elastic Service (https://elastic.co/cloud). + APIKey string // Base64-encoded token for authorization; if set, overrides username/password and service token. + ServiceToken string // Service token for authorization; if set, overrides username/password. + CertificateFingerprint string // SHA256 hex fingerprint given by Elasticsearch on first launch. + + Header http.Header // Global HTTP request header. + + // PEM-encoded certificate authorities. + // When set, an empty certificate pool will be created, and the certificates will be appended to it. + // The option is only valid when the transport is not specified, or when it's http.Transport. + CACert []byte + + RetryOnStatus []int // List of status codes for retry. Default: 502, 503, 504. + DisableRetry bool // Default: false. + EnableRetryOnTimeout bool // Default: false. + MaxRetries int // Default: 3. + + CompressRequestBody bool // Default: false. + DiscoverNodesOnStart bool // Discover nodes when initializing the client. Default: false. + + DiscoverNodesInterval time.Duration // Discover nodes periodically. Default: disabled. + + EnableMetrics bool // Enable the metrics collection. + EnableDebugLogger bool // Enable the debug logging. + EnableCompatibilityMode bool // Enable sends compatibility header + + DisableMetaHeader bool // Disable the additional "X-Elastic-Client-Meta" HTTP header. + UseResponseCheckOnly bool + + RetryBackoff func(attempt int) time.Duration // Optional backoff duration. Default: nil. + + Transport http.RoundTripper // The HTTP transport object. + Logger estransport.Logger // The logger object. + Selector estransport.Selector // The selector object. + + // Optional constructor function for a custom ConnectionPool. Default: nil. + ConnectionPoolFunc func([]*estransport.Connection, estransport.Selector) estransport.ConnectionPool +} + +// Client represents the Elasticsearch client. +// +type Client struct { + *esapi.API // Embeds the API methods + Transport estransport.Interface + useResponseCheckOnly bool + + productCheckMu sync.RWMutex + productCheckSuccess bool +} + +type esVersion struct { + Number string `json:"number"` + BuildFlavor string `json:"build_flavor"` +} + +type info struct { + Version esVersion `json:"version"` + Tagline string `json:"tagline"` +} + +// NewDefaultClient creates a new client with default options. +// +// It will use http://localhost:9200 as the default address. +// +// It will use the ELASTICSEARCH_URL environment variable, if set, +// to configure the addresses; use a comma to separate multiple URLs. +// +func NewDefaultClient() (*Client, error) { + return NewClient(Config{}) +} + +// NewClient creates a new client with configuration from cfg. +// +// It will use http://localhost:9200 as the default address. +// +// It will use the ELASTICSEARCH_URL environment variable, if set, +// to configure the addresses; use a comma to separate multiple URLs. +// +// If either cfg.Addresses or cfg.CloudID is set, the ELASTICSEARCH_URL +// environment variable is ignored. +// +// It's an error to set both cfg.Addresses and cfg.CloudID. +// +func NewClient(cfg Config) (*Client, error) { + var addrs []string + + if len(cfg.Addresses) == 0 && cfg.CloudID == "" { + addrs = addrsFromEnvironment() + } else { + if len(cfg.Addresses) > 0 && cfg.CloudID != "" { + return nil, errors.New("cannot create client: both Addresses and CloudID are set") + } + + if cfg.CloudID != "" { + cloudAddr, err := addrFromCloudID(cfg.CloudID) + if err != nil { + return nil, fmt.Errorf("cannot create client: cannot parse CloudID: %s", err) + } + addrs = append(addrs, cloudAddr) + } + + if len(cfg.Addresses) > 0 { + addrs = append(addrs, cfg.Addresses...) + } + } + + urls, err := addrsToURLs(addrs) + if err != nil { + return nil, fmt.Errorf("cannot create client: %s", err) + } + + if len(urls) == 0 { + u, _ := url.Parse(defaultURL) // errcheck exclude + urls = append(urls, u) + } + + // TODO(karmi): Refactor + if urls[0].User != nil { + cfg.Username = urls[0].User.Username() + pw, _ := urls[0].User.Password() + cfg.Password = pw + } + + tp, err := estransport.New(estransport.Config{ + URLs: urls, + Username: cfg.Username, + Password: cfg.Password, + APIKey: cfg.APIKey, + ServiceToken: cfg.ServiceToken, + CertificateFingerprint: cfg.CertificateFingerprint, + + Header: cfg.Header, + CACert: cfg.CACert, + + RetryOnStatus: cfg.RetryOnStatus, + DisableRetry: cfg.DisableRetry, + EnableRetryOnTimeout: cfg.EnableRetryOnTimeout, + MaxRetries: cfg.MaxRetries, + RetryBackoff: cfg.RetryBackoff, + + CompressRequestBody: cfg.CompressRequestBody, + CompatibilityHeader: cfg.EnableCompatibilityMode, + + EnableMetrics: cfg.EnableMetrics, + EnableDebugLogger: cfg.EnableDebugLogger, + + DisableMetaHeader: cfg.DisableMetaHeader, + + DiscoverNodesInterval: cfg.DiscoverNodesInterval, + + Transport: cfg.Transport, + Logger: cfg.Logger, + Selector: cfg.Selector, + ConnectionPoolFunc: cfg.ConnectionPoolFunc, + }) + if err != nil { + return nil, fmt.Errorf("error creating transport: %s", err) + } + + client := &Client{Transport: tp, useResponseCheckOnly: cfg.UseResponseCheckOnly} + client.API = esapi.New(client) + + if cfg.DiscoverNodesOnStart { + go client.DiscoverNodes() + } + + return client, err +} + +// genuineCheckHeader validates the presence of the X-Elastic-Product header +// +func genuineCheckHeader(header http.Header) error { + if header.Get("X-Elastic-Product") != "Elasticsearch" { + return errors.New(unknownProduct) + } + return nil +} + +// genuineCheckInfo validates the informations given by Elasticsearch +// +func genuineCheckInfo(info info) error { + major, minor, _, err := ParseElasticsearchVersion(info.Version.Number) + if err != nil { + return err + } + + if major < 6 { + return errors.New(unknownProduct) + } + if major < 7 { + if info.Tagline != tagline { + return errors.New(unknownProduct) + } + } + if major >= 7 { + if minor < 14 { + if info.Tagline != tagline { + return errors.New(unknownProduct) + } else if info.Version.BuildFlavor != "default" { + return errors.New(unsupportedProduct) + } + } + } + + return nil +} + +// ParseElasticsearchVersion returns an int64 representation of Elasticsearch version. +// +func ParseElasticsearchVersion(version string) (int64, int64, int64, error) { + matches := reVersion.FindStringSubmatch(version) + + if len(matches) < 4 { + return 0, 0, 0, fmt.Errorf("") + } + major, _ := strconv.ParseInt(matches[1], 10, 0) + minor, _ := strconv.ParseInt(matches[2], 10, 0) + patch, _ := strconv.ParseInt(matches[3], 10, 0) + + return major, minor, patch, nil +} + +// Perform delegates to Transport to execute a request and return a response. +// +func (c *Client) Perform(req *http.Request) (*http.Response, error) { + // ProductCheck validation. We skip this validation of we only want the + // header validation. ResponseCheck path continues after original request. + if !c.useResponseCheckOnly { + // Launch product check for 7.x, request info, check header then payload. + if err := c.doProductCheck(req.Context(), c.productCheck); err != nil { + return nil, err + } + } + + // Retrieve the original request. + res, err := c.Transport.Perform(req) + + // ResponseCheck path continues, we run the header check on the first answer from ES. + if err == nil && (res.StatusCode >= 200 && res.StatusCode < 300){ + checkHeader := func(context.Context) error { + return genuineCheckHeader(res.Header) + } + if err := c.doProductCheck(req.Context(), checkHeader); err != nil { + res.Body.Close() + return nil, err + } + } + return res, err +} + +// doProductCheck calls f if there as not been a prior successful call to doProductCheck, +// returning nil otherwise. +func (c *Client) doProductCheck(ctx context.Context, f func(context.Context) error) error { + c.productCheckMu.RLock() + productCheckSuccess := c.productCheckSuccess + c.productCheckMu.RUnlock() + + if productCheckSuccess { + return nil + } + + c.productCheckMu.Lock() + defer c.productCheckMu.Unlock() + + if c.productCheckSuccess { + return nil + } + + if err := f(ctx); err != nil { + return err + } + + c.productCheckSuccess = true + + return nil +} + +// productCheck runs an esapi.Info query to retrieve informations of the current cluster +// decodes the response and decides if the cluster is a genuine Elasticsearch product. +func (c *Client) productCheck(ctx context.Context) error { + req := esapi.InfoRequest{} + res, err := req.Do(ctx, c.Transport) + if err != nil { + return err + } + defer res.Body.Close() + + if res.IsError() { + _, err = io.Copy(ioutil.Discard, res.Body) + if err != nil { + return err + } + switch res.StatusCode { + case http.StatusUnauthorized: + return nil + case http.StatusForbidden: + return nil + default: + return fmt.Errorf("cannot retrieve informations from Elasticsearch") + } + } + + err = genuineCheckHeader(res.Header) + + if err != nil { + var info info + contentType := res.Header.Get("Content-Type") + if strings.Contains(contentType, "json") { + err = json.NewDecoder(res.Body).Decode(&info) + if err != nil { + return fmt.Errorf("error decoding Elasticsearch informations: %s", err) + } + } + + if info.Version.Number != "" { + err = genuineCheckInfo(info) + } + } + + if err != nil { + return err + } + + return nil +} + +// Metrics returns the client metrics. +// +func (c *Client) Metrics() (estransport.Metrics, error) { + if mt, ok := c.Transport.(estransport.Measurable); ok { + return mt.Metrics() + } + return estransport.Metrics{}, errors.New("transport is missing method Metrics()") +} + +// DiscoverNodes reloads the client connections by fetching information from the cluster. +// +func (c *Client) DiscoverNodes() error { + if dt, ok := c.Transport.(estransport.Discoverable); ok { + return dt.DiscoverNodes() + } + return errors.New("transport is missing method DiscoverNodes()") +} + +// addrsFromEnvironment returns a list of addresses by splitting +// the ELASTICSEARCH_URL environment variable with comma, or an empty list. +// +func addrsFromEnvironment() []string { + var addrs []string + + if envURLs, ok := os.LookupEnv("ELASTICSEARCH_URL"); ok && envURLs != "" { + list := strings.Split(envURLs, ",") + for _, u := range list { + addrs = append(addrs, strings.TrimSpace(u)) + } + } + + return addrs +} + +// addrsToURLs creates a list of url.URL structures from url list. +// +func addrsToURLs(addrs []string) ([]*url.URL, error) { + var urls []*url.URL + for _, addr := range addrs { + u, err := url.Parse(strings.TrimRight(addr, "/")) + if err != nil { + return nil, fmt.Errorf("cannot parse url: %v", err) + } + + urls = append(urls, u) + } + return urls, nil +} + +// addrFromCloudID extracts the Elasticsearch URL from CloudID. +// See: https://www.elastic.co/guide/en/cloud/current/ec-cloud-id.html +// +func addrFromCloudID(input string) (string, error) { + var scheme = "https://" + + values := strings.Split(input, ":") + if len(values) != 2 { + return "", fmt.Errorf("unexpected format: %q", input) + } + data, err := base64.StdEncoding.DecodeString(values[1]) + if err != nil { + return "", err + } + parts := strings.Split(string(data), "$") + + if len(parts) < 2 { + return "", fmt.Errorf("invalid encoded value: %s", parts) + } + + return fmt.Sprintf("%s%s.%s", scheme, parts[1], parts[0]), nil +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api._.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api._.go new file mode 100644 index 00000000..1ac589bf --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api._.go @@ -0,0 +1,989 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10 (fecd68e): DO NOT EDIT + +package esapi + +// API contains the Elasticsearch APIs +type API struct { + Cat *Cat + Cluster *Cluster + Indices *Indices + Ingest *Ingest + Nodes *Nodes + Remote *Remote + Snapshot *Snapshot + Tasks *Tasks + AsyncSearch *AsyncSearch + CCR *CCR + ILM *ILM + License *License + Migration *Migration + ML *ML + Monitoring *Monitoring + Rollup *Rollup + Security *Security + SQL *SQL + SSL *SSL + Watcher *Watcher + XPack *XPack + + AutoscalingDeleteAutoscalingPolicy AutoscalingDeleteAutoscalingPolicy + AutoscalingGetAutoscalingCapacity AutoscalingGetAutoscalingCapacity + AutoscalingGetAutoscalingDecision AutoscalingGetAutoscalingDecision + AutoscalingGetAutoscalingPolicy AutoscalingGetAutoscalingPolicy + AutoscalingPutAutoscalingPolicy AutoscalingPutAutoscalingPolicy + Bulk Bulk + ClearScroll ClearScroll + ClosePointInTime ClosePointInTime + Count Count + Create Create + DanglingIndicesDeleteDanglingIndex DanglingIndicesDeleteDanglingIndex + DanglingIndicesImportDanglingIndex DanglingIndicesImportDanglingIndex + DanglingIndicesListDanglingIndices DanglingIndicesListDanglingIndices + DataFrameTransformDeprecatedDeleteTransform DataFrameTransformDeprecatedDeleteTransform + DataFrameTransformDeprecatedGetTransform DataFrameTransformDeprecatedGetTransform + DataFrameTransformDeprecatedGetTransformStats DataFrameTransformDeprecatedGetTransformStats + DataFrameTransformDeprecatedPreviewTransform DataFrameTransformDeprecatedPreviewTransform + DataFrameTransformDeprecatedPutTransform DataFrameTransformDeprecatedPutTransform + DataFrameTransformDeprecatedStartTransform DataFrameTransformDeprecatedStartTransform + DataFrameTransformDeprecatedStopTransform DataFrameTransformDeprecatedStopTransform + DataFrameTransformDeprecatedUpdateTransform DataFrameTransformDeprecatedUpdateTransform + DeleteByQuery DeleteByQuery + DeleteByQueryRethrottle DeleteByQueryRethrottle + Delete Delete + DeleteScript DeleteScript + EnrichDeletePolicy EnrichDeletePolicy + EnrichExecutePolicy EnrichExecutePolicy + EnrichGetPolicy EnrichGetPolicy + EnrichPutPolicy EnrichPutPolicy + EnrichStats EnrichStats + EqlDelete EqlDelete + EqlGet EqlGet + EqlGetStatus EqlGetStatus + EqlSearch EqlSearch + Exists Exists + ExistsSource ExistsSource + Explain Explain + FeaturesGetFeatures FeaturesGetFeatures + FeaturesResetFeatures FeaturesResetFeatures + FieldCaps FieldCaps + FleetGlobalCheckpoints FleetGlobalCheckpoints + FleetMsearch FleetMsearch + FleetSearch FleetSearch + Get Get + GetScriptContext GetScriptContext + GetScriptLanguages GetScriptLanguages + GetScript GetScript + GetSource GetSource + GraphExplore GraphExplore + Index Index + Info Info + LogstashDeletePipeline LogstashDeletePipeline + LogstashGetPipeline LogstashGetPipeline + LogstashPutPipeline LogstashPutPipeline + Mget Mget + Msearch Msearch + MsearchTemplate MsearchTemplate + Mtermvectors Mtermvectors + OpenPointInTime OpenPointInTime + Ping Ping + PutScript PutScript + RankEval RankEval + Reindex Reindex + ReindexRethrottle ReindexRethrottle + RenderSearchTemplate RenderSearchTemplate + ScriptsPainlessExecute ScriptsPainlessExecute + Scroll Scroll + SearchMvt SearchMvt + Search Search + SearchShards SearchShards + SearchTemplate SearchTemplate + SearchableSnapshotsCacheStats SearchableSnapshotsCacheStats + SearchableSnapshotsClearCache SearchableSnapshotsClearCache + SearchableSnapshotsMount SearchableSnapshotsMount + SearchableSnapshotsRepositoryStats SearchableSnapshotsRepositoryStats + SearchableSnapshotsStats SearchableSnapshotsStats + ShutdownDeleteNode ShutdownDeleteNode + ShutdownGetNode ShutdownGetNode + ShutdownPutNode ShutdownPutNode + SlmDeleteLifecycle SlmDeleteLifecycle + SlmExecuteLifecycle SlmExecuteLifecycle + SlmExecuteRetention SlmExecuteRetention + SlmGetLifecycle SlmGetLifecycle + SlmGetStats SlmGetStats + SlmGetStatus SlmGetStatus + SlmPutLifecycle SlmPutLifecycle + SlmStart SlmStart + SlmStop SlmStop + TermsEnum TermsEnum + Termvectors Termvectors + TextStructureFindStructure TextStructureFindStructure + TransformDeleteTransform TransformDeleteTransform + TransformGetTransform TransformGetTransform + TransformGetTransformStats TransformGetTransformStats + TransformPreviewTransform TransformPreviewTransform + TransformPutTransform TransformPutTransform + TransformStartTransform TransformStartTransform + TransformStopTransform TransformStopTransform + TransformUpdateTransform TransformUpdateTransform + TransformUpgradeTransforms TransformUpgradeTransforms + UpdateByQuery UpdateByQuery + UpdateByQueryRethrottle UpdateByQueryRethrottle + Update Update +} + +// Cat contains the Cat APIs +type Cat struct { + Aliases CatAliases + Allocation CatAllocation + Count CatCount + Fielddata CatFielddata + Health CatHealth + Help CatHelp + Indices CatIndices + MLDataFrameAnalytics CatMLDataFrameAnalytics + MLDatafeeds CatMLDatafeeds + MLJobs CatMLJobs + MLTrainedModels CatMLTrainedModels + Master CatMaster + Nodeattrs CatNodeattrs + Nodes CatNodes + PendingTasks CatPendingTasks + Plugins CatPlugins + Recovery CatRecovery + Repositories CatRepositories + Segments CatSegments + Shards CatShards + Snapshots CatSnapshots + Tasks CatTasks + Templates CatTemplates + ThreadPool CatThreadPool + Transforms CatTransforms +} + +// Cluster contains the Cluster APIs +type Cluster struct { + AllocationExplain ClusterAllocationExplain + DeleteComponentTemplate ClusterDeleteComponentTemplate + DeleteVotingConfigExclusions ClusterDeleteVotingConfigExclusions + ExistsComponentTemplate ClusterExistsComponentTemplate + GetComponentTemplate ClusterGetComponentTemplate + GetSettings ClusterGetSettings + Health ClusterHealth + PendingTasks ClusterPendingTasks + PostVotingConfigExclusions ClusterPostVotingConfigExclusions + PutComponentTemplate ClusterPutComponentTemplate + PutSettings ClusterPutSettings + RemoteInfo ClusterRemoteInfo + Reroute ClusterReroute + State ClusterState + Stats ClusterStats +} + +// Indices contains the Indices APIs +type Indices struct { + AddBlock IndicesAddBlock + Analyze IndicesAnalyze + ClearCache IndicesClearCache + Clone IndicesClone + Close IndicesClose + CreateDataStream IndicesCreateDataStream + Create IndicesCreate + DataStreamsStats IndicesDataStreamsStats + DeleteAlias IndicesDeleteAlias + DeleteDataStream IndicesDeleteDataStream + DeleteIndexTemplate IndicesDeleteIndexTemplate + Delete IndicesDelete + DeleteTemplate IndicesDeleteTemplate + DiskUsage IndicesDiskUsage + ExistsAlias IndicesExistsAlias + ExistsDocumentType IndicesExistsDocumentType + ExistsIndexTemplate IndicesExistsIndexTemplate + Exists IndicesExists + ExistsTemplate IndicesExistsTemplate + FieldUsageStats IndicesFieldUsageStats + Flush IndicesFlush + FlushSynced IndicesFlushSynced + Forcemerge IndicesForcemerge + Freeze IndicesFreeze + GetAlias IndicesGetAlias + GetDataStream IndicesGetDataStream + GetFieldMapping IndicesGetFieldMapping + GetIndexTemplate IndicesGetIndexTemplate + GetMapping IndicesGetMapping + Get IndicesGet + GetSettings IndicesGetSettings + GetTemplate IndicesGetTemplate + GetUpgrade IndicesGetUpgrade + MigrateToDataStream IndicesMigrateToDataStream + ModifyDataStream IndicesModifyDataStream + Open IndicesOpen + PromoteDataStream IndicesPromoteDataStream + PutAlias IndicesPutAlias + PutIndexTemplate IndicesPutIndexTemplate + PutMapping IndicesPutMapping + PutSettings IndicesPutSettings + PutTemplate IndicesPutTemplate + Recovery IndicesRecovery + Refresh IndicesRefresh + ReloadSearchAnalyzers IndicesReloadSearchAnalyzers + ResolveIndex IndicesResolveIndex + Rollover IndicesRollover + Segments IndicesSegments + ShardStores IndicesShardStores + Shrink IndicesShrink + SimulateIndexTemplate IndicesSimulateIndexTemplate + SimulateTemplate IndicesSimulateTemplate + Split IndicesSplit + Stats IndicesStats + Unfreeze IndicesUnfreeze + UpdateAliases IndicesUpdateAliases + Upgrade IndicesUpgrade + ValidateQuery IndicesValidateQuery +} + +// Ingest contains the Ingest APIs +type Ingest struct { + DeletePipeline IngestDeletePipeline + GeoIPStats IngestGeoIPStats + GetPipeline IngestGetPipeline + ProcessorGrok IngestProcessorGrok + PutPipeline IngestPutPipeline + Simulate IngestSimulate +} + +// Nodes contains the Nodes APIs +type Nodes struct { + ClearMeteringArchive NodesClearMeteringArchive + ClearRepositoriesMeteringArchive NodesClearRepositoriesMeteringArchive + GetMeteringInfo NodesGetMeteringInfo + GetRepositoriesMeteringInfo NodesGetRepositoriesMeteringInfo + HotThreads NodesHotThreads + Info NodesInfo + ReloadSecureSettings NodesReloadSecureSettings + Stats NodesStats + Usage NodesUsage +} + +// Remote contains the Remote APIs +type Remote struct { +} + +// Snapshot contains the Snapshot APIs +type Snapshot struct { + CleanupRepository SnapshotCleanupRepository + Clone SnapshotClone + CreateRepository SnapshotCreateRepository + Create SnapshotCreate + DeleteRepository SnapshotDeleteRepository + Delete SnapshotDelete + GetRepository SnapshotGetRepository + Get SnapshotGet + RepositoryAnalyze SnapshotRepositoryAnalyze + Restore SnapshotRestore + Status SnapshotStatus + VerifyRepository SnapshotVerifyRepository +} + +// Tasks contains the Tasks APIs +type Tasks struct { + Cancel TasksCancel + Get TasksGet + List TasksList +} + +// AsyncSearch contains the AsyncSearch APIs +type AsyncSearch struct { + Delete AsyncSearchDelete + Get AsyncSearchGet + Status AsyncSearchStatus + Submit AsyncSearchSubmit +} + +// CCR contains the CCR APIs +type CCR struct { + DeleteAutoFollowPattern CCRDeleteAutoFollowPattern + FollowInfo CCRFollowInfo + Follow CCRFollow + FollowStats CCRFollowStats + ForgetFollower CCRForgetFollower + GetAutoFollowPattern CCRGetAutoFollowPattern + PauseAutoFollowPattern CCRPauseAutoFollowPattern + PauseFollow CCRPauseFollow + PutAutoFollowPattern CCRPutAutoFollowPattern + ResumeAutoFollowPattern CCRResumeAutoFollowPattern + ResumeFollow CCRResumeFollow + Stats CCRStats + Unfollow CCRUnfollow +} + +// ILM contains the ILM APIs +type ILM struct { + DeleteLifecycle ILMDeleteLifecycle + ExplainLifecycle ILMExplainLifecycle + GetLifecycle ILMGetLifecycle + GetStatus ILMGetStatus + MigrateToDataTiers ILMMigrateToDataTiers + MoveToStep ILMMoveToStep + PutLifecycle ILMPutLifecycle + RemovePolicy ILMRemovePolicy + Retry ILMRetry + Start ILMStart + Stop ILMStop +} + +// License contains the License APIs +type License struct { + Delete LicenseDelete + GetBasicStatus LicenseGetBasicStatus + Get LicenseGet + GetTrialStatus LicenseGetTrialStatus + Post LicensePost + PostStartBasic LicensePostStartBasic + PostStartTrial LicensePostStartTrial +} + +// Migration contains the Migration APIs +type Migration struct { + Deprecations MigrationDeprecations + GetFeatureUpgradeStatus MigrationGetFeatureUpgradeStatus + PostFeatureUpgrade MigrationPostFeatureUpgrade +} + +// ML contains the ML APIs +type ML struct { + CloseJob MLCloseJob + DeleteCalendarEvent MLDeleteCalendarEvent + DeleteCalendarJob MLDeleteCalendarJob + DeleteCalendar MLDeleteCalendar + DeleteDataFrameAnalytics MLDeleteDataFrameAnalytics + DeleteDatafeed MLDeleteDatafeed + DeleteExpiredData MLDeleteExpiredData + DeleteFilter MLDeleteFilter + DeleteForecast MLDeleteForecast + DeleteJob MLDeleteJob + DeleteModelSnapshot MLDeleteModelSnapshot + DeleteTrainedModelAlias MLDeleteTrainedModelAlias + DeleteTrainedModel MLDeleteTrainedModel + EstimateModelMemory MLEstimateModelMemory + EvaluateDataFrame MLEvaluateDataFrame + ExplainDataFrameAnalytics MLExplainDataFrameAnalytics + FindFileStructure MLFindFileStructure + FlushJob MLFlushJob + Forecast MLForecast + GetBuckets MLGetBuckets + GetCalendarEvents MLGetCalendarEvents + GetCalendars MLGetCalendars + GetCategories MLGetCategories + GetDataFrameAnalytics MLGetDataFrameAnalytics + GetDataFrameAnalyticsStats MLGetDataFrameAnalyticsStats + GetDatafeedStats MLGetDatafeedStats + GetDatafeeds MLGetDatafeeds + GetFilters MLGetFilters + GetInfluencers MLGetInfluencers + GetJobStats MLGetJobStats + GetJobs MLGetJobs + GetModelSnapshotUpgradeStats MLGetModelSnapshotUpgradeStats + GetModelSnapshots MLGetModelSnapshots + GetOverallBuckets MLGetOverallBuckets + GetRecords MLGetRecords + GetTrainedModels MLGetTrainedModels + GetTrainedModelsStats MLGetTrainedModelsStats + Info MLInfo + OpenJob MLOpenJob + PostCalendarEvents MLPostCalendarEvents + PostData MLPostData + PreviewDataFrameAnalytics MLPreviewDataFrameAnalytics + PreviewDatafeed MLPreviewDatafeed + PutCalendarJob MLPutCalendarJob + PutCalendar MLPutCalendar + PutDataFrameAnalytics MLPutDataFrameAnalytics + PutDatafeed MLPutDatafeed + PutFilter MLPutFilter + PutJob MLPutJob + PutTrainedModelAlias MLPutTrainedModelAlias + PutTrainedModel MLPutTrainedModel + ResetJob MLResetJob + RevertModelSnapshot MLRevertModelSnapshot + SetUpgradeMode MLSetUpgradeMode + StartDataFrameAnalytics MLStartDataFrameAnalytics + StartDatafeed MLStartDatafeed + StopDataFrameAnalytics MLStopDataFrameAnalytics + StopDatafeed MLStopDatafeed + UpdateDataFrameAnalytics MLUpdateDataFrameAnalytics + UpdateDatafeed MLUpdateDatafeed + UpdateFilter MLUpdateFilter + UpdateJob MLUpdateJob + UpdateModelSnapshot MLUpdateModelSnapshot + UpgradeJobSnapshot MLUpgradeJobSnapshot + ValidateDetector MLValidateDetector + Validate MLValidate +} + +// Monitoring contains the Monitoring APIs +type Monitoring struct { + Bulk MonitoringBulk +} + +// Rollup contains the Rollup APIs +type Rollup struct { + DeleteJob RollupDeleteJob + GetJobs RollupGetJobs + GetCaps RollupGetRollupCaps + GetIndexCaps RollupGetRollupIndexCaps + PutJob RollupPutJob + Rollup RollupRollup + Search RollupRollupSearch + StartJob RollupStartJob + StopJob RollupStopJob +} + +// Security contains the Security APIs +type Security struct { + Authenticate SecurityAuthenticate + ChangePassword SecurityChangePassword + ClearAPIKeyCache SecurityClearAPIKeyCache + ClearCachedPrivileges SecurityClearCachedPrivileges + ClearCachedRealms SecurityClearCachedRealms + ClearCachedRoles SecurityClearCachedRoles + ClearCachedServiceTokens SecurityClearCachedServiceTokens + CreateAPIKey SecurityCreateAPIKey + CreateServiceToken SecurityCreateServiceToken + DeletePrivileges SecurityDeletePrivileges + DeleteRoleMapping SecurityDeleteRoleMapping + DeleteRole SecurityDeleteRole + DeleteServiceToken SecurityDeleteServiceToken + DeleteUser SecurityDeleteUser + DisableUser SecurityDisableUser + EnableUser SecurityEnableUser + GetAPIKey SecurityGetAPIKey + GetBuiltinPrivileges SecurityGetBuiltinPrivileges + GetPrivileges SecurityGetPrivileges + GetRoleMapping SecurityGetRoleMapping + GetRole SecurityGetRole + GetServiceAccounts SecurityGetServiceAccounts + GetServiceCredentials SecurityGetServiceCredentials + GetToken SecurityGetToken + GetUserPrivileges SecurityGetUserPrivileges + GetUser SecurityGetUser + GrantAPIKey SecurityGrantAPIKey + HasPrivileges SecurityHasPrivileges + InvalidateAPIKey SecurityInvalidateAPIKey + InvalidateToken SecurityInvalidateToken + PutPrivileges SecurityPutPrivileges + PutRoleMapping SecurityPutRoleMapping + PutRole SecurityPutRole + PutUser SecurityPutUser + QueryAPIKeys SecurityQueryAPIKeys + SamlAuthenticate SecuritySamlAuthenticate + SamlCompleteLogout SecuritySamlCompleteLogout + SamlInvalidate SecuritySamlInvalidate + SamlLogout SecuritySamlLogout + SamlPrepareAuthentication SecuritySamlPrepareAuthentication + SamlServiceProviderMetadata SecuritySamlServiceProviderMetadata +} + +// SQL contains the SQL APIs +type SQL struct { + ClearCursor SQLClearCursor + DeleteAsync SQLDeleteAsync + GetAsync SQLGetAsync + GetAsyncStatus SQLGetAsyncStatus + Query SQLQuery + Translate SQLTranslate +} + +// SSL contains the SSL APIs +type SSL struct { + Certificates SSLCertificates +} + +// Watcher contains the Watcher APIs +type Watcher struct { + AckWatch WatcherAckWatch + ActivateWatch WatcherActivateWatch + DeactivateWatch WatcherDeactivateWatch + DeleteWatch WatcherDeleteWatch + ExecuteWatch WatcherExecuteWatch + GetWatch WatcherGetWatch + PutWatch WatcherPutWatch + QueryWatches WatcherQueryWatches + Start WatcherStart + Stats WatcherStats + Stop WatcherStop +} + +// XPack contains the XPack APIs +type XPack struct { + Info XPackInfo + Usage XPackUsage +} + +// New creates new API +func New(t Transport) *API { + return &API{ + AutoscalingDeleteAutoscalingPolicy: newAutoscalingDeleteAutoscalingPolicyFunc(t), + AutoscalingGetAutoscalingCapacity: newAutoscalingGetAutoscalingCapacityFunc(t), + AutoscalingGetAutoscalingDecision: newAutoscalingGetAutoscalingDecisionFunc(t), + AutoscalingGetAutoscalingPolicy: newAutoscalingGetAutoscalingPolicyFunc(t), + AutoscalingPutAutoscalingPolicy: newAutoscalingPutAutoscalingPolicyFunc(t), + Bulk: newBulkFunc(t), + ClearScroll: newClearScrollFunc(t), + ClosePointInTime: newClosePointInTimeFunc(t), + Count: newCountFunc(t), + Create: newCreateFunc(t), + DanglingIndicesDeleteDanglingIndex: newDanglingIndicesDeleteDanglingIndexFunc(t), + DanglingIndicesImportDanglingIndex: newDanglingIndicesImportDanglingIndexFunc(t), + DanglingIndicesListDanglingIndices: newDanglingIndicesListDanglingIndicesFunc(t), + DataFrameTransformDeprecatedDeleteTransform: newDataFrameTransformDeprecatedDeleteTransformFunc(t), + DataFrameTransformDeprecatedGetTransform: newDataFrameTransformDeprecatedGetTransformFunc(t), + DataFrameTransformDeprecatedGetTransformStats: newDataFrameTransformDeprecatedGetTransformStatsFunc(t), + DataFrameTransformDeprecatedPreviewTransform: newDataFrameTransformDeprecatedPreviewTransformFunc(t), + DataFrameTransformDeprecatedPutTransform: newDataFrameTransformDeprecatedPutTransformFunc(t), + DataFrameTransformDeprecatedStartTransform: newDataFrameTransformDeprecatedStartTransformFunc(t), + DataFrameTransformDeprecatedStopTransform: newDataFrameTransformDeprecatedStopTransformFunc(t), + DataFrameTransformDeprecatedUpdateTransform: newDataFrameTransformDeprecatedUpdateTransformFunc(t), + DeleteByQuery: newDeleteByQueryFunc(t), + DeleteByQueryRethrottle: newDeleteByQueryRethrottleFunc(t), + Delete: newDeleteFunc(t), + DeleteScript: newDeleteScriptFunc(t), + EnrichDeletePolicy: newEnrichDeletePolicyFunc(t), + EnrichExecutePolicy: newEnrichExecutePolicyFunc(t), + EnrichGetPolicy: newEnrichGetPolicyFunc(t), + EnrichPutPolicy: newEnrichPutPolicyFunc(t), + EnrichStats: newEnrichStatsFunc(t), + EqlDelete: newEqlDeleteFunc(t), + EqlGet: newEqlGetFunc(t), + EqlGetStatus: newEqlGetStatusFunc(t), + EqlSearch: newEqlSearchFunc(t), + Exists: newExistsFunc(t), + ExistsSource: newExistsSourceFunc(t), + Explain: newExplainFunc(t), + FeaturesGetFeatures: newFeaturesGetFeaturesFunc(t), + FeaturesResetFeatures: newFeaturesResetFeaturesFunc(t), + FieldCaps: newFieldCapsFunc(t), + FleetGlobalCheckpoints: newFleetGlobalCheckpointsFunc(t), + FleetMsearch: newFleetMsearchFunc(t), + FleetSearch: newFleetSearchFunc(t), + Get: newGetFunc(t), + GetScriptContext: newGetScriptContextFunc(t), + GetScriptLanguages: newGetScriptLanguagesFunc(t), + GetScript: newGetScriptFunc(t), + GetSource: newGetSourceFunc(t), + GraphExplore: newGraphExploreFunc(t), + Index: newIndexFunc(t), + Info: newInfoFunc(t), + LogstashDeletePipeline: newLogstashDeletePipelineFunc(t), + LogstashGetPipeline: newLogstashGetPipelineFunc(t), + LogstashPutPipeline: newLogstashPutPipelineFunc(t), + Mget: newMgetFunc(t), + Msearch: newMsearchFunc(t), + MsearchTemplate: newMsearchTemplateFunc(t), + Mtermvectors: newMtermvectorsFunc(t), + OpenPointInTime: newOpenPointInTimeFunc(t), + Ping: newPingFunc(t), + PutScript: newPutScriptFunc(t), + RankEval: newRankEvalFunc(t), + Reindex: newReindexFunc(t), + ReindexRethrottle: newReindexRethrottleFunc(t), + RenderSearchTemplate: newRenderSearchTemplateFunc(t), + ScriptsPainlessExecute: newScriptsPainlessExecuteFunc(t), + Scroll: newScrollFunc(t), + SearchMvt: newSearchMvtFunc(t), + Search: newSearchFunc(t), + SearchShards: newSearchShardsFunc(t), + SearchTemplate: newSearchTemplateFunc(t), + SearchableSnapshotsCacheStats: newSearchableSnapshotsCacheStatsFunc(t), + SearchableSnapshotsClearCache: newSearchableSnapshotsClearCacheFunc(t), + SearchableSnapshotsMount: newSearchableSnapshotsMountFunc(t), + SearchableSnapshotsRepositoryStats: newSearchableSnapshotsRepositoryStatsFunc(t), + SearchableSnapshotsStats: newSearchableSnapshotsStatsFunc(t), + ShutdownDeleteNode: newShutdownDeleteNodeFunc(t), + ShutdownGetNode: newShutdownGetNodeFunc(t), + ShutdownPutNode: newShutdownPutNodeFunc(t), + SlmDeleteLifecycle: newSlmDeleteLifecycleFunc(t), + SlmExecuteLifecycle: newSlmExecuteLifecycleFunc(t), + SlmExecuteRetention: newSlmExecuteRetentionFunc(t), + SlmGetLifecycle: newSlmGetLifecycleFunc(t), + SlmGetStats: newSlmGetStatsFunc(t), + SlmGetStatus: newSlmGetStatusFunc(t), + SlmPutLifecycle: newSlmPutLifecycleFunc(t), + SlmStart: newSlmStartFunc(t), + SlmStop: newSlmStopFunc(t), + TermsEnum: newTermsEnumFunc(t), + Termvectors: newTermvectorsFunc(t), + TextStructureFindStructure: newTextStructureFindStructureFunc(t), + TransformDeleteTransform: newTransformDeleteTransformFunc(t), + TransformGetTransform: newTransformGetTransformFunc(t), + TransformGetTransformStats: newTransformGetTransformStatsFunc(t), + TransformPreviewTransform: newTransformPreviewTransformFunc(t), + TransformPutTransform: newTransformPutTransformFunc(t), + TransformStartTransform: newTransformStartTransformFunc(t), + TransformStopTransform: newTransformStopTransformFunc(t), + TransformUpdateTransform: newTransformUpdateTransformFunc(t), + TransformUpgradeTransforms: newTransformUpgradeTransformsFunc(t), + UpdateByQuery: newUpdateByQueryFunc(t), + UpdateByQueryRethrottle: newUpdateByQueryRethrottleFunc(t), + Update: newUpdateFunc(t), + Cat: &Cat{ + Aliases: newCatAliasesFunc(t), + Allocation: newCatAllocationFunc(t), + Count: newCatCountFunc(t), + Fielddata: newCatFielddataFunc(t), + Health: newCatHealthFunc(t), + Help: newCatHelpFunc(t), + Indices: newCatIndicesFunc(t), + MLDataFrameAnalytics: newCatMLDataFrameAnalyticsFunc(t), + MLDatafeeds: newCatMLDatafeedsFunc(t), + MLJobs: newCatMLJobsFunc(t), + MLTrainedModels: newCatMLTrainedModelsFunc(t), + Master: newCatMasterFunc(t), + Nodeattrs: newCatNodeattrsFunc(t), + Nodes: newCatNodesFunc(t), + PendingTasks: newCatPendingTasksFunc(t), + Plugins: newCatPluginsFunc(t), + Recovery: newCatRecoveryFunc(t), + Repositories: newCatRepositoriesFunc(t), + Segments: newCatSegmentsFunc(t), + Shards: newCatShardsFunc(t), + Snapshots: newCatSnapshotsFunc(t), + Tasks: newCatTasksFunc(t), + Templates: newCatTemplatesFunc(t), + ThreadPool: newCatThreadPoolFunc(t), + Transforms: newCatTransformsFunc(t), + }, + Cluster: &Cluster{ + AllocationExplain: newClusterAllocationExplainFunc(t), + DeleteComponentTemplate: newClusterDeleteComponentTemplateFunc(t), + DeleteVotingConfigExclusions: newClusterDeleteVotingConfigExclusionsFunc(t), + ExistsComponentTemplate: newClusterExistsComponentTemplateFunc(t), + GetComponentTemplate: newClusterGetComponentTemplateFunc(t), + GetSettings: newClusterGetSettingsFunc(t), + Health: newClusterHealthFunc(t), + PendingTasks: newClusterPendingTasksFunc(t), + PostVotingConfigExclusions: newClusterPostVotingConfigExclusionsFunc(t), + PutComponentTemplate: newClusterPutComponentTemplateFunc(t), + PutSettings: newClusterPutSettingsFunc(t), + RemoteInfo: newClusterRemoteInfoFunc(t), + Reroute: newClusterRerouteFunc(t), + State: newClusterStateFunc(t), + Stats: newClusterStatsFunc(t), + }, + Indices: &Indices{ + AddBlock: newIndicesAddBlockFunc(t), + Analyze: newIndicesAnalyzeFunc(t), + ClearCache: newIndicesClearCacheFunc(t), + Clone: newIndicesCloneFunc(t), + Close: newIndicesCloseFunc(t), + CreateDataStream: newIndicesCreateDataStreamFunc(t), + Create: newIndicesCreateFunc(t), + DataStreamsStats: newIndicesDataStreamsStatsFunc(t), + DeleteAlias: newIndicesDeleteAliasFunc(t), + DeleteDataStream: newIndicesDeleteDataStreamFunc(t), + DeleteIndexTemplate: newIndicesDeleteIndexTemplateFunc(t), + Delete: newIndicesDeleteFunc(t), + DeleteTemplate: newIndicesDeleteTemplateFunc(t), + DiskUsage: newIndicesDiskUsageFunc(t), + ExistsAlias: newIndicesExistsAliasFunc(t), + ExistsDocumentType: newIndicesExistsDocumentTypeFunc(t), + ExistsIndexTemplate: newIndicesExistsIndexTemplateFunc(t), + Exists: newIndicesExistsFunc(t), + ExistsTemplate: newIndicesExistsTemplateFunc(t), + FieldUsageStats: newIndicesFieldUsageStatsFunc(t), + Flush: newIndicesFlushFunc(t), + FlushSynced: newIndicesFlushSyncedFunc(t), + Forcemerge: newIndicesForcemergeFunc(t), + Freeze: newIndicesFreezeFunc(t), + GetAlias: newIndicesGetAliasFunc(t), + GetDataStream: newIndicesGetDataStreamFunc(t), + GetFieldMapping: newIndicesGetFieldMappingFunc(t), + GetIndexTemplate: newIndicesGetIndexTemplateFunc(t), + GetMapping: newIndicesGetMappingFunc(t), + Get: newIndicesGetFunc(t), + GetSettings: newIndicesGetSettingsFunc(t), + GetTemplate: newIndicesGetTemplateFunc(t), + GetUpgrade: newIndicesGetUpgradeFunc(t), + MigrateToDataStream: newIndicesMigrateToDataStreamFunc(t), + ModifyDataStream: newIndicesModifyDataStreamFunc(t), + Open: newIndicesOpenFunc(t), + PromoteDataStream: newIndicesPromoteDataStreamFunc(t), + PutAlias: newIndicesPutAliasFunc(t), + PutIndexTemplate: newIndicesPutIndexTemplateFunc(t), + PutMapping: newIndicesPutMappingFunc(t), + PutSettings: newIndicesPutSettingsFunc(t), + PutTemplate: newIndicesPutTemplateFunc(t), + Recovery: newIndicesRecoveryFunc(t), + Refresh: newIndicesRefreshFunc(t), + ReloadSearchAnalyzers: newIndicesReloadSearchAnalyzersFunc(t), + ResolveIndex: newIndicesResolveIndexFunc(t), + Rollover: newIndicesRolloverFunc(t), + Segments: newIndicesSegmentsFunc(t), + ShardStores: newIndicesShardStoresFunc(t), + Shrink: newIndicesShrinkFunc(t), + SimulateIndexTemplate: newIndicesSimulateIndexTemplateFunc(t), + SimulateTemplate: newIndicesSimulateTemplateFunc(t), + Split: newIndicesSplitFunc(t), + Stats: newIndicesStatsFunc(t), + Unfreeze: newIndicesUnfreezeFunc(t), + UpdateAliases: newIndicesUpdateAliasesFunc(t), + Upgrade: newIndicesUpgradeFunc(t), + ValidateQuery: newIndicesValidateQueryFunc(t), + }, + Ingest: &Ingest{ + DeletePipeline: newIngestDeletePipelineFunc(t), + GeoIPStats: newIngestGeoIPStatsFunc(t), + GetPipeline: newIngestGetPipelineFunc(t), + ProcessorGrok: newIngestProcessorGrokFunc(t), + PutPipeline: newIngestPutPipelineFunc(t), + Simulate: newIngestSimulateFunc(t), + }, + Nodes: &Nodes{ + ClearMeteringArchive: newNodesClearMeteringArchiveFunc(t), + ClearRepositoriesMeteringArchive: newNodesClearRepositoriesMeteringArchiveFunc(t), + GetMeteringInfo: newNodesGetMeteringInfoFunc(t), + GetRepositoriesMeteringInfo: newNodesGetRepositoriesMeteringInfoFunc(t), + HotThreads: newNodesHotThreadsFunc(t), + Info: newNodesInfoFunc(t), + ReloadSecureSettings: newNodesReloadSecureSettingsFunc(t), + Stats: newNodesStatsFunc(t), + Usage: newNodesUsageFunc(t), + }, + Remote: &Remote{}, + Snapshot: &Snapshot{ + CleanupRepository: newSnapshotCleanupRepositoryFunc(t), + Clone: newSnapshotCloneFunc(t), + CreateRepository: newSnapshotCreateRepositoryFunc(t), + Create: newSnapshotCreateFunc(t), + DeleteRepository: newSnapshotDeleteRepositoryFunc(t), + Delete: newSnapshotDeleteFunc(t), + GetRepository: newSnapshotGetRepositoryFunc(t), + Get: newSnapshotGetFunc(t), + RepositoryAnalyze: newSnapshotRepositoryAnalyzeFunc(t), + Restore: newSnapshotRestoreFunc(t), + Status: newSnapshotStatusFunc(t), + VerifyRepository: newSnapshotVerifyRepositoryFunc(t), + }, + Tasks: &Tasks{ + Cancel: newTasksCancelFunc(t), + Get: newTasksGetFunc(t), + List: newTasksListFunc(t), + }, + AsyncSearch: &AsyncSearch{ + Delete: newAsyncSearchDeleteFunc(t), + Get: newAsyncSearchGetFunc(t), + Status: newAsyncSearchStatusFunc(t), + Submit: newAsyncSearchSubmitFunc(t), + }, + CCR: &CCR{ + DeleteAutoFollowPattern: newCCRDeleteAutoFollowPatternFunc(t), + FollowInfo: newCCRFollowInfoFunc(t), + Follow: newCCRFollowFunc(t), + FollowStats: newCCRFollowStatsFunc(t), + ForgetFollower: newCCRForgetFollowerFunc(t), + GetAutoFollowPattern: newCCRGetAutoFollowPatternFunc(t), + PauseAutoFollowPattern: newCCRPauseAutoFollowPatternFunc(t), + PauseFollow: newCCRPauseFollowFunc(t), + PutAutoFollowPattern: newCCRPutAutoFollowPatternFunc(t), + ResumeAutoFollowPattern: newCCRResumeAutoFollowPatternFunc(t), + ResumeFollow: newCCRResumeFollowFunc(t), + Stats: newCCRStatsFunc(t), + Unfollow: newCCRUnfollowFunc(t), + }, + ILM: &ILM{ + DeleteLifecycle: newILMDeleteLifecycleFunc(t), + ExplainLifecycle: newILMExplainLifecycleFunc(t), + GetLifecycle: newILMGetLifecycleFunc(t), + GetStatus: newILMGetStatusFunc(t), + MigrateToDataTiers: newILMMigrateToDataTiersFunc(t), + MoveToStep: newILMMoveToStepFunc(t), + PutLifecycle: newILMPutLifecycleFunc(t), + RemovePolicy: newILMRemovePolicyFunc(t), + Retry: newILMRetryFunc(t), + Start: newILMStartFunc(t), + Stop: newILMStopFunc(t), + }, + License: &License{ + Delete: newLicenseDeleteFunc(t), + GetBasicStatus: newLicenseGetBasicStatusFunc(t), + Get: newLicenseGetFunc(t), + GetTrialStatus: newLicenseGetTrialStatusFunc(t), + Post: newLicensePostFunc(t), + PostStartBasic: newLicensePostStartBasicFunc(t), + PostStartTrial: newLicensePostStartTrialFunc(t), + }, + Migration: &Migration{ + Deprecations: newMigrationDeprecationsFunc(t), + GetFeatureUpgradeStatus: newMigrationGetFeatureUpgradeStatusFunc(t), + PostFeatureUpgrade: newMigrationPostFeatureUpgradeFunc(t), + }, + ML: &ML{ + CloseJob: newMLCloseJobFunc(t), + DeleteCalendarEvent: newMLDeleteCalendarEventFunc(t), + DeleteCalendarJob: newMLDeleteCalendarJobFunc(t), + DeleteCalendar: newMLDeleteCalendarFunc(t), + DeleteDataFrameAnalytics: newMLDeleteDataFrameAnalyticsFunc(t), + DeleteDatafeed: newMLDeleteDatafeedFunc(t), + DeleteExpiredData: newMLDeleteExpiredDataFunc(t), + DeleteFilter: newMLDeleteFilterFunc(t), + DeleteForecast: newMLDeleteForecastFunc(t), + DeleteJob: newMLDeleteJobFunc(t), + DeleteModelSnapshot: newMLDeleteModelSnapshotFunc(t), + DeleteTrainedModelAlias: newMLDeleteTrainedModelAliasFunc(t), + DeleteTrainedModel: newMLDeleteTrainedModelFunc(t), + EstimateModelMemory: newMLEstimateModelMemoryFunc(t), + EvaluateDataFrame: newMLEvaluateDataFrameFunc(t), + ExplainDataFrameAnalytics: newMLExplainDataFrameAnalyticsFunc(t), + FindFileStructure: newMLFindFileStructureFunc(t), + FlushJob: newMLFlushJobFunc(t), + Forecast: newMLForecastFunc(t), + GetBuckets: newMLGetBucketsFunc(t), + GetCalendarEvents: newMLGetCalendarEventsFunc(t), + GetCalendars: newMLGetCalendarsFunc(t), + GetCategories: newMLGetCategoriesFunc(t), + GetDataFrameAnalytics: newMLGetDataFrameAnalyticsFunc(t), + GetDataFrameAnalyticsStats: newMLGetDataFrameAnalyticsStatsFunc(t), + GetDatafeedStats: newMLGetDatafeedStatsFunc(t), + GetDatafeeds: newMLGetDatafeedsFunc(t), + GetFilters: newMLGetFiltersFunc(t), + GetInfluencers: newMLGetInfluencersFunc(t), + GetJobStats: newMLGetJobStatsFunc(t), + GetJobs: newMLGetJobsFunc(t), + GetModelSnapshotUpgradeStats: newMLGetModelSnapshotUpgradeStatsFunc(t), + GetModelSnapshots: newMLGetModelSnapshotsFunc(t), + GetOverallBuckets: newMLGetOverallBucketsFunc(t), + GetRecords: newMLGetRecordsFunc(t), + GetTrainedModels: newMLGetTrainedModelsFunc(t), + GetTrainedModelsStats: newMLGetTrainedModelsStatsFunc(t), + Info: newMLInfoFunc(t), + OpenJob: newMLOpenJobFunc(t), + PostCalendarEvents: newMLPostCalendarEventsFunc(t), + PostData: newMLPostDataFunc(t), + PreviewDataFrameAnalytics: newMLPreviewDataFrameAnalyticsFunc(t), + PreviewDatafeed: newMLPreviewDatafeedFunc(t), + PutCalendarJob: newMLPutCalendarJobFunc(t), + PutCalendar: newMLPutCalendarFunc(t), + PutDataFrameAnalytics: newMLPutDataFrameAnalyticsFunc(t), + PutDatafeed: newMLPutDatafeedFunc(t), + PutFilter: newMLPutFilterFunc(t), + PutJob: newMLPutJobFunc(t), + PutTrainedModelAlias: newMLPutTrainedModelAliasFunc(t), + PutTrainedModel: newMLPutTrainedModelFunc(t), + ResetJob: newMLResetJobFunc(t), + RevertModelSnapshot: newMLRevertModelSnapshotFunc(t), + SetUpgradeMode: newMLSetUpgradeModeFunc(t), + StartDataFrameAnalytics: newMLStartDataFrameAnalyticsFunc(t), + StartDatafeed: newMLStartDatafeedFunc(t), + StopDataFrameAnalytics: newMLStopDataFrameAnalyticsFunc(t), + StopDatafeed: newMLStopDatafeedFunc(t), + UpdateDataFrameAnalytics: newMLUpdateDataFrameAnalyticsFunc(t), + UpdateDatafeed: newMLUpdateDatafeedFunc(t), + UpdateFilter: newMLUpdateFilterFunc(t), + UpdateJob: newMLUpdateJobFunc(t), + UpdateModelSnapshot: newMLUpdateModelSnapshotFunc(t), + UpgradeJobSnapshot: newMLUpgradeJobSnapshotFunc(t), + ValidateDetector: newMLValidateDetectorFunc(t), + Validate: newMLValidateFunc(t), + }, + Monitoring: &Monitoring{ + Bulk: newMonitoringBulkFunc(t), + }, + Rollup: &Rollup{ + DeleteJob: newRollupDeleteJobFunc(t), + GetJobs: newRollupGetJobsFunc(t), + GetCaps: newRollupGetRollupCapsFunc(t), + GetIndexCaps: newRollupGetRollupIndexCapsFunc(t), + PutJob: newRollupPutJobFunc(t), + Rollup: newRollupRollupFunc(t), + Search: newRollupRollupSearchFunc(t), + StartJob: newRollupStartJobFunc(t), + StopJob: newRollupStopJobFunc(t), + }, + Security: &Security{ + Authenticate: newSecurityAuthenticateFunc(t), + ChangePassword: newSecurityChangePasswordFunc(t), + ClearAPIKeyCache: newSecurityClearAPIKeyCacheFunc(t), + ClearCachedPrivileges: newSecurityClearCachedPrivilegesFunc(t), + ClearCachedRealms: newSecurityClearCachedRealmsFunc(t), + ClearCachedRoles: newSecurityClearCachedRolesFunc(t), + ClearCachedServiceTokens: newSecurityClearCachedServiceTokensFunc(t), + CreateAPIKey: newSecurityCreateAPIKeyFunc(t), + CreateServiceToken: newSecurityCreateServiceTokenFunc(t), + DeletePrivileges: newSecurityDeletePrivilegesFunc(t), + DeleteRoleMapping: newSecurityDeleteRoleMappingFunc(t), + DeleteRole: newSecurityDeleteRoleFunc(t), + DeleteServiceToken: newSecurityDeleteServiceTokenFunc(t), + DeleteUser: newSecurityDeleteUserFunc(t), + DisableUser: newSecurityDisableUserFunc(t), + EnableUser: newSecurityEnableUserFunc(t), + GetAPIKey: newSecurityGetAPIKeyFunc(t), + GetBuiltinPrivileges: newSecurityGetBuiltinPrivilegesFunc(t), + GetPrivileges: newSecurityGetPrivilegesFunc(t), + GetRoleMapping: newSecurityGetRoleMappingFunc(t), + GetRole: newSecurityGetRoleFunc(t), + GetServiceAccounts: newSecurityGetServiceAccountsFunc(t), + GetServiceCredentials: newSecurityGetServiceCredentialsFunc(t), + GetToken: newSecurityGetTokenFunc(t), + GetUserPrivileges: newSecurityGetUserPrivilegesFunc(t), + GetUser: newSecurityGetUserFunc(t), + GrantAPIKey: newSecurityGrantAPIKeyFunc(t), + HasPrivileges: newSecurityHasPrivilegesFunc(t), + InvalidateAPIKey: newSecurityInvalidateAPIKeyFunc(t), + InvalidateToken: newSecurityInvalidateTokenFunc(t), + PutPrivileges: newSecurityPutPrivilegesFunc(t), + PutRoleMapping: newSecurityPutRoleMappingFunc(t), + PutRole: newSecurityPutRoleFunc(t), + PutUser: newSecurityPutUserFunc(t), + QueryAPIKeys: newSecurityQueryAPIKeysFunc(t), + SamlAuthenticate: newSecuritySamlAuthenticateFunc(t), + SamlCompleteLogout: newSecuritySamlCompleteLogoutFunc(t), + SamlInvalidate: newSecuritySamlInvalidateFunc(t), + SamlLogout: newSecuritySamlLogoutFunc(t), + SamlPrepareAuthentication: newSecuritySamlPrepareAuthenticationFunc(t), + SamlServiceProviderMetadata: newSecuritySamlServiceProviderMetadataFunc(t), + }, + SQL: &SQL{ + ClearCursor: newSQLClearCursorFunc(t), + DeleteAsync: newSQLDeleteAsyncFunc(t), + GetAsync: newSQLGetAsyncFunc(t), + GetAsyncStatus: newSQLGetAsyncStatusFunc(t), + Query: newSQLQueryFunc(t), + Translate: newSQLTranslateFunc(t), + }, + SSL: &SSL{ + Certificates: newSSLCertificatesFunc(t), + }, + Watcher: &Watcher{ + AckWatch: newWatcherAckWatchFunc(t), + ActivateWatch: newWatcherActivateWatchFunc(t), + DeactivateWatch: newWatcherDeactivateWatchFunc(t), + DeleteWatch: newWatcherDeleteWatchFunc(t), + ExecuteWatch: newWatcherExecuteWatchFunc(t), + GetWatch: newWatcherGetWatchFunc(t), + PutWatch: newWatcherPutWatchFunc(t), + QueryWatches: newWatcherQueryWatchesFunc(t), + Start: newWatcherStartFunc(t), + Stats: newWatcherStatsFunc(t), + Stop: newWatcherStopFunc(t), + }, + XPack: &XPack{ + Info: newXPackInfoFunc(t), + Usage: newXPackUsageFunc(t), + }, + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.bulk.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.bulk.go new file mode 100644 index 00000000..5a800e30 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.bulk.go @@ -0,0 +1,334 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" + "time" +) + +func newBulkFunc(t Transport) Bulk { + return func(body io.Reader, o ...func(*BulkRequest)) (*Response, error) { + var r = BulkRequest{Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// Bulk allows to perform multiple index/update/delete operations in a single request. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-bulk.html. +type Bulk func(body io.Reader, o ...func(*BulkRequest)) (*Response, error) + +// BulkRequest configures the Bulk API request. +type BulkRequest struct { + Index string + DocumentType string + + Body io.Reader + + Pipeline string + Refresh string + RequireAlias *bool + Routing string + Source []string + SourceExcludes []string + SourceIncludes []string + Timeout time.Duration + WaitForActiveShards string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r BulkRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len(r.Index) + 1 + len(r.DocumentType) + 1 + len("_bulk")) + if r.Index != "" { + path.WriteString("/") + path.WriteString(r.Index) + } + if r.DocumentType != "" { + path.WriteString("/") + path.WriteString(r.DocumentType) + } + path.WriteString("/") + path.WriteString("_bulk") + + params = make(map[string]string) + + if r.Pipeline != "" { + params["pipeline"] = r.Pipeline + } + + if r.Refresh != "" { + params["refresh"] = r.Refresh + } + + if r.RequireAlias != nil { + params["require_alias"] = strconv.FormatBool(*r.RequireAlias) + } + + if r.Routing != "" { + params["routing"] = r.Routing + } + + if len(r.Source) > 0 { + params["_source"] = strings.Join(r.Source, ",") + } + + if len(r.SourceExcludes) > 0 { + params["_source_excludes"] = strings.Join(r.SourceExcludes, ",") + } + + if len(r.SourceIncludes) > 0 { + params["_source_includes"] = strings.Join(r.SourceIncludes, ",") + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.DocumentType != "" { + params["type"] = r.DocumentType + } + + if r.WaitForActiveShards != "" { + params["wait_for_active_shards"] = r.WaitForActiveShards + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f Bulk) WithContext(v context.Context) func(*BulkRequest) { + return func(r *BulkRequest) { + r.ctx = v + } +} + +// WithIndex - default index for items which don't provide one. +func (f Bulk) WithIndex(v string) func(*BulkRequest) { + return func(r *BulkRequest) { + r.Index = v + } +} + +// WithDocumentType - default document type for items which don't provide one. +func (f Bulk) WithDocumentType(v string) func(*BulkRequest) { + return func(r *BulkRequest) { + r.DocumentType = v + } +} + +// WithPipeline - the pipeline ID to preprocess incoming documents with. +func (f Bulk) WithPipeline(v string) func(*BulkRequest) { + return func(r *BulkRequest) { + r.Pipeline = v + } +} + +// WithRefresh - if `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes.. +func (f Bulk) WithRefresh(v string) func(*BulkRequest) { + return func(r *BulkRequest) { + r.Refresh = v + } +} + +// WithRequireAlias - sets require_alias for all incoming documents. defaults to unset (false). +func (f Bulk) WithRequireAlias(v bool) func(*BulkRequest) { + return func(r *BulkRequest) { + r.RequireAlias = &v + } +} + +// WithRouting - specific routing value. +func (f Bulk) WithRouting(v string) func(*BulkRequest) { + return func(r *BulkRequest) { + r.Routing = v + } +} + +// WithSource - true or false to return the _source field or not, or default list of fields to return, can be overridden on each sub-request. +func (f Bulk) WithSource(v ...string) func(*BulkRequest) { + return func(r *BulkRequest) { + r.Source = v + } +} + +// WithSourceExcludes - default list of fields to exclude from the returned _source field, can be overridden on each sub-request. +func (f Bulk) WithSourceExcludes(v ...string) func(*BulkRequest) { + return func(r *BulkRequest) { + r.SourceExcludes = v + } +} + +// WithSourceIncludes - default list of fields to extract and return from the _source field, can be overridden on each sub-request. +func (f Bulk) WithSourceIncludes(v ...string) func(*BulkRequest) { + return func(r *BulkRequest) { + r.SourceIncludes = v + } +} + +// WithTimeout - explicit operation timeout. +func (f Bulk) WithTimeout(v time.Duration) func(*BulkRequest) { + return func(r *BulkRequest) { + r.Timeout = v + } +} + +// WithWaitForActiveShards - sets the number of shard copies that must be active before proceeding with the bulk operation. defaults to 1, meaning the primary shard only. set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1). +func (f Bulk) WithWaitForActiveShards(v string) func(*BulkRequest) { + return func(r *BulkRequest) { + r.WaitForActiveShards = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f Bulk) WithPretty() func(*BulkRequest) { + return func(r *BulkRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f Bulk) WithHuman() func(*BulkRequest) { + return func(r *BulkRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f Bulk) WithErrorTrace() func(*BulkRequest) { + return func(r *BulkRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f Bulk) WithFilterPath(v ...string) func(*BulkRequest) { + return func(r *BulkRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f Bulk) WithHeader(h map[string]string) func(*BulkRequest) { + return func(r *BulkRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f Bulk) WithOpaqueID(s string) func(*BulkRequest) { + return func(r *BulkRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.aliases.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.aliases.go new file mode 100644 index 00000000..8fcb31ac --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.aliases.go @@ -0,0 +1,288 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newCatAliasesFunc(t Transport) CatAliases { + return func(o ...func(*CatAliasesRequest)) (*Response, error) { + var r = CatAliasesRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// CatAliases shows information about currently configured aliases to indices including filter and routing infos. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-alias.html. +type CatAliases func(o ...func(*CatAliasesRequest)) (*Response, error) + +// CatAliasesRequest configures the Cat Aliases API request. +type CatAliasesRequest struct { + Name []string + + ExpandWildcards string + Format string + H []string + Help *bool + Local *bool + S []string + V *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r CatAliasesRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_cat") + 1 + len("aliases") + 1 + len(strings.Join(r.Name, ","))) + path.WriteString("/") + path.WriteString("_cat") + path.WriteString("/") + path.WriteString("aliases") + if len(r.Name) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Name, ",")) + } + + params = make(map[string]string) + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if r.Format != "" { + params["format"] = r.Format + } + + if len(r.H) > 0 { + params["h"] = strings.Join(r.H, ",") + } + + if r.Help != nil { + params["help"] = strconv.FormatBool(*r.Help) + } + + if r.Local != nil { + params["local"] = strconv.FormatBool(*r.Local) + } + + if len(r.S) > 0 { + params["s"] = strings.Join(r.S, ",") + } + + if r.V != nil { + params["v"] = strconv.FormatBool(*r.V) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f CatAliases) WithContext(v context.Context) func(*CatAliasesRequest) { + return func(r *CatAliasesRequest) { + r.ctx = v + } +} + +// WithName - a list of alias names to return. +func (f CatAliases) WithName(v ...string) func(*CatAliasesRequest) { + return func(r *CatAliasesRequest) { + r.Name = v + } +} + +// WithExpandWildcards - whether to expand wildcard expression to concrete indices that are open, closed or both.. +func (f CatAliases) WithExpandWildcards(v string) func(*CatAliasesRequest) { + return func(r *CatAliasesRequest) { + r.ExpandWildcards = v + } +} + +// WithFormat - a short version of the accept header, e.g. json, yaml. +func (f CatAliases) WithFormat(v string) func(*CatAliasesRequest) { + return func(r *CatAliasesRequest) { + r.Format = v + } +} + +// WithH - comma-separated list of column names to display. +func (f CatAliases) WithH(v ...string) func(*CatAliasesRequest) { + return func(r *CatAliasesRequest) { + r.H = v + } +} + +// WithHelp - return help information. +func (f CatAliases) WithHelp(v bool) func(*CatAliasesRequest) { + return func(r *CatAliasesRequest) { + r.Help = &v + } +} + +// WithLocal - return local information, do not retrieve the state from master node (default: false). +func (f CatAliases) WithLocal(v bool) func(*CatAliasesRequest) { + return func(r *CatAliasesRequest) { + r.Local = &v + } +} + +// WithS - comma-separated list of column names or column aliases to sort by. +func (f CatAliases) WithS(v ...string) func(*CatAliasesRequest) { + return func(r *CatAliasesRequest) { + r.S = v + } +} + +// WithV - verbose mode. display column headers. +func (f CatAliases) WithV(v bool) func(*CatAliasesRequest) { + return func(r *CatAliasesRequest) { + r.V = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f CatAliases) WithPretty() func(*CatAliasesRequest) { + return func(r *CatAliasesRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f CatAliases) WithHuman() func(*CatAliasesRequest) { + return func(r *CatAliasesRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f CatAliases) WithErrorTrace() func(*CatAliasesRequest) { + return func(r *CatAliasesRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f CatAliases) WithFilterPath(v ...string) func(*CatAliasesRequest) { + return func(r *CatAliasesRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f CatAliases) WithHeader(h map[string]string) func(*CatAliasesRequest) { + return func(r *CatAliasesRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f CatAliases) WithOpaqueID(s string) func(*CatAliasesRequest) { + return func(r *CatAliasesRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.allocation.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.allocation.go new file mode 100644 index 00000000..ab15cc2b --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.allocation.go @@ -0,0 +1,301 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" + "time" +) + +func newCatAllocationFunc(t Transport) CatAllocation { + return func(o ...func(*CatAllocationRequest)) (*Response, error) { + var r = CatAllocationRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// CatAllocation provides a snapshot of how many shards are allocated to each data node and how much disk space they are using. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-allocation.html. +type CatAllocation func(o ...func(*CatAllocationRequest)) (*Response, error) + +// CatAllocationRequest configures the Cat Allocation API request. +type CatAllocationRequest struct { + NodeID []string + + Bytes string + Format string + H []string + Help *bool + Local *bool + MasterTimeout time.Duration + S []string + V *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r CatAllocationRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_cat") + 1 + len("allocation") + 1 + len(strings.Join(r.NodeID, ","))) + path.WriteString("/") + path.WriteString("_cat") + path.WriteString("/") + path.WriteString("allocation") + if len(r.NodeID) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.NodeID, ",")) + } + + params = make(map[string]string) + + if r.Bytes != "" { + params["bytes"] = r.Bytes + } + + if r.Format != "" { + params["format"] = r.Format + } + + if len(r.H) > 0 { + params["h"] = strings.Join(r.H, ",") + } + + if r.Help != nil { + params["help"] = strconv.FormatBool(*r.Help) + } + + if r.Local != nil { + params["local"] = strconv.FormatBool(*r.Local) + } + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if len(r.S) > 0 { + params["s"] = strings.Join(r.S, ",") + } + + if r.V != nil { + params["v"] = strconv.FormatBool(*r.V) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f CatAllocation) WithContext(v context.Context) func(*CatAllocationRequest) { + return func(r *CatAllocationRequest) { + r.ctx = v + } +} + +// WithNodeID - a list of node ids or names to limit the returned information. +func (f CatAllocation) WithNodeID(v ...string) func(*CatAllocationRequest) { + return func(r *CatAllocationRequest) { + r.NodeID = v + } +} + +// WithBytes - the unit in which to display byte values. +func (f CatAllocation) WithBytes(v string) func(*CatAllocationRequest) { + return func(r *CatAllocationRequest) { + r.Bytes = v + } +} + +// WithFormat - a short version of the accept header, e.g. json, yaml. +func (f CatAllocation) WithFormat(v string) func(*CatAllocationRequest) { + return func(r *CatAllocationRequest) { + r.Format = v + } +} + +// WithH - comma-separated list of column names to display. +func (f CatAllocation) WithH(v ...string) func(*CatAllocationRequest) { + return func(r *CatAllocationRequest) { + r.H = v + } +} + +// WithHelp - return help information. +func (f CatAllocation) WithHelp(v bool) func(*CatAllocationRequest) { + return func(r *CatAllocationRequest) { + r.Help = &v + } +} + +// WithLocal - return local information, do not retrieve the state from master node (default: false). +func (f CatAllocation) WithLocal(v bool) func(*CatAllocationRequest) { + return func(r *CatAllocationRequest) { + r.Local = &v + } +} + +// WithMasterTimeout - explicit operation timeout for connection to master node. +func (f CatAllocation) WithMasterTimeout(v time.Duration) func(*CatAllocationRequest) { + return func(r *CatAllocationRequest) { + r.MasterTimeout = v + } +} + +// WithS - comma-separated list of column names or column aliases to sort by. +func (f CatAllocation) WithS(v ...string) func(*CatAllocationRequest) { + return func(r *CatAllocationRequest) { + r.S = v + } +} + +// WithV - verbose mode. display column headers. +func (f CatAllocation) WithV(v bool) func(*CatAllocationRequest) { + return func(r *CatAllocationRequest) { + r.V = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f CatAllocation) WithPretty() func(*CatAllocationRequest) { + return func(r *CatAllocationRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f CatAllocation) WithHuman() func(*CatAllocationRequest) { + return func(r *CatAllocationRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f CatAllocation) WithErrorTrace() func(*CatAllocationRequest) { + return func(r *CatAllocationRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f CatAllocation) WithFilterPath(v ...string) func(*CatAllocationRequest) { + return func(r *CatAllocationRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f CatAllocation) WithHeader(h map[string]string) func(*CatAllocationRequest) { + return func(r *CatAllocationRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f CatAllocation) WithOpaqueID(s string) func(*CatAllocationRequest) { + return func(r *CatAllocationRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.count.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.count.go new file mode 100644 index 00000000..8b6b6eff --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.count.go @@ -0,0 +1,264 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newCatCountFunc(t Transport) CatCount { + return func(o ...func(*CatCountRequest)) (*Response, error) { + var r = CatCountRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// CatCount provides quick access to the document count of the entire cluster, or individual indices. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-count.html. +type CatCount func(o ...func(*CatCountRequest)) (*Response, error) + +// CatCountRequest configures the Cat Count API request. +type CatCountRequest struct { + Index []string + + Format string + H []string + Help *bool + S []string + V *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r CatCountRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_cat") + 1 + len("count") + 1 + len(strings.Join(r.Index, ","))) + path.WriteString("/") + path.WriteString("_cat") + path.WriteString("/") + path.WriteString("count") + if len(r.Index) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + } + + params = make(map[string]string) + + if r.Format != "" { + params["format"] = r.Format + } + + if len(r.H) > 0 { + params["h"] = strings.Join(r.H, ",") + } + + if r.Help != nil { + params["help"] = strconv.FormatBool(*r.Help) + } + + if len(r.S) > 0 { + params["s"] = strings.Join(r.S, ",") + } + + if r.V != nil { + params["v"] = strconv.FormatBool(*r.V) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f CatCount) WithContext(v context.Context) func(*CatCountRequest) { + return func(r *CatCountRequest) { + r.ctx = v + } +} + +// WithIndex - a list of index names to limit the returned information. +func (f CatCount) WithIndex(v ...string) func(*CatCountRequest) { + return func(r *CatCountRequest) { + r.Index = v + } +} + +// WithFormat - a short version of the accept header, e.g. json, yaml. +func (f CatCount) WithFormat(v string) func(*CatCountRequest) { + return func(r *CatCountRequest) { + r.Format = v + } +} + +// WithH - comma-separated list of column names to display. +func (f CatCount) WithH(v ...string) func(*CatCountRequest) { + return func(r *CatCountRequest) { + r.H = v + } +} + +// WithHelp - return help information. +func (f CatCount) WithHelp(v bool) func(*CatCountRequest) { + return func(r *CatCountRequest) { + r.Help = &v + } +} + +// WithS - comma-separated list of column names or column aliases to sort by. +func (f CatCount) WithS(v ...string) func(*CatCountRequest) { + return func(r *CatCountRequest) { + r.S = v + } +} + +// WithV - verbose mode. display column headers. +func (f CatCount) WithV(v bool) func(*CatCountRequest) { + return func(r *CatCountRequest) { + r.V = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f CatCount) WithPretty() func(*CatCountRequest) { + return func(r *CatCountRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f CatCount) WithHuman() func(*CatCountRequest) { + return func(r *CatCountRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f CatCount) WithErrorTrace() func(*CatCountRequest) { + return func(r *CatCountRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f CatCount) WithFilterPath(v ...string) func(*CatCountRequest) { + return func(r *CatCountRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f CatCount) WithHeader(h map[string]string) func(*CatCountRequest) { + return func(r *CatCountRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f CatCount) WithOpaqueID(s string) func(*CatCountRequest) { + return func(r *CatCountRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.fielddata.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.fielddata.go new file mode 100644 index 00000000..f9fdc2f5 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.fielddata.go @@ -0,0 +1,280 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newCatFielddataFunc(t Transport) CatFielddata { + return func(o ...func(*CatFielddataRequest)) (*Response, error) { + var r = CatFielddataRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// CatFielddata shows how much heap memory is currently being used by fielddata on every data node in the cluster. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-fielddata.html. +type CatFielddata func(o ...func(*CatFielddataRequest)) (*Response, error) + +// CatFielddataRequest configures the Cat Fielddata API request. +type CatFielddataRequest struct { + Fields []string + + Bytes string + Format string + H []string + Help *bool + S []string + V *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r CatFielddataRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_cat") + 1 + len("fielddata") + 1 + len(strings.Join(r.Fields, ","))) + path.WriteString("/") + path.WriteString("_cat") + path.WriteString("/") + path.WriteString("fielddata") + if len(r.Fields) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Fields, ",")) + } + + params = make(map[string]string) + + if r.Bytes != "" { + params["bytes"] = r.Bytes + } + + if len(r.Fields) > 0 { + params["fields"] = strings.Join(r.Fields, ",") + } + + if r.Format != "" { + params["format"] = r.Format + } + + if len(r.H) > 0 { + params["h"] = strings.Join(r.H, ",") + } + + if r.Help != nil { + params["help"] = strconv.FormatBool(*r.Help) + } + + if len(r.S) > 0 { + params["s"] = strings.Join(r.S, ",") + } + + if r.V != nil { + params["v"] = strconv.FormatBool(*r.V) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f CatFielddata) WithContext(v context.Context) func(*CatFielddataRequest) { + return func(r *CatFielddataRequest) { + r.ctx = v + } +} + +// WithFields - a list of fields to return the fielddata size. +func (f CatFielddata) WithFields(v ...string) func(*CatFielddataRequest) { + return func(r *CatFielddataRequest) { + r.Fields = v + } +} + +// WithBytes - the unit in which to display byte values. +func (f CatFielddata) WithBytes(v string) func(*CatFielddataRequest) { + return func(r *CatFielddataRequest) { + r.Bytes = v + } +} + +// WithFormat - a short version of the accept header, e.g. json, yaml. +func (f CatFielddata) WithFormat(v string) func(*CatFielddataRequest) { + return func(r *CatFielddataRequest) { + r.Format = v + } +} + +// WithH - comma-separated list of column names to display. +func (f CatFielddata) WithH(v ...string) func(*CatFielddataRequest) { + return func(r *CatFielddataRequest) { + r.H = v + } +} + +// WithHelp - return help information. +func (f CatFielddata) WithHelp(v bool) func(*CatFielddataRequest) { + return func(r *CatFielddataRequest) { + r.Help = &v + } +} + +// WithS - comma-separated list of column names or column aliases to sort by. +func (f CatFielddata) WithS(v ...string) func(*CatFielddataRequest) { + return func(r *CatFielddataRequest) { + r.S = v + } +} + +// WithV - verbose mode. display column headers. +func (f CatFielddata) WithV(v bool) func(*CatFielddataRequest) { + return func(r *CatFielddataRequest) { + r.V = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f CatFielddata) WithPretty() func(*CatFielddataRequest) { + return func(r *CatFielddataRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f CatFielddata) WithHuman() func(*CatFielddataRequest) { + return func(r *CatFielddataRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f CatFielddata) WithErrorTrace() func(*CatFielddataRequest) { + return func(r *CatFielddataRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f CatFielddata) WithFilterPath(v ...string) func(*CatFielddataRequest) { + return func(r *CatFielddataRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f CatFielddata) WithHeader(h map[string]string) func(*CatFielddataRequest) { + return func(r *CatFielddataRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f CatFielddata) WithOpaqueID(s string) func(*CatFielddataRequest) { + return func(r *CatFielddataRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.health.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.health.go new file mode 100644 index 00000000..a6757ec0 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.health.go @@ -0,0 +1,272 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newCatHealthFunc(t Transport) CatHealth { + return func(o ...func(*CatHealthRequest)) (*Response, error) { + var r = CatHealthRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// CatHealth returns a concise representation of the cluster health. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-health.html. +type CatHealth func(o ...func(*CatHealthRequest)) (*Response, error) + +// CatHealthRequest configures the Cat Health API request. +type CatHealthRequest struct { + Format string + H []string + Help *bool + S []string + Time string + Ts *bool + V *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r CatHealthRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(len("/_cat/health")) + path.WriteString("/_cat/health") + + params = make(map[string]string) + + if r.Format != "" { + params["format"] = r.Format + } + + if len(r.H) > 0 { + params["h"] = strings.Join(r.H, ",") + } + + if r.Help != nil { + params["help"] = strconv.FormatBool(*r.Help) + } + + if len(r.S) > 0 { + params["s"] = strings.Join(r.S, ",") + } + + if r.Time != "" { + params["time"] = r.Time + } + + if r.Ts != nil { + params["ts"] = strconv.FormatBool(*r.Ts) + } + + if r.V != nil { + params["v"] = strconv.FormatBool(*r.V) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f CatHealth) WithContext(v context.Context) func(*CatHealthRequest) { + return func(r *CatHealthRequest) { + r.ctx = v + } +} + +// WithFormat - a short version of the accept header, e.g. json, yaml. +func (f CatHealth) WithFormat(v string) func(*CatHealthRequest) { + return func(r *CatHealthRequest) { + r.Format = v + } +} + +// WithH - comma-separated list of column names to display. +func (f CatHealth) WithH(v ...string) func(*CatHealthRequest) { + return func(r *CatHealthRequest) { + r.H = v + } +} + +// WithHelp - return help information. +func (f CatHealth) WithHelp(v bool) func(*CatHealthRequest) { + return func(r *CatHealthRequest) { + r.Help = &v + } +} + +// WithS - comma-separated list of column names or column aliases to sort by. +func (f CatHealth) WithS(v ...string) func(*CatHealthRequest) { + return func(r *CatHealthRequest) { + r.S = v + } +} + +// WithTime - the unit in which to display time values. +func (f CatHealth) WithTime(v string) func(*CatHealthRequest) { + return func(r *CatHealthRequest) { + r.Time = v + } +} + +// WithTs - set to false to disable timestamping. +func (f CatHealth) WithTs(v bool) func(*CatHealthRequest) { + return func(r *CatHealthRequest) { + r.Ts = &v + } +} + +// WithV - verbose mode. display column headers. +func (f CatHealth) WithV(v bool) func(*CatHealthRequest) { + return func(r *CatHealthRequest) { + r.V = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f CatHealth) WithPretty() func(*CatHealthRequest) { + return func(r *CatHealthRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f CatHealth) WithHuman() func(*CatHealthRequest) { + return func(r *CatHealthRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f CatHealth) WithErrorTrace() func(*CatHealthRequest) { + return func(r *CatHealthRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f CatHealth) WithFilterPath(v ...string) func(*CatHealthRequest) { + return func(r *CatHealthRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f CatHealth) WithHeader(h map[string]string) func(*CatHealthRequest) { + return func(r *CatHealthRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f CatHealth) WithOpaqueID(s string) func(*CatHealthRequest) { + return func(r *CatHealthRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.help.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.help.go new file mode 100644 index 00000000..14dadfe5 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.help.go @@ -0,0 +1,212 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newCatHelpFunc(t Transport) CatHelp { + return func(o ...func(*CatHelpRequest)) (*Response, error) { + var r = CatHelpRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// CatHelp returns help for the Cat APIs. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/cat.html. +type CatHelp func(o ...func(*CatHelpRequest)) (*Response, error) + +// CatHelpRequest configures the Cat Help API request. +type CatHelpRequest struct { + Help *bool + S []string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r CatHelpRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(len("/_cat")) + path.WriteString("/_cat") + + params = make(map[string]string) + + if r.Help != nil { + params["help"] = strconv.FormatBool(*r.Help) + } + + if len(r.S) > 0 { + params["s"] = strings.Join(r.S, ",") + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f CatHelp) WithContext(v context.Context) func(*CatHelpRequest) { + return func(r *CatHelpRequest) { + r.ctx = v + } +} + +// WithHelp - return help information. +func (f CatHelp) WithHelp(v bool) func(*CatHelpRequest) { + return func(r *CatHelpRequest) { + r.Help = &v + } +} + +// WithS - comma-separated list of column names or column aliases to sort by. +func (f CatHelp) WithS(v ...string) func(*CatHelpRequest) { + return func(r *CatHelpRequest) { + r.S = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f CatHelp) WithPretty() func(*CatHelpRequest) { + return func(r *CatHelpRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f CatHelp) WithHuman() func(*CatHelpRequest) { + return func(r *CatHelpRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f CatHelp) WithErrorTrace() func(*CatHelpRequest) { + return func(r *CatHelpRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f CatHelp) WithFilterPath(v ...string) func(*CatHelpRequest) { + return func(r *CatHelpRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f CatHelp) WithHeader(h map[string]string) func(*CatHelpRequest) { + return func(r *CatHelpRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f CatHelp) WithOpaqueID(s string) func(*CatHelpRequest) { + return func(r *CatHelpRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.indices.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.indices.go new file mode 100644 index 00000000..c6ec534b --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.indices.go @@ -0,0 +1,361 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" + "time" +) + +func newCatIndicesFunc(t Transport) CatIndices { + return func(o ...func(*CatIndicesRequest)) (*Response, error) { + var r = CatIndicesRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// CatIndices returns information about indices: number of primaries and replicas, document counts, disk size, ... +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-indices.html. +type CatIndices func(o ...func(*CatIndicesRequest)) (*Response, error) + +// CatIndicesRequest configures the Cat Indices API request. +type CatIndicesRequest struct { + Index []string + + Bytes string + ExpandWildcards string + Format string + H []string + Health string + Help *bool + IncludeUnloadedSegments *bool + Local *bool + MasterTimeout time.Duration + Pri *bool + S []string + Time string + V *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r CatIndicesRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_cat") + 1 + len("indices") + 1 + len(strings.Join(r.Index, ","))) + path.WriteString("/") + path.WriteString("_cat") + path.WriteString("/") + path.WriteString("indices") + if len(r.Index) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + } + + params = make(map[string]string) + + if r.Bytes != "" { + params["bytes"] = r.Bytes + } + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if r.Format != "" { + params["format"] = r.Format + } + + if len(r.H) > 0 { + params["h"] = strings.Join(r.H, ",") + } + + if r.Health != "" { + params["health"] = r.Health + } + + if r.Help != nil { + params["help"] = strconv.FormatBool(*r.Help) + } + + if r.IncludeUnloadedSegments != nil { + params["include_unloaded_segments"] = strconv.FormatBool(*r.IncludeUnloadedSegments) + } + + if r.Local != nil { + params["local"] = strconv.FormatBool(*r.Local) + } + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Pri != nil { + params["pri"] = strconv.FormatBool(*r.Pri) + } + + if len(r.S) > 0 { + params["s"] = strings.Join(r.S, ",") + } + + if r.Time != "" { + params["time"] = r.Time + } + + if r.V != nil { + params["v"] = strconv.FormatBool(*r.V) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f CatIndices) WithContext(v context.Context) func(*CatIndicesRequest) { + return func(r *CatIndicesRequest) { + r.ctx = v + } +} + +// WithIndex - a list of index names to limit the returned information. +func (f CatIndices) WithIndex(v ...string) func(*CatIndicesRequest) { + return func(r *CatIndicesRequest) { + r.Index = v + } +} + +// WithBytes - the unit in which to display byte values. +func (f CatIndices) WithBytes(v string) func(*CatIndicesRequest) { + return func(r *CatIndicesRequest) { + r.Bytes = v + } +} + +// WithExpandWildcards - whether to expand wildcard expression to concrete indices that are open, closed or both.. +func (f CatIndices) WithExpandWildcards(v string) func(*CatIndicesRequest) { + return func(r *CatIndicesRequest) { + r.ExpandWildcards = v + } +} + +// WithFormat - a short version of the accept header, e.g. json, yaml. +func (f CatIndices) WithFormat(v string) func(*CatIndicesRequest) { + return func(r *CatIndicesRequest) { + r.Format = v + } +} + +// WithH - comma-separated list of column names to display. +func (f CatIndices) WithH(v ...string) func(*CatIndicesRequest) { + return func(r *CatIndicesRequest) { + r.H = v + } +} + +// WithHealth - a health status ("green", "yellow", or "red" to filter only indices matching the specified health status. +func (f CatIndices) WithHealth(v string) func(*CatIndicesRequest) { + return func(r *CatIndicesRequest) { + r.Health = v + } +} + +// WithHelp - return help information. +func (f CatIndices) WithHelp(v bool) func(*CatIndicesRequest) { + return func(r *CatIndicesRequest) { + r.Help = &v + } +} + +// WithIncludeUnloadedSegments - if set to true segment stats will include stats for segments that are not currently loaded into memory. +func (f CatIndices) WithIncludeUnloadedSegments(v bool) func(*CatIndicesRequest) { + return func(r *CatIndicesRequest) { + r.IncludeUnloadedSegments = &v + } +} + +// WithLocal - return local information, do not retrieve the state from master node (default: false). +func (f CatIndices) WithLocal(v bool) func(*CatIndicesRequest) { + return func(r *CatIndicesRequest) { + r.Local = &v + } +} + +// WithMasterTimeout - explicit operation timeout for connection to master node. +func (f CatIndices) WithMasterTimeout(v time.Duration) func(*CatIndicesRequest) { + return func(r *CatIndicesRequest) { + r.MasterTimeout = v + } +} + +// WithPri - set to true to return stats only for primary shards. +func (f CatIndices) WithPri(v bool) func(*CatIndicesRequest) { + return func(r *CatIndicesRequest) { + r.Pri = &v + } +} + +// WithS - comma-separated list of column names or column aliases to sort by. +func (f CatIndices) WithS(v ...string) func(*CatIndicesRequest) { + return func(r *CatIndicesRequest) { + r.S = v + } +} + +// WithTime - the unit in which to display time values. +func (f CatIndices) WithTime(v string) func(*CatIndicesRequest) { + return func(r *CatIndicesRequest) { + r.Time = v + } +} + +// WithV - verbose mode. display column headers. +func (f CatIndices) WithV(v bool) func(*CatIndicesRequest) { + return func(r *CatIndicesRequest) { + r.V = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f CatIndices) WithPretty() func(*CatIndicesRequest) { + return func(r *CatIndicesRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f CatIndices) WithHuman() func(*CatIndicesRequest) { + return func(r *CatIndicesRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f CatIndices) WithErrorTrace() func(*CatIndicesRequest) { + return func(r *CatIndicesRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f CatIndices) WithFilterPath(v ...string) func(*CatIndicesRequest) { + return func(r *CatIndicesRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f CatIndices) WithHeader(h map[string]string) func(*CatIndicesRequest) { + return func(r *CatIndicesRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f CatIndices) WithOpaqueID(s string) func(*CatIndicesRequest) { + return func(r *CatIndicesRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.master.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.master.go new file mode 100644 index 00000000..4f65e3d8 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.master.go @@ -0,0 +1,273 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" + "time" +) + +func newCatMasterFunc(t Transport) CatMaster { + return func(o ...func(*CatMasterRequest)) (*Response, error) { + var r = CatMasterRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// CatMaster returns information about the master node. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-master.html. +type CatMaster func(o ...func(*CatMasterRequest)) (*Response, error) + +// CatMasterRequest configures the Cat Master API request. +type CatMasterRequest struct { + Format string + H []string + Help *bool + Local *bool + MasterTimeout time.Duration + S []string + V *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r CatMasterRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(len("/_cat/master")) + path.WriteString("/_cat/master") + + params = make(map[string]string) + + if r.Format != "" { + params["format"] = r.Format + } + + if len(r.H) > 0 { + params["h"] = strings.Join(r.H, ",") + } + + if r.Help != nil { + params["help"] = strconv.FormatBool(*r.Help) + } + + if r.Local != nil { + params["local"] = strconv.FormatBool(*r.Local) + } + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if len(r.S) > 0 { + params["s"] = strings.Join(r.S, ",") + } + + if r.V != nil { + params["v"] = strconv.FormatBool(*r.V) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f CatMaster) WithContext(v context.Context) func(*CatMasterRequest) { + return func(r *CatMasterRequest) { + r.ctx = v + } +} + +// WithFormat - a short version of the accept header, e.g. json, yaml. +func (f CatMaster) WithFormat(v string) func(*CatMasterRequest) { + return func(r *CatMasterRequest) { + r.Format = v + } +} + +// WithH - comma-separated list of column names to display. +func (f CatMaster) WithH(v ...string) func(*CatMasterRequest) { + return func(r *CatMasterRequest) { + r.H = v + } +} + +// WithHelp - return help information. +func (f CatMaster) WithHelp(v bool) func(*CatMasterRequest) { + return func(r *CatMasterRequest) { + r.Help = &v + } +} + +// WithLocal - return local information, do not retrieve the state from master node (default: false). +func (f CatMaster) WithLocal(v bool) func(*CatMasterRequest) { + return func(r *CatMasterRequest) { + r.Local = &v + } +} + +// WithMasterTimeout - explicit operation timeout for connection to master node. +func (f CatMaster) WithMasterTimeout(v time.Duration) func(*CatMasterRequest) { + return func(r *CatMasterRequest) { + r.MasterTimeout = v + } +} + +// WithS - comma-separated list of column names or column aliases to sort by. +func (f CatMaster) WithS(v ...string) func(*CatMasterRequest) { + return func(r *CatMasterRequest) { + r.S = v + } +} + +// WithV - verbose mode. display column headers. +func (f CatMaster) WithV(v bool) func(*CatMasterRequest) { + return func(r *CatMasterRequest) { + r.V = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f CatMaster) WithPretty() func(*CatMasterRequest) { + return func(r *CatMasterRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f CatMaster) WithHuman() func(*CatMasterRequest) { + return func(r *CatMasterRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f CatMaster) WithErrorTrace() func(*CatMasterRequest) { + return func(r *CatMasterRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f CatMaster) WithFilterPath(v ...string) func(*CatMasterRequest) { + return func(r *CatMasterRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f CatMaster) WithHeader(h map[string]string) func(*CatMasterRequest) { + return func(r *CatMasterRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f CatMaster) WithOpaqueID(s string) func(*CatMasterRequest) { + return func(r *CatMasterRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.nodeattrs.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.nodeattrs.go new file mode 100644 index 00000000..e18b3454 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.nodeattrs.go @@ -0,0 +1,273 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" + "time" +) + +func newCatNodeattrsFunc(t Transport) CatNodeattrs { + return func(o ...func(*CatNodeattrsRequest)) (*Response, error) { + var r = CatNodeattrsRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// CatNodeattrs returns information about custom node attributes. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-nodeattrs.html. +type CatNodeattrs func(o ...func(*CatNodeattrsRequest)) (*Response, error) + +// CatNodeattrsRequest configures the Cat Nodeattrs API request. +type CatNodeattrsRequest struct { + Format string + H []string + Help *bool + Local *bool + MasterTimeout time.Duration + S []string + V *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r CatNodeattrsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(len("/_cat/nodeattrs")) + path.WriteString("/_cat/nodeattrs") + + params = make(map[string]string) + + if r.Format != "" { + params["format"] = r.Format + } + + if len(r.H) > 0 { + params["h"] = strings.Join(r.H, ",") + } + + if r.Help != nil { + params["help"] = strconv.FormatBool(*r.Help) + } + + if r.Local != nil { + params["local"] = strconv.FormatBool(*r.Local) + } + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if len(r.S) > 0 { + params["s"] = strings.Join(r.S, ",") + } + + if r.V != nil { + params["v"] = strconv.FormatBool(*r.V) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f CatNodeattrs) WithContext(v context.Context) func(*CatNodeattrsRequest) { + return func(r *CatNodeattrsRequest) { + r.ctx = v + } +} + +// WithFormat - a short version of the accept header, e.g. json, yaml. +func (f CatNodeattrs) WithFormat(v string) func(*CatNodeattrsRequest) { + return func(r *CatNodeattrsRequest) { + r.Format = v + } +} + +// WithH - comma-separated list of column names to display. +func (f CatNodeattrs) WithH(v ...string) func(*CatNodeattrsRequest) { + return func(r *CatNodeattrsRequest) { + r.H = v + } +} + +// WithHelp - return help information. +func (f CatNodeattrs) WithHelp(v bool) func(*CatNodeattrsRequest) { + return func(r *CatNodeattrsRequest) { + r.Help = &v + } +} + +// WithLocal - return local information, do not retrieve the state from master node (default: false). +func (f CatNodeattrs) WithLocal(v bool) func(*CatNodeattrsRequest) { + return func(r *CatNodeattrsRequest) { + r.Local = &v + } +} + +// WithMasterTimeout - explicit operation timeout for connection to master node. +func (f CatNodeattrs) WithMasterTimeout(v time.Duration) func(*CatNodeattrsRequest) { + return func(r *CatNodeattrsRequest) { + r.MasterTimeout = v + } +} + +// WithS - comma-separated list of column names or column aliases to sort by. +func (f CatNodeattrs) WithS(v ...string) func(*CatNodeattrsRequest) { + return func(r *CatNodeattrsRequest) { + r.S = v + } +} + +// WithV - verbose mode. display column headers. +func (f CatNodeattrs) WithV(v bool) func(*CatNodeattrsRequest) { + return func(r *CatNodeattrsRequest) { + r.V = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f CatNodeattrs) WithPretty() func(*CatNodeattrsRequest) { + return func(r *CatNodeattrsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f CatNodeattrs) WithHuman() func(*CatNodeattrsRequest) { + return func(r *CatNodeattrsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f CatNodeattrs) WithErrorTrace() func(*CatNodeattrsRequest) { + return func(r *CatNodeattrsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f CatNodeattrs) WithFilterPath(v ...string) func(*CatNodeattrsRequest) { + return func(r *CatNodeattrsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f CatNodeattrs) WithHeader(h map[string]string) func(*CatNodeattrsRequest) { + return func(r *CatNodeattrsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f CatNodeattrs) WithOpaqueID(s string) func(*CatNodeattrsRequest) { + return func(r *CatNodeattrsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.nodes.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.nodes.go new file mode 100644 index 00000000..be00451a --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.nodes.go @@ -0,0 +1,321 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" + "time" +) + +func newCatNodesFunc(t Transport) CatNodes { + return func(o ...func(*CatNodesRequest)) (*Response, error) { + var r = CatNodesRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// CatNodes returns basic statistics about performance of cluster nodes. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-nodes.html. +type CatNodes func(o ...func(*CatNodesRequest)) (*Response, error) + +// CatNodesRequest configures the Cat Nodes API request. +type CatNodesRequest struct { + Bytes string + Format string + FullID *bool + H []string + Help *bool + IncludeUnloadedSegments *bool + Local *bool + MasterTimeout time.Duration + S []string + Time string + V *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r CatNodesRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(len("/_cat/nodes")) + path.WriteString("/_cat/nodes") + + params = make(map[string]string) + + if r.Bytes != "" { + params["bytes"] = r.Bytes + } + + if r.Format != "" { + params["format"] = r.Format + } + + if r.FullID != nil { + params["full_id"] = strconv.FormatBool(*r.FullID) + } + + if len(r.H) > 0 { + params["h"] = strings.Join(r.H, ",") + } + + if r.Help != nil { + params["help"] = strconv.FormatBool(*r.Help) + } + + if r.IncludeUnloadedSegments != nil { + params["include_unloaded_segments"] = strconv.FormatBool(*r.IncludeUnloadedSegments) + } + + if r.Local != nil { + params["local"] = strconv.FormatBool(*r.Local) + } + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if len(r.S) > 0 { + params["s"] = strings.Join(r.S, ",") + } + + if r.Time != "" { + params["time"] = r.Time + } + + if r.V != nil { + params["v"] = strconv.FormatBool(*r.V) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f CatNodes) WithContext(v context.Context) func(*CatNodesRequest) { + return func(r *CatNodesRequest) { + r.ctx = v + } +} + +// WithBytes - the unit in which to display byte values. +func (f CatNodes) WithBytes(v string) func(*CatNodesRequest) { + return func(r *CatNodesRequest) { + r.Bytes = v + } +} + +// WithFormat - a short version of the accept header, e.g. json, yaml. +func (f CatNodes) WithFormat(v string) func(*CatNodesRequest) { + return func(r *CatNodesRequest) { + r.Format = v + } +} + +// WithFullID - return the full node ID instead of the shortened version (default: false). +func (f CatNodes) WithFullID(v bool) func(*CatNodesRequest) { + return func(r *CatNodesRequest) { + r.FullID = &v + } +} + +// WithH - comma-separated list of column names to display. +func (f CatNodes) WithH(v ...string) func(*CatNodesRequest) { + return func(r *CatNodesRequest) { + r.H = v + } +} + +// WithHelp - return help information. +func (f CatNodes) WithHelp(v bool) func(*CatNodesRequest) { + return func(r *CatNodesRequest) { + r.Help = &v + } +} + +// WithIncludeUnloadedSegments - if set to true segment stats will include stats for segments that are not currently loaded into memory. +func (f CatNodes) WithIncludeUnloadedSegments(v bool) func(*CatNodesRequest) { + return func(r *CatNodesRequest) { + r.IncludeUnloadedSegments = &v + } +} + +// WithLocal - calculate the selected nodes using the local cluster state rather than the state from master node (default: false). +func (f CatNodes) WithLocal(v bool) func(*CatNodesRequest) { + return func(r *CatNodesRequest) { + r.Local = &v + } +} + +// WithMasterTimeout - explicit operation timeout for connection to master node. +func (f CatNodes) WithMasterTimeout(v time.Duration) func(*CatNodesRequest) { + return func(r *CatNodesRequest) { + r.MasterTimeout = v + } +} + +// WithS - comma-separated list of column names or column aliases to sort by. +func (f CatNodes) WithS(v ...string) func(*CatNodesRequest) { + return func(r *CatNodesRequest) { + r.S = v + } +} + +// WithTime - the unit in which to display time values. +func (f CatNodes) WithTime(v string) func(*CatNodesRequest) { + return func(r *CatNodesRequest) { + r.Time = v + } +} + +// WithV - verbose mode. display column headers. +func (f CatNodes) WithV(v bool) func(*CatNodesRequest) { + return func(r *CatNodesRequest) { + r.V = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f CatNodes) WithPretty() func(*CatNodesRequest) { + return func(r *CatNodesRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f CatNodes) WithHuman() func(*CatNodesRequest) { + return func(r *CatNodesRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f CatNodes) WithErrorTrace() func(*CatNodesRequest) { + return func(r *CatNodesRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f CatNodes) WithFilterPath(v ...string) func(*CatNodesRequest) { + return func(r *CatNodesRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f CatNodes) WithHeader(h map[string]string) func(*CatNodesRequest) { + return func(r *CatNodesRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f CatNodes) WithOpaqueID(s string) func(*CatNodesRequest) { + return func(r *CatNodesRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.pending_tasks.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.pending_tasks.go new file mode 100644 index 00000000..609be8cc --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.pending_tasks.go @@ -0,0 +1,285 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" + "time" +) + +func newCatPendingTasksFunc(t Transport) CatPendingTasks { + return func(o ...func(*CatPendingTasksRequest)) (*Response, error) { + var r = CatPendingTasksRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// CatPendingTasks returns a concise representation of the cluster pending tasks. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-pending-tasks.html. +type CatPendingTasks func(o ...func(*CatPendingTasksRequest)) (*Response, error) + +// CatPendingTasksRequest configures the Cat Pending Tasks API request. +type CatPendingTasksRequest struct { + Format string + H []string + Help *bool + Local *bool + MasterTimeout time.Duration + S []string + Time string + V *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r CatPendingTasksRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(len("/_cat/pending_tasks")) + path.WriteString("/_cat/pending_tasks") + + params = make(map[string]string) + + if r.Format != "" { + params["format"] = r.Format + } + + if len(r.H) > 0 { + params["h"] = strings.Join(r.H, ",") + } + + if r.Help != nil { + params["help"] = strconv.FormatBool(*r.Help) + } + + if r.Local != nil { + params["local"] = strconv.FormatBool(*r.Local) + } + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if len(r.S) > 0 { + params["s"] = strings.Join(r.S, ",") + } + + if r.Time != "" { + params["time"] = r.Time + } + + if r.V != nil { + params["v"] = strconv.FormatBool(*r.V) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f CatPendingTasks) WithContext(v context.Context) func(*CatPendingTasksRequest) { + return func(r *CatPendingTasksRequest) { + r.ctx = v + } +} + +// WithFormat - a short version of the accept header, e.g. json, yaml. +func (f CatPendingTasks) WithFormat(v string) func(*CatPendingTasksRequest) { + return func(r *CatPendingTasksRequest) { + r.Format = v + } +} + +// WithH - comma-separated list of column names to display. +func (f CatPendingTasks) WithH(v ...string) func(*CatPendingTasksRequest) { + return func(r *CatPendingTasksRequest) { + r.H = v + } +} + +// WithHelp - return help information. +func (f CatPendingTasks) WithHelp(v bool) func(*CatPendingTasksRequest) { + return func(r *CatPendingTasksRequest) { + r.Help = &v + } +} + +// WithLocal - return local information, do not retrieve the state from master node (default: false). +func (f CatPendingTasks) WithLocal(v bool) func(*CatPendingTasksRequest) { + return func(r *CatPendingTasksRequest) { + r.Local = &v + } +} + +// WithMasterTimeout - explicit operation timeout for connection to master node. +func (f CatPendingTasks) WithMasterTimeout(v time.Duration) func(*CatPendingTasksRequest) { + return func(r *CatPendingTasksRequest) { + r.MasterTimeout = v + } +} + +// WithS - comma-separated list of column names or column aliases to sort by. +func (f CatPendingTasks) WithS(v ...string) func(*CatPendingTasksRequest) { + return func(r *CatPendingTasksRequest) { + r.S = v + } +} + +// WithTime - the unit in which to display time values. +func (f CatPendingTasks) WithTime(v string) func(*CatPendingTasksRequest) { + return func(r *CatPendingTasksRequest) { + r.Time = v + } +} + +// WithV - verbose mode. display column headers. +func (f CatPendingTasks) WithV(v bool) func(*CatPendingTasksRequest) { + return func(r *CatPendingTasksRequest) { + r.V = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f CatPendingTasks) WithPretty() func(*CatPendingTasksRequest) { + return func(r *CatPendingTasksRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f CatPendingTasks) WithHuman() func(*CatPendingTasksRequest) { + return func(r *CatPendingTasksRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f CatPendingTasks) WithErrorTrace() func(*CatPendingTasksRequest) { + return func(r *CatPendingTasksRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f CatPendingTasks) WithFilterPath(v ...string) func(*CatPendingTasksRequest) { + return func(r *CatPendingTasksRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f CatPendingTasks) WithHeader(h map[string]string) func(*CatPendingTasksRequest) { + return func(r *CatPendingTasksRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f CatPendingTasks) WithOpaqueID(s string) func(*CatPendingTasksRequest) { + return func(r *CatPendingTasksRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.plugins.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.plugins.go new file mode 100644 index 00000000..4877edfe --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.plugins.go @@ -0,0 +1,285 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" + "time" +) + +func newCatPluginsFunc(t Transport) CatPlugins { + return func(o ...func(*CatPluginsRequest)) (*Response, error) { + var r = CatPluginsRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// CatPlugins returns information about installed plugins across nodes node. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-plugins.html. +type CatPlugins func(o ...func(*CatPluginsRequest)) (*Response, error) + +// CatPluginsRequest configures the Cat Plugins API request. +type CatPluginsRequest struct { + Format string + H []string + Help *bool + IncludeBootstrap *bool + Local *bool + MasterTimeout time.Duration + S []string + V *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r CatPluginsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(len("/_cat/plugins")) + path.WriteString("/_cat/plugins") + + params = make(map[string]string) + + if r.Format != "" { + params["format"] = r.Format + } + + if len(r.H) > 0 { + params["h"] = strings.Join(r.H, ",") + } + + if r.Help != nil { + params["help"] = strconv.FormatBool(*r.Help) + } + + if r.IncludeBootstrap != nil { + params["include_bootstrap"] = strconv.FormatBool(*r.IncludeBootstrap) + } + + if r.Local != nil { + params["local"] = strconv.FormatBool(*r.Local) + } + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if len(r.S) > 0 { + params["s"] = strings.Join(r.S, ",") + } + + if r.V != nil { + params["v"] = strconv.FormatBool(*r.V) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f CatPlugins) WithContext(v context.Context) func(*CatPluginsRequest) { + return func(r *CatPluginsRequest) { + r.ctx = v + } +} + +// WithFormat - a short version of the accept header, e.g. json, yaml. +func (f CatPlugins) WithFormat(v string) func(*CatPluginsRequest) { + return func(r *CatPluginsRequest) { + r.Format = v + } +} + +// WithH - comma-separated list of column names to display. +func (f CatPlugins) WithH(v ...string) func(*CatPluginsRequest) { + return func(r *CatPluginsRequest) { + r.H = v + } +} + +// WithHelp - return help information. +func (f CatPlugins) WithHelp(v bool) func(*CatPluginsRequest) { + return func(r *CatPluginsRequest) { + r.Help = &v + } +} + +// WithIncludeBootstrap - include bootstrap plugins in the response. +func (f CatPlugins) WithIncludeBootstrap(v bool) func(*CatPluginsRequest) { + return func(r *CatPluginsRequest) { + r.IncludeBootstrap = &v + } +} + +// WithLocal - return local information, do not retrieve the state from master node (default: false). +func (f CatPlugins) WithLocal(v bool) func(*CatPluginsRequest) { + return func(r *CatPluginsRequest) { + r.Local = &v + } +} + +// WithMasterTimeout - explicit operation timeout for connection to master node. +func (f CatPlugins) WithMasterTimeout(v time.Duration) func(*CatPluginsRequest) { + return func(r *CatPluginsRequest) { + r.MasterTimeout = v + } +} + +// WithS - comma-separated list of column names or column aliases to sort by. +func (f CatPlugins) WithS(v ...string) func(*CatPluginsRequest) { + return func(r *CatPluginsRequest) { + r.S = v + } +} + +// WithV - verbose mode. display column headers. +func (f CatPlugins) WithV(v bool) func(*CatPluginsRequest) { + return func(r *CatPluginsRequest) { + r.V = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f CatPlugins) WithPretty() func(*CatPluginsRequest) { + return func(r *CatPluginsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f CatPlugins) WithHuman() func(*CatPluginsRequest) { + return func(r *CatPluginsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f CatPlugins) WithErrorTrace() func(*CatPluginsRequest) { + return func(r *CatPluginsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f CatPlugins) WithFilterPath(v ...string) func(*CatPluginsRequest) { + return func(r *CatPluginsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f CatPlugins) WithHeader(h map[string]string) func(*CatPluginsRequest) { + return func(r *CatPluginsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f CatPlugins) WithOpaqueID(s string) func(*CatPluginsRequest) { + return func(r *CatPluginsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.recovery.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.recovery.go new file mode 100644 index 00000000..b33439f4 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.recovery.go @@ -0,0 +1,316 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newCatRecoveryFunc(t Transport) CatRecovery { + return func(o ...func(*CatRecoveryRequest)) (*Response, error) { + var r = CatRecoveryRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// CatRecovery returns information about index shard recoveries, both on-going completed. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-recovery.html. +type CatRecovery func(o ...func(*CatRecoveryRequest)) (*Response, error) + +// CatRecoveryRequest configures the Cat Recovery API request. +type CatRecoveryRequest struct { + Index []string + + ActiveOnly *bool + Bytes string + Detailed *bool + Format string + H []string + Help *bool + S []string + Time string + V *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r CatRecoveryRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_cat") + 1 + len("recovery") + 1 + len(strings.Join(r.Index, ","))) + path.WriteString("/") + path.WriteString("_cat") + path.WriteString("/") + path.WriteString("recovery") + if len(r.Index) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + } + + params = make(map[string]string) + + if r.ActiveOnly != nil { + params["active_only"] = strconv.FormatBool(*r.ActiveOnly) + } + + if r.Bytes != "" { + params["bytes"] = r.Bytes + } + + if r.Detailed != nil { + params["detailed"] = strconv.FormatBool(*r.Detailed) + } + + if r.Format != "" { + params["format"] = r.Format + } + + if len(r.H) > 0 { + params["h"] = strings.Join(r.H, ",") + } + + if r.Help != nil { + params["help"] = strconv.FormatBool(*r.Help) + } + + if len(r.Index) > 0 { + params["index"] = strings.Join(r.Index, ",") + } + + if len(r.S) > 0 { + params["s"] = strings.Join(r.S, ",") + } + + if r.Time != "" { + params["time"] = r.Time + } + + if r.V != nil { + params["v"] = strconv.FormatBool(*r.V) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f CatRecovery) WithContext(v context.Context) func(*CatRecoveryRequest) { + return func(r *CatRecoveryRequest) { + r.ctx = v + } +} + +// WithIndex - comma-separated list or wildcard expression of index names to limit the returned information. +func (f CatRecovery) WithIndex(v ...string) func(*CatRecoveryRequest) { + return func(r *CatRecoveryRequest) { + r.Index = v + } +} + +// WithActiveOnly - if `true`, the response only includes ongoing shard recoveries. +func (f CatRecovery) WithActiveOnly(v bool) func(*CatRecoveryRequest) { + return func(r *CatRecoveryRequest) { + r.ActiveOnly = &v + } +} + +// WithBytes - the unit in which to display byte values. +func (f CatRecovery) WithBytes(v string) func(*CatRecoveryRequest) { + return func(r *CatRecoveryRequest) { + r.Bytes = v + } +} + +// WithDetailed - if `true`, the response includes detailed information about shard recoveries. +func (f CatRecovery) WithDetailed(v bool) func(*CatRecoveryRequest) { + return func(r *CatRecoveryRequest) { + r.Detailed = &v + } +} + +// WithFormat - a short version of the accept header, e.g. json, yaml. +func (f CatRecovery) WithFormat(v string) func(*CatRecoveryRequest) { + return func(r *CatRecoveryRequest) { + r.Format = v + } +} + +// WithH - comma-separated list of column names to display. +func (f CatRecovery) WithH(v ...string) func(*CatRecoveryRequest) { + return func(r *CatRecoveryRequest) { + r.H = v + } +} + +// WithHelp - return help information. +func (f CatRecovery) WithHelp(v bool) func(*CatRecoveryRequest) { + return func(r *CatRecoveryRequest) { + r.Help = &v + } +} + +// WithS - comma-separated list of column names or column aliases to sort by. +func (f CatRecovery) WithS(v ...string) func(*CatRecoveryRequest) { + return func(r *CatRecoveryRequest) { + r.S = v + } +} + +// WithTime - the unit in which to display time values. +func (f CatRecovery) WithTime(v string) func(*CatRecoveryRequest) { + return func(r *CatRecoveryRequest) { + r.Time = v + } +} + +// WithV - verbose mode. display column headers. +func (f CatRecovery) WithV(v bool) func(*CatRecoveryRequest) { + return func(r *CatRecoveryRequest) { + r.V = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f CatRecovery) WithPretty() func(*CatRecoveryRequest) { + return func(r *CatRecoveryRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f CatRecovery) WithHuman() func(*CatRecoveryRequest) { + return func(r *CatRecoveryRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f CatRecovery) WithErrorTrace() func(*CatRecoveryRequest) { + return func(r *CatRecoveryRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f CatRecovery) WithFilterPath(v ...string) func(*CatRecoveryRequest) { + return func(r *CatRecoveryRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f CatRecovery) WithHeader(h map[string]string) func(*CatRecoveryRequest) { + return func(r *CatRecoveryRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f CatRecovery) WithOpaqueID(s string) func(*CatRecoveryRequest) { + return func(r *CatRecoveryRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.repositories.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.repositories.go new file mode 100644 index 00000000..716091b1 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.repositories.go @@ -0,0 +1,273 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" + "time" +) + +func newCatRepositoriesFunc(t Transport) CatRepositories { + return func(o ...func(*CatRepositoriesRequest)) (*Response, error) { + var r = CatRepositoriesRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// CatRepositories returns information about snapshot repositories registered in the cluster. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-repositories.html. +type CatRepositories func(o ...func(*CatRepositoriesRequest)) (*Response, error) + +// CatRepositoriesRequest configures the Cat Repositories API request. +type CatRepositoriesRequest struct { + Format string + H []string + Help *bool + Local *bool + MasterTimeout time.Duration + S []string + V *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r CatRepositoriesRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(len("/_cat/repositories")) + path.WriteString("/_cat/repositories") + + params = make(map[string]string) + + if r.Format != "" { + params["format"] = r.Format + } + + if len(r.H) > 0 { + params["h"] = strings.Join(r.H, ",") + } + + if r.Help != nil { + params["help"] = strconv.FormatBool(*r.Help) + } + + if r.Local != nil { + params["local"] = strconv.FormatBool(*r.Local) + } + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if len(r.S) > 0 { + params["s"] = strings.Join(r.S, ",") + } + + if r.V != nil { + params["v"] = strconv.FormatBool(*r.V) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f CatRepositories) WithContext(v context.Context) func(*CatRepositoriesRequest) { + return func(r *CatRepositoriesRequest) { + r.ctx = v + } +} + +// WithFormat - a short version of the accept header, e.g. json, yaml. +func (f CatRepositories) WithFormat(v string) func(*CatRepositoriesRequest) { + return func(r *CatRepositoriesRequest) { + r.Format = v + } +} + +// WithH - comma-separated list of column names to display. +func (f CatRepositories) WithH(v ...string) func(*CatRepositoriesRequest) { + return func(r *CatRepositoriesRequest) { + r.H = v + } +} + +// WithHelp - return help information. +func (f CatRepositories) WithHelp(v bool) func(*CatRepositoriesRequest) { + return func(r *CatRepositoriesRequest) { + r.Help = &v + } +} + +// WithLocal - return local information, do not retrieve the state from master node. +func (f CatRepositories) WithLocal(v bool) func(*CatRepositoriesRequest) { + return func(r *CatRepositoriesRequest) { + r.Local = &v + } +} + +// WithMasterTimeout - explicit operation timeout for connection to master node. +func (f CatRepositories) WithMasterTimeout(v time.Duration) func(*CatRepositoriesRequest) { + return func(r *CatRepositoriesRequest) { + r.MasterTimeout = v + } +} + +// WithS - comma-separated list of column names or column aliases to sort by. +func (f CatRepositories) WithS(v ...string) func(*CatRepositoriesRequest) { + return func(r *CatRepositoriesRequest) { + r.S = v + } +} + +// WithV - verbose mode. display column headers. +func (f CatRepositories) WithV(v bool) func(*CatRepositoriesRequest) { + return func(r *CatRepositoriesRequest) { + r.V = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f CatRepositories) WithPretty() func(*CatRepositoriesRequest) { + return func(r *CatRepositoriesRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f CatRepositories) WithHuman() func(*CatRepositoriesRequest) { + return func(r *CatRepositoriesRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f CatRepositories) WithErrorTrace() func(*CatRepositoriesRequest) { + return func(r *CatRepositoriesRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f CatRepositories) WithFilterPath(v ...string) func(*CatRepositoriesRequest) { + return func(r *CatRepositoriesRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f CatRepositories) WithHeader(h map[string]string) func(*CatRepositoriesRequest) { + return func(r *CatRepositoriesRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f CatRepositories) WithOpaqueID(s string) func(*CatRepositoriesRequest) { + return func(r *CatRepositoriesRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.segments.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.segments.go new file mode 100644 index 00000000..80da5263 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.segments.go @@ -0,0 +1,276 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newCatSegmentsFunc(t Transport) CatSegments { + return func(o ...func(*CatSegmentsRequest)) (*Response, error) { + var r = CatSegmentsRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// CatSegments provides low-level information about the segments in the shards of an index. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-segments.html. +type CatSegments func(o ...func(*CatSegmentsRequest)) (*Response, error) + +// CatSegmentsRequest configures the Cat Segments API request. +type CatSegmentsRequest struct { + Index []string + + Bytes string + Format string + H []string + Help *bool + S []string + V *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r CatSegmentsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_cat") + 1 + len("segments") + 1 + len(strings.Join(r.Index, ","))) + path.WriteString("/") + path.WriteString("_cat") + path.WriteString("/") + path.WriteString("segments") + if len(r.Index) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + } + + params = make(map[string]string) + + if r.Bytes != "" { + params["bytes"] = r.Bytes + } + + if r.Format != "" { + params["format"] = r.Format + } + + if len(r.H) > 0 { + params["h"] = strings.Join(r.H, ",") + } + + if r.Help != nil { + params["help"] = strconv.FormatBool(*r.Help) + } + + if len(r.S) > 0 { + params["s"] = strings.Join(r.S, ",") + } + + if r.V != nil { + params["v"] = strconv.FormatBool(*r.V) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f CatSegments) WithContext(v context.Context) func(*CatSegmentsRequest) { + return func(r *CatSegmentsRequest) { + r.ctx = v + } +} + +// WithIndex - a list of index names to limit the returned information. +func (f CatSegments) WithIndex(v ...string) func(*CatSegmentsRequest) { + return func(r *CatSegmentsRequest) { + r.Index = v + } +} + +// WithBytes - the unit in which to display byte values. +func (f CatSegments) WithBytes(v string) func(*CatSegmentsRequest) { + return func(r *CatSegmentsRequest) { + r.Bytes = v + } +} + +// WithFormat - a short version of the accept header, e.g. json, yaml. +func (f CatSegments) WithFormat(v string) func(*CatSegmentsRequest) { + return func(r *CatSegmentsRequest) { + r.Format = v + } +} + +// WithH - comma-separated list of column names to display. +func (f CatSegments) WithH(v ...string) func(*CatSegmentsRequest) { + return func(r *CatSegmentsRequest) { + r.H = v + } +} + +// WithHelp - return help information. +func (f CatSegments) WithHelp(v bool) func(*CatSegmentsRequest) { + return func(r *CatSegmentsRequest) { + r.Help = &v + } +} + +// WithS - comma-separated list of column names or column aliases to sort by. +func (f CatSegments) WithS(v ...string) func(*CatSegmentsRequest) { + return func(r *CatSegmentsRequest) { + r.S = v + } +} + +// WithV - verbose mode. display column headers. +func (f CatSegments) WithV(v bool) func(*CatSegmentsRequest) { + return func(r *CatSegmentsRequest) { + r.V = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f CatSegments) WithPretty() func(*CatSegmentsRequest) { + return func(r *CatSegmentsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f CatSegments) WithHuman() func(*CatSegmentsRequest) { + return func(r *CatSegmentsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f CatSegments) WithErrorTrace() func(*CatSegmentsRequest) { + return func(r *CatSegmentsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f CatSegments) WithFilterPath(v ...string) func(*CatSegmentsRequest) { + return func(r *CatSegmentsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f CatSegments) WithHeader(h map[string]string) func(*CatSegmentsRequest) { + return func(r *CatSegmentsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f CatSegments) WithOpaqueID(s string) func(*CatSegmentsRequest) { + return func(r *CatSegmentsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.shards.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.shards.go new file mode 100644 index 00000000..39050500 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.shards.go @@ -0,0 +1,313 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" + "time" +) + +func newCatShardsFunc(t Transport) CatShards { + return func(o ...func(*CatShardsRequest)) (*Response, error) { + var r = CatShardsRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// CatShards provides a detailed view of shard allocation on nodes. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-shards.html. +type CatShards func(o ...func(*CatShardsRequest)) (*Response, error) + +// CatShardsRequest configures the Cat Shards API request. +type CatShardsRequest struct { + Index []string + + Bytes string + Format string + H []string + Help *bool + Local *bool + MasterTimeout time.Duration + S []string + Time string + V *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r CatShardsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_cat") + 1 + len("shards") + 1 + len(strings.Join(r.Index, ","))) + path.WriteString("/") + path.WriteString("_cat") + path.WriteString("/") + path.WriteString("shards") + if len(r.Index) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + } + + params = make(map[string]string) + + if r.Bytes != "" { + params["bytes"] = r.Bytes + } + + if r.Format != "" { + params["format"] = r.Format + } + + if len(r.H) > 0 { + params["h"] = strings.Join(r.H, ",") + } + + if r.Help != nil { + params["help"] = strconv.FormatBool(*r.Help) + } + + if r.Local != nil { + params["local"] = strconv.FormatBool(*r.Local) + } + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if len(r.S) > 0 { + params["s"] = strings.Join(r.S, ",") + } + + if r.Time != "" { + params["time"] = r.Time + } + + if r.V != nil { + params["v"] = strconv.FormatBool(*r.V) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f CatShards) WithContext(v context.Context) func(*CatShardsRequest) { + return func(r *CatShardsRequest) { + r.ctx = v + } +} + +// WithIndex - a list of index names to limit the returned information. +func (f CatShards) WithIndex(v ...string) func(*CatShardsRequest) { + return func(r *CatShardsRequest) { + r.Index = v + } +} + +// WithBytes - the unit in which to display byte values. +func (f CatShards) WithBytes(v string) func(*CatShardsRequest) { + return func(r *CatShardsRequest) { + r.Bytes = v + } +} + +// WithFormat - a short version of the accept header, e.g. json, yaml. +func (f CatShards) WithFormat(v string) func(*CatShardsRequest) { + return func(r *CatShardsRequest) { + r.Format = v + } +} + +// WithH - comma-separated list of column names to display. +func (f CatShards) WithH(v ...string) func(*CatShardsRequest) { + return func(r *CatShardsRequest) { + r.H = v + } +} + +// WithHelp - return help information. +func (f CatShards) WithHelp(v bool) func(*CatShardsRequest) { + return func(r *CatShardsRequest) { + r.Help = &v + } +} + +// WithLocal - return local information, do not retrieve the state from master node (default: false). +func (f CatShards) WithLocal(v bool) func(*CatShardsRequest) { + return func(r *CatShardsRequest) { + r.Local = &v + } +} + +// WithMasterTimeout - explicit operation timeout for connection to master node. +func (f CatShards) WithMasterTimeout(v time.Duration) func(*CatShardsRequest) { + return func(r *CatShardsRequest) { + r.MasterTimeout = v + } +} + +// WithS - comma-separated list of column names or column aliases to sort by. +func (f CatShards) WithS(v ...string) func(*CatShardsRequest) { + return func(r *CatShardsRequest) { + r.S = v + } +} + +// WithTime - the unit in which to display time values. +func (f CatShards) WithTime(v string) func(*CatShardsRequest) { + return func(r *CatShardsRequest) { + r.Time = v + } +} + +// WithV - verbose mode. display column headers. +func (f CatShards) WithV(v bool) func(*CatShardsRequest) { + return func(r *CatShardsRequest) { + r.V = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f CatShards) WithPretty() func(*CatShardsRequest) { + return func(r *CatShardsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f CatShards) WithHuman() func(*CatShardsRequest) { + return func(r *CatShardsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f CatShards) WithErrorTrace() func(*CatShardsRequest) { + return func(r *CatShardsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f CatShards) WithFilterPath(v ...string) func(*CatShardsRequest) { + return func(r *CatShardsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f CatShards) WithHeader(h map[string]string) func(*CatShardsRequest) { + return func(r *CatShardsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f CatShards) WithOpaqueID(s string) func(*CatShardsRequest) { + return func(r *CatShardsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.snapshots.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.snapshots.go new file mode 100644 index 00000000..15a639b9 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.snapshots.go @@ -0,0 +1,301 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" + "time" +) + +func newCatSnapshotsFunc(t Transport) CatSnapshots { + return func(o ...func(*CatSnapshotsRequest)) (*Response, error) { + var r = CatSnapshotsRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// CatSnapshots returns all snapshots in a specific repository. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-snapshots.html. +type CatSnapshots func(o ...func(*CatSnapshotsRequest)) (*Response, error) + +// CatSnapshotsRequest configures the Cat Snapshots API request. +type CatSnapshotsRequest struct { + Repository []string + + Format string + H []string + Help *bool + IgnoreUnavailable *bool + MasterTimeout time.Duration + S []string + Time string + V *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r CatSnapshotsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_cat") + 1 + len("snapshots") + 1 + len(strings.Join(r.Repository, ","))) + path.WriteString("/") + path.WriteString("_cat") + path.WriteString("/") + path.WriteString("snapshots") + if len(r.Repository) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Repository, ",")) + } + + params = make(map[string]string) + + if r.Format != "" { + params["format"] = r.Format + } + + if len(r.H) > 0 { + params["h"] = strings.Join(r.H, ",") + } + + if r.Help != nil { + params["help"] = strconv.FormatBool(*r.Help) + } + + if r.IgnoreUnavailable != nil { + params["ignore_unavailable"] = strconv.FormatBool(*r.IgnoreUnavailable) + } + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if len(r.S) > 0 { + params["s"] = strings.Join(r.S, ",") + } + + if r.Time != "" { + params["time"] = r.Time + } + + if r.V != nil { + params["v"] = strconv.FormatBool(*r.V) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f CatSnapshots) WithContext(v context.Context) func(*CatSnapshotsRequest) { + return func(r *CatSnapshotsRequest) { + r.ctx = v + } +} + +// WithRepository - name of repository from which to fetch the snapshot information. +func (f CatSnapshots) WithRepository(v ...string) func(*CatSnapshotsRequest) { + return func(r *CatSnapshotsRequest) { + r.Repository = v + } +} + +// WithFormat - a short version of the accept header, e.g. json, yaml. +func (f CatSnapshots) WithFormat(v string) func(*CatSnapshotsRequest) { + return func(r *CatSnapshotsRequest) { + r.Format = v + } +} + +// WithH - comma-separated list of column names to display. +func (f CatSnapshots) WithH(v ...string) func(*CatSnapshotsRequest) { + return func(r *CatSnapshotsRequest) { + r.H = v + } +} + +// WithHelp - return help information. +func (f CatSnapshots) WithHelp(v bool) func(*CatSnapshotsRequest) { + return func(r *CatSnapshotsRequest) { + r.Help = &v + } +} + +// WithIgnoreUnavailable - set to true to ignore unavailable snapshots. +func (f CatSnapshots) WithIgnoreUnavailable(v bool) func(*CatSnapshotsRequest) { + return func(r *CatSnapshotsRequest) { + r.IgnoreUnavailable = &v + } +} + +// WithMasterTimeout - explicit operation timeout for connection to master node. +func (f CatSnapshots) WithMasterTimeout(v time.Duration) func(*CatSnapshotsRequest) { + return func(r *CatSnapshotsRequest) { + r.MasterTimeout = v + } +} + +// WithS - comma-separated list of column names or column aliases to sort by. +func (f CatSnapshots) WithS(v ...string) func(*CatSnapshotsRequest) { + return func(r *CatSnapshotsRequest) { + r.S = v + } +} + +// WithTime - the unit in which to display time values. +func (f CatSnapshots) WithTime(v string) func(*CatSnapshotsRequest) { + return func(r *CatSnapshotsRequest) { + r.Time = v + } +} + +// WithV - verbose mode. display column headers. +func (f CatSnapshots) WithV(v bool) func(*CatSnapshotsRequest) { + return func(r *CatSnapshotsRequest) { + r.V = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f CatSnapshots) WithPretty() func(*CatSnapshotsRequest) { + return func(r *CatSnapshotsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f CatSnapshots) WithHuman() func(*CatSnapshotsRequest) { + return func(r *CatSnapshotsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f CatSnapshots) WithErrorTrace() func(*CatSnapshotsRequest) { + return func(r *CatSnapshotsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f CatSnapshots) WithFilterPath(v ...string) func(*CatSnapshotsRequest) { + return func(r *CatSnapshotsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f CatSnapshots) WithHeader(h map[string]string) func(*CatSnapshotsRequest) { + return func(r *CatSnapshotsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f CatSnapshots) WithOpaqueID(s string) func(*CatSnapshotsRequest) { + return func(r *CatSnapshotsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.tasks.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.tasks.go new file mode 100644 index 00000000..b2f1f80e --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.tasks.go @@ -0,0 +1,308 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newCatTasksFunc(t Transport) CatTasks { + return func(o ...func(*CatTasksRequest)) (*Response, error) { + var r = CatTasksRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// CatTasks returns information about the tasks currently executing on one or more nodes in the cluster. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html. +type CatTasks func(o ...func(*CatTasksRequest)) (*Response, error) + +// CatTasksRequest configures the Cat Tasks API request. +type CatTasksRequest struct { + Actions []string + Detailed *bool + Format string + H []string + Help *bool + Nodes []string + ParentTaskID string + S []string + Time string + V *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r CatTasksRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(len("/_cat/tasks")) + path.WriteString("/_cat/tasks") + + params = make(map[string]string) + + if len(r.Actions) > 0 { + params["actions"] = strings.Join(r.Actions, ",") + } + + if r.Detailed != nil { + params["detailed"] = strconv.FormatBool(*r.Detailed) + } + + if r.Format != "" { + params["format"] = r.Format + } + + if len(r.H) > 0 { + params["h"] = strings.Join(r.H, ",") + } + + if r.Help != nil { + params["help"] = strconv.FormatBool(*r.Help) + } + + if len(r.Nodes) > 0 { + params["nodes"] = strings.Join(r.Nodes, ",") + } + + if r.ParentTaskID != "" { + params["parent_task_id"] = r.ParentTaskID + } + + if len(r.S) > 0 { + params["s"] = strings.Join(r.S, ",") + } + + if r.Time != "" { + params["time"] = r.Time + } + + if r.V != nil { + params["v"] = strconv.FormatBool(*r.V) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f CatTasks) WithContext(v context.Context) func(*CatTasksRequest) { + return func(r *CatTasksRequest) { + r.ctx = v + } +} + +// WithActions - a list of actions that should be returned. leave empty to return all.. +func (f CatTasks) WithActions(v ...string) func(*CatTasksRequest) { + return func(r *CatTasksRequest) { + r.Actions = v + } +} + +// WithDetailed - return detailed task information (default: false). +func (f CatTasks) WithDetailed(v bool) func(*CatTasksRequest) { + return func(r *CatTasksRequest) { + r.Detailed = &v + } +} + +// WithFormat - a short version of the accept header, e.g. json, yaml. +func (f CatTasks) WithFormat(v string) func(*CatTasksRequest) { + return func(r *CatTasksRequest) { + r.Format = v + } +} + +// WithH - comma-separated list of column names to display. +func (f CatTasks) WithH(v ...string) func(*CatTasksRequest) { + return func(r *CatTasksRequest) { + r.H = v + } +} + +// WithHelp - return help information. +func (f CatTasks) WithHelp(v bool) func(*CatTasksRequest) { + return func(r *CatTasksRequest) { + r.Help = &v + } +} + +// WithNodes - a list of node ids or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes. +func (f CatTasks) WithNodes(v ...string) func(*CatTasksRequest) { + return func(r *CatTasksRequest) { + r.Nodes = v + } +} + +// WithParentTaskID - return tasks with specified parent task ID (node_id:task_number). set to -1 to return all.. +func (f CatTasks) WithParentTaskID(v string) func(*CatTasksRequest) { + return func(r *CatTasksRequest) { + r.ParentTaskID = v + } +} + +// WithS - comma-separated list of column names or column aliases to sort by. +func (f CatTasks) WithS(v ...string) func(*CatTasksRequest) { + return func(r *CatTasksRequest) { + r.S = v + } +} + +// WithTime - the unit in which to display time values. +func (f CatTasks) WithTime(v string) func(*CatTasksRequest) { + return func(r *CatTasksRequest) { + r.Time = v + } +} + +// WithV - verbose mode. display column headers. +func (f CatTasks) WithV(v bool) func(*CatTasksRequest) { + return func(r *CatTasksRequest) { + r.V = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f CatTasks) WithPretty() func(*CatTasksRequest) { + return func(r *CatTasksRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f CatTasks) WithHuman() func(*CatTasksRequest) { + return func(r *CatTasksRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f CatTasks) WithErrorTrace() func(*CatTasksRequest) { + return func(r *CatTasksRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f CatTasks) WithFilterPath(v ...string) func(*CatTasksRequest) { + return func(r *CatTasksRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f CatTasks) WithHeader(h map[string]string) func(*CatTasksRequest) { + return func(r *CatTasksRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f CatTasks) WithOpaqueID(s string) func(*CatTasksRequest) { + return func(r *CatTasksRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.templates.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.templates.go new file mode 100644 index 00000000..471dcbdc --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.templates.go @@ -0,0 +1,289 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" + "time" +) + +func newCatTemplatesFunc(t Transport) CatTemplates { + return func(o ...func(*CatTemplatesRequest)) (*Response, error) { + var r = CatTemplatesRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// CatTemplates returns information about existing templates. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-templates.html. +type CatTemplates func(o ...func(*CatTemplatesRequest)) (*Response, error) + +// CatTemplatesRequest configures the Cat Templates API request. +type CatTemplatesRequest struct { + Name string + + Format string + H []string + Help *bool + Local *bool + MasterTimeout time.Duration + S []string + V *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r CatTemplatesRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_cat") + 1 + len("templates") + 1 + len(r.Name)) + path.WriteString("/") + path.WriteString("_cat") + path.WriteString("/") + path.WriteString("templates") + if r.Name != "" { + path.WriteString("/") + path.WriteString(r.Name) + } + + params = make(map[string]string) + + if r.Format != "" { + params["format"] = r.Format + } + + if len(r.H) > 0 { + params["h"] = strings.Join(r.H, ",") + } + + if r.Help != nil { + params["help"] = strconv.FormatBool(*r.Help) + } + + if r.Local != nil { + params["local"] = strconv.FormatBool(*r.Local) + } + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if len(r.S) > 0 { + params["s"] = strings.Join(r.S, ",") + } + + if r.V != nil { + params["v"] = strconv.FormatBool(*r.V) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f CatTemplates) WithContext(v context.Context) func(*CatTemplatesRequest) { + return func(r *CatTemplatesRequest) { + r.ctx = v + } +} + +// WithName - a pattern that returned template names must match. +func (f CatTemplates) WithName(v string) func(*CatTemplatesRequest) { + return func(r *CatTemplatesRequest) { + r.Name = v + } +} + +// WithFormat - a short version of the accept header, e.g. json, yaml. +func (f CatTemplates) WithFormat(v string) func(*CatTemplatesRequest) { + return func(r *CatTemplatesRequest) { + r.Format = v + } +} + +// WithH - comma-separated list of column names to display. +func (f CatTemplates) WithH(v ...string) func(*CatTemplatesRequest) { + return func(r *CatTemplatesRequest) { + r.H = v + } +} + +// WithHelp - return help information. +func (f CatTemplates) WithHelp(v bool) func(*CatTemplatesRequest) { + return func(r *CatTemplatesRequest) { + r.Help = &v + } +} + +// WithLocal - return local information, do not retrieve the state from master node (default: false). +func (f CatTemplates) WithLocal(v bool) func(*CatTemplatesRequest) { + return func(r *CatTemplatesRequest) { + r.Local = &v + } +} + +// WithMasterTimeout - explicit operation timeout for connection to master node. +func (f CatTemplates) WithMasterTimeout(v time.Duration) func(*CatTemplatesRequest) { + return func(r *CatTemplatesRequest) { + r.MasterTimeout = v + } +} + +// WithS - comma-separated list of column names or column aliases to sort by. +func (f CatTemplates) WithS(v ...string) func(*CatTemplatesRequest) { + return func(r *CatTemplatesRequest) { + r.S = v + } +} + +// WithV - verbose mode. display column headers. +func (f CatTemplates) WithV(v bool) func(*CatTemplatesRequest) { + return func(r *CatTemplatesRequest) { + r.V = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f CatTemplates) WithPretty() func(*CatTemplatesRequest) { + return func(r *CatTemplatesRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f CatTemplates) WithHuman() func(*CatTemplatesRequest) { + return func(r *CatTemplatesRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f CatTemplates) WithErrorTrace() func(*CatTemplatesRequest) { + return func(r *CatTemplatesRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f CatTemplates) WithFilterPath(v ...string) func(*CatTemplatesRequest) { + return func(r *CatTemplatesRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f CatTemplates) WithHeader(h map[string]string) func(*CatTemplatesRequest) { + return func(r *CatTemplatesRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f CatTemplates) WithOpaqueID(s string) func(*CatTemplatesRequest) { + return func(r *CatTemplatesRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.thread_pool.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.thread_pool.go new file mode 100644 index 00000000..45362e34 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cat.thread_pool.go @@ -0,0 +1,302 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" + "time" +) + +func newCatThreadPoolFunc(t Transport) CatThreadPool { + return func(o ...func(*CatThreadPoolRequest)) (*Response, error) { + var r = CatThreadPoolRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// CatThreadPool returns cluster-wide thread pool statistics per node. +// By default the active, queue and rejected statistics are returned for all thread pools. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-thread-pool.html. +type CatThreadPool func(o ...func(*CatThreadPoolRequest)) (*Response, error) + +// CatThreadPoolRequest configures the Cat Thread Pool API request. +type CatThreadPoolRequest struct { + ThreadPoolPatterns []string + + Format string + H []string + Help *bool + Local *bool + MasterTimeout time.Duration + S []string + Size string + V *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r CatThreadPoolRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_cat") + 1 + len("thread_pool") + 1 + len(strings.Join(r.ThreadPoolPatterns, ","))) + path.WriteString("/") + path.WriteString("_cat") + path.WriteString("/") + path.WriteString("thread_pool") + if len(r.ThreadPoolPatterns) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.ThreadPoolPatterns, ",")) + } + + params = make(map[string]string) + + if r.Format != "" { + params["format"] = r.Format + } + + if len(r.H) > 0 { + params["h"] = strings.Join(r.H, ",") + } + + if r.Help != nil { + params["help"] = strconv.FormatBool(*r.Help) + } + + if r.Local != nil { + params["local"] = strconv.FormatBool(*r.Local) + } + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if len(r.S) > 0 { + params["s"] = strings.Join(r.S, ",") + } + + if r.Size != "" { + params["size"] = r.Size + } + + if r.V != nil { + params["v"] = strconv.FormatBool(*r.V) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f CatThreadPool) WithContext(v context.Context) func(*CatThreadPoolRequest) { + return func(r *CatThreadPoolRequest) { + r.ctx = v + } +} + +// WithThreadPoolPatterns - a list of regular-expressions to filter the thread pools in the output. +func (f CatThreadPool) WithThreadPoolPatterns(v ...string) func(*CatThreadPoolRequest) { + return func(r *CatThreadPoolRequest) { + r.ThreadPoolPatterns = v + } +} + +// WithFormat - a short version of the accept header, e.g. json, yaml. +func (f CatThreadPool) WithFormat(v string) func(*CatThreadPoolRequest) { + return func(r *CatThreadPoolRequest) { + r.Format = v + } +} + +// WithH - comma-separated list of column names to display. +func (f CatThreadPool) WithH(v ...string) func(*CatThreadPoolRequest) { + return func(r *CatThreadPoolRequest) { + r.H = v + } +} + +// WithHelp - return help information. +func (f CatThreadPool) WithHelp(v bool) func(*CatThreadPoolRequest) { + return func(r *CatThreadPoolRequest) { + r.Help = &v + } +} + +// WithLocal - return local information, do not retrieve the state from master node (default: false). +func (f CatThreadPool) WithLocal(v bool) func(*CatThreadPoolRequest) { + return func(r *CatThreadPoolRequest) { + r.Local = &v + } +} + +// WithMasterTimeout - explicit operation timeout for connection to master node. +func (f CatThreadPool) WithMasterTimeout(v time.Duration) func(*CatThreadPoolRequest) { + return func(r *CatThreadPoolRequest) { + r.MasterTimeout = v + } +} + +// WithS - comma-separated list of column names or column aliases to sort by. +func (f CatThreadPool) WithS(v ...string) func(*CatThreadPoolRequest) { + return func(r *CatThreadPoolRequest) { + r.S = v + } +} + +// WithSize - the multiplier in which to display values. +func (f CatThreadPool) WithSize(v string) func(*CatThreadPoolRequest) { + return func(r *CatThreadPoolRequest) { + r.Size = v + } +} + +// WithV - verbose mode. display column headers. +func (f CatThreadPool) WithV(v bool) func(*CatThreadPoolRequest) { + return func(r *CatThreadPoolRequest) { + r.V = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f CatThreadPool) WithPretty() func(*CatThreadPoolRequest) { + return func(r *CatThreadPoolRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f CatThreadPool) WithHuman() func(*CatThreadPoolRequest) { + return func(r *CatThreadPoolRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f CatThreadPool) WithErrorTrace() func(*CatThreadPoolRequest) { + return func(r *CatThreadPoolRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f CatThreadPool) WithFilterPath(v ...string) func(*CatThreadPoolRequest) { + return func(r *CatThreadPoolRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f CatThreadPool) WithHeader(h map[string]string) func(*CatThreadPoolRequest) { + return func(r *CatThreadPoolRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f CatThreadPool) WithOpaqueID(s string) func(*CatThreadPoolRequest) { + return func(r *CatThreadPoolRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.clear_scroll.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.clear_scroll.go new file mode 100644 index 00000000..eeba15d1 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.clear_scroll.go @@ -0,0 +1,216 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newClearScrollFunc(t Transport) ClearScroll { + return func(o ...func(*ClearScrollRequest)) (*Response, error) { + var r = ClearScrollRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// ClearScroll explicitly clears the search context for a scroll. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/clear-scroll-api.html. +type ClearScroll func(o ...func(*ClearScrollRequest)) (*Response, error) + +// ClearScrollRequest configures the Clear Scroll API request. +type ClearScrollRequest struct { + Body io.Reader + + ScrollID []string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r ClearScrollRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + path.Grow(1 + len("_search") + 1 + len("scroll") + 1 + len(strings.Join(r.ScrollID, ","))) + path.WriteString("/") + path.WriteString("_search") + path.WriteString("/") + path.WriteString("scroll") + if len(r.ScrollID) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.ScrollID, ",")) + } + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f ClearScroll) WithContext(v context.Context) func(*ClearScrollRequest) { + return func(r *ClearScrollRequest) { + r.ctx = v + } +} + +// WithBody - A comma-separated list of scroll IDs to clear if none was specified via the scroll_id parameter. +func (f ClearScroll) WithBody(v io.Reader) func(*ClearScrollRequest) { + return func(r *ClearScrollRequest) { + r.Body = v + } +} + +// WithScrollID - a list of scroll ids to clear. +func (f ClearScroll) WithScrollID(v ...string) func(*ClearScrollRequest) { + return func(r *ClearScrollRequest) { + r.ScrollID = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f ClearScroll) WithPretty() func(*ClearScrollRequest) { + return func(r *ClearScrollRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f ClearScroll) WithHuman() func(*ClearScrollRequest) { + return func(r *ClearScrollRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f ClearScroll) WithErrorTrace() func(*ClearScrollRequest) { + return func(r *ClearScrollRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f ClearScroll) WithFilterPath(v ...string) func(*ClearScrollRequest) { + return func(r *ClearScrollRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f ClearScroll) WithHeader(h map[string]string) func(*ClearScrollRequest) { + return func(r *ClearScrollRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f ClearScroll) WithOpaqueID(s string) func(*ClearScrollRequest) { + return func(r *ClearScrollRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.allocation_explain.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.allocation_explain.go new file mode 100644 index 00000000..7fbfd01b --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.allocation_explain.go @@ -0,0 +1,226 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" +) + +func newClusterAllocationExplainFunc(t Transport) ClusterAllocationExplain { + return func(o ...func(*ClusterAllocationExplainRequest)) (*Response, error) { + var r = ClusterAllocationExplainRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// ClusterAllocationExplain provides explanations for shard allocations in the cluster. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-allocation-explain.html. +type ClusterAllocationExplain func(o ...func(*ClusterAllocationExplainRequest)) (*Response, error) + +// ClusterAllocationExplainRequest configures the Cluster Allocation Explain API request. +type ClusterAllocationExplainRequest struct { + Body io.Reader + + IncludeDiskInfo *bool + IncludeYesDecisions *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r ClusterAllocationExplainRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(len("/_cluster/allocation/explain")) + path.WriteString("/_cluster/allocation/explain") + + params = make(map[string]string) + + if r.IncludeDiskInfo != nil { + params["include_disk_info"] = strconv.FormatBool(*r.IncludeDiskInfo) + } + + if r.IncludeYesDecisions != nil { + params["include_yes_decisions"] = strconv.FormatBool(*r.IncludeYesDecisions) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f ClusterAllocationExplain) WithContext(v context.Context) func(*ClusterAllocationExplainRequest) { + return func(r *ClusterAllocationExplainRequest) { + r.ctx = v + } +} + +// WithBody - The index, shard, and primary flag to explain. Empty means 'explain a randomly-chosen unassigned shard'. +func (f ClusterAllocationExplain) WithBody(v io.Reader) func(*ClusterAllocationExplainRequest) { + return func(r *ClusterAllocationExplainRequest) { + r.Body = v + } +} + +// WithIncludeDiskInfo - return information about disk usage and shard sizes (default: false). +func (f ClusterAllocationExplain) WithIncludeDiskInfo(v bool) func(*ClusterAllocationExplainRequest) { + return func(r *ClusterAllocationExplainRequest) { + r.IncludeDiskInfo = &v + } +} + +// WithIncludeYesDecisions - return 'yes' decisions in explanation (default: false). +func (f ClusterAllocationExplain) WithIncludeYesDecisions(v bool) func(*ClusterAllocationExplainRequest) { + return func(r *ClusterAllocationExplainRequest) { + r.IncludeYesDecisions = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f ClusterAllocationExplain) WithPretty() func(*ClusterAllocationExplainRequest) { + return func(r *ClusterAllocationExplainRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f ClusterAllocationExplain) WithHuman() func(*ClusterAllocationExplainRequest) { + return func(r *ClusterAllocationExplainRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f ClusterAllocationExplain) WithErrorTrace() func(*ClusterAllocationExplainRequest) { + return func(r *ClusterAllocationExplainRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f ClusterAllocationExplain) WithFilterPath(v ...string) func(*ClusterAllocationExplainRequest) { + return func(r *ClusterAllocationExplainRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f ClusterAllocationExplain) WithHeader(h map[string]string) func(*ClusterAllocationExplainRequest) { + return func(r *ClusterAllocationExplainRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f ClusterAllocationExplain) WithOpaqueID(s string) func(*ClusterAllocationExplainRequest) { + return func(r *ClusterAllocationExplainRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.delete_component_template.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.delete_component_template.go new file mode 100644 index 00000000..48e74248 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.delete_component_template.go @@ -0,0 +1,217 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" + "time" +) + +func newClusterDeleteComponentTemplateFunc(t Transport) ClusterDeleteComponentTemplate { + return func(name string, o ...func(*ClusterDeleteComponentTemplateRequest)) (*Response, error) { + var r = ClusterDeleteComponentTemplateRequest{Name: name} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// ClusterDeleteComponentTemplate deletes a component template +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-component-template.html. +type ClusterDeleteComponentTemplate func(name string, o ...func(*ClusterDeleteComponentTemplateRequest)) (*Response, error) + +// ClusterDeleteComponentTemplateRequest configures the Cluster Delete Component Template API request. +type ClusterDeleteComponentTemplateRequest struct { + Name string + + MasterTimeout time.Duration + Timeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r ClusterDeleteComponentTemplateRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + path.Grow(1 + len("_component_template") + 1 + len(r.Name)) + path.WriteString("/") + path.WriteString("_component_template") + path.WriteString("/") + path.WriteString(r.Name) + + params = make(map[string]string) + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f ClusterDeleteComponentTemplate) WithContext(v context.Context) func(*ClusterDeleteComponentTemplateRequest) { + return func(r *ClusterDeleteComponentTemplateRequest) { + r.ctx = v + } +} + +// WithMasterTimeout - specify timeout for connection to master. +func (f ClusterDeleteComponentTemplate) WithMasterTimeout(v time.Duration) func(*ClusterDeleteComponentTemplateRequest) { + return func(r *ClusterDeleteComponentTemplateRequest) { + r.MasterTimeout = v + } +} + +// WithTimeout - explicit operation timeout. +func (f ClusterDeleteComponentTemplate) WithTimeout(v time.Duration) func(*ClusterDeleteComponentTemplateRequest) { + return func(r *ClusterDeleteComponentTemplateRequest) { + r.Timeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f ClusterDeleteComponentTemplate) WithPretty() func(*ClusterDeleteComponentTemplateRequest) { + return func(r *ClusterDeleteComponentTemplateRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f ClusterDeleteComponentTemplate) WithHuman() func(*ClusterDeleteComponentTemplateRequest) { + return func(r *ClusterDeleteComponentTemplateRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f ClusterDeleteComponentTemplate) WithErrorTrace() func(*ClusterDeleteComponentTemplateRequest) { + return func(r *ClusterDeleteComponentTemplateRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f ClusterDeleteComponentTemplate) WithFilterPath(v ...string) func(*ClusterDeleteComponentTemplateRequest) { + return func(r *ClusterDeleteComponentTemplateRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f ClusterDeleteComponentTemplate) WithHeader(h map[string]string) func(*ClusterDeleteComponentTemplateRequest) { + return func(r *ClusterDeleteComponentTemplateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f ClusterDeleteComponentTemplate) WithOpaqueID(s string) func(*ClusterDeleteComponentTemplateRequest) { + return func(r *ClusterDeleteComponentTemplateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.delete_voting_config_exclusions.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.delete_voting_config_exclusions.go new file mode 100644 index 00000000..c8b051e1 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.delete_voting_config_exclusions.go @@ -0,0 +1,200 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newClusterDeleteVotingConfigExclusionsFunc(t Transport) ClusterDeleteVotingConfigExclusions { + return func(o ...func(*ClusterDeleteVotingConfigExclusionsRequest)) (*Response, error) { + var r = ClusterDeleteVotingConfigExclusionsRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// ClusterDeleteVotingConfigExclusions clears cluster voting config exclusions. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/voting-config-exclusions.html. +type ClusterDeleteVotingConfigExclusions func(o ...func(*ClusterDeleteVotingConfigExclusionsRequest)) (*Response, error) + +// ClusterDeleteVotingConfigExclusionsRequest configures the Cluster Delete Voting Config Exclusions API request. +type ClusterDeleteVotingConfigExclusionsRequest struct { + WaitForRemoval *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r ClusterDeleteVotingConfigExclusionsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + path.Grow(len("/_cluster/voting_config_exclusions")) + path.WriteString("/_cluster/voting_config_exclusions") + + params = make(map[string]string) + + if r.WaitForRemoval != nil { + params["wait_for_removal"] = strconv.FormatBool(*r.WaitForRemoval) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f ClusterDeleteVotingConfigExclusions) WithContext(v context.Context) func(*ClusterDeleteVotingConfigExclusionsRequest) { + return func(r *ClusterDeleteVotingConfigExclusionsRequest) { + r.ctx = v + } +} + +// WithWaitForRemoval - specifies whether to wait for all excluded nodes to be removed from the cluster before clearing the voting configuration exclusions list.. +func (f ClusterDeleteVotingConfigExclusions) WithWaitForRemoval(v bool) func(*ClusterDeleteVotingConfigExclusionsRequest) { + return func(r *ClusterDeleteVotingConfigExclusionsRequest) { + r.WaitForRemoval = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f ClusterDeleteVotingConfigExclusions) WithPretty() func(*ClusterDeleteVotingConfigExclusionsRequest) { + return func(r *ClusterDeleteVotingConfigExclusionsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f ClusterDeleteVotingConfigExclusions) WithHuman() func(*ClusterDeleteVotingConfigExclusionsRequest) { + return func(r *ClusterDeleteVotingConfigExclusionsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f ClusterDeleteVotingConfigExclusions) WithErrorTrace() func(*ClusterDeleteVotingConfigExclusionsRequest) { + return func(r *ClusterDeleteVotingConfigExclusionsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f ClusterDeleteVotingConfigExclusions) WithFilterPath(v ...string) func(*ClusterDeleteVotingConfigExclusionsRequest) { + return func(r *ClusterDeleteVotingConfigExclusionsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f ClusterDeleteVotingConfigExclusions) WithHeader(h map[string]string) func(*ClusterDeleteVotingConfigExclusionsRequest) { + return func(r *ClusterDeleteVotingConfigExclusionsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f ClusterDeleteVotingConfigExclusions) WithOpaqueID(s string) func(*ClusterDeleteVotingConfigExclusionsRequest) { + return func(r *ClusterDeleteVotingConfigExclusionsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.exists_component_template.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.exists_component_template.go new file mode 100644 index 00000000..24681627 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.exists_component_template.go @@ -0,0 +1,218 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" + "time" +) + +func newClusterExistsComponentTemplateFunc(t Transport) ClusterExistsComponentTemplate { + return func(name string, o ...func(*ClusterExistsComponentTemplateRequest)) (*Response, error) { + var r = ClusterExistsComponentTemplateRequest{Name: name} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// ClusterExistsComponentTemplate returns information about whether a particular component template exist +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-component-template.html. +type ClusterExistsComponentTemplate func(name string, o ...func(*ClusterExistsComponentTemplateRequest)) (*Response, error) + +// ClusterExistsComponentTemplateRequest configures the Cluster Exists Component Template API request. +type ClusterExistsComponentTemplateRequest struct { + Name string + + Local *bool + MasterTimeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r ClusterExistsComponentTemplateRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "HEAD" + + path.Grow(1 + len("_component_template") + 1 + len(r.Name)) + path.WriteString("/") + path.WriteString("_component_template") + path.WriteString("/") + path.WriteString(r.Name) + + params = make(map[string]string) + + if r.Local != nil { + params["local"] = strconv.FormatBool(*r.Local) + } + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f ClusterExistsComponentTemplate) WithContext(v context.Context) func(*ClusterExistsComponentTemplateRequest) { + return func(r *ClusterExistsComponentTemplateRequest) { + r.ctx = v + } +} + +// WithLocal - return local information, do not retrieve the state from master node (default: false). +func (f ClusterExistsComponentTemplate) WithLocal(v bool) func(*ClusterExistsComponentTemplateRequest) { + return func(r *ClusterExistsComponentTemplateRequest) { + r.Local = &v + } +} + +// WithMasterTimeout - explicit operation timeout for connection to master node. +func (f ClusterExistsComponentTemplate) WithMasterTimeout(v time.Duration) func(*ClusterExistsComponentTemplateRequest) { + return func(r *ClusterExistsComponentTemplateRequest) { + r.MasterTimeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f ClusterExistsComponentTemplate) WithPretty() func(*ClusterExistsComponentTemplateRequest) { + return func(r *ClusterExistsComponentTemplateRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f ClusterExistsComponentTemplate) WithHuman() func(*ClusterExistsComponentTemplateRequest) { + return func(r *ClusterExistsComponentTemplateRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f ClusterExistsComponentTemplate) WithErrorTrace() func(*ClusterExistsComponentTemplateRequest) { + return func(r *ClusterExistsComponentTemplateRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f ClusterExistsComponentTemplate) WithFilterPath(v ...string) func(*ClusterExistsComponentTemplateRequest) { + return func(r *ClusterExistsComponentTemplateRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f ClusterExistsComponentTemplate) WithHeader(h map[string]string) func(*ClusterExistsComponentTemplateRequest) { + return func(r *ClusterExistsComponentTemplateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f ClusterExistsComponentTemplate) WithOpaqueID(s string) func(*ClusterExistsComponentTemplateRequest) { + return func(r *ClusterExistsComponentTemplateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.get_component_template.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.get_component_template.go new file mode 100644 index 00000000..3815a095 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.get_component_template.go @@ -0,0 +1,227 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" + "time" +) + +func newClusterGetComponentTemplateFunc(t Transport) ClusterGetComponentTemplate { + return func(o ...func(*ClusterGetComponentTemplateRequest)) (*Response, error) { + var r = ClusterGetComponentTemplateRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// ClusterGetComponentTemplate returns one or more component templates +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-component-template.html. +type ClusterGetComponentTemplate func(o ...func(*ClusterGetComponentTemplateRequest)) (*Response, error) + +// ClusterGetComponentTemplateRequest configures the Cluster Get Component Template API request. +type ClusterGetComponentTemplateRequest struct { + Name []string + + Local *bool + MasterTimeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r ClusterGetComponentTemplateRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_component_template") + 1 + len(strings.Join(r.Name, ","))) + path.WriteString("/") + path.WriteString("_component_template") + if len(r.Name) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Name, ",")) + } + + params = make(map[string]string) + + if r.Local != nil { + params["local"] = strconv.FormatBool(*r.Local) + } + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f ClusterGetComponentTemplate) WithContext(v context.Context) func(*ClusterGetComponentTemplateRequest) { + return func(r *ClusterGetComponentTemplateRequest) { + r.ctx = v + } +} + +// WithName - the comma separated names of the component templates. +func (f ClusterGetComponentTemplate) WithName(v ...string) func(*ClusterGetComponentTemplateRequest) { + return func(r *ClusterGetComponentTemplateRequest) { + r.Name = v + } +} + +// WithLocal - return local information, do not retrieve the state from master node (default: false). +func (f ClusterGetComponentTemplate) WithLocal(v bool) func(*ClusterGetComponentTemplateRequest) { + return func(r *ClusterGetComponentTemplateRequest) { + r.Local = &v + } +} + +// WithMasterTimeout - explicit operation timeout for connection to master node. +func (f ClusterGetComponentTemplate) WithMasterTimeout(v time.Duration) func(*ClusterGetComponentTemplateRequest) { + return func(r *ClusterGetComponentTemplateRequest) { + r.MasterTimeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f ClusterGetComponentTemplate) WithPretty() func(*ClusterGetComponentTemplateRequest) { + return func(r *ClusterGetComponentTemplateRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f ClusterGetComponentTemplate) WithHuman() func(*ClusterGetComponentTemplateRequest) { + return func(r *ClusterGetComponentTemplateRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f ClusterGetComponentTemplate) WithErrorTrace() func(*ClusterGetComponentTemplateRequest) { + return func(r *ClusterGetComponentTemplateRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f ClusterGetComponentTemplate) WithFilterPath(v ...string) func(*ClusterGetComponentTemplateRequest) { + return func(r *ClusterGetComponentTemplateRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f ClusterGetComponentTemplate) WithHeader(h map[string]string) func(*ClusterGetComponentTemplateRequest) { + return func(r *ClusterGetComponentTemplateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f ClusterGetComponentTemplate) WithOpaqueID(s string) func(*ClusterGetComponentTemplateRequest) { + return func(r *ClusterGetComponentTemplateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.get_settings.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.get_settings.go new file mode 100644 index 00000000..c4a6cfa2 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.get_settings.go @@ -0,0 +1,237 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" + "time" +) + +func newClusterGetSettingsFunc(t Transport) ClusterGetSettings { + return func(o ...func(*ClusterGetSettingsRequest)) (*Response, error) { + var r = ClusterGetSettingsRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// ClusterGetSettings returns cluster settings. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-get-settings.html. +type ClusterGetSettings func(o ...func(*ClusterGetSettingsRequest)) (*Response, error) + +// ClusterGetSettingsRequest configures the Cluster Get Settings API request. +type ClusterGetSettingsRequest struct { + FlatSettings *bool + IncludeDefaults *bool + MasterTimeout time.Duration + Timeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r ClusterGetSettingsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(len("/_cluster/settings")) + path.WriteString("/_cluster/settings") + + params = make(map[string]string) + + if r.FlatSettings != nil { + params["flat_settings"] = strconv.FormatBool(*r.FlatSettings) + } + + if r.IncludeDefaults != nil { + params["include_defaults"] = strconv.FormatBool(*r.IncludeDefaults) + } + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f ClusterGetSettings) WithContext(v context.Context) func(*ClusterGetSettingsRequest) { + return func(r *ClusterGetSettingsRequest) { + r.ctx = v + } +} + +// WithFlatSettings - return settings in flat format (default: false). +func (f ClusterGetSettings) WithFlatSettings(v bool) func(*ClusterGetSettingsRequest) { + return func(r *ClusterGetSettingsRequest) { + r.FlatSettings = &v + } +} + +// WithIncludeDefaults - whether to return all default clusters setting.. +func (f ClusterGetSettings) WithIncludeDefaults(v bool) func(*ClusterGetSettingsRequest) { + return func(r *ClusterGetSettingsRequest) { + r.IncludeDefaults = &v + } +} + +// WithMasterTimeout - explicit operation timeout for connection to master node. +func (f ClusterGetSettings) WithMasterTimeout(v time.Duration) func(*ClusterGetSettingsRequest) { + return func(r *ClusterGetSettingsRequest) { + r.MasterTimeout = v + } +} + +// WithTimeout - explicit operation timeout. +func (f ClusterGetSettings) WithTimeout(v time.Duration) func(*ClusterGetSettingsRequest) { + return func(r *ClusterGetSettingsRequest) { + r.Timeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f ClusterGetSettings) WithPretty() func(*ClusterGetSettingsRequest) { + return func(r *ClusterGetSettingsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f ClusterGetSettings) WithHuman() func(*ClusterGetSettingsRequest) { + return func(r *ClusterGetSettingsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f ClusterGetSettings) WithErrorTrace() func(*ClusterGetSettingsRequest) { + return func(r *ClusterGetSettingsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f ClusterGetSettings) WithFilterPath(v ...string) func(*ClusterGetSettingsRequest) { + return func(r *ClusterGetSettingsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f ClusterGetSettings) WithHeader(h map[string]string) func(*ClusterGetSettingsRequest) { + return func(r *ClusterGetSettingsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f ClusterGetSettings) WithOpaqueID(s string) func(*ClusterGetSettingsRequest) { + return func(r *ClusterGetSettingsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.health.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.health.go new file mode 100644 index 00000000..2a801b16 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.health.go @@ -0,0 +1,337 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" + "time" +) + +func newClusterHealthFunc(t Transport) ClusterHealth { + return func(o ...func(*ClusterHealthRequest)) (*Response, error) { + var r = ClusterHealthRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// ClusterHealth returns basic information about the health of the cluster. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-health.html. +type ClusterHealth func(o ...func(*ClusterHealthRequest)) (*Response, error) + +// ClusterHealthRequest configures the Cluster Health API request. +type ClusterHealthRequest struct { + Index []string + + ExpandWildcards string + Level string + Local *bool + MasterTimeout time.Duration + Timeout time.Duration + WaitForActiveShards string + WaitForEvents string + WaitForNoInitializingShards *bool + WaitForNoRelocatingShards *bool + WaitForNodes string + WaitForStatus string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r ClusterHealthRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_cluster") + 1 + len("health") + 1 + len(strings.Join(r.Index, ","))) + path.WriteString("/") + path.WriteString("_cluster") + path.WriteString("/") + path.WriteString("health") + if len(r.Index) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + } + + params = make(map[string]string) + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if r.Level != "" { + params["level"] = r.Level + } + + if r.Local != nil { + params["local"] = strconv.FormatBool(*r.Local) + } + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.WaitForActiveShards != "" { + params["wait_for_active_shards"] = r.WaitForActiveShards + } + + if r.WaitForEvents != "" { + params["wait_for_events"] = r.WaitForEvents + } + + if r.WaitForNoInitializingShards != nil { + params["wait_for_no_initializing_shards"] = strconv.FormatBool(*r.WaitForNoInitializingShards) + } + + if r.WaitForNoRelocatingShards != nil { + params["wait_for_no_relocating_shards"] = strconv.FormatBool(*r.WaitForNoRelocatingShards) + } + + if r.WaitForNodes != "" { + params["wait_for_nodes"] = r.WaitForNodes + } + + if r.WaitForStatus != "" { + params["wait_for_status"] = r.WaitForStatus + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f ClusterHealth) WithContext(v context.Context) func(*ClusterHealthRequest) { + return func(r *ClusterHealthRequest) { + r.ctx = v + } +} + +// WithIndex - limit the information returned to a specific index. +func (f ClusterHealth) WithIndex(v ...string) func(*ClusterHealthRequest) { + return func(r *ClusterHealthRequest) { + r.Index = v + } +} + +// WithExpandWildcards - whether to expand wildcard expression to concrete indices that are open, closed or both.. +func (f ClusterHealth) WithExpandWildcards(v string) func(*ClusterHealthRequest) { + return func(r *ClusterHealthRequest) { + r.ExpandWildcards = v + } +} + +// WithLevel - specify the level of detail for returned information. +func (f ClusterHealth) WithLevel(v string) func(*ClusterHealthRequest) { + return func(r *ClusterHealthRequest) { + r.Level = v + } +} + +// WithLocal - return local information, do not retrieve the state from master node (default: false). +func (f ClusterHealth) WithLocal(v bool) func(*ClusterHealthRequest) { + return func(r *ClusterHealthRequest) { + r.Local = &v + } +} + +// WithMasterTimeout - explicit operation timeout for connection to master node. +func (f ClusterHealth) WithMasterTimeout(v time.Duration) func(*ClusterHealthRequest) { + return func(r *ClusterHealthRequest) { + r.MasterTimeout = v + } +} + +// WithTimeout - explicit operation timeout. +func (f ClusterHealth) WithTimeout(v time.Duration) func(*ClusterHealthRequest) { + return func(r *ClusterHealthRequest) { + r.Timeout = v + } +} + +// WithWaitForActiveShards - wait until the specified number of shards is active. +func (f ClusterHealth) WithWaitForActiveShards(v string) func(*ClusterHealthRequest) { + return func(r *ClusterHealthRequest) { + r.WaitForActiveShards = v + } +} + +// WithWaitForEvents - wait until all currently queued events with the given priority are processed. +func (f ClusterHealth) WithWaitForEvents(v string) func(*ClusterHealthRequest) { + return func(r *ClusterHealthRequest) { + r.WaitForEvents = v + } +} + +// WithWaitForNoInitializingShards - whether to wait until there are no initializing shards in the cluster. +func (f ClusterHealth) WithWaitForNoInitializingShards(v bool) func(*ClusterHealthRequest) { + return func(r *ClusterHealthRequest) { + r.WaitForNoInitializingShards = &v + } +} + +// WithWaitForNoRelocatingShards - whether to wait until there are no relocating shards in the cluster. +func (f ClusterHealth) WithWaitForNoRelocatingShards(v bool) func(*ClusterHealthRequest) { + return func(r *ClusterHealthRequest) { + r.WaitForNoRelocatingShards = &v + } +} + +// WithWaitForNodes - wait until the specified number of nodes is available. +func (f ClusterHealth) WithWaitForNodes(v string) func(*ClusterHealthRequest) { + return func(r *ClusterHealthRequest) { + r.WaitForNodes = v + } +} + +// WithWaitForStatus - wait until cluster is in a specific state. +func (f ClusterHealth) WithWaitForStatus(v string) func(*ClusterHealthRequest) { + return func(r *ClusterHealthRequest) { + r.WaitForStatus = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f ClusterHealth) WithPretty() func(*ClusterHealthRequest) { + return func(r *ClusterHealthRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f ClusterHealth) WithHuman() func(*ClusterHealthRequest) { + return func(r *ClusterHealthRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f ClusterHealth) WithErrorTrace() func(*ClusterHealthRequest) { + return func(r *ClusterHealthRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f ClusterHealth) WithFilterPath(v ...string) func(*ClusterHealthRequest) { + return func(r *ClusterHealthRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f ClusterHealth) WithHeader(h map[string]string) func(*ClusterHealthRequest) { + return func(r *ClusterHealthRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f ClusterHealth) WithOpaqueID(s string) func(*ClusterHealthRequest) { + return func(r *ClusterHealthRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.pending_tasks.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.pending_tasks.go new file mode 100644 index 00000000..0264947e --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.pending_tasks.go @@ -0,0 +1,214 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" + "time" +) + +func newClusterPendingTasksFunc(t Transport) ClusterPendingTasks { + return func(o ...func(*ClusterPendingTasksRequest)) (*Response, error) { + var r = ClusterPendingTasksRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// ClusterPendingTasks returns a list of any cluster-level changes (e.g. create index, update mapping, +// allocate or fail shard) which have not yet been executed. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-pending.html. +type ClusterPendingTasks func(o ...func(*ClusterPendingTasksRequest)) (*Response, error) + +// ClusterPendingTasksRequest configures the Cluster Pending Tasks API request. +type ClusterPendingTasksRequest struct { + Local *bool + MasterTimeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r ClusterPendingTasksRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(len("/_cluster/pending_tasks")) + path.WriteString("/_cluster/pending_tasks") + + params = make(map[string]string) + + if r.Local != nil { + params["local"] = strconv.FormatBool(*r.Local) + } + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f ClusterPendingTasks) WithContext(v context.Context) func(*ClusterPendingTasksRequest) { + return func(r *ClusterPendingTasksRequest) { + r.ctx = v + } +} + +// WithLocal - return local information, do not retrieve the state from master node (default: false). +func (f ClusterPendingTasks) WithLocal(v bool) func(*ClusterPendingTasksRequest) { + return func(r *ClusterPendingTasksRequest) { + r.Local = &v + } +} + +// WithMasterTimeout - specify timeout for connection to master. +func (f ClusterPendingTasks) WithMasterTimeout(v time.Duration) func(*ClusterPendingTasksRequest) { + return func(r *ClusterPendingTasksRequest) { + r.MasterTimeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f ClusterPendingTasks) WithPretty() func(*ClusterPendingTasksRequest) { + return func(r *ClusterPendingTasksRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f ClusterPendingTasks) WithHuman() func(*ClusterPendingTasksRequest) { + return func(r *ClusterPendingTasksRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f ClusterPendingTasks) WithErrorTrace() func(*ClusterPendingTasksRequest) { + return func(r *ClusterPendingTasksRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f ClusterPendingTasks) WithFilterPath(v ...string) func(*ClusterPendingTasksRequest) { + return func(r *ClusterPendingTasksRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f ClusterPendingTasks) WithHeader(h map[string]string) func(*ClusterPendingTasksRequest) { + return func(r *ClusterPendingTasksRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f ClusterPendingTasks) WithOpaqueID(s string) func(*ClusterPendingTasksRequest) { + return func(r *ClusterPendingTasksRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.post_voting_config_exclusions.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.post_voting_config_exclusions.go new file mode 100644 index 00000000..cfd50a7e --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.post_voting_config_exclusions.go @@ -0,0 +1,224 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" + "time" +) + +func newClusterPostVotingConfigExclusionsFunc(t Transport) ClusterPostVotingConfigExclusions { + return func(o ...func(*ClusterPostVotingConfigExclusionsRequest)) (*Response, error) { + var r = ClusterPostVotingConfigExclusionsRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// ClusterPostVotingConfigExclusions updates the cluster voting config exclusions by node ids or node names. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/voting-config-exclusions.html. +type ClusterPostVotingConfigExclusions func(o ...func(*ClusterPostVotingConfigExclusionsRequest)) (*Response, error) + +// ClusterPostVotingConfigExclusionsRequest configures the Cluster Post Voting Config Exclusions API request. +type ClusterPostVotingConfigExclusionsRequest struct { + NodeIds string + NodeNames string + Timeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r ClusterPostVotingConfigExclusionsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(len("/_cluster/voting_config_exclusions")) + path.WriteString("/_cluster/voting_config_exclusions") + + params = make(map[string]string) + + if r.NodeIds != "" { + params["node_ids"] = r.NodeIds + } + + if r.NodeNames != "" { + params["node_names"] = r.NodeNames + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f ClusterPostVotingConfigExclusions) WithContext(v context.Context) func(*ClusterPostVotingConfigExclusionsRequest) { + return func(r *ClusterPostVotingConfigExclusionsRequest) { + r.ctx = v + } +} + +// WithNodeIds - a list of the persistent ids of the nodes to exclude from the voting configuration. if specified, you may not also specify ?node_names.. +func (f ClusterPostVotingConfigExclusions) WithNodeIds(v string) func(*ClusterPostVotingConfigExclusionsRequest) { + return func(r *ClusterPostVotingConfigExclusionsRequest) { + r.NodeIds = v + } +} + +// WithNodeNames - a list of the names of the nodes to exclude from the voting configuration. if specified, you may not also specify ?node_ids.. +func (f ClusterPostVotingConfigExclusions) WithNodeNames(v string) func(*ClusterPostVotingConfigExclusionsRequest) { + return func(r *ClusterPostVotingConfigExclusionsRequest) { + r.NodeNames = v + } +} + +// WithTimeout - explicit operation timeout. +func (f ClusterPostVotingConfigExclusions) WithTimeout(v time.Duration) func(*ClusterPostVotingConfigExclusionsRequest) { + return func(r *ClusterPostVotingConfigExclusionsRequest) { + r.Timeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f ClusterPostVotingConfigExclusions) WithPretty() func(*ClusterPostVotingConfigExclusionsRequest) { + return func(r *ClusterPostVotingConfigExclusionsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f ClusterPostVotingConfigExclusions) WithHuman() func(*ClusterPostVotingConfigExclusionsRequest) { + return func(r *ClusterPostVotingConfigExclusionsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f ClusterPostVotingConfigExclusions) WithErrorTrace() func(*ClusterPostVotingConfigExclusionsRequest) { + return func(r *ClusterPostVotingConfigExclusionsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f ClusterPostVotingConfigExclusions) WithFilterPath(v ...string) func(*ClusterPostVotingConfigExclusionsRequest) { + return func(r *ClusterPostVotingConfigExclusionsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f ClusterPostVotingConfigExclusions) WithHeader(h map[string]string) func(*ClusterPostVotingConfigExclusionsRequest) { + return func(r *ClusterPostVotingConfigExclusionsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f ClusterPostVotingConfigExclusions) WithOpaqueID(s string) func(*ClusterPostVotingConfigExclusionsRequest) { + return func(r *ClusterPostVotingConfigExclusionsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.put_component_template.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.put_component_template.go new file mode 100644 index 00000000..e336a701 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.put_component_template.go @@ -0,0 +1,237 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" + "time" +) + +func newClusterPutComponentTemplateFunc(t Transport) ClusterPutComponentTemplate { + return func(name string, body io.Reader, o ...func(*ClusterPutComponentTemplateRequest)) (*Response, error) { + var r = ClusterPutComponentTemplateRequest{Name: name, Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// ClusterPutComponentTemplate creates or updates a component template +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-component-template.html. +type ClusterPutComponentTemplate func(name string, body io.Reader, o ...func(*ClusterPutComponentTemplateRequest)) (*Response, error) + +// ClusterPutComponentTemplateRequest configures the Cluster Put Component Template API request. +type ClusterPutComponentTemplateRequest struct { + Body io.Reader + + Name string + + Create *bool + MasterTimeout time.Duration + Timeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r ClusterPutComponentTemplateRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(1 + len("_component_template") + 1 + len(r.Name)) + path.WriteString("/") + path.WriteString("_component_template") + path.WriteString("/") + path.WriteString(r.Name) + + params = make(map[string]string) + + if r.Create != nil { + params["create"] = strconv.FormatBool(*r.Create) + } + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f ClusterPutComponentTemplate) WithContext(v context.Context) func(*ClusterPutComponentTemplateRequest) { + return func(r *ClusterPutComponentTemplateRequest) { + r.ctx = v + } +} + +// WithCreate - whether the index template should only be added if new or can also replace an existing one. +func (f ClusterPutComponentTemplate) WithCreate(v bool) func(*ClusterPutComponentTemplateRequest) { + return func(r *ClusterPutComponentTemplateRequest) { + r.Create = &v + } +} + +// WithMasterTimeout - specify timeout for connection to master. +func (f ClusterPutComponentTemplate) WithMasterTimeout(v time.Duration) func(*ClusterPutComponentTemplateRequest) { + return func(r *ClusterPutComponentTemplateRequest) { + r.MasterTimeout = v + } +} + +// WithTimeout - explicit operation timeout. +func (f ClusterPutComponentTemplate) WithTimeout(v time.Duration) func(*ClusterPutComponentTemplateRequest) { + return func(r *ClusterPutComponentTemplateRequest) { + r.Timeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f ClusterPutComponentTemplate) WithPretty() func(*ClusterPutComponentTemplateRequest) { + return func(r *ClusterPutComponentTemplateRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f ClusterPutComponentTemplate) WithHuman() func(*ClusterPutComponentTemplateRequest) { + return func(r *ClusterPutComponentTemplateRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f ClusterPutComponentTemplate) WithErrorTrace() func(*ClusterPutComponentTemplateRequest) { + return func(r *ClusterPutComponentTemplateRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f ClusterPutComponentTemplate) WithFilterPath(v ...string) func(*ClusterPutComponentTemplateRequest) { + return func(r *ClusterPutComponentTemplateRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f ClusterPutComponentTemplate) WithHeader(h map[string]string) func(*ClusterPutComponentTemplateRequest) { + return func(r *ClusterPutComponentTemplateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f ClusterPutComponentTemplate) WithOpaqueID(s string) func(*ClusterPutComponentTemplateRequest) { + return func(r *ClusterPutComponentTemplateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.put_settings.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.put_settings.go new file mode 100644 index 00000000..ded7d172 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.put_settings.go @@ -0,0 +1,232 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" + "time" +) + +func newClusterPutSettingsFunc(t Transport) ClusterPutSettings { + return func(body io.Reader, o ...func(*ClusterPutSettingsRequest)) (*Response, error) { + var r = ClusterPutSettingsRequest{Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// ClusterPutSettings updates the cluster settings. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-update-settings.html. +type ClusterPutSettings func(body io.Reader, o ...func(*ClusterPutSettingsRequest)) (*Response, error) + +// ClusterPutSettingsRequest configures the Cluster Put Settings API request. +type ClusterPutSettingsRequest struct { + Body io.Reader + + FlatSettings *bool + MasterTimeout time.Duration + Timeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r ClusterPutSettingsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(len("/_cluster/settings")) + path.WriteString("/_cluster/settings") + + params = make(map[string]string) + + if r.FlatSettings != nil { + params["flat_settings"] = strconv.FormatBool(*r.FlatSettings) + } + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f ClusterPutSettings) WithContext(v context.Context) func(*ClusterPutSettingsRequest) { + return func(r *ClusterPutSettingsRequest) { + r.ctx = v + } +} + +// WithFlatSettings - return settings in flat format (default: false). +func (f ClusterPutSettings) WithFlatSettings(v bool) func(*ClusterPutSettingsRequest) { + return func(r *ClusterPutSettingsRequest) { + r.FlatSettings = &v + } +} + +// WithMasterTimeout - explicit operation timeout for connection to master node. +func (f ClusterPutSettings) WithMasterTimeout(v time.Duration) func(*ClusterPutSettingsRequest) { + return func(r *ClusterPutSettingsRequest) { + r.MasterTimeout = v + } +} + +// WithTimeout - explicit operation timeout. +func (f ClusterPutSettings) WithTimeout(v time.Duration) func(*ClusterPutSettingsRequest) { + return func(r *ClusterPutSettingsRequest) { + r.Timeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f ClusterPutSettings) WithPretty() func(*ClusterPutSettingsRequest) { + return func(r *ClusterPutSettingsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f ClusterPutSettings) WithHuman() func(*ClusterPutSettingsRequest) { + return func(r *ClusterPutSettingsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f ClusterPutSettings) WithErrorTrace() func(*ClusterPutSettingsRequest) { + return func(r *ClusterPutSettingsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f ClusterPutSettings) WithFilterPath(v ...string) func(*ClusterPutSettingsRequest) { + return func(r *ClusterPutSettingsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f ClusterPutSettings) WithHeader(h map[string]string) func(*ClusterPutSettingsRequest) { + return func(r *ClusterPutSettingsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f ClusterPutSettings) WithOpaqueID(s string) func(*ClusterPutSettingsRequest) { + return func(r *ClusterPutSettingsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.remote_info.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.remote_info.go new file mode 100644 index 00000000..65b23995 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.remote_info.go @@ -0,0 +1,186 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newClusterRemoteInfoFunc(t Transport) ClusterRemoteInfo { + return func(o ...func(*ClusterRemoteInfoRequest)) (*Response, error) { + var r = ClusterRemoteInfoRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// ClusterRemoteInfo returns the information about configured remote clusters. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-remote-info.html. +type ClusterRemoteInfo func(o ...func(*ClusterRemoteInfoRequest)) (*Response, error) + +// ClusterRemoteInfoRequest configures the Cluster Remote Info API request. +type ClusterRemoteInfoRequest struct { + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r ClusterRemoteInfoRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(len("/_remote/info")) + path.WriteString("/_remote/info") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f ClusterRemoteInfo) WithContext(v context.Context) func(*ClusterRemoteInfoRequest) { + return func(r *ClusterRemoteInfoRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f ClusterRemoteInfo) WithPretty() func(*ClusterRemoteInfoRequest) { + return func(r *ClusterRemoteInfoRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f ClusterRemoteInfo) WithHuman() func(*ClusterRemoteInfoRequest) { + return func(r *ClusterRemoteInfoRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f ClusterRemoteInfo) WithErrorTrace() func(*ClusterRemoteInfoRequest) { + return func(r *ClusterRemoteInfoRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f ClusterRemoteInfo) WithFilterPath(v ...string) func(*ClusterRemoteInfoRequest) { + return func(r *ClusterRemoteInfoRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f ClusterRemoteInfo) WithHeader(h map[string]string) func(*ClusterRemoteInfoRequest) { + return func(r *ClusterRemoteInfoRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f ClusterRemoteInfo) WithOpaqueID(s string) func(*ClusterRemoteInfoRequest) { + return func(r *ClusterRemoteInfoRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.reroute.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.reroute.go new file mode 100644 index 00000000..e4ef506f --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.reroute.go @@ -0,0 +1,275 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" + "time" +) + +func newClusterRerouteFunc(t Transport) ClusterReroute { + return func(o ...func(*ClusterRerouteRequest)) (*Response, error) { + var r = ClusterRerouteRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// ClusterReroute allows to manually change the allocation of individual shards in the cluster. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-reroute.html. +type ClusterReroute func(o ...func(*ClusterRerouteRequest)) (*Response, error) + +// ClusterRerouteRequest configures the Cluster Reroute API request. +type ClusterRerouteRequest struct { + Body io.Reader + + DryRun *bool + Explain *bool + MasterTimeout time.Duration + Metric []string + RetryFailed *bool + Timeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r ClusterRerouteRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(len("/_cluster/reroute")) + path.WriteString("/_cluster/reroute") + + params = make(map[string]string) + + if r.DryRun != nil { + params["dry_run"] = strconv.FormatBool(*r.DryRun) + } + + if r.Explain != nil { + params["explain"] = strconv.FormatBool(*r.Explain) + } + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if len(r.Metric) > 0 { + params["metric"] = strings.Join(r.Metric, ",") + } + + if r.RetryFailed != nil { + params["retry_failed"] = strconv.FormatBool(*r.RetryFailed) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f ClusterReroute) WithContext(v context.Context) func(*ClusterRerouteRequest) { + return func(r *ClusterRerouteRequest) { + r.ctx = v + } +} + +// WithBody - The definition of `commands` to perform (`move`, `cancel`, `allocate`). +func (f ClusterReroute) WithBody(v io.Reader) func(*ClusterRerouteRequest) { + return func(r *ClusterRerouteRequest) { + r.Body = v + } +} + +// WithDryRun - simulate the operation only and return the resulting state. +func (f ClusterReroute) WithDryRun(v bool) func(*ClusterRerouteRequest) { + return func(r *ClusterRerouteRequest) { + r.DryRun = &v + } +} + +// WithExplain - return an explanation of why the commands can or cannot be executed. +func (f ClusterReroute) WithExplain(v bool) func(*ClusterRerouteRequest) { + return func(r *ClusterRerouteRequest) { + r.Explain = &v + } +} + +// WithMasterTimeout - explicit operation timeout for connection to master node. +func (f ClusterReroute) WithMasterTimeout(v time.Duration) func(*ClusterRerouteRequest) { + return func(r *ClusterRerouteRequest) { + r.MasterTimeout = v + } +} + +// WithMetric - limit the information returned to the specified metrics. defaults to all but metadata. +func (f ClusterReroute) WithMetric(v ...string) func(*ClusterRerouteRequest) { + return func(r *ClusterRerouteRequest) { + r.Metric = v + } +} + +// WithRetryFailed - retries allocation of shards that are blocked due to too many subsequent allocation failures. +func (f ClusterReroute) WithRetryFailed(v bool) func(*ClusterRerouteRequest) { + return func(r *ClusterRerouteRequest) { + r.RetryFailed = &v + } +} + +// WithTimeout - explicit operation timeout. +func (f ClusterReroute) WithTimeout(v time.Duration) func(*ClusterRerouteRequest) { + return func(r *ClusterRerouteRequest) { + r.Timeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f ClusterReroute) WithPretty() func(*ClusterRerouteRequest) { + return func(r *ClusterRerouteRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f ClusterReroute) WithHuman() func(*ClusterRerouteRequest) { + return func(r *ClusterRerouteRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f ClusterReroute) WithErrorTrace() func(*ClusterRerouteRequest) { + return func(r *ClusterRerouteRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f ClusterReroute) WithFilterPath(v ...string) func(*ClusterRerouteRequest) { + return func(r *ClusterRerouteRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f ClusterReroute) WithHeader(h map[string]string) func(*ClusterRerouteRequest) { + return func(r *ClusterRerouteRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f ClusterReroute) WithOpaqueID(s string) func(*ClusterRerouteRequest) { + return func(r *ClusterRerouteRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.state.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.state.go new file mode 100644 index 00000000..fe338b6d --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.state.go @@ -0,0 +1,314 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" + "time" +) + +func newClusterStateFunc(t Transport) ClusterState { + return func(o ...func(*ClusterStateRequest)) (*Response, error) { + var r = ClusterStateRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// ClusterState returns a comprehensive information about the state of the cluster. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-state.html. +type ClusterState func(o ...func(*ClusterStateRequest)) (*Response, error) + +// ClusterStateRequest configures the Cluster State API request. +type ClusterStateRequest struct { + Index []string + + Metric []string + + AllowNoIndices *bool + ExpandWildcards string + FlatSettings *bool + IgnoreUnavailable *bool + Local *bool + MasterTimeout time.Duration + WaitForMetadataVersion *int + WaitForTimeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r ClusterStateRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_cluster") + 1 + len("state") + 1 + len(strings.Join(r.Metric, ",")) + 1 + len(strings.Join(r.Index, ","))) + path.WriteString("/") + path.WriteString("_cluster") + path.WriteString("/") + path.WriteString("state") + if len(r.Metric) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Metric, ",")) + } + if len(r.Index) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + } + + params = make(map[string]string) + + if r.AllowNoIndices != nil { + params["allow_no_indices"] = strconv.FormatBool(*r.AllowNoIndices) + } + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if r.FlatSettings != nil { + params["flat_settings"] = strconv.FormatBool(*r.FlatSettings) + } + + if r.IgnoreUnavailable != nil { + params["ignore_unavailable"] = strconv.FormatBool(*r.IgnoreUnavailable) + } + + if r.Local != nil { + params["local"] = strconv.FormatBool(*r.Local) + } + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.WaitForMetadataVersion != nil { + params["wait_for_metadata_version"] = strconv.FormatInt(int64(*r.WaitForMetadataVersion), 10) + } + + if r.WaitForTimeout != 0 { + params["wait_for_timeout"] = formatDuration(r.WaitForTimeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f ClusterState) WithContext(v context.Context) func(*ClusterStateRequest) { + return func(r *ClusterStateRequest) { + r.ctx = v + } +} + +// WithIndex - a list of index names; use _all to perform the operation on all indices. +func (f ClusterState) WithIndex(v ...string) func(*ClusterStateRequest) { + return func(r *ClusterStateRequest) { + r.Index = v + } +} + +// WithMetric - limit the information returned to the specified metrics. +func (f ClusterState) WithMetric(v ...string) func(*ClusterStateRequest) { + return func(r *ClusterStateRequest) { + r.Metric = v + } +} + +// WithAllowNoIndices - whether to ignore if a wildcard indices expression resolves into no concrete indices. (this includes `_all` string or when no indices have been specified). +func (f ClusterState) WithAllowNoIndices(v bool) func(*ClusterStateRequest) { + return func(r *ClusterStateRequest) { + r.AllowNoIndices = &v + } +} + +// WithExpandWildcards - whether to expand wildcard expression to concrete indices that are open, closed or both.. +func (f ClusterState) WithExpandWildcards(v string) func(*ClusterStateRequest) { + return func(r *ClusterStateRequest) { + r.ExpandWildcards = v + } +} + +// WithFlatSettings - return settings in flat format (default: false). +func (f ClusterState) WithFlatSettings(v bool) func(*ClusterStateRequest) { + return func(r *ClusterStateRequest) { + r.FlatSettings = &v + } +} + +// WithIgnoreUnavailable - whether specified concrete indices should be ignored when unavailable (missing or closed). +func (f ClusterState) WithIgnoreUnavailable(v bool) func(*ClusterStateRequest) { + return func(r *ClusterStateRequest) { + r.IgnoreUnavailable = &v + } +} + +// WithLocal - return local information, do not retrieve the state from master node (default: false). +func (f ClusterState) WithLocal(v bool) func(*ClusterStateRequest) { + return func(r *ClusterStateRequest) { + r.Local = &v + } +} + +// WithMasterTimeout - specify timeout for connection to master. +func (f ClusterState) WithMasterTimeout(v time.Duration) func(*ClusterStateRequest) { + return func(r *ClusterStateRequest) { + r.MasterTimeout = v + } +} + +// WithWaitForMetadataVersion - wait for the metadata version to be equal or greater than the specified metadata version. +func (f ClusterState) WithWaitForMetadataVersion(v int) func(*ClusterStateRequest) { + return func(r *ClusterStateRequest) { + r.WaitForMetadataVersion = &v + } +} + +// WithWaitForTimeout - the maximum time to wait for wait_for_metadata_version before timing out. +func (f ClusterState) WithWaitForTimeout(v time.Duration) func(*ClusterStateRequest) { + return func(r *ClusterStateRequest) { + r.WaitForTimeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f ClusterState) WithPretty() func(*ClusterStateRequest) { + return func(r *ClusterStateRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f ClusterState) WithHuman() func(*ClusterStateRequest) { + return func(r *ClusterStateRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f ClusterState) WithErrorTrace() func(*ClusterStateRequest) { + return func(r *ClusterStateRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f ClusterState) WithFilterPath(v ...string) func(*ClusterStateRequest) { + return func(r *ClusterStateRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f ClusterState) WithHeader(h map[string]string) func(*ClusterStateRequest) { + return func(r *ClusterStateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f ClusterState) WithOpaqueID(s string) func(*ClusterStateRequest) { + return func(r *ClusterStateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.stats.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.stats.go new file mode 100644 index 00000000..6309faae --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.cluster.stats.go @@ -0,0 +1,231 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" + "time" +) + +func newClusterStatsFunc(t Transport) ClusterStats { + return func(o ...func(*ClusterStatsRequest)) (*Response, error) { + var r = ClusterStatsRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// ClusterStats returns high-level overview of cluster statistics. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-stats.html. +type ClusterStats func(o ...func(*ClusterStatsRequest)) (*Response, error) + +// ClusterStatsRequest configures the Cluster Stats API request. +type ClusterStatsRequest struct { + NodeID []string + + FlatSettings *bool + Timeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r ClusterStatsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(len("/nodes/_cluster/stats/nodes/") + len(strings.Join(r.NodeID, ","))) + path.WriteString("/") + path.WriteString("_cluster") + path.WriteString("/") + path.WriteString("stats") + if len(r.NodeID) > 0 { + path.WriteString("/") + path.WriteString("nodes") + path.WriteString("/") + path.WriteString(strings.Join(r.NodeID, ",")) + } + + params = make(map[string]string) + + if r.FlatSettings != nil { + params["flat_settings"] = strconv.FormatBool(*r.FlatSettings) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f ClusterStats) WithContext(v context.Context) func(*ClusterStatsRequest) { + return func(r *ClusterStatsRequest) { + r.ctx = v + } +} + +// WithNodeID - a list of node ids or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes. +func (f ClusterStats) WithNodeID(v ...string) func(*ClusterStatsRequest) { + return func(r *ClusterStatsRequest) { + r.NodeID = v + } +} + +// WithFlatSettings - return settings in flat format (default: false). +func (f ClusterStats) WithFlatSettings(v bool) func(*ClusterStatsRequest) { + return func(r *ClusterStatsRequest) { + r.FlatSettings = &v + } +} + +// WithTimeout - explicit operation timeout. +func (f ClusterStats) WithTimeout(v time.Duration) func(*ClusterStatsRequest) { + return func(r *ClusterStatsRequest) { + r.Timeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f ClusterStats) WithPretty() func(*ClusterStatsRequest) { + return func(r *ClusterStatsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f ClusterStats) WithHuman() func(*ClusterStatsRequest) { + return func(r *ClusterStatsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f ClusterStats) WithErrorTrace() func(*ClusterStatsRequest) { + return func(r *ClusterStatsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f ClusterStats) WithFilterPath(v ...string) func(*ClusterStatsRequest) { + return func(r *ClusterStatsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f ClusterStats) WithHeader(h map[string]string) func(*ClusterStatsRequest) { + return func(r *ClusterStatsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f ClusterStats) WithOpaqueID(s string) func(*ClusterStatsRequest) { + return func(r *ClusterStatsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.count.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.count.go new file mode 100644 index 00000000..6c81fb91 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.count.go @@ -0,0 +1,396 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" +) + +func newCountFunc(t Transport) Count { + return func(o ...func(*CountRequest)) (*Response, error) { + var r = CountRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// Count returns number of documents matching a query. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/search-count.html. +type Count func(o ...func(*CountRequest)) (*Response, error) + +// CountRequest configures the Count API request. +type CountRequest struct { + Index []string + DocumentType []string + + Body io.Reader + + AllowNoIndices *bool + Analyzer string + AnalyzeWildcard *bool + DefaultOperator string + Df string + ExpandWildcards string + IgnoreThrottled *bool + IgnoreUnavailable *bool + Lenient *bool + MinScore *int + Preference string + Query string + Routing []string + TerminateAfter *int + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r CountRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len(strings.Join(r.Index, ",")) + 1 + len(strings.Join(r.DocumentType, ",")) + 1 + len("_count")) + if len(r.Index) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + } + if len(r.DocumentType) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.DocumentType, ",")) + } + path.WriteString("/") + path.WriteString("_count") + + params = make(map[string]string) + + if r.AllowNoIndices != nil { + params["allow_no_indices"] = strconv.FormatBool(*r.AllowNoIndices) + } + + if r.Analyzer != "" { + params["analyzer"] = r.Analyzer + } + + if r.AnalyzeWildcard != nil { + params["analyze_wildcard"] = strconv.FormatBool(*r.AnalyzeWildcard) + } + + if r.DefaultOperator != "" { + params["default_operator"] = r.DefaultOperator + } + + if r.Df != "" { + params["df"] = r.Df + } + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if r.IgnoreThrottled != nil { + params["ignore_throttled"] = strconv.FormatBool(*r.IgnoreThrottled) + } + + if r.IgnoreUnavailable != nil { + params["ignore_unavailable"] = strconv.FormatBool(*r.IgnoreUnavailable) + } + + if r.Lenient != nil { + params["lenient"] = strconv.FormatBool(*r.Lenient) + } + + if r.MinScore != nil { + params["min_score"] = strconv.FormatInt(int64(*r.MinScore), 10) + } + + if r.Preference != "" { + params["preference"] = r.Preference + } + + if r.Query != "" { + params["q"] = r.Query + } + + if len(r.Routing) > 0 { + params["routing"] = strings.Join(r.Routing, ",") + } + + if r.TerminateAfter != nil { + params["terminate_after"] = strconv.FormatInt(int64(*r.TerminateAfter), 10) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f Count) WithContext(v context.Context) func(*CountRequest) { + return func(r *CountRequest) { + r.ctx = v + } +} + +// WithBody - A query to restrict the results specified with the Query DSL (optional). +func (f Count) WithBody(v io.Reader) func(*CountRequest) { + return func(r *CountRequest) { + r.Body = v + } +} + +// WithIndex - a list of indices to restrict the results. +func (f Count) WithIndex(v ...string) func(*CountRequest) { + return func(r *CountRequest) { + r.Index = v + } +} + +// WithDocumentType - a list of types to restrict the results. +func (f Count) WithDocumentType(v ...string) func(*CountRequest) { + return func(r *CountRequest) { + r.DocumentType = v + } +} + +// WithAllowNoIndices - whether to ignore if a wildcard indices expression resolves into no concrete indices. (this includes `_all` string or when no indices have been specified). +func (f Count) WithAllowNoIndices(v bool) func(*CountRequest) { + return func(r *CountRequest) { + r.AllowNoIndices = &v + } +} + +// WithAnalyzer - the analyzer to use for the query string. +func (f Count) WithAnalyzer(v string) func(*CountRequest) { + return func(r *CountRequest) { + r.Analyzer = v + } +} + +// WithAnalyzeWildcard - specify whether wildcard and prefix queries should be analyzed (default: false). +func (f Count) WithAnalyzeWildcard(v bool) func(*CountRequest) { + return func(r *CountRequest) { + r.AnalyzeWildcard = &v + } +} + +// WithDefaultOperator - the default operator for query string query (and or or). +func (f Count) WithDefaultOperator(v string) func(*CountRequest) { + return func(r *CountRequest) { + r.DefaultOperator = v + } +} + +// WithDf - the field to use as default where no field prefix is given in the query string. +func (f Count) WithDf(v string) func(*CountRequest) { + return func(r *CountRequest) { + r.Df = v + } +} + +// WithExpandWildcards - whether to expand wildcard expression to concrete indices that are open, closed or both.. +func (f Count) WithExpandWildcards(v string) func(*CountRequest) { + return func(r *CountRequest) { + r.ExpandWildcards = v + } +} + +// WithIgnoreThrottled - whether specified concrete, expanded or aliased indices should be ignored when throttled. +func (f Count) WithIgnoreThrottled(v bool) func(*CountRequest) { + return func(r *CountRequest) { + r.IgnoreThrottled = &v + } +} + +// WithIgnoreUnavailable - whether specified concrete indices should be ignored when unavailable (missing or closed). +func (f Count) WithIgnoreUnavailable(v bool) func(*CountRequest) { + return func(r *CountRequest) { + r.IgnoreUnavailable = &v + } +} + +// WithLenient - specify whether format-based query failures (such as providing text to a numeric field) should be ignored. +func (f Count) WithLenient(v bool) func(*CountRequest) { + return func(r *CountRequest) { + r.Lenient = &v + } +} + +// WithMinScore - include only documents with a specific `_score` value in the result. +func (f Count) WithMinScore(v int) func(*CountRequest) { + return func(r *CountRequest) { + r.MinScore = &v + } +} + +// WithPreference - specify the node or shard the operation should be performed on (default: random). +func (f Count) WithPreference(v string) func(*CountRequest) { + return func(r *CountRequest) { + r.Preference = v + } +} + +// WithQuery - query in the lucene query string syntax. +func (f Count) WithQuery(v string) func(*CountRequest) { + return func(r *CountRequest) { + r.Query = v + } +} + +// WithRouting - a list of specific routing values. +func (f Count) WithRouting(v ...string) func(*CountRequest) { + return func(r *CountRequest) { + r.Routing = v + } +} + +// WithTerminateAfter - the maximum count for each shard, upon reaching which the query execution will terminate early. +func (f Count) WithTerminateAfter(v int) func(*CountRequest) { + return func(r *CountRequest) { + r.TerminateAfter = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f Count) WithPretty() func(*CountRequest) { + return func(r *CountRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f Count) WithHuman() func(*CountRequest) { + return func(r *CountRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f Count) WithErrorTrace() func(*CountRequest) { + return func(r *CountRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f Count) WithFilterPath(v ...string) func(*CountRequest) { + return func(r *CountRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f Count) WithHeader(h map[string]string) func(*CountRequest) { + return func(r *CountRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f Count) WithOpaqueID(s string) func(*CountRequest) { + return func(r *CountRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.create.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.create.go new file mode 100644 index 00000000..b854241f --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.create.go @@ -0,0 +1,306 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" + "time" +) + +func newCreateFunc(t Transport) Create { + return func(index string, id string, body io.Reader, o ...func(*CreateRequest)) (*Response, error) { + var r = CreateRequest{Index: index, DocumentID: id, Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// Create creates a new document in the index. +// +// Returns a 409 response when a document with a same ID already exists in the index. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-index_.html. +type Create func(index string, id string, body io.Reader, o ...func(*CreateRequest)) (*Response, error) + +// CreateRequest configures the Create API request. +type CreateRequest struct { + Index string + DocumentType string + DocumentID string + + Body io.Reader + + Pipeline string + Refresh string + Routing string + Timeout time.Duration + Version *int + VersionType string + WaitForActiveShards string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r CreateRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + if r.DocumentType == "" { + r.DocumentType = "_doc" + } + + path.Grow(1 + len(r.Index) + 1 + len(r.DocumentType) + 1 + len(r.DocumentID) + 1 + len("_create")) + path.WriteString("/") + path.WriteString(r.Index) + if r.DocumentType != "" { + path.WriteString("/") + path.WriteString(r.DocumentType) + } + path.WriteString("/") + path.WriteString(r.DocumentID) + path.WriteString("/") + path.WriteString("_create") + + params = make(map[string]string) + + if r.Pipeline != "" { + params["pipeline"] = r.Pipeline + } + + if r.Refresh != "" { + params["refresh"] = r.Refresh + } + + if r.Routing != "" { + params["routing"] = r.Routing + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Version != nil { + params["version"] = strconv.FormatInt(int64(*r.Version), 10) + } + + if r.VersionType != "" { + params["version_type"] = r.VersionType + } + + if r.WaitForActiveShards != "" { + params["wait_for_active_shards"] = r.WaitForActiveShards + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f Create) WithContext(v context.Context) func(*CreateRequest) { + return func(r *CreateRequest) { + r.ctx = v + } +} + +// WithDocumentType - the type of the document. +func (f Create) WithDocumentType(v string) func(*CreateRequest) { + return func(r *CreateRequest) { + r.DocumentType = v + } +} + +// WithPipeline - the pipeline ID to preprocess incoming documents with. +func (f Create) WithPipeline(v string) func(*CreateRequest) { + return func(r *CreateRequest) { + r.Pipeline = v + } +} + +// WithRefresh - if `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes.. +func (f Create) WithRefresh(v string) func(*CreateRequest) { + return func(r *CreateRequest) { + r.Refresh = v + } +} + +// WithRouting - specific routing value. +func (f Create) WithRouting(v string) func(*CreateRequest) { + return func(r *CreateRequest) { + r.Routing = v + } +} + +// WithTimeout - explicit operation timeout. +func (f Create) WithTimeout(v time.Duration) func(*CreateRequest) { + return func(r *CreateRequest) { + r.Timeout = v + } +} + +// WithVersion - explicit version number for concurrency control. +func (f Create) WithVersion(v int) func(*CreateRequest) { + return func(r *CreateRequest) { + r.Version = &v + } +} + +// WithVersionType - specific version type. +func (f Create) WithVersionType(v string) func(*CreateRequest) { + return func(r *CreateRequest) { + r.VersionType = v + } +} + +// WithWaitForActiveShards - sets the number of shard copies that must be active before proceeding with the index operation. defaults to 1, meaning the primary shard only. set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1). +func (f Create) WithWaitForActiveShards(v string) func(*CreateRequest) { + return func(r *CreateRequest) { + r.WaitForActiveShards = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f Create) WithPretty() func(*CreateRequest) { + return func(r *CreateRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f Create) WithHuman() func(*CreateRequest) { + return func(r *CreateRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f Create) WithErrorTrace() func(*CreateRequest) { + return func(r *CreateRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f Create) WithFilterPath(v ...string) func(*CreateRequest) { + return func(r *CreateRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f Create) WithHeader(h map[string]string) func(*CreateRequest) { + return func(r *CreateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f Create) WithOpaqueID(s string) func(*CreateRequest) { + return func(r *CreateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.dangling_indices.delete_dangling_index.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.dangling_indices.delete_dangling_index.go new file mode 100644 index 00000000..7e124ce0 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.dangling_indices.delete_dangling_index.go @@ -0,0 +1,230 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" + "time" +) + +func newDanglingIndicesDeleteDanglingIndexFunc(t Transport) DanglingIndicesDeleteDanglingIndex { + return func(index_uuid string, o ...func(*DanglingIndicesDeleteDanglingIndexRequest)) (*Response, error) { + var r = DanglingIndicesDeleteDanglingIndexRequest{IndexUUID: index_uuid} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// DanglingIndicesDeleteDanglingIndex deletes the specified dangling index +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-gateway-dangling-indices.html. +type DanglingIndicesDeleteDanglingIndex func(index_uuid string, o ...func(*DanglingIndicesDeleteDanglingIndexRequest)) (*Response, error) + +// DanglingIndicesDeleteDanglingIndexRequest configures the Dangling Indices Delete Dangling Index API request. +type DanglingIndicesDeleteDanglingIndexRequest struct { + IndexUUID string + + AcceptDataLoss *bool + MasterTimeout time.Duration + Timeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r DanglingIndicesDeleteDanglingIndexRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + path.Grow(1 + len("_dangling") + 1 + len(r.IndexUUID)) + path.WriteString("/") + path.WriteString("_dangling") + path.WriteString("/") + path.WriteString(r.IndexUUID) + + params = make(map[string]string) + + if r.AcceptDataLoss != nil { + params["accept_data_loss"] = strconv.FormatBool(*r.AcceptDataLoss) + } + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f DanglingIndicesDeleteDanglingIndex) WithContext(v context.Context) func(*DanglingIndicesDeleteDanglingIndexRequest) { + return func(r *DanglingIndicesDeleteDanglingIndexRequest) { + r.ctx = v + } +} + +// WithAcceptDataLoss - must be set to true in order to delete the dangling index. +func (f DanglingIndicesDeleteDanglingIndex) WithAcceptDataLoss(v bool) func(*DanglingIndicesDeleteDanglingIndexRequest) { + return func(r *DanglingIndicesDeleteDanglingIndexRequest) { + r.AcceptDataLoss = &v + } +} + +// WithMasterTimeout - specify timeout for connection to master. +func (f DanglingIndicesDeleteDanglingIndex) WithMasterTimeout(v time.Duration) func(*DanglingIndicesDeleteDanglingIndexRequest) { + return func(r *DanglingIndicesDeleteDanglingIndexRequest) { + r.MasterTimeout = v + } +} + +// WithTimeout - explicit operation timeout. +func (f DanglingIndicesDeleteDanglingIndex) WithTimeout(v time.Duration) func(*DanglingIndicesDeleteDanglingIndexRequest) { + return func(r *DanglingIndicesDeleteDanglingIndexRequest) { + r.Timeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f DanglingIndicesDeleteDanglingIndex) WithPretty() func(*DanglingIndicesDeleteDanglingIndexRequest) { + return func(r *DanglingIndicesDeleteDanglingIndexRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f DanglingIndicesDeleteDanglingIndex) WithHuman() func(*DanglingIndicesDeleteDanglingIndexRequest) { + return func(r *DanglingIndicesDeleteDanglingIndexRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f DanglingIndicesDeleteDanglingIndex) WithErrorTrace() func(*DanglingIndicesDeleteDanglingIndexRequest) { + return func(r *DanglingIndicesDeleteDanglingIndexRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f DanglingIndicesDeleteDanglingIndex) WithFilterPath(v ...string) func(*DanglingIndicesDeleteDanglingIndexRequest) { + return func(r *DanglingIndicesDeleteDanglingIndexRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f DanglingIndicesDeleteDanglingIndex) WithHeader(h map[string]string) func(*DanglingIndicesDeleteDanglingIndexRequest) { + return func(r *DanglingIndicesDeleteDanglingIndexRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f DanglingIndicesDeleteDanglingIndex) WithOpaqueID(s string) func(*DanglingIndicesDeleteDanglingIndexRequest) { + return func(r *DanglingIndicesDeleteDanglingIndexRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.dangling_indices.import_dangling_index.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.dangling_indices.import_dangling_index.go new file mode 100644 index 00000000..eafb30cc --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.dangling_indices.import_dangling_index.go @@ -0,0 +1,230 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" + "time" +) + +func newDanglingIndicesImportDanglingIndexFunc(t Transport) DanglingIndicesImportDanglingIndex { + return func(index_uuid string, o ...func(*DanglingIndicesImportDanglingIndexRequest)) (*Response, error) { + var r = DanglingIndicesImportDanglingIndexRequest{IndexUUID: index_uuid} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// DanglingIndicesImportDanglingIndex imports the specified dangling index +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-gateway-dangling-indices.html. +type DanglingIndicesImportDanglingIndex func(index_uuid string, o ...func(*DanglingIndicesImportDanglingIndexRequest)) (*Response, error) + +// DanglingIndicesImportDanglingIndexRequest configures the Dangling Indices Import Dangling Index API request. +type DanglingIndicesImportDanglingIndexRequest struct { + IndexUUID string + + AcceptDataLoss *bool + MasterTimeout time.Duration + Timeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r DanglingIndicesImportDanglingIndexRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_dangling") + 1 + len(r.IndexUUID)) + path.WriteString("/") + path.WriteString("_dangling") + path.WriteString("/") + path.WriteString(r.IndexUUID) + + params = make(map[string]string) + + if r.AcceptDataLoss != nil { + params["accept_data_loss"] = strconv.FormatBool(*r.AcceptDataLoss) + } + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f DanglingIndicesImportDanglingIndex) WithContext(v context.Context) func(*DanglingIndicesImportDanglingIndexRequest) { + return func(r *DanglingIndicesImportDanglingIndexRequest) { + r.ctx = v + } +} + +// WithAcceptDataLoss - must be set to true in order to import the dangling index. +func (f DanglingIndicesImportDanglingIndex) WithAcceptDataLoss(v bool) func(*DanglingIndicesImportDanglingIndexRequest) { + return func(r *DanglingIndicesImportDanglingIndexRequest) { + r.AcceptDataLoss = &v + } +} + +// WithMasterTimeout - specify timeout for connection to master. +func (f DanglingIndicesImportDanglingIndex) WithMasterTimeout(v time.Duration) func(*DanglingIndicesImportDanglingIndexRequest) { + return func(r *DanglingIndicesImportDanglingIndexRequest) { + r.MasterTimeout = v + } +} + +// WithTimeout - explicit operation timeout. +func (f DanglingIndicesImportDanglingIndex) WithTimeout(v time.Duration) func(*DanglingIndicesImportDanglingIndexRequest) { + return func(r *DanglingIndicesImportDanglingIndexRequest) { + r.Timeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f DanglingIndicesImportDanglingIndex) WithPretty() func(*DanglingIndicesImportDanglingIndexRequest) { + return func(r *DanglingIndicesImportDanglingIndexRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f DanglingIndicesImportDanglingIndex) WithHuman() func(*DanglingIndicesImportDanglingIndexRequest) { + return func(r *DanglingIndicesImportDanglingIndexRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f DanglingIndicesImportDanglingIndex) WithErrorTrace() func(*DanglingIndicesImportDanglingIndexRequest) { + return func(r *DanglingIndicesImportDanglingIndexRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f DanglingIndicesImportDanglingIndex) WithFilterPath(v ...string) func(*DanglingIndicesImportDanglingIndexRequest) { + return func(r *DanglingIndicesImportDanglingIndexRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f DanglingIndicesImportDanglingIndex) WithHeader(h map[string]string) func(*DanglingIndicesImportDanglingIndexRequest) { + return func(r *DanglingIndicesImportDanglingIndexRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f DanglingIndicesImportDanglingIndex) WithOpaqueID(s string) func(*DanglingIndicesImportDanglingIndexRequest) { + return func(r *DanglingIndicesImportDanglingIndexRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.dangling_indices.list_dangling_indices.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.dangling_indices.list_dangling_indices.go new file mode 100644 index 00000000..a7b80972 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.dangling_indices.list_dangling_indices.go @@ -0,0 +1,186 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newDanglingIndicesListDanglingIndicesFunc(t Transport) DanglingIndicesListDanglingIndices { + return func(o ...func(*DanglingIndicesListDanglingIndicesRequest)) (*Response, error) { + var r = DanglingIndicesListDanglingIndicesRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// DanglingIndicesListDanglingIndices returns all dangling indices. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-gateway-dangling-indices.html. +type DanglingIndicesListDanglingIndices func(o ...func(*DanglingIndicesListDanglingIndicesRequest)) (*Response, error) + +// DanglingIndicesListDanglingIndicesRequest configures the Dangling Indices List Dangling Indices API request. +type DanglingIndicesListDanglingIndicesRequest struct { + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r DanglingIndicesListDanglingIndicesRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(len("/_dangling")) + path.WriteString("/_dangling") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f DanglingIndicesListDanglingIndices) WithContext(v context.Context) func(*DanglingIndicesListDanglingIndicesRequest) { + return func(r *DanglingIndicesListDanglingIndicesRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f DanglingIndicesListDanglingIndices) WithPretty() func(*DanglingIndicesListDanglingIndicesRequest) { + return func(r *DanglingIndicesListDanglingIndicesRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f DanglingIndicesListDanglingIndices) WithHuman() func(*DanglingIndicesListDanglingIndicesRequest) { + return func(r *DanglingIndicesListDanglingIndicesRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f DanglingIndicesListDanglingIndices) WithErrorTrace() func(*DanglingIndicesListDanglingIndicesRequest) { + return func(r *DanglingIndicesListDanglingIndicesRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f DanglingIndicesListDanglingIndices) WithFilterPath(v ...string) func(*DanglingIndicesListDanglingIndicesRequest) { + return func(r *DanglingIndicesListDanglingIndicesRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f DanglingIndicesListDanglingIndices) WithHeader(h map[string]string) func(*DanglingIndicesListDanglingIndicesRequest) { + return func(r *DanglingIndicesListDanglingIndicesRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f DanglingIndicesListDanglingIndices) WithOpaqueID(s string) func(*DanglingIndicesListDanglingIndicesRequest) { + return func(r *DanglingIndicesListDanglingIndicesRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.delete.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.delete.go new file mode 100644 index 00000000..349ba7a1 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.delete.go @@ -0,0 +1,307 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" + "time" +) + +func newDeleteFunc(t Transport) Delete { + return func(index string, id string, o ...func(*DeleteRequest)) (*Response, error) { + var r = DeleteRequest{Index: index, DocumentID: id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// Delete removes a document from the index. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-delete.html. +type Delete func(index string, id string, o ...func(*DeleteRequest)) (*Response, error) + +// DeleteRequest configures the Delete API request. +type DeleteRequest struct { + Index string + DocumentType string + DocumentID string + + IfPrimaryTerm *int + IfSeqNo *int + Refresh string + Routing string + Timeout time.Duration + Version *int + VersionType string + WaitForActiveShards string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r DeleteRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + if r.DocumentType == "" { + r.DocumentType = "_doc" + } + + path.Grow(1 + len(r.Index) + 1 + len(r.DocumentType) + 1 + len(r.DocumentID)) + path.WriteString("/") + path.WriteString(r.Index) + if r.DocumentType != "" { + path.WriteString("/") + path.WriteString(r.DocumentType) + } + path.WriteString("/") + path.WriteString(r.DocumentID) + + params = make(map[string]string) + + if r.IfPrimaryTerm != nil { + params["if_primary_term"] = strconv.FormatInt(int64(*r.IfPrimaryTerm), 10) + } + + if r.IfSeqNo != nil { + params["if_seq_no"] = strconv.FormatInt(int64(*r.IfSeqNo), 10) + } + + if r.Refresh != "" { + params["refresh"] = r.Refresh + } + + if r.Routing != "" { + params["routing"] = r.Routing + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Version != nil { + params["version"] = strconv.FormatInt(int64(*r.Version), 10) + } + + if r.VersionType != "" { + params["version_type"] = r.VersionType + } + + if r.WaitForActiveShards != "" { + params["wait_for_active_shards"] = r.WaitForActiveShards + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f Delete) WithContext(v context.Context) func(*DeleteRequest) { + return func(r *DeleteRequest) { + r.ctx = v + } +} + +// WithDocumentType - the type of the document. +func (f Delete) WithDocumentType(v string) func(*DeleteRequest) { + return func(r *DeleteRequest) { + r.DocumentType = v + } +} + +// WithIfPrimaryTerm - only perform the delete operation if the last operation that has changed the document has the specified primary term. +func (f Delete) WithIfPrimaryTerm(v int) func(*DeleteRequest) { + return func(r *DeleteRequest) { + r.IfPrimaryTerm = &v + } +} + +// WithIfSeqNo - only perform the delete operation if the last operation that has changed the document has the specified sequence number. +func (f Delete) WithIfSeqNo(v int) func(*DeleteRequest) { + return func(r *DeleteRequest) { + r.IfSeqNo = &v + } +} + +// WithRefresh - if `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes.. +func (f Delete) WithRefresh(v string) func(*DeleteRequest) { + return func(r *DeleteRequest) { + r.Refresh = v + } +} + +// WithRouting - specific routing value. +func (f Delete) WithRouting(v string) func(*DeleteRequest) { + return func(r *DeleteRequest) { + r.Routing = v + } +} + +// WithTimeout - explicit operation timeout. +func (f Delete) WithTimeout(v time.Duration) func(*DeleteRequest) { + return func(r *DeleteRequest) { + r.Timeout = v + } +} + +// WithVersion - explicit version number for concurrency control. +func (f Delete) WithVersion(v int) func(*DeleteRequest) { + return func(r *DeleteRequest) { + r.Version = &v + } +} + +// WithVersionType - specific version type. +func (f Delete) WithVersionType(v string) func(*DeleteRequest) { + return func(r *DeleteRequest) { + r.VersionType = v + } +} + +// WithWaitForActiveShards - sets the number of shard copies that must be active before proceeding with the delete operation. defaults to 1, meaning the primary shard only. set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1). +func (f Delete) WithWaitForActiveShards(v string) func(*DeleteRequest) { + return func(r *DeleteRequest) { + r.WaitForActiveShards = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f Delete) WithPretty() func(*DeleteRequest) { + return func(r *DeleteRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f Delete) WithHuman() func(*DeleteRequest) { + return func(r *DeleteRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f Delete) WithErrorTrace() func(*DeleteRequest) { + return func(r *DeleteRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f Delete) WithFilterPath(v ...string) func(*DeleteRequest) { + return func(r *DeleteRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f Delete) WithHeader(h map[string]string) func(*DeleteRequest) { + return func(r *DeleteRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f Delete) WithOpaqueID(s string) func(*DeleteRequest) { + return func(r *DeleteRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.delete_by_query.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.delete_by_query.go new file mode 100644 index 00000000..f21ec784 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.delete_by_query.go @@ -0,0 +1,579 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "errors" + "fmt" + "io" + "net/http" + "strconv" + "strings" + "time" +) + +func newDeleteByQueryFunc(t Transport) DeleteByQuery { + return func(index []string, body io.Reader, o ...func(*DeleteByQueryRequest)) (*Response, error) { + var r = DeleteByQueryRequest{Index: index, Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// DeleteByQuery deletes documents matching the provided query. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-delete-by-query.html. +type DeleteByQuery func(index []string, body io.Reader, o ...func(*DeleteByQueryRequest)) (*Response, error) + +// DeleteByQueryRequest configures the Delete By Query API request. +type DeleteByQueryRequest struct { + Index []string + DocumentType []string + + Body io.Reader + + AllowNoIndices *bool + Analyzer string + AnalyzeWildcard *bool + Conflicts string + DefaultOperator string + Df string + ExpandWildcards string + From *int + IgnoreUnavailable *bool + Lenient *bool + MaxDocs *int + Preference string + Query string + Refresh *bool + RequestCache *bool + RequestsPerSecond *int + Routing []string + Scroll time.Duration + ScrollSize *int + SearchTimeout time.Duration + SearchType string + Size *int + Slices interface{} + Sort []string + Stats []string + TerminateAfter *int + Timeout time.Duration + Version *bool + WaitForActiveShards string + WaitForCompletion *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r DeleteByQueryRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + if len(r.Index) == 0 { + return nil, errors.New("index is required and cannot be nil or empty") + } + + path.Grow(1 + len(strings.Join(r.Index, ",")) + 1 + len(strings.Join(r.DocumentType, ",")) + 1 + len("_delete_by_query")) + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + if len(r.DocumentType) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.DocumentType, ",")) + } + path.WriteString("/") + path.WriteString("_delete_by_query") + + params = make(map[string]string) + + if r.AllowNoIndices != nil { + params["allow_no_indices"] = strconv.FormatBool(*r.AllowNoIndices) + } + + if r.Analyzer != "" { + params["analyzer"] = r.Analyzer + } + + if r.AnalyzeWildcard != nil { + params["analyze_wildcard"] = strconv.FormatBool(*r.AnalyzeWildcard) + } + + if r.Conflicts != "" { + params["conflicts"] = r.Conflicts + } + + if r.DefaultOperator != "" { + params["default_operator"] = r.DefaultOperator + } + + if r.Df != "" { + params["df"] = r.Df + } + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if r.From != nil { + params["from"] = strconv.FormatInt(int64(*r.From), 10) + } + + if r.IgnoreUnavailable != nil { + params["ignore_unavailable"] = strconv.FormatBool(*r.IgnoreUnavailable) + } + + if r.Lenient != nil { + params["lenient"] = strconv.FormatBool(*r.Lenient) + } + + if r.MaxDocs != nil { + params["max_docs"] = strconv.FormatInt(int64(*r.MaxDocs), 10) + } + + if r.Preference != "" { + params["preference"] = r.Preference + } + + if r.Query != "" { + params["q"] = r.Query + } + + if r.Refresh != nil { + params["refresh"] = strconv.FormatBool(*r.Refresh) + } + + if r.RequestCache != nil { + params["request_cache"] = strconv.FormatBool(*r.RequestCache) + } + + if r.RequestsPerSecond != nil { + params["requests_per_second"] = strconv.FormatInt(int64(*r.RequestsPerSecond), 10) + } + + if len(r.Routing) > 0 { + params["routing"] = strings.Join(r.Routing, ",") + } + + if r.Scroll != 0 { + params["scroll"] = formatDuration(r.Scroll) + } + + if r.ScrollSize != nil { + params["scroll_size"] = strconv.FormatInt(int64(*r.ScrollSize), 10) + } + + if r.SearchTimeout != 0 { + params["search_timeout"] = formatDuration(r.SearchTimeout) + } + + if r.SearchType != "" { + params["search_type"] = r.SearchType + } + + if r.Size != nil { + params["size"] = strconv.FormatInt(int64(*r.Size), 10) + } + + if r.Slices != nil { + params["slices"] = fmt.Sprintf("%v", r.Slices) + } + + if len(r.Sort) > 0 { + params["sort"] = strings.Join(r.Sort, ",") + } + + if len(r.Stats) > 0 { + params["stats"] = strings.Join(r.Stats, ",") + } + + if r.TerminateAfter != nil { + params["terminate_after"] = strconv.FormatInt(int64(*r.TerminateAfter), 10) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Version != nil { + params["version"] = strconv.FormatBool(*r.Version) + } + + if r.WaitForActiveShards != "" { + params["wait_for_active_shards"] = r.WaitForActiveShards + } + + if r.WaitForCompletion != nil { + params["wait_for_completion"] = strconv.FormatBool(*r.WaitForCompletion) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f DeleteByQuery) WithContext(v context.Context) func(*DeleteByQueryRequest) { + return func(r *DeleteByQueryRequest) { + r.ctx = v + } +} + +// WithDocumentType - a list of document types to search; leave empty to perform the operation on all types. +func (f DeleteByQuery) WithDocumentType(v ...string) func(*DeleteByQueryRequest) { + return func(r *DeleteByQueryRequest) { + r.DocumentType = v + } +} + +// WithAllowNoIndices - whether to ignore if a wildcard indices expression resolves into no concrete indices. (this includes `_all` string or when no indices have been specified). +func (f DeleteByQuery) WithAllowNoIndices(v bool) func(*DeleteByQueryRequest) { + return func(r *DeleteByQueryRequest) { + r.AllowNoIndices = &v + } +} + +// WithAnalyzer - the analyzer to use for the query string. +func (f DeleteByQuery) WithAnalyzer(v string) func(*DeleteByQueryRequest) { + return func(r *DeleteByQueryRequest) { + r.Analyzer = v + } +} + +// WithAnalyzeWildcard - specify whether wildcard and prefix queries should be analyzed (default: false). +func (f DeleteByQuery) WithAnalyzeWildcard(v bool) func(*DeleteByQueryRequest) { + return func(r *DeleteByQueryRequest) { + r.AnalyzeWildcard = &v + } +} + +// WithConflicts - what to do when the delete by query hits version conflicts?. +func (f DeleteByQuery) WithConflicts(v string) func(*DeleteByQueryRequest) { + return func(r *DeleteByQueryRequest) { + r.Conflicts = v + } +} + +// WithDefaultOperator - the default operator for query string query (and or or). +func (f DeleteByQuery) WithDefaultOperator(v string) func(*DeleteByQueryRequest) { + return func(r *DeleteByQueryRequest) { + r.DefaultOperator = v + } +} + +// WithDf - the field to use as default where no field prefix is given in the query string. +func (f DeleteByQuery) WithDf(v string) func(*DeleteByQueryRequest) { + return func(r *DeleteByQueryRequest) { + r.Df = v + } +} + +// WithExpandWildcards - whether to expand wildcard expression to concrete indices that are open, closed or both.. +func (f DeleteByQuery) WithExpandWildcards(v string) func(*DeleteByQueryRequest) { + return func(r *DeleteByQueryRequest) { + r.ExpandWildcards = v + } +} + +// WithFrom - starting offset (default: 0). +func (f DeleteByQuery) WithFrom(v int) func(*DeleteByQueryRequest) { + return func(r *DeleteByQueryRequest) { + r.From = &v + } +} + +// WithIgnoreUnavailable - whether specified concrete indices should be ignored when unavailable (missing or closed). +func (f DeleteByQuery) WithIgnoreUnavailable(v bool) func(*DeleteByQueryRequest) { + return func(r *DeleteByQueryRequest) { + r.IgnoreUnavailable = &v + } +} + +// WithLenient - specify whether format-based query failures (such as providing text to a numeric field) should be ignored. +func (f DeleteByQuery) WithLenient(v bool) func(*DeleteByQueryRequest) { + return func(r *DeleteByQueryRequest) { + r.Lenient = &v + } +} + +// WithMaxDocs - maximum number of documents to process (default: all documents). +func (f DeleteByQuery) WithMaxDocs(v int) func(*DeleteByQueryRequest) { + return func(r *DeleteByQueryRequest) { + r.MaxDocs = &v + } +} + +// WithPreference - specify the node or shard the operation should be performed on (default: random). +func (f DeleteByQuery) WithPreference(v string) func(*DeleteByQueryRequest) { + return func(r *DeleteByQueryRequest) { + r.Preference = v + } +} + +// WithQuery - query in the lucene query string syntax. +func (f DeleteByQuery) WithQuery(v string) func(*DeleteByQueryRequest) { + return func(r *DeleteByQueryRequest) { + r.Query = v + } +} + +// WithRefresh - should the effected indexes be refreshed?. +func (f DeleteByQuery) WithRefresh(v bool) func(*DeleteByQueryRequest) { + return func(r *DeleteByQueryRequest) { + r.Refresh = &v + } +} + +// WithRequestCache - specify if request cache should be used for this request or not, defaults to index level setting. +func (f DeleteByQuery) WithRequestCache(v bool) func(*DeleteByQueryRequest) { + return func(r *DeleteByQueryRequest) { + r.RequestCache = &v + } +} + +// WithRequestsPerSecond - the throttle for this request in sub-requests per second. -1 means no throttle.. +func (f DeleteByQuery) WithRequestsPerSecond(v int) func(*DeleteByQueryRequest) { + return func(r *DeleteByQueryRequest) { + r.RequestsPerSecond = &v + } +} + +// WithRouting - a list of specific routing values. +func (f DeleteByQuery) WithRouting(v ...string) func(*DeleteByQueryRequest) { + return func(r *DeleteByQueryRequest) { + r.Routing = v + } +} + +// WithScroll - specify how long a consistent view of the index should be maintained for scrolled search. +func (f DeleteByQuery) WithScroll(v time.Duration) func(*DeleteByQueryRequest) { + return func(r *DeleteByQueryRequest) { + r.Scroll = v + } +} + +// WithScrollSize - size on the scroll request powering the delete by query. +func (f DeleteByQuery) WithScrollSize(v int) func(*DeleteByQueryRequest) { + return func(r *DeleteByQueryRequest) { + r.ScrollSize = &v + } +} + +// WithSearchTimeout - explicit timeout for each search request. defaults to no timeout.. +func (f DeleteByQuery) WithSearchTimeout(v time.Duration) func(*DeleteByQueryRequest) { + return func(r *DeleteByQueryRequest) { + r.SearchTimeout = v + } +} + +// WithSearchType - search operation type. +func (f DeleteByQuery) WithSearchType(v string) func(*DeleteByQueryRequest) { + return func(r *DeleteByQueryRequest) { + r.SearchType = v + } +} + +// WithSize - deprecated, please use `max_docs` instead. +func (f DeleteByQuery) WithSize(v int) func(*DeleteByQueryRequest) { + return func(r *DeleteByQueryRequest) { + r.Size = &v + } +} + +// WithSlices - the number of slices this task should be divided into. defaults to 1, meaning the task isn't sliced into subtasks. can be set to `auto`.. +func (f DeleteByQuery) WithSlices(v interface{}) func(*DeleteByQueryRequest) { + return func(r *DeleteByQueryRequest) { + r.Slices = v + } +} + +// WithSort - a list of : pairs. +func (f DeleteByQuery) WithSort(v ...string) func(*DeleteByQueryRequest) { + return func(r *DeleteByQueryRequest) { + r.Sort = v + } +} + +// WithStats - specific 'tag' of the request for logging and statistical purposes. +func (f DeleteByQuery) WithStats(v ...string) func(*DeleteByQueryRequest) { + return func(r *DeleteByQueryRequest) { + r.Stats = v + } +} + +// WithTerminateAfter - the maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.. +func (f DeleteByQuery) WithTerminateAfter(v int) func(*DeleteByQueryRequest) { + return func(r *DeleteByQueryRequest) { + r.TerminateAfter = &v + } +} + +// WithTimeout - time each individual bulk request should wait for shards that are unavailable.. +func (f DeleteByQuery) WithTimeout(v time.Duration) func(*DeleteByQueryRequest) { + return func(r *DeleteByQueryRequest) { + r.Timeout = v + } +} + +// WithVersion - specify whether to return document version as part of a hit. +func (f DeleteByQuery) WithVersion(v bool) func(*DeleteByQueryRequest) { + return func(r *DeleteByQueryRequest) { + r.Version = &v + } +} + +// WithWaitForActiveShards - sets the number of shard copies that must be active before proceeding with the delete by query operation. defaults to 1, meaning the primary shard only. set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1). +func (f DeleteByQuery) WithWaitForActiveShards(v string) func(*DeleteByQueryRequest) { + return func(r *DeleteByQueryRequest) { + r.WaitForActiveShards = v + } +} + +// WithWaitForCompletion - should the request should block until the delete by query is complete.. +func (f DeleteByQuery) WithWaitForCompletion(v bool) func(*DeleteByQueryRequest) { + return func(r *DeleteByQueryRequest) { + r.WaitForCompletion = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f DeleteByQuery) WithPretty() func(*DeleteByQueryRequest) { + return func(r *DeleteByQueryRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f DeleteByQuery) WithHuman() func(*DeleteByQueryRequest) { + return func(r *DeleteByQueryRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f DeleteByQuery) WithErrorTrace() func(*DeleteByQueryRequest) { + return func(r *DeleteByQueryRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f DeleteByQuery) WithFilterPath(v ...string) func(*DeleteByQueryRequest) { + return func(r *DeleteByQueryRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f DeleteByQuery) WithHeader(h map[string]string) func(*DeleteByQueryRequest) { + return func(r *DeleteByQueryRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f DeleteByQuery) WithOpaqueID(s string) func(*DeleteByQueryRequest) { + return func(r *DeleteByQueryRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.delete_by_query_rethrottle.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.delete_by_query_rethrottle.go new file mode 100644 index 00000000..82c2edad --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.delete_by_query_rethrottle.go @@ -0,0 +1,207 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newDeleteByQueryRethrottleFunc(t Transport) DeleteByQueryRethrottle { + return func(task_id string, requests_per_second *int, o ...func(*DeleteByQueryRethrottleRequest)) (*Response, error) { + var r = DeleteByQueryRethrottleRequest{TaskID: task_id, RequestsPerSecond: requests_per_second} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// DeleteByQueryRethrottle changes the number of requests per second for a particular Delete By Query operation. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html. +type DeleteByQueryRethrottle func(task_id string, requests_per_second *int, o ...func(*DeleteByQueryRethrottleRequest)) (*Response, error) + +// DeleteByQueryRethrottleRequest configures the Delete By Query Rethrottle API request. +type DeleteByQueryRethrottleRequest struct { + TaskID string + + RequestsPerSecond *int + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r DeleteByQueryRethrottleRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_delete_by_query") + 1 + len(r.TaskID) + 1 + len("_rethrottle")) + path.WriteString("/") + path.WriteString("_delete_by_query") + path.WriteString("/") + path.WriteString(r.TaskID) + path.WriteString("/") + path.WriteString("_rethrottle") + + params = make(map[string]string) + + if r.RequestsPerSecond != nil { + params["requests_per_second"] = strconv.FormatInt(int64(*r.RequestsPerSecond), 10) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f DeleteByQueryRethrottle) WithContext(v context.Context) func(*DeleteByQueryRethrottleRequest) { + return func(r *DeleteByQueryRethrottleRequest) { + r.ctx = v + } +} + +// WithRequestsPerSecond - the throttle to set on this request in floating sub-requests per second. -1 means set no throttle.. +func (f DeleteByQueryRethrottle) WithRequestsPerSecond(v int) func(*DeleteByQueryRethrottleRequest) { + return func(r *DeleteByQueryRethrottleRequest) { + r.RequestsPerSecond = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f DeleteByQueryRethrottle) WithPretty() func(*DeleteByQueryRethrottleRequest) { + return func(r *DeleteByQueryRethrottleRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f DeleteByQueryRethrottle) WithHuman() func(*DeleteByQueryRethrottleRequest) { + return func(r *DeleteByQueryRethrottleRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f DeleteByQueryRethrottle) WithErrorTrace() func(*DeleteByQueryRethrottleRequest) { + return func(r *DeleteByQueryRethrottleRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f DeleteByQueryRethrottle) WithFilterPath(v ...string) func(*DeleteByQueryRethrottleRequest) { + return func(r *DeleteByQueryRethrottleRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f DeleteByQueryRethrottle) WithHeader(h map[string]string) func(*DeleteByQueryRethrottleRequest) { + return func(r *DeleteByQueryRethrottleRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f DeleteByQueryRethrottle) WithOpaqueID(s string) func(*DeleteByQueryRethrottleRequest) { + return func(r *DeleteByQueryRethrottleRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.delete_script.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.delete_script.go new file mode 100644 index 00000000..0155ca6e --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.delete_script.go @@ -0,0 +1,217 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" + "time" +) + +func newDeleteScriptFunc(t Transport) DeleteScript { + return func(id string, o ...func(*DeleteScriptRequest)) (*Response, error) { + var r = DeleteScriptRequest{ScriptID: id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// DeleteScript deletes a script. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html. +type DeleteScript func(id string, o ...func(*DeleteScriptRequest)) (*Response, error) + +// DeleteScriptRequest configures the Delete Script API request. +type DeleteScriptRequest struct { + ScriptID string + + MasterTimeout time.Duration + Timeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r DeleteScriptRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + path.Grow(1 + len("_scripts") + 1 + len(r.ScriptID)) + path.WriteString("/") + path.WriteString("_scripts") + path.WriteString("/") + path.WriteString(r.ScriptID) + + params = make(map[string]string) + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f DeleteScript) WithContext(v context.Context) func(*DeleteScriptRequest) { + return func(r *DeleteScriptRequest) { + r.ctx = v + } +} + +// WithMasterTimeout - specify timeout for connection to master. +func (f DeleteScript) WithMasterTimeout(v time.Duration) func(*DeleteScriptRequest) { + return func(r *DeleteScriptRequest) { + r.MasterTimeout = v + } +} + +// WithTimeout - explicit operation timeout. +func (f DeleteScript) WithTimeout(v time.Duration) func(*DeleteScriptRequest) { + return func(r *DeleteScriptRequest) { + r.Timeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f DeleteScript) WithPretty() func(*DeleteScriptRequest) { + return func(r *DeleteScriptRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f DeleteScript) WithHuman() func(*DeleteScriptRequest) { + return func(r *DeleteScriptRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f DeleteScript) WithErrorTrace() func(*DeleteScriptRequest) { + return func(r *DeleteScriptRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f DeleteScript) WithFilterPath(v ...string) func(*DeleteScriptRequest) { + return func(r *DeleteScriptRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f DeleteScript) WithHeader(h map[string]string) func(*DeleteScriptRequest) { + return func(r *DeleteScriptRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f DeleteScript) WithOpaqueID(s string) func(*DeleteScriptRequest) { + return func(r *DeleteScriptRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.exists.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.exists.go new file mode 100644 index 00000000..688b45a4 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.exists.go @@ -0,0 +1,330 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newExistsFunc(t Transport) Exists { + return func(index string, id string, o ...func(*ExistsRequest)) (*Response, error) { + var r = ExistsRequest{Index: index, DocumentID: id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// Exists returns information about whether a document exists in an index. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html. +type Exists func(index string, id string, o ...func(*ExistsRequest)) (*Response, error) + +// ExistsRequest configures the Exists API request. +type ExistsRequest struct { + Index string + DocumentType string + DocumentID string + + Preference string + Realtime *bool + Refresh *bool + Routing string + Source []string + SourceExcludes []string + SourceIncludes []string + StoredFields []string + Version *int + VersionType string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r ExistsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "HEAD" + + if r.DocumentType == "" { + r.DocumentType = "_doc" + } + + path.Grow(1 + len(r.Index) + 1 + len(r.DocumentType) + 1 + len(r.DocumentID)) + path.WriteString("/") + path.WriteString(r.Index) + if r.DocumentType != "" { + path.WriteString("/") + path.WriteString(r.DocumentType) + } + path.WriteString("/") + path.WriteString(r.DocumentID) + + params = make(map[string]string) + + if r.Preference != "" { + params["preference"] = r.Preference + } + + if r.Realtime != nil { + params["realtime"] = strconv.FormatBool(*r.Realtime) + } + + if r.Refresh != nil { + params["refresh"] = strconv.FormatBool(*r.Refresh) + } + + if r.Routing != "" { + params["routing"] = r.Routing + } + + if len(r.Source) > 0 { + params["_source"] = strings.Join(r.Source, ",") + } + + if len(r.SourceExcludes) > 0 { + params["_source_excludes"] = strings.Join(r.SourceExcludes, ",") + } + + if len(r.SourceIncludes) > 0 { + params["_source_includes"] = strings.Join(r.SourceIncludes, ",") + } + + if len(r.StoredFields) > 0 { + params["stored_fields"] = strings.Join(r.StoredFields, ",") + } + + if r.Version != nil { + params["version"] = strconv.FormatInt(int64(*r.Version), 10) + } + + if r.VersionType != "" { + params["version_type"] = r.VersionType + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f Exists) WithContext(v context.Context) func(*ExistsRequest) { + return func(r *ExistsRequest) { + r.ctx = v + } +} + +// WithDocumentType - the type of the document (use `_all` to fetch the first document matching the ID across all types). +func (f Exists) WithDocumentType(v string) func(*ExistsRequest) { + return func(r *ExistsRequest) { + r.DocumentType = v + } +} + +// WithPreference - specify the node or shard the operation should be performed on (default: random). +func (f Exists) WithPreference(v string) func(*ExistsRequest) { + return func(r *ExistsRequest) { + r.Preference = v + } +} + +// WithRealtime - specify whether to perform the operation in realtime or search mode. +func (f Exists) WithRealtime(v bool) func(*ExistsRequest) { + return func(r *ExistsRequest) { + r.Realtime = &v + } +} + +// WithRefresh - refresh the shard containing the document before performing the operation. +func (f Exists) WithRefresh(v bool) func(*ExistsRequest) { + return func(r *ExistsRequest) { + r.Refresh = &v + } +} + +// WithRouting - specific routing value. +func (f Exists) WithRouting(v string) func(*ExistsRequest) { + return func(r *ExistsRequest) { + r.Routing = v + } +} + +// WithSource - true or false to return the _source field or not, or a list of fields to return. +func (f Exists) WithSource(v ...string) func(*ExistsRequest) { + return func(r *ExistsRequest) { + r.Source = v + } +} + +// WithSourceExcludes - a list of fields to exclude from the returned _source field. +func (f Exists) WithSourceExcludes(v ...string) func(*ExistsRequest) { + return func(r *ExistsRequest) { + r.SourceExcludes = v + } +} + +// WithSourceIncludes - a list of fields to extract and return from the _source field. +func (f Exists) WithSourceIncludes(v ...string) func(*ExistsRequest) { + return func(r *ExistsRequest) { + r.SourceIncludes = v + } +} + +// WithStoredFields - a list of stored fields to return in the response. +func (f Exists) WithStoredFields(v ...string) func(*ExistsRequest) { + return func(r *ExistsRequest) { + r.StoredFields = v + } +} + +// WithVersion - explicit version number for concurrency control. +func (f Exists) WithVersion(v int) func(*ExistsRequest) { + return func(r *ExistsRequest) { + r.Version = &v + } +} + +// WithVersionType - specific version type. +func (f Exists) WithVersionType(v string) func(*ExistsRequest) { + return func(r *ExistsRequest) { + r.VersionType = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f Exists) WithPretty() func(*ExistsRequest) { + return func(r *ExistsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f Exists) WithHuman() func(*ExistsRequest) { + return func(r *ExistsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f Exists) WithErrorTrace() func(*ExistsRequest) { + return func(r *ExistsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f Exists) WithFilterPath(v ...string) func(*ExistsRequest) { + return func(r *ExistsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f Exists) WithHeader(h map[string]string) func(*ExistsRequest) { + return func(r *ExistsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f Exists) WithOpaqueID(s string) func(*ExistsRequest) { + return func(r *ExistsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.exists_source.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.exists_source.go new file mode 100644 index 00000000..21dabae0 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.exists_source.go @@ -0,0 +1,316 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newExistsSourceFunc(t Transport) ExistsSource { + return func(index string, id string, o ...func(*ExistsSourceRequest)) (*Response, error) { + var r = ExistsSourceRequest{Index: index, DocumentID: id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// ExistsSource returns information about whether a document source exists in an index. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html. +type ExistsSource func(index string, id string, o ...func(*ExistsSourceRequest)) (*Response, error) + +// ExistsSourceRequest configures the Exists Source API request. +type ExistsSourceRequest struct { + Index string + DocumentType string + DocumentID string + + Preference string + Realtime *bool + Refresh *bool + Routing string + Source []string + SourceExcludes []string + SourceIncludes []string + Version *int + VersionType string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r ExistsSourceRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "HEAD" + + path.Grow(1 + len(r.Index) + 1 + len(r.DocumentType) + 1 + len(r.DocumentID) + 1 + len("_source")) + path.WriteString("/") + path.WriteString(r.Index) + if r.DocumentType != "" { + path.WriteString("/") + path.WriteString(r.DocumentType) + } + path.WriteString("/") + path.WriteString(r.DocumentID) + path.WriteString("/") + path.WriteString("_source") + + params = make(map[string]string) + + if r.Preference != "" { + params["preference"] = r.Preference + } + + if r.Realtime != nil { + params["realtime"] = strconv.FormatBool(*r.Realtime) + } + + if r.Refresh != nil { + params["refresh"] = strconv.FormatBool(*r.Refresh) + } + + if r.Routing != "" { + params["routing"] = r.Routing + } + + if len(r.Source) > 0 { + params["_source"] = strings.Join(r.Source, ",") + } + + if len(r.SourceExcludes) > 0 { + params["_source_excludes"] = strings.Join(r.SourceExcludes, ",") + } + + if len(r.SourceIncludes) > 0 { + params["_source_includes"] = strings.Join(r.SourceIncludes, ",") + } + + if r.Version != nil { + params["version"] = strconv.FormatInt(int64(*r.Version), 10) + } + + if r.VersionType != "" { + params["version_type"] = r.VersionType + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f ExistsSource) WithContext(v context.Context) func(*ExistsSourceRequest) { + return func(r *ExistsSourceRequest) { + r.ctx = v + } +} + +// WithDocumentType - the type of the document; deprecated and optional starting with 7.0. +func (f ExistsSource) WithDocumentType(v string) func(*ExistsSourceRequest) { + return func(r *ExistsSourceRequest) { + r.DocumentType = v + } +} + +// WithPreference - specify the node or shard the operation should be performed on (default: random). +func (f ExistsSource) WithPreference(v string) func(*ExistsSourceRequest) { + return func(r *ExistsSourceRequest) { + r.Preference = v + } +} + +// WithRealtime - specify whether to perform the operation in realtime or search mode. +func (f ExistsSource) WithRealtime(v bool) func(*ExistsSourceRequest) { + return func(r *ExistsSourceRequest) { + r.Realtime = &v + } +} + +// WithRefresh - refresh the shard containing the document before performing the operation. +func (f ExistsSource) WithRefresh(v bool) func(*ExistsSourceRequest) { + return func(r *ExistsSourceRequest) { + r.Refresh = &v + } +} + +// WithRouting - specific routing value. +func (f ExistsSource) WithRouting(v string) func(*ExistsSourceRequest) { + return func(r *ExistsSourceRequest) { + r.Routing = v + } +} + +// WithSource - true or false to return the _source field or not, or a list of fields to return. +func (f ExistsSource) WithSource(v ...string) func(*ExistsSourceRequest) { + return func(r *ExistsSourceRequest) { + r.Source = v + } +} + +// WithSourceExcludes - a list of fields to exclude from the returned _source field. +func (f ExistsSource) WithSourceExcludes(v ...string) func(*ExistsSourceRequest) { + return func(r *ExistsSourceRequest) { + r.SourceExcludes = v + } +} + +// WithSourceIncludes - a list of fields to extract and return from the _source field. +func (f ExistsSource) WithSourceIncludes(v ...string) func(*ExistsSourceRequest) { + return func(r *ExistsSourceRequest) { + r.SourceIncludes = v + } +} + +// WithVersion - explicit version number for concurrency control. +func (f ExistsSource) WithVersion(v int) func(*ExistsSourceRequest) { + return func(r *ExistsSourceRequest) { + r.Version = &v + } +} + +// WithVersionType - specific version type. +func (f ExistsSource) WithVersionType(v string) func(*ExistsSourceRequest) { + return func(r *ExistsSourceRequest) { + r.VersionType = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f ExistsSource) WithPretty() func(*ExistsSourceRequest) { + return func(r *ExistsSourceRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f ExistsSource) WithHuman() func(*ExistsSourceRequest) { + return func(r *ExistsSourceRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f ExistsSource) WithErrorTrace() func(*ExistsSourceRequest) { + return func(r *ExistsSourceRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f ExistsSource) WithFilterPath(v ...string) func(*ExistsSourceRequest) { + return func(r *ExistsSourceRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f ExistsSource) WithHeader(h map[string]string) func(*ExistsSourceRequest) { + return func(r *ExistsSourceRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f ExistsSource) WithOpaqueID(s string) func(*ExistsSourceRequest) { + return func(r *ExistsSourceRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.explain.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.explain.go new file mode 100644 index 00000000..487eeb12 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.explain.go @@ -0,0 +1,370 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" +) + +func newExplainFunc(t Transport) Explain { + return func(index string, id string, o ...func(*ExplainRequest)) (*Response, error) { + var r = ExplainRequest{Index: index, DocumentID: id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// Explain returns information about why a specific matches (or doesn't match) a query. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/search-explain.html. +type Explain func(index string, id string, o ...func(*ExplainRequest)) (*Response, error) + +// ExplainRequest configures the Explain API request. +type ExplainRequest struct { + Index string + DocumentType string + DocumentID string + + Body io.Reader + + Analyzer string + AnalyzeWildcard *bool + DefaultOperator string + Df string + Lenient *bool + Preference string + Query string + Routing string + Source []string + SourceExcludes []string + SourceIncludes []string + StoredFields []string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r ExplainRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + if r.DocumentType == "" { + r.DocumentType = "_doc" + } + + path.Grow(1 + len(r.Index) + 1 + len(r.DocumentType) + 1 + len(r.DocumentID) + 1 + len("_explain")) + path.WriteString("/") + path.WriteString(r.Index) + if r.DocumentType != "" { + path.WriteString("/") + path.WriteString(r.DocumentType) + } + path.WriteString("/") + path.WriteString(r.DocumentID) + path.WriteString("/") + path.WriteString("_explain") + + params = make(map[string]string) + + if r.Analyzer != "" { + params["analyzer"] = r.Analyzer + } + + if r.AnalyzeWildcard != nil { + params["analyze_wildcard"] = strconv.FormatBool(*r.AnalyzeWildcard) + } + + if r.DefaultOperator != "" { + params["default_operator"] = r.DefaultOperator + } + + if r.Df != "" { + params["df"] = r.Df + } + + if r.Lenient != nil { + params["lenient"] = strconv.FormatBool(*r.Lenient) + } + + if r.Preference != "" { + params["preference"] = r.Preference + } + + if r.Query != "" { + params["q"] = r.Query + } + + if r.Routing != "" { + params["routing"] = r.Routing + } + + if len(r.Source) > 0 { + params["_source"] = strings.Join(r.Source, ",") + } + + if len(r.SourceExcludes) > 0 { + params["_source_excludes"] = strings.Join(r.SourceExcludes, ",") + } + + if len(r.SourceIncludes) > 0 { + params["_source_includes"] = strings.Join(r.SourceIncludes, ",") + } + + if len(r.StoredFields) > 0 { + params["stored_fields"] = strings.Join(r.StoredFields, ",") + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f Explain) WithContext(v context.Context) func(*ExplainRequest) { + return func(r *ExplainRequest) { + r.ctx = v + } +} + +// WithBody - The query definition using the Query DSL. +func (f Explain) WithBody(v io.Reader) func(*ExplainRequest) { + return func(r *ExplainRequest) { + r.Body = v + } +} + +// WithDocumentType - the type of the document. +func (f Explain) WithDocumentType(v string) func(*ExplainRequest) { + return func(r *ExplainRequest) { + r.DocumentType = v + } +} + +// WithAnalyzer - the analyzer for the query string query. +func (f Explain) WithAnalyzer(v string) func(*ExplainRequest) { + return func(r *ExplainRequest) { + r.Analyzer = v + } +} + +// WithAnalyzeWildcard - specify whether wildcards and prefix queries in the query string query should be analyzed (default: false). +func (f Explain) WithAnalyzeWildcard(v bool) func(*ExplainRequest) { + return func(r *ExplainRequest) { + r.AnalyzeWildcard = &v + } +} + +// WithDefaultOperator - the default operator for query string query (and or or). +func (f Explain) WithDefaultOperator(v string) func(*ExplainRequest) { + return func(r *ExplainRequest) { + r.DefaultOperator = v + } +} + +// WithDf - the default field for query string query (default: _all). +func (f Explain) WithDf(v string) func(*ExplainRequest) { + return func(r *ExplainRequest) { + r.Df = v + } +} + +// WithLenient - specify whether format-based query failures (such as providing text to a numeric field) should be ignored. +func (f Explain) WithLenient(v bool) func(*ExplainRequest) { + return func(r *ExplainRequest) { + r.Lenient = &v + } +} + +// WithPreference - specify the node or shard the operation should be performed on (default: random). +func (f Explain) WithPreference(v string) func(*ExplainRequest) { + return func(r *ExplainRequest) { + r.Preference = v + } +} + +// WithQuery - query in the lucene query string syntax. +func (f Explain) WithQuery(v string) func(*ExplainRequest) { + return func(r *ExplainRequest) { + r.Query = v + } +} + +// WithRouting - specific routing value. +func (f Explain) WithRouting(v string) func(*ExplainRequest) { + return func(r *ExplainRequest) { + r.Routing = v + } +} + +// WithSource - true or false to return the _source field or not, or a list of fields to return. +func (f Explain) WithSource(v ...string) func(*ExplainRequest) { + return func(r *ExplainRequest) { + r.Source = v + } +} + +// WithSourceExcludes - a list of fields to exclude from the returned _source field. +func (f Explain) WithSourceExcludes(v ...string) func(*ExplainRequest) { + return func(r *ExplainRequest) { + r.SourceExcludes = v + } +} + +// WithSourceIncludes - a list of fields to extract and return from the _source field. +func (f Explain) WithSourceIncludes(v ...string) func(*ExplainRequest) { + return func(r *ExplainRequest) { + r.SourceIncludes = v + } +} + +// WithStoredFields - a list of stored fields to return in the response. +func (f Explain) WithStoredFields(v ...string) func(*ExplainRequest) { + return func(r *ExplainRequest) { + r.StoredFields = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f Explain) WithPretty() func(*ExplainRequest) { + return func(r *ExplainRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f Explain) WithHuman() func(*ExplainRequest) { + return func(r *ExplainRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f Explain) WithErrorTrace() func(*ExplainRequest) { + return func(r *ExplainRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f Explain) WithFilterPath(v ...string) func(*ExplainRequest) { + return func(r *ExplainRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f Explain) WithHeader(h map[string]string) func(*ExplainRequest) { + return func(r *ExplainRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f Explain) WithOpaqueID(s string) func(*ExplainRequest) { + return func(r *ExplainRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.features.get_features.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.features.get_features.go new file mode 100644 index 00000000..9c4af103 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.features.get_features.go @@ -0,0 +1,200 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" + "time" +) + +func newFeaturesGetFeaturesFunc(t Transport) FeaturesGetFeatures { + return func(o ...func(*FeaturesGetFeaturesRequest)) (*Response, error) { + var r = FeaturesGetFeaturesRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// FeaturesGetFeatures gets a list of features which can be included in snapshots using the feature_states field when creating a snapshot +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/get-features-api.html. +type FeaturesGetFeatures func(o ...func(*FeaturesGetFeaturesRequest)) (*Response, error) + +// FeaturesGetFeaturesRequest configures the Features Get Features API request. +type FeaturesGetFeaturesRequest struct { + MasterTimeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r FeaturesGetFeaturesRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(len("/_features")) + path.WriteString("/_features") + + params = make(map[string]string) + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f FeaturesGetFeatures) WithContext(v context.Context) func(*FeaturesGetFeaturesRequest) { + return func(r *FeaturesGetFeaturesRequest) { + r.ctx = v + } +} + +// WithMasterTimeout - explicit operation timeout for connection to master node. +func (f FeaturesGetFeatures) WithMasterTimeout(v time.Duration) func(*FeaturesGetFeaturesRequest) { + return func(r *FeaturesGetFeaturesRequest) { + r.MasterTimeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f FeaturesGetFeatures) WithPretty() func(*FeaturesGetFeaturesRequest) { + return func(r *FeaturesGetFeaturesRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f FeaturesGetFeatures) WithHuman() func(*FeaturesGetFeaturesRequest) { + return func(r *FeaturesGetFeaturesRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f FeaturesGetFeatures) WithErrorTrace() func(*FeaturesGetFeaturesRequest) { + return func(r *FeaturesGetFeaturesRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f FeaturesGetFeatures) WithFilterPath(v ...string) func(*FeaturesGetFeaturesRequest) { + return func(r *FeaturesGetFeaturesRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f FeaturesGetFeatures) WithHeader(h map[string]string) func(*FeaturesGetFeaturesRequest) { + return func(r *FeaturesGetFeaturesRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f FeaturesGetFeatures) WithOpaqueID(s string) func(*FeaturesGetFeaturesRequest) { + return func(r *FeaturesGetFeaturesRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.features.reset_features.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.features.reset_features.go new file mode 100644 index 00000000..f1c65b8b --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.features.reset_features.go @@ -0,0 +1,188 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newFeaturesResetFeaturesFunc(t Transport) FeaturesResetFeatures { + return func(o ...func(*FeaturesResetFeaturesRequest)) (*Response, error) { + var r = FeaturesResetFeaturesRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// FeaturesResetFeatures resets the internal state of features, usually by deleting system indices +// +// This API is experimental. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html. +type FeaturesResetFeatures func(o ...func(*FeaturesResetFeaturesRequest)) (*Response, error) + +// FeaturesResetFeaturesRequest configures the Features Reset Features API request. +type FeaturesResetFeaturesRequest struct { + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r FeaturesResetFeaturesRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(len("/_features/_reset")) + path.WriteString("/_features/_reset") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f FeaturesResetFeatures) WithContext(v context.Context) func(*FeaturesResetFeaturesRequest) { + return func(r *FeaturesResetFeaturesRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f FeaturesResetFeatures) WithPretty() func(*FeaturesResetFeaturesRequest) { + return func(r *FeaturesResetFeaturesRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f FeaturesResetFeatures) WithHuman() func(*FeaturesResetFeaturesRequest) { + return func(r *FeaturesResetFeaturesRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f FeaturesResetFeatures) WithErrorTrace() func(*FeaturesResetFeaturesRequest) { + return func(r *FeaturesResetFeaturesRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f FeaturesResetFeatures) WithFilterPath(v ...string) func(*FeaturesResetFeaturesRequest) { + return func(r *FeaturesResetFeaturesRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f FeaturesResetFeatures) WithHeader(h map[string]string) func(*FeaturesResetFeaturesRequest) { + return func(r *FeaturesResetFeaturesRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f FeaturesResetFeatures) WithOpaqueID(s string) func(*FeaturesResetFeaturesRequest) { + return func(r *FeaturesResetFeaturesRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.field_caps.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.field_caps.go new file mode 100644 index 00000000..3036737c --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.field_caps.go @@ -0,0 +1,276 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" +) + +func newFieldCapsFunc(t Transport) FieldCaps { + return func(o ...func(*FieldCapsRequest)) (*Response, error) { + var r = FieldCapsRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// FieldCaps returns the information about the capabilities of fields among multiple indices. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/search-field-caps.html. +type FieldCaps func(o ...func(*FieldCapsRequest)) (*Response, error) + +// FieldCapsRequest configures the Field Caps API request. +type FieldCapsRequest struct { + Index []string + + Body io.Reader + + AllowNoIndices *bool + ExpandWildcards string + Fields []string + IgnoreUnavailable *bool + IncludeUnmapped *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r FieldCapsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len(strings.Join(r.Index, ",")) + 1 + len("_field_caps")) + if len(r.Index) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + } + path.WriteString("/") + path.WriteString("_field_caps") + + params = make(map[string]string) + + if r.AllowNoIndices != nil { + params["allow_no_indices"] = strconv.FormatBool(*r.AllowNoIndices) + } + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if len(r.Fields) > 0 { + params["fields"] = strings.Join(r.Fields, ",") + } + + if r.IgnoreUnavailable != nil { + params["ignore_unavailable"] = strconv.FormatBool(*r.IgnoreUnavailable) + } + + if r.IncludeUnmapped != nil { + params["include_unmapped"] = strconv.FormatBool(*r.IncludeUnmapped) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f FieldCaps) WithContext(v context.Context) func(*FieldCapsRequest) { + return func(r *FieldCapsRequest) { + r.ctx = v + } +} + +// WithBody - An index filter specified with the Query DSL. +func (f FieldCaps) WithBody(v io.Reader) func(*FieldCapsRequest) { + return func(r *FieldCapsRequest) { + r.Body = v + } +} + +// WithIndex - a list of index names; use _all to perform the operation on all indices. +func (f FieldCaps) WithIndex(v ...string) func(*FieldCapsRequest) { + return func(r *FieldCapsRequest) { + r.Index = v + } +} + +// WithAllowNoIndices - whether to ignore if a wildcard indices expression resolves into no concrete indices. (this includes `_all` string or when no indices have been specified). +func (f FieldCaps) WithAllowNoIndices(v bool) func(*FieldCapsRequest) { + return func(r *FieldCapsRequest) { + r.AllowNoIndices = &v + } +} + +// WithExpandWildcards - whether to expand wildcard expression to concrete indices that are open, closed or both.. +func (f FieldCaps) WithExpandWildcards(v string) func(*FieldCapsRequest) { + return func(r *FieldCapsRequest) { + r.ExpandWildcards = v + } +} + +// WithFields - a list of field names. +func (f FieldCaps) WithFields(v ...string) func(*FieldCapsRequest) { + return func(r *FieldCapsRequest) { + r.Fields = v + } +} + +// WithIgnoreUnavailable - whether specified concrete indices should be ignored when unavailable (missing or closed). +func (f FieldCaps) WithIgnoreUnavailable(v bool) func(*FieldCapsRequest) { + return func(r *FieldCapsRequest) { + r.IgnoreUnavailable = &v + } +} + +// WithIncludeUnmapped - indicates whether unmapped fields should be included in the response.. +func (f FieldCaps) WithIncludeUnmapped(v bool) func(*FieldCapsRequest) { + return func(r *FieldCapsRequest) { + r.IncludeUnmapped = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f FieldCaps) WithPretty() func(*FieldCapsRequest) { + return func(r *FieldCapsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f FieldCaps) WithHuman() func(*FieldCapsRequest) { + return func(r *FieldCapsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f FieldCaps) WithErrorTrace() func(*FieldCapsRequest) { + return func(r *FieldCapsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f FieldCaps) WithFilterPath(v ...string) func(*FieldCapsRequest) { + return func(r *FieldCapsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f FieldCaps) WithHeader(h map[string]string) func(*FieldCapsRequest) { + return func(r *FieldCapsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f FieldCaps) WithOpaqueID(s string) func(*FieldCapsRequest) { + return func(r *FieldCapsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.fleet.global_checkpoints.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.fleet.global_checkpoints.go new file mode 100644 index 00000000..f034fa68 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.fleet.global_checkpoints.go @@ -0,0 +1,244 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" + "time" +) + +func newFleetGlobalCheckpointsFunc(t Transport) FleetGlobalCheckpoints { + return func(index string, o ...func(*FleetGlobalCheckpointsRequest)) (*Response, error) { + var r = FleetGlobalCheckpointsRequest{Index: index} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// FleetGlobalCheckpoints returns the current global checkpoints for an index. This API is design for internal use by the fleet server project. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/get-global-checkpoints.html. +type FleetGlobalCheckpoints func(index string, o ...func(*FleetGlobalCheckpointsRequest)) (*Response, error) + +// FleetGlobalCheckpointsRequest configures the Fleet Global Checkpoints API request. +type FleetGlobalCheckpointsRequest struct { + Index string + + Checkpoints []string + Timeout time.Duration + WaitForAdvance *bool + WaitForIndex *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r FleetGlobalCheckpointsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len(r.Index) + 1 + len("_fleet") + 1 + len("global_checkpoints")) + path.WriteString("/") + path.WriteString(r.Index) + path.WriteString("/") + path.WriteString("_fleet") + path.WriteString("/") + path.WriteString("global_checkpoints") + + params = make(map[string]string) + + if len(r.Checkpoints) > 0 { + params["checkpoints"] = strings.Join(r.Checkpoints, ",") + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.WaitForAdvance != nil { + params["wait_for_advance"] = strconv.FormatBool(*r.WaitForAdvance) + } + + if r.WaitForIndex != nil { + params["wait_for_index"] = strconv.FormatBool(*r.WaitForIndex) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f FleetGlobalCheckpoints) WithContext(v context.Context) func(*FleetGlobalCheckpointsRequest) { + return func(r *FleetGlobalCheckpointsRequest) { + r.ctx = v + } +} + +// WithCheckpoints - comma separated list of checkpoints. +func (f FleetGlobalCheckpoints) WithCheckpoints(v ...string) func(*FleetGlobalCheckpointsRequest) { + return func(r *FleetGlobalCheckpointsRequest) { + r.Checkpoints = v + } +} + +// WithTimeout - timeout to wait for global checkpoint to advance. +func (f FleetGlobalCheckpoints) WithTimeout(v time.Duration) func(*FleetGlobalCheckpointsRequest) { + return func(r *FleetGlobalCheckpointsRequest) { + r.Timeout = v + } +} + +// WithWaitForAdvance - whether to wait for the global checkpoint to advance past the specified current checkpoints. +func (f FleetGlobalCheckpoints) WithWaitForAdvance(v bool) func(*FleetGlobalCheckpointsRequest) { + return func(r *FleetGlobalCheckpointsRequest) { + r.WaitForAdvance = &v + } +} + +// WithWaitForIndex - whether to wait for the target index to exist and all primary shards be active. +func (f FleetGlobalCheckpoints) WithWaitForIndex(v bool) func(*FleetGlobalCheckpointsRequest) { + return func(r *FleetGlobalCheckpointsRequest) { + r.WaitForIndex = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f FleetGlobalCheckpoints) WithPretty() func(*FleetGlobalCheckpointsRequest) { + return func(r *FleetGlobalCheckpointsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f FleetGlobalCheckpoints) WithHuman() func(*FleetGlobalCheckpointsRequest) { + return func(r *FleetGlobalCheckpointsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f FleetGlobalCheckpoints) WithErrorTrace() func(*FleetGlobalCheckpointsRequest) { + return func(r *FleetGlobalCheckpointsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f FleetGlobalCheckpoints) WithFilterPath(v ...string) func(*FleetGlobalCheckpointsRequest) { + return func(r *FleetGlobalCheckpointsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f FleetGlobalCheckpoints) WithHeader(h map[string]string) func(*FleetGlobalCheckpointsRequest) { + return func(r *FleetGlobalCheckpointsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f FleetGlobalCheckpoints) WithOpaqueID(s string) func(*FleetGlobalCheckpointsRequest) { + return func(r *FleetGlobalCheckpointsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.fleet.msearch.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.fleet.msearch.go new file mode 100644 index 00000000..59f8fe93 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.fleet.msearch.go @@ -0,0 +1,209 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newFleetMsearchFunc(t Transport) FleetMsearch { + return func(body io.Reader, o ...func(*FleetMsearchRequest)) (*Response, error) { + var r = FleetMsearchRequest{Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// FleetMsearch multi Search API where the search will only be executed after specified checkpoints are available due to a refresh. This API is designed for internal use by the fleet server project. +// +// This API is experimental. +type FleetMsearch func(body io.Reader, o ...func(*FleetMsearchRequest)) (*Response, error) + +// FleetMsearchRequest configures the Fleet Msearch API request. +type FleetMsearchRequest struct { + Index string + + Body io.Reader + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r FleetMsearchRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len(r.Index) + 1 + len("_fleet") + 1 + len("_fleet_msearch")) + if r.Index != "" { + path.WriteString("/") + path.WriteString(r.Index) + } + path.WriteString("/") + path.WriteString("_fleet") + path.WriteString("/") + path.WriteString("_fleet_msearch") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f FleetMsearch) WithContext(v context.Context) func(*FleetMsearchRequest) { + return func(r *FleetMsearchRequest) { + r.ctx = v + } +} + +// WithIndex - the index name to use as the default. +func (f FleetMsearch) WithIndex(v string) func(*FleetMsearchRequest) { + return func(r *FleetMsearchRequest) { + r.Index = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f FleetMsearch) WithPretty() func(*FleetMsearchRequest) { + return func(r *FleetMsearchRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f FleetMsearch) WithHuman() func(*FleetMsearchRequest) { + return func(r *FleetMsearchRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f FleetMsearch) WithErrorTrace() func(*FleetMsearchRequest) { + return func(r *FleetMsearchRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f FleetMsearch) WithFilterPath(v ...string) func(*FleetMsearchRequest) { + return func(r *FleetMsearchRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f FleetMsearch) WithHeader(h map[string]string) func(*FleetMsearchRequest) { + return func(r *FleetMsearchRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f FleetMsearch) WithOpaqueID(s string) func(*FleetMsearchRequest) { + return func(r *FleetMsearchRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.fleet.search.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.fleet.search.go new file mode 100644 index 00000000..0b5b4090 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.fleet.search.go @@ -0,0 +1,246 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" + "time" +) + +func newFleetSearchFunc(t Transport) FleetSearch { + return func(index string, o ...func(*FleetSearchRequest)) (*Response, error) { + var r = FleetSearchRequest{Index: index} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// FleetSearch search API where the search will only be executed after specified checkpoints are available due to a refresh. This API is designed for internal use by the fleet server project. +// +// This API is experimental. +type FleetSearch func(index string, o ...func(*FleetSearchRequest)) (*Response, error) + +// FleetSearchRequest configures the Fleet Search API request. +type FleetSearchRequest struct { + Index string + + Body io.Reader + + AllowPartialSearchResults *bool + WaitForCheckpoints []string + WaitForCheckpointsTimeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r FleetSearchRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len(r.Index) + 1 + len("_fleet") + 1 + len("_fleet_search")) + path.WriteString("/") + path.WriteString(r.Index) + path.WriteString("/") + path.WriteString("_fleet") + path.WriteString("/") + path.WriteString("_fleet_search") + + params = make(map[string]string) + + if r.AllowPartialSearchResults != nil { + params["allow_partial_search_results"] = strconv.FormatBool(*r.AllowPartialSearchResults) + } + + if len(r.WaitForCheckpoints) > 0 { + params["wait_for_checkpoints"] = strings.Join(r.WaitForCheckpoints, ",") + } + + if r.WaitForCheckpointsTimeout != 0 { + params["wait_for_checkpoints_timeout"] = formatDuration(r.WaitForCheckpointsTimeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f FleetSearch) WithContext(v context.Context) func(*FleetSearchRequest) { + return func(r *FleetSearchRequest) { + r.ctx = v + } +} + +// WithBody - The search definition using the Query DSL. +func (f FleetSearch) WithBody(v io.Reader) func(*FleetSearchRequest) { + return func(r *FleetSearchRequest) { + r.Body = v + } +} + +// WithAllowPartialSearchResults - indicate if an error should be returned if there is a partial search failure or timeout. +func (f FleetSearch) WithAllowPartialSearchResults(v bool) func(*FleetSearchRequest) { + return func(r *FleetSearchRequest) { + r.AllowPartialSearchResults = &v + } +} + +// WithWaitForCheckpoints - comma separated list of checkpoints, one per shard. +func (f FleetSearch) WithWaitForCheckpoints(v ...string) func(*FleetSearchRequest) { + return func(r *FleetSearchRequest) { + r.WaitForCheckpoints = v + } +} + +// WithWaitForCheckpointsTimeout - explicit wait_for_checkpoints timeout. +func (f FleetSearch) WithWaitForCheckpointsTimeout(v time.Duration) func(*FleetSearchRequest) { + return func(r *FleetSearchRequest) { + r.WaitForCheckpointsTimeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f FleetSearch) WithPretty() func(*FleetSearchRequest) { + return func(r *FleetSearchRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f FleetSearch) WithHuman() func(*FleetSearchRequest) { + return func(r *FleetSearchRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f FleetSearch) WithErrorTrace() func(*FleetSearchRequest) { + return func(r *FleetSearchRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f FleetSearch) WithFilterPath(v ...string) func(*FleetSearchRequest) { + return func(r *FleetSearchRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f FleetSearch) WithHeader(h map[string]string) func(*FleetSearchRequest) { + return func(r *FleetSearchRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f FleetSearch) WithOpaqueID(s string) func(*FleetSearchRequest) { + return func(r *FleetSearchRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.get.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.get.go new file mode 100644 index 00000000..51308971 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.get.go @@ -0,0 +1,330 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newGetFunc(t Transport) Get { + return func(index string, id string, o ...func(*GetRequest)) (*Response, error) { + var r = GetRequest{Index: index, DocumentID: id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// Get returns a document. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html. +type Get func(index string, id string, o ...func(*GetRequest)) (*Response, error) + +// GetRequest configures the Get API request. +type GetRequest struct { + Index string + DocumentType string + DocumentID string + + Preference string + Realtime *bool + Refresh *bool + Routing string + Source []string + SourceExcludes []string + SourceIncludes []string + StoredFields []string + Version *int + VersionType string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r GetRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + if r.DocumentType == "" { + r.DocumentType = "_doc" + } + + path.Grow(1 + len(r.Index) + 1 + len(r.DocumentType) + 1 + len(r.DocumentID)) + path.WriteString("/") + path.WriteString(r.Index) + if r.DocumentType != "" { + path.WriteString("/") + path.WriteString(r.DocumentType) + } + path.WriteString("/") + path.WriteString(r.DocumentID) + + params = make(map[string]string) + + if r.Preference != "" { + params["preference"] = r.Preference + } + + if r.Realtime != nil { + params["realtime"] = strconv.FormatBool(*r.Realtime) + } + + if r.Refresh != nil { + params["refresh"] = strconv.FormatBool(*r.Refresh) + } + + if r.Routing != "" { + params["routing"] = r.Routing + } + + if len(r.Source) > 0 { + params["_source"] = strings.Join(r.Source, ",") + } + + if len(r.SourceExcludes) > 0 { + params["_source_excludes"] = strings.Join(r.SourceExcludes, ",") + } + + if len(r.SourceIncludes) > 0 { + params["_source_includes"] = strings.Join(r.SourceIncludes, ",") + } + + if len(r.StoredFields) > 0 { + params["stored_fields"] = strings.Join(r.StoredFields, ",") + } + + if r.Version != nil { + params["version"] = strconv.FormatInt(int64(*r.Version), 10) + } + + if r.VersionType != "" { + params["version_type"] = r.VersionType + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f Get) WithContext(v context.Context) func(*GetRequest) { + return func(r *GetRequest) { + r.ctx = v + } +} + +// WithDocumentType - the type of the document (use `_all` to fetch the first document matching the ID across all types). +func (f Get) WithDocumentType(v string) func(*GetRequest) { + return func(r *GetRequest) { + r.DocumentType = v + } +} + +// WithPreference - specify the node or shard the operation should be performed on (default: random). +func (f Get) WithPreference(v string) func(*GetRequest) { + return func(r *GetRequest) { + r.Preference = v + } +} + +// WithRealtime - specify whether to perform the operation in realtime or search mode. +func (f Get) WithRealtime(v bool) func(*GetRequest) { + return func(r *GetRequest) { + r.Realtime = &v + } +} + +// WithRefresh - refresh the shard containing the document before performing the operation. +func (f Get) WithRefresh(v bool) func(*GetRequest) { + return func(r *GetRequest) { + r.Refresh = &v + } +} + +// WithRouting - specific routing value. +func (f Get) WithRouting(v string) func(*GetRequest) { + return func(r *GetRequest) { + r.Routing = v + } +} + +// WithSource - true or false to return the _source field or not, or a list of fields to return. +func (f Get) WithSource(v ...string) func(*GetRequest) { + return func(r *GetRequest) { + r.Source = v + } +} + +// WithSourceExcludes - a list of fields to exclude from the returned _source field. +func (f Get) WithSourceExcludes(v ...string) func(*GetRequest) { + return func(r *GetRequest) { + r.SourceExcludes = v + } +} + +// WithSourceIncludes - a list of fields to extract and return from the _source field. +func (f Get) WithSourceIncludes(v ...string) func(*GetRequest) { + return func(r *GetRequest) { + r.SourceIncludes = v + } +} + +// WithStoredFields - a list of stored fields to return in the response. +func (f Get) WithStoredFields(v ...string) func(*GetRequest) { + return func(r *GetRequest) { + r.StoredFields = v + } +} + +// WithVersion - explicit version number for concurrency control. +func (f Get) WithVersion(v int) func(*GetRequest) { + return func(r *GetRequest) { + r.Version = &v + } +} + +// WithVersionType - specific version type. +func (f Get) WithVersionType(v string) func(*GetRequest) { + return func(r *GetRequest) { + r.VersionType = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f Get) WithPretty() func(*GetRequest) { + return func(r *GetRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f Get) WithHuman() func(*GetRequest) { + return func(r *GetRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f Get) WithErrorTrace() func(*GetRequest) { + return func(r *GetRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f Get) WithFilterPath(v ...string) func(*GetRequest) { + return func(r *GetRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f Get) WithHeader(h map[string]string) func(*GetRequest) { + return func(r *GetRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f Get) WithOpaqueID(s string) func(*GetRequest) { + return func(r *GetRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.get_script.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.get_script.go new file mode 100644 index 00000000..53b7204a --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.get_script.go @@ -0,0 +1,205 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" + "time" +) + +func newGetScriptFunc(t Transport) GetScript { + return func(id string, o ...func(*GetScriptRequest)) (*Response, error) { + var r = GetScriptRequest{ScriptID: id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// GetScript returns a script. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html. +type GetScript func(id string, o ...func(*GetScriptRequest)) (*Response, error) + +// GetScriptRequest configures the Get Script API request. +type GetScriptRequest struct { + ScriptID string + + MasterTimeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r GetScriptRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_scripts") + 1 + len(r.ScriptID)) + path.WriteString("/") + path.WriteString("_scripts") + path.WriteString("/") + path.WriteString(r.ScriptID) + + params = make(map[string]string) + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f GetScript) WithContext(v context.Context) func(*GetScriptRequest) { + return func(r *GetScriptRequest) { + r.ctx = v + } +} + +// WithMasterTimeout - specify timeout for connection to master. +func (f GetScript) WithMasterTimeout(v time.Duration) func(*GetScriptRequest) { + return func(r *GetScriptRequest) { + r.MasterTimeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f GetScript) WithPretty() func(*GetScriptRequest) { + return func(r *GetScriptRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f GetScript) WithHuman() func(*GetScriptRequest) { + return func(r *GetScriptRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f GetScript) WithErrorTrace() func(*GetScriptRequest) { + return func(r *GetScriptRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f GetScript) WithFilterPath(v ...string) func(*GetScriptRequest) { + return func(r *GetScriptRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f GetScript) WithHeader(h map[string]string) func(*GetScriptRequest) { + return func(r *GetScriptRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f GetScript) WithOpaqueID(s string) func(*GetScriptRequest) { + return func(r *GetScriptRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.get_script_context.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.get_script_context.go new file mode 100644 index 00000000..e7cd046d --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.get_script_context.go @@ -0,0 +1,186 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newGetScriptContextFunc(t Transport) GetScriptContext { + return func(o ...func(*GetScriptContextRequest)) (*Response, error) { + var r = GetScriptContextRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// GetScriptContext returns all script contexts. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/painless/master/painless-contexts.html. +type GetScriptContext func(o ...func(*GetScriptContextRequest)) (*Response, error) + +// GetScriptContextRequest configures the Get Script Context API request. +type GetScriptContextRequest struct { + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r GetScriptContextRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(len("/_script_context")) + path.WriteString("/_script_context") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f GetScriptContext) WithContext(v context.Context) func(*GetScriptContextRequest) { + return func(r *GetScriptContextRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f GetScriptContext) WithPretty() func(*GetScriptContextRequest) { + return func(r *GetScriptContextRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f GetScriptContext) WithHuman() func(*GetScriptContextRequest) { + return func(r *GetScriptContextRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f GetScriptContext) WithErrorTrace() func(*GetScriptContextRequest) { + return func(r *GetScriptContextRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f GetScriptContext) WithFilterPath(v ...string) func(*GetScriptContextRequest) { + return func(r *GetScriptContextRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f GetScriptContext) WithHeader(h map[string]string) func(*GetScriptContextRequest) { + return func(r *GetScriptContextRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f GetScriptContext) WithOpaqueID(s string) func(*GetScriptContextRequest) { + return func(r *GetScriptContextRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.get_script_languages.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.get_script_languages.go new file mode 100644 index 00000000..08a8626e --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.get_script_languages.go @@ -0,0 +1,186 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newGetScriptLanguagesFunc(t Transport) GetScriptLanguages { + return func(o ...func(*GetScriptLanguagesRequest)) (*Response, error) { + var r = GetScriptLanguagesRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// GetScriptLanguages returns available script types, languages and contexts +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html. +type GetScriptLanguages func(o ...func(*GetScriptLanguagesRequest)) (*Response, error) + +// GetScriptLanguagesRequest configures the Get Script Languages API request. +type GetScriptLanguagesRequest struct { + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r GetScriptLanguagesRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(len("/_script_language")) + path.WriteString("/_script_language") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f GetScriptLanguages) WithContext(v context.Context) func(*GetScriptLanguagesRequest) { + return func(r *GetScriptLanguagesRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f GetScriptLanguages) WithPretty() func(*GetScriptLanguagesRequest) { + return func(r *GetScriptLanguagesRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f GetScriptLanguages) WithHuman() func(*GetScriptLanguagesRequest) { + return func(r *GetScriptLanguagesRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f GetScriptLanguages) WithErrorTrace() func(*GetScriptLanguagesRequest) { + return func(r *GetScriptLanguagesRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f GetScriptLanguages) WithFilterPath(v ...string) func(*GetScriptLanguagesRequest) { + return func(r *GetScriptLanguagesRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f GetScriptLanguages) WithHeader(h map[string]string) func(*GetScriptLanguagesRequest) { + return func(r *GetScriptLanguagesRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f GetScriptLanguages) WithOpaqueID(s string) func(*GetScriptLanguagesRequest) { + return func(r *GetScriptLanguagesRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.get_source.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.get_source.go new file mode 100644 index 00000000..2090dc54 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.get_source.go @@ -0,0 +1,320 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newGetSourceFunc(t Transport) GetSource { + return func(index string, id string, o ...func(*GetSourceRequest)) (*Response, error) { + var r = GetSourceRequest{Index: index, DocumentID: id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// GetSource returns the source of a document. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html. +type GetSource func(index string, id string, o ...func(*GetSourceRequest)) (*Response, error) + +// GetSourceRequest configures the Get Source API request. +type GetSourceRequest struct { + Index string + DocumentType string + DocumentID string + + Preference string + Realtime *bool + Refresh *bool + Routing string + Source []string + SourceExcludes []string + SourceIncludes []string + Version *int + VersionType string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r GetSourceRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + if r.DocumentType == "" { + r.DocumentType = "_doc" + } + + path.Grow(1 + len(r.Index) + 1 + len(r.DocumentType) + 1 + len(r.DocumentID) + 1 + len("_source")) + path.WriteString("/") + path.WriteString(r.Index) + if r.DocumentType != "" { + path.WriteString("/") + path.WriteString(r.DocumentType) + } + path.WriteString("/") + path.WriteString(r.DocumentID) + path.WriteString("/") + path.WriteString("_source") + + params = make(map[string]string) + + if r.Preference != "" { + params["preference"] = r.Preference + } + + if r.Realtime != nil { + params["realtime"] = strconv.FormatBool(*r.Realtime) + } + + if r.Refresh != nil { + params["refresh"] = strconv.FormatBool(*r.Refresh) + } + + if r.Routing != "" { + params["routing"] = r.Routing + } + + if len(r.Source) > 0 { + params["_source"] = strings.Join(r.Source, ",") + } + + if len(r.SourceExcludes) > 0 { + params["_source_excludes"] = strings.Join(r.SourceExcludes, ",") + } + + if len(r.SourceIncludes) > 0 { + params["_source_includes"] = strings.Join(r.SourceIncludes, ",") + } + + if r.Version != nil { + params["version"] = strconv.FormatInt(int64(*r.Version), 10) + } + + if r.VersionType != "" { + params["version_type"] = r.VersionType + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f GetSource) WithContext(v context.Context) func(*GetSourceRequest) { + return func(r *GetSourceRequest) { + r.ctx = v + } +} + +// WithDocumentType - the type of the document; deprecated and optional starting with 7.0. +func (f GetSource) WithDocumentType(v string) func(*GetSourceRequest) { + return func(r *GetSourceRequest) { + r.DocumentType = v + } +} + +// WithPreference - specify the node or shard the operation should be performed on (default: random). +func (f GetSource) WithPreference(v string) func(*GetSourceRequest) { + return func(r *GetSourceRequest) { + r.Preference = v + } +} + +// WithRealtime - specify whether to perform the operation in realtime or search mode. +func (f GetSource) WithRealtime(v bool) func(*GetSourceRequest) { + return func(r *GetSourceRequest) { + r.Realtime = &v + } +} + +// WithRefresh - refresh the shard containing the document before performing the operation. +func (f GetSource) WithRefresh(v bool) func(*GetSourceRequest) { + return func(r *GetSourceRequest) { + r.Refresh = &v + } +} + +// WithRouting - specific routing value. +func (f GetSource) WithRouting(v string) func(*GetSourceRequest) { + return func(r *GetSourceRequest) { + r.Routing = v + } +} + +// WithSource - true or false to return the _source field or not, or a list of fields to return. +func (f GetSource) WithSource(v ...string) func(*GetSourceRequest) { + return func(r *GetSourceRequest) { + r.Source = v + } +} + +// WithSourceExcludes - a list of fields to exclude from the returned _source field. +func (f GetSource) WithSourceExcludes(v ...string) func(*GetSourceRequest) { + return func(r *GetSourceRequest) { + r.SourceExcludes = v + } +} + +// WithSourceIncludes - a list of fields to extract and return from the _source field. +func (f GetSource) WithSourceIncludes(v ...string) func(*GetSourceRequest) { + return func(r *GetSourceRequest) { + r.SourceIncludes = v + } +} + +// WithVersion - explicit version number for concurrency control. +func (f GetSource) WithVersion(v int) func(*GetSourceRequest) { + return func(r *GetSourceRequest) { + r.Version = &v + } +} + +// WithVersionType - specific version type. +func (f GetSource) WithVersionType(v string) func(*GetSourceRequest) { + return func(r *GetSourceRequest) { + r.VersionType = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f GetSource) WithPretty() func(*GetSourceRequest) { + return func(r *GetSourceRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f GetSource) WithHuman() func(*GetSourceRequest) { + return func(r *GetSourceRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f GetSource) WithErrorTrace() func(*GetSourceRequest) { + return func(r *GetSourceRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f GetSource) WithFilterPath(v ...string) func(*GetSourceRequest) { + return func(r *GetSourceRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f GetSource) WithHeader(h map[string]string) func(*GetSourceRequest) { + return func(r *GetSourceRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f GetSource) WithOpaqueID(s string) func(*GetSourceRequest) { + return func(r *GetSourceRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.index.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.index.go new file mode 100644 index 00000000..5b913c7c --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.index.go @@ -0,0 +1,363 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" + "time" +) + +func newIndexFunc(t Transport) Index { + return func(index string, body io.Reader, o ...func(*IndexRequest)) (*Response, error) { + var r = IndexRequest{Index: index, Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// Index creates or updates a document in an index. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-index_.html. +type Index func(index string, body io.Reader, o ...func(*IndexRequest)) (*Response, error) + +// IndexRequest configures the Index API request. +type IndexRequest struct { + Index string + DocumentType string + DocumentID string + + Body io.Reader + + IfPrimaryTerm *int + IfSeqNo *int + OpType string + Pipeline string + Refresh string + RequireAlias *bool + Routing string + Timeout time.Duration + Version *int + VersionType string + WaitForActiveShards string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndexRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + if r.DocumentID != "" { + method = "PUT" + } else { + method = "POST" + } + + if r.DocumentType == "" { + r.DocumentType = "_doc" + } + + path.Grow(1 + len(r.Index) + 1 + len(r.DocumentType) + 1 + len(r.DocumentID)) + path.WriteString("/") + path.WriteString(r.Index) + if r.DocumentType != "" { + path.WriteString("/") + path.WriteString(r.DocumentType) + } + if r.DocumentID != "" { + path.WriteString("/") + path.WriteString(r.DocumentID) + } + + params = make(map[string]string) + + if r.IfPrimaryTerm != nil { + params["if_primary_term"] = strconv.FormatInt(int64(*r.IfPrimaryTerm), 10) + } + + if r.IfSeqNo != nil { + params["if_seq_no"] = strconv.FormatInt(int64(*r.IfSeqNo), 10) + } + + if r.OpType != "" { + params["op_type"] = r.OpType + } + + if r.Pipeline != "" { + params["pipeline"] = r.Pipeline + } + + if r.Refresh != "" { + params["refresh"] = r.Refresh + } + + if r.RequireAlias != nil { + params["require_alias"] = strconv.FormatBool(*r.RequireAlias) + } + + if r.Routing != "" { + params["routing"] = r.Routing + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Version != nil { + params["version"] = strconv.FormatInt(int64(*r.Version), 10) + } + + if r.VersionType != "" { + params["version_type"] = r.VersionType + } + + if r.WaitForActiveShards != "" { + params["wait_for_active_shards"] = r.WaitForActiveShards + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f Index) WithContext(v context.Context) func(*IndexRequest) { + return func(r *IndexRequest) { + r.ctx = v + } +} + +// WithDocumentID - document ID. +func (f Index) WithDocumentID(v string) func(*IndexRequest) { + return func(r *IndexRequest) { + r.DocumentID = v + } +} + +// WithDocumentType - the type of the document. +func (f Index) WithDocumentType(v string) func(*IndexRequest) { + return func(r *IndexRequest) { + r.DocumentType = v + } +} + +// WithIfPrimaryTerm - only perform the index operation if the last operation that has changed the document has the specified primary term. +func (f Index) WithIfPrimaryTerm(v int) func(*IndexRequest) { + return func(r *IndexRequest) { + r.IfPrimaryTerm = &v + } +} + +// WithIfSeqNo - only perform the index operation if the last operation that has changed the document has the specified sequence number. +func (f Index) WithIfSeqNo(v int) func(*IndexRequest) { + return func(r *IndexRequest) { + r.IfSeqNo = &v + } +} + +// WithOpType - explicit operation type. defaults to `index` for requests with an explicit document ID, and to `create`for requests without an explicit document ID. +func (f Index) WithOpType(v string) func(*IndexRequest) { + return func(r *IndexRequest) { + r.OpType = v + } +} + +// WithPipeline - the pipeline ID to preprocess incoming documents with. +func (f Index) WithPipeline(v string) func(*IndexRequest) { + return func(r *IndexRequest) { + r.Pipeline = v + } +} + +// WithRefresh - if `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes.. +func (f Index) WithRefresh(v string) func(*IndexRequest) { + return func(r *IndexRequest) { + r.Refresh = v + } +} + +// WithRequireAlias - when true, requires destination to be an alias. default is false. +func (f Index) WithRequireAlias(v bool) func(*IndexRequest) { + return func(r *IndexRequest) { + r.RequireAlias = &v + } +} + +// WithRouting - specific routing value. +func (f Index) WithRouting(v string) func(*IndexRequest) { + return func(r *IndexRequest) { + r.Routing = v + } +} + +// WithTimeout - explicit operation timeout. +func (f Index) WithTimeout(v time.Duration) func(*IndexRequest) { + return func(r *IndexRequest) { + r.Timeout = v + } +} + +// WithVersion - explicit version number for concurrency control. +func (f Index) WithVersion(v int) func(*IndexRequest) { + return func(r *IndexRequest) { + r.Version = &v + } +} + +// WithVersionType - specific version type. +func (f Index) WithVersionType(v string) func(*IndexRequest) { + return func(r *IndexRequest) { + r.VersionType = v + } +} + +// WithWaitForActiveShards - sets the number of shard copies that must be active before proceeding with the index operation. defaults to 1, meaning the primary shard only. set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1). +func (f Index) WithWaitForActiveShards(v string) func(*IndexRequest) { + return func(r *IndexRequest) { + r.WaitForActiveShards = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f Index) WithPretty() func(*IndexRequest) { + return func(r *IndexRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f Index) WithHuman() func(*IndexRequest) { + return func(r *IndexRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f Index) WithErrorTrace() func(*IndexRequest) { + return func(r *IndexRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f Index) WithFilterPath(v ...string) func(*IndexRequest) { + return func(r *IndexRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f Index) WithHeader(h map[string]string) func(*IndexRequest) { + return func(r *IndexRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f Index) WithOpaqueID(s string) func(*IndexRequest) { + return func(r *IndexRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.add_block.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.add_block.go new file mode 100644 index 00000000..d51a3bd1 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.add_block.go @@ -0,0 +1,263 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "errors" + "net/http" + "strconv" + "strings" + "time" +) + +func newIndicesAddBlockFunc(t Transport) IndicesAddBlock { + return func(index []string, block string, o ...func(*IndicesAddBlockRequest)) (*Response, error) { + var r = IndicesAddBlockRequest{Index: index, Block: block} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesAddBlock adds a block to an index. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/index-modules-blocks.html. +type IndicesAddBlock func(index []string, block string, o ...func(*IndicesAddBlockRequest)) (*Response, error) + +// IndicesAddBlockRequest configures the Indices Add Block API request. +type IndicesAddBlockRequest struct { + Index []string + + Block string + + AllowNoIndices *bool + ExpandWildcards string + IgnoreUnavailable *bool + MasterTimeout time.Duration + Timeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesAddBlockRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + if len(r.Index) == 0 { + return nil, errors.New("index is required and cannot be nil or empty") + } + + path.Grow(1 + len(strings.Join(r.Index, ",")) + 1 + len("_block") + 1 + len(r.Block)) + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + path.WriteString("/") + path.WriteString("_block") + path.WriteString("/") + path.WriteString(r.Block) + + params = make(map[string]string) + + if r.AllowNoIndices != nil { + params["allow_no_indices"] = strconv.FormatBool(*r.AllowNoIndices) + } + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if r.IgnoreUnavailable != nil { + params["ignore_unavailable"] = strconv.FormatBool(*r.IgnoreUnavailable) + } + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesAddBlock) WithContext(v context.Context) func(*IndicesAddBlockRequest) { + return func(r *IndicesAddBlockRequest) { + r.ctx = v + } +} + +// WithAllowNoIndices - whether to ignore if a wildcard indices expression resolves into no concrete indices. (this includes `_all` string or when no indices have been specified). +func (f IndicesAddBlock) WithAllowNoIndices(v bool) func(*IndicesAddBlockRequest) { + return func(r *IndicesAddBlockRequest) { + r.AllowNoIndices = &v + } +} + +// WithExpandWildcards - whether to expand wildcard expression to concrete indices that are open, closed or both.. +func (f IndicesAddBlock) WithExpandWildcards(v string) func(*IndicesAddBlockRequest) { + return func(r *IndicesAddBlockRequest) { + r.ExpandWildcards = v + } +} + +// WithIgnoreUnavailable - whether specified concrete indices should be ignored when unavailable (missing or closed). +func (f IndicesAddBlock) WithIgnoreUnavailable(v bool) func(*IndicesAddBlockRequest) { + return func(r *IndicesAddBlockRequest) { + r.IgnoreUnavailable = &v + } +} + +// WithMasterTimeout - specify timeout for connection to master. +func (f IndicesAddBlock) WithMasterTimeout(v time.Duration) func(*IndicesAddBlockRequest) { + return func(r *IndicesAddBlockRequest) { + r.MasterTimeout = v + } +} + +// WithTimeout - explicit operation timeout. +func (f IndicesAddBlock) WithTimeout(v time.Duration) func(*IndicesAddBlockRequest) { + return func(r *IndicesAddBlockRequest) { + r.Timeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesAddBlock) WithPretty() func(*IndicesAddBlockRequest) { + return func(r *IndicesAddBlockRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesAddBlock) WithHuman() func(*IndicesAddBlockRequest) { + return func(r *IndicesAddBlockRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesAddBlock) WithErrorTrace() func(*IndicesAddBlockRequest) { + return func(r *IndicesAddBlockRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesAddBlock) WithFilterPath(v ...string) func(*IndicesAddBlockRequest) { + return func(r *IndicesAddBlockRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesAddBlock) WithHeader(h map[string]string) func(*IndicesAddBlockRequest) { + return func(r *IndicesAddBlockRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesAddBlock) WithOpaqueID(s string) func(*IndicesAddBlockRequest) { + return func(r *IndicesAddBlockRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.analyze.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.analyze.go new file mode 100644 index 00000000..bdbb9a97 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.analyze.go @@ -0,0 +1,218 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newIndicesAnalyzeFunc(t Transport) IndicesAnalyze { + return func(o ...func(*IndicesAnalyzeRequest)) (*Response, error) { + var r = IndicesAnalyzeRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesAnalyze performs the analysis process on a text and return the tokens breakdown of the text. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-analyze.html. +type IndicesAnalyze func(o ...func(*IndicesAnalyzeRequest)) (*Response, error) + +// IndicesAnalyzeRequest configures the Indices Analyze API request. +type IndicesAnalyzeRequest struct { + Index string + + Body io.Reader + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesAnalyzeRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len(r.Index) + 1 + len("_analyze")) + if r.Index != "" { + path.WriteString("/") + path.WriteString(r.Index) + } + path.WriteString("/") + path.WriteString("_analyze") + + params = make(map[string]string) + + if r.Index != "" { + params["index"] = r.Index + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesAnalyze) WithContext(v context.Context) func(*IndicesAnalyzeRequest) { + return func(r *IndicesAnalyzeRequest) { + r.ctx = v + } +} + +// WithBody - Define analyzer/tokenizer parameters and the text on which the analysis should be performed. +func (f IndicesAnalyze) WithBody(v io.Reader) func(*IndicesAnalyzeRequest) { + return func(r *IndicesAnalyzeRequest) { + r.Body = v + } +} + +// WithIndex - the name of the index to scope the operation. +func (f IndicesAnalyze) WithIndex(v string) func(*IndicesAnalyzeRequest) { + return func(r *IndicesAnalyzeRequest) { + r.Index = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesAnalyze) WithPretty() func(*IndicesAnalyzeRequest) { + return func(r *IndicesAnalyzeRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesAnalyze) WithHuman() func(*IndicesAnalyzeRequest) { + return func(r *IndicesAnalyzeRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesAnalyze) WithErrorTrace() func(*IndicesAnalyzeRequest) { + return func(r *IndicesAnalyzeRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesAnalyze) WithFilterPath(v ...string) func(*IndicesAnalyzeRequest) { + return func(r *IndicesAnalyzeRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesAnalyze) WithHeader(h map[string]string) func(*IndicesAnalyzeRequest) { + return func(r *IndicesAnalyzeRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesAnalyze) WithOpaqueID(s string) func(*IndicesAnalyzeRequest) { + return func(r *IndicesAnalyzeRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.clear_cache.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.clear_cache.go new file mode 100644 index 00000000..cd10e822 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.clear_cache.go @@ -0,0 +1,292 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newIndicesClearCacheFunc(t Transport) IndicesClearCache { + return func(o ...func(*IndicesClearCacheRequest)) (*Response, error) { + var r = IndicesClearCacheRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesClearCache clears all or specific caches for one or more indices. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-clearcache.html. +type IndicesClearCache func(o ...func(*IndicesClearCacheRequest)) (*Response, error) + +// IndicesClearCacheRequest configures the Indices Clear Cache API request. +type IndicesClearCacheRequest struct { + Index []string + + AllowNoIndices *bool + ExpandWildcards string + Fielddata *bool + Fields []string + IgnoreUnavailable *bool + Query *bool + Request *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesClearCacheRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len(strings.Join(r.Index, ",")) + 1 + len("_cache") + 1 + len("clear")) + if len(r.Index) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + } + path.WriteString("/") + path.WriteString("_cache") + path.WriteString("/") + path.WriteString("clear") + + params = make(map[string]string) + + if r.AllowNoIndices != nil { + params["allow_no_indices"] = strconv.FormatBool(*r.AllowNoIndices) + } + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if r.Fielddata != nil { + params["fielddata"] = strconv.FormatBool(*r.Fielddata) + } + + if len(r.Fields) > 0 { + params["fields"] = strings.Join(r.Fields, ",") + } + + if r.IgnoreUnavailable != nil { + params["ignore_unavailable"] = strconv.FormatBool(*r.IgnoreUnavailable) + } + + if len(r.Index) > 0 { + params["index"] = strings.Join(r.Index, ",") + } + + if r.Query != nil { + params["query"] = strconv.FormatBool(*r.Query) + } + + if r.Request != nil { + params["request"] = strconv.FormatBool(*r.Request) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesClearCache) WithContext(v context.Context) func(*IndicesClearCacheRequest) { + return func(r *IndicesClearCacheRequest) { + r.ctx = v + } +} + +// WithIndex - a list of index name to limit the operation. +func (f IndicesClearCache) WithIndex(v ...string) func(*IndicesClearCacheRequest) { + return func(r *IndicesClearCacheRequest) { + r.Index = v + } +} + +// WithAllowNoIndices - whether to ignore if a wildcard indices expression resolves into no concrete indices. (this includes `_all` string or when no indices have been specified). +func (f IndicesClearCache) WithAllowNoIndices(v bool) func(*IndicesClearCacheRequest) { + return func(r *IndicesClearCacheRequest) { + r.AllowNoIndices = &v + } +} + +// WithExpandWildcards - whether to expand wildcard expression to concrete indices that are open, closed or both.. +func (f IndicesClearCache) WithExpandWildcards(v string) func(*IndicesClearCacheRequest) { + return func(r *IndicesClearCacheRequest) { + r.ExpandWildcards = v + } +} + +// WithFielddata - clear field data. +func (f IndicesClearCache) WithFielddata(v bool) func(*IndicesClearCacheRequest) { + return func(r *IndicesClearCacheRequest) { + r.Fielddata = &v + } +} + +// WithFields - a list of fields to clear when using the `fielddata` parameter (default: all). +func (f IndicesClearCache) WithFields(v ...string) func(*IndicesClearCacheRequest) { + return func(r *IndicesClearCacheRequest) { + r.Fields = v + } +} + +// WithIgnoreUnavailable - whether specified concrete indices should be ignored when unavailable (missing or closed). +func (f IndicesClearCache) WithIgnoreUnavailable(v bool) func(*IndicesClearCacheRequest) { + return func(r *IndicesClearCacheRequest) { + r.IgnoreUnavailable = &v + } +} + +// WithQuery - clear query caches. +func (f IndicesClearCache) WithQuery(v bool) func(*IndicesClearCacheRequest) { + return func(r *IndicesClearCacheRequest) { + r.Query = &v + } +} + +// WithRequest - clear request cache. +func (f IndicesClearCache) WithRequest(v bool) func(*IndicesClearCacheRequest) { + return func(r *IndicesClearCacheRequest) { + r.Request = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesClearCache) WithPretty() func(*IndicesClearCacheRequest) { + return func(r *IndicesClearCacheRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesClearCache) WithHuman() func(*IndicesClearCacheRequest) { + return func(r *IndicesClearCacheRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesClearCache) WithErrorTrace() func(*IndicesClearCacheRequest) { + return func(r *IndicesClearCacheRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesClearCache) WithFilterPath(v ...string) func(*IndicesClearCacheRequest) { + return func(r *IndicesClearCacheRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesClearCache) WithHeader(h map[string]string) func(*IndicesClearCacheRequest) { + return func(r *IndicesClearCacheRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesClearCache) WithOpaqueID(s string) func(*IndicesClearCacheRequest) { + return func(r *IndicesClearCacheRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.clone.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.clone.go new file mode 100644 index 00000000..b773cf95 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.clone.go @@ -0,0 +1,247 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" + "time" +) + +func newIndicesCloneFunc(t Transport) IndicesClone { + return func(index string, target string, o ...func(*IndicesCloneRequest)) (*Response, error) { + var r = IndicesCloneRequest{Index: index, Target: target} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesClone clones an index +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-clone-index.html. +type IndicesClone func(index string, target string, o ...func(*IndicesCloneRequest)) (*Response, error) + +// IndicesCloneRequest configures the Indices Clone API request. +type IndicesCloneRequest struct { + Index string + + Body io.Reader + + Target string + + MasterTimeout time.Duration + Timeout time.Duration + WaitForActiveShards string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesCloneRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(1 + len(r.Index) + 1 + len("_clone") + 1 + len(r.Target)) + path.WriteString("/") + path.WriteString(r.Index) + path.WriteString("/") + path.WriteString("_clone") + path.WriteString("/") + path.WriteString(r.Target) + + params = make(map[string]string) + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.WaitForActiveShards != "" { + params["wait_for_active_shards"] = r.WaitForActiveShards + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesClone) WithContext(v context.Context) func(*IndicesCloneRequest) { + return func(r *IndicesCloneRequest) { + r.ctx = v + } +} + +// WithBody - The configuration for the target index (`settings` and `aliases`). +func (f IndicesClone) WithBody(v io.Reader) func(*IndicesCloneRequest) { + return func(r *IndicesCloneRequest) { + r.Body = v + } +} + +// WithMasterTimeout - specify timeout for connection to master. +func (f IndicesClone) WithMasterTimeout(v time.Duration) func(*IndicesCloneRequest) { + return func(r *IndicesCloneRequest) { + r.MasterTimeout = v + } +} + +// WithTimeout - explicit operation timeout. +func (f IndicesClone) WithTimeout(v time.Duration) func(*IndicesCloneRequest) { + return func(r *IndicesCloneRequest) { + r.Timeout = v + } +} + +// WithWaitForActiveShards - set the number of active shards to wait for on the cloned index before the operation returns.. +func (f IndicesClone) WithWaitForActiveShards(v string) func(*IndicesCloneRequest) { + return func(r *IndicesCloneRequest) { + r.WaitForActiveShards = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesClone) WithPretty() func(*IndicesCloneRequest) { + return func(r *IndicesCloneRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesClone) WithHuman() func(*IndicesCloneRequest) { + return func(r *IndicesCloneRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesClone) WithErrorTrace() func(*IndicesCloneRequest) { + return func(r *IndicesCloneRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesClone) WithFilterPath(v ...string) func(*IndicesCloneRequest) { + return func(r *IndicesCloneRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesClone) WithHeader(h map[string]string) func(*IndicesCloneRequest) { + return func(r *IndicesCloneRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesClone) WithOpaqueID(s string) func(*IndicesCloneRequest) { + return func(r *IndicesCloneRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.close.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.close.go new file mode 100644 index 00000000..f7c79449 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.close.go @@ -0,0 +1,271 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "errors" + "net/http" + "strconv" + "strings" + "time" +) + +func newIndicesCloseFunc(t Transport) IndicesClose { + return func(index []string, o ...func(*IndicesCloseRequest)) (*Response, error) { + var r = IndicesCloseRequest{Index: index} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesClose closes an index. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-open-close.html. +type IndicesClose func(index []string, o ...func(*IndicesCloseRequest)) (*Response, error) + +// IndicesCloseRequest configures the Indices Close API request. +type IndicesCloseRequest struct { + Index []string + + AllowNoIndices *bool + ExpandWildcards string + IgnoreUnavailable *bool + MasterTimeout time.Duration + Timeout time.Duration + WaitForActiveShards string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesCloseRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + if len(r.Index) == 0 { + return nil, errors.New("index is required and cannot be nil or empty") + } + + path.Grow(1 + len(strings.Join(r.Index, ",")) + 1 + len("_close")) + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + path.WriteString("/") + path.WriteString("_close") + + params = make(map[string]string) + + if r.AllowNoIndices != nil { + params["allow_no_indices"] = strconv.FormatBool(*r.AllowNoIndices) + } + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if r.IgnoreUnavailable != nil { + params["ignore_unavailable"] = strconv.FormatBool(*r.IgnoreUnavailable) + } + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.WaitForActiveShards != "" { + params["wait_for_active_shards"] = r.WaitForActiveShards + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesClose) WithContext(v context.Context) func(*IndicesCloseRequest) { + return func(r *IndicesCloseRequest) { + r.ctx = v + } +} + +// WithAllowNoIndices - whether to ignore if a wildcard indices expression resolves into no concrete indices. (this includes `_all` string or when no indices have been specified). +func (f IndicesClose) WithAllowNoIndices(v bool) func(*IndicesCloseRequest) { + return func(r *IndicesCloseRequest) { + r.AllowNoIndices = &v + } +} + +// WithExpandWildcards - whether to expand wildcard expression to concrete indices that are open, closed or both.. +func (f IndicesClose) WithExpandWildcards(v string) func(*IndicesCloseRequest) { + return func(r *IndicesCloseRequest) { + r.ExpandWildcards = v + } +} + +// WithIgnoreUnavailable - whether specified concrete indices should be ignored when unavailable (missing or closed). +func (f IndicesClose) WithIgnoreUnavailable(v bool) func(*IndicesCloseRequest) { + return func(r *IndicesCloseRequest) { + r.IgnoreUnavailable = &v + } +} + +// WithMasterTimeout - specify timeout for connection to master. +func (f IndicesClose) WithMasterTimeout(v time.Duration) func(*IndicesCloseRequest) { + return func(r *IndicesCloseRequest) { + r.MasterTimeout = v + } +} + +// WithTimeout - explicit operation timeout. +func (f IndicesClose) WithTimeout(v time.Duration) func(*IndicesCloseRequest) { + return func(r *IndicesCloseRequest) { + r.Timeout = v + } +} + +// WithWaitForActiveShards - sets the number of active shards to wait for before the operation returns. set to `index-setting` to wait according to the index setting `index.write.wait_for_active_shards`, or `all` to wait for all shards, or an integer. defaults to `0`.. +func (f IndicesClose) WithWaitForActiveShards(v string) func(*IndicesCloseRequest) { + return func(r *IndicesCloseRequest) { + r.WaitForActiveShards = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesClose) WithPretty() func(*IndicesCloseRequest) { + return func(r *IndicesCloseRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesClose) WithHuman() func(*IndicesCloseRequest) { + return func(r *IndicesCloseRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesClose) WithErrorTrace() func(*IndicesCloseRequest) { + return func(r *IndicesCloseRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesClose) WithFilterPath(v ...string) func(*IndicesCloseRequest) { + return func(r *IndicesCloseRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesClose) WithHeader(h map[string]string) func(*IndicesCloseRequest) { + return func(r *IndicesCloseRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesClose) WithOpaqueID(s string) func(*IndicesCloseRequest) { + return func(r *IndicesCloseRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.create.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.create.go new file mode 100644 index 00000000..0c9b8c12 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.create.go @@ -0,0 +1,254 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" + "time" +) + +func newIndicesCreateFunc(t Transport) IndicesCreate { + return func(index string, o ...func(*IndicesCreateRequest)) (*Response, error) { + var r = IndicesCreateRequest{Index: index} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesCreate creates an index with optional settings and mappings. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-create-index.html. +type IndicesCreate func(index string, o ...func(*IndicesCreateRequest)) (*Response, error) + +// IndicesCreateRequest configures the Indices Create API request. +type IndicesCreateRequest struct { + Index string + + Body io.Reader + + IncludeTypeName *bool + MasterTimeout time.Duration + Timeout time.Duration + WaitForActiveShards string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesCreateRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(1 + len(r.Index)) + path.WriteString("/") + path.WriteString(r.Index) + + params = make(map[string]string) + + if r.IncludeTypeName != nil { + params["include_type_name"] = strconv.FormatBool(*r.IncludeTypeName) + } + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.WaitForActiveShards != "" { + params["wait_for_active_shards"] = r.WaitForActiveShards + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesCreate) WithContext(v context.Context) func(*IndicesCreateRequest) { + return func(r *IndicesCreateRequest) { + r.ctx = v + } +} + +// WithBody - The configuration for the index (`settings` and `mappings`). +func (f IndicesCreate) WithBody(v io.Reader) func(*IndicesCreateRequest) { + return func(r *IndicesCreateRequest) { + r.Body = v + } +} + +// WithIncludeTypeName - whether a type should be expected in the body of the mappings.. +func (f IndicesCreate) WithIncludeTypeName(v bool) func(*IndicesCreateRequest) { + return func(r *IndicesCreateRequest) { + r.IncludeTypeName = &v + } +} + +// WithMasterTimeout - specify timeout for connection to master. +func (f IndicesCreate) WithMasterTimeout(v time.Duration) func(*IndicesCreateRequest) { + return func(r *IndicesCreateRequest) { + r.MasterTimeout = v + } +} + +// WithTimeout - explicit operation timeout. +func (f IndicesCreate) WithTimeout(v time.Duration) func(*IndicesCreateRequest) { + return func(r *IndicesCreateRequest) { + r.Timeout = v + } +} + +// WithWaitForActiveShards - set the number of active shards to wait for before the operation returns.. +func (f IndicesCreate) WithWaitForActiveShards(v string) func(*IndicesCreateRequest) { + return func(r *IndicesCreateRequest) { + r.WaitForActiveShards = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesCreate) WithPretty() func(*IndicesCreateRequest) { + return func(r *IndicesCreateRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesCreate) WithHuman() func(*IndicesCreateRequest) { + return func(r *IndicesCreateRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesCreate) WithErrorTrace() func(*IndicesCreateRequest) { + return func(r *IndicesCreateRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesCreate) WithFilterPath(v ...string) func(*IndicesCreateRequest) { + return func(r *IndicesCreateRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesCreate) WithHeader(h map[string]string) func(*IndicesCreateRequest) { + return func(r *IndicesCreateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesCreate) WithOpaqueID(s string) func(*IndicesCreateRequest) { + return func(r *IndicesCreateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.delete.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.delete.go new file mode 100644 index 00000000..39f95aa6 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.delete.go @@ -0,0 +1,257 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "errors" + "net/http" + "strconv" + "strings" + "time" +) + +func newIndicesDeleteFunc(t Transport) IndicesDelete { + return func(index []string, o ...func(*IndicesDeleteRequest)) (*Response, error) { + var r = IndicesDeleteRequest{Index: index} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesDelete deletes an index. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-delete-index.html. +type IndicesDelete func(index []string, o ...func(*IndicesDeleteRequest)) (*Response, error) + +// IndicesDeleteRequest configures the Indices Delete API request. +type IndicesDeleteRequest struct { + Index []string + + AllowNoIndices *bool + ExpandWildcards string + IgnoreUnavailable *bool + MasterTimeout time.Duration + Timeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesDeleteRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + if len(r.Index) == 0 { + return nil, errors.New("index is required and cannot be nil or empty") + } + + path.Grow(1 + len(strings.Join(r.Index, ","))) + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + + params = make(map[string]string) + + if r.AllowNoIndices != nil { + params["allow_no_indices"] = strconv.FormatBool(*r.AllowNoIndices) + } + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if r.IgnoreUnavailable != nil { + params["ignore_unavailable"] = strconv.FormatBool(*r.IgnoreUnavailable) + } + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesDelete) WithContext(v context.Context) func(*IndicesDeleteRequest) { + return func(r *IndicesDeleteRequest) { + r.ctx = v + } +} + +// WithAllowNoIndices - ignore if a wildcard expression resolves to no concrete indices (default: false). +func (f IndicesDelete) WithAllowNoIndices(v bool) func(*IndicesDeleteRequest) { + return func(r *IndicesDeleteRequest) { + r.AllowNoIndices = &v + } +} + +// WithExpandWildcards - whether wildcard expressions should get expanded to open, closed, or hidden indices. +func (f IndicesDelete) WithExpandWildcards(v string) func(*IndicesDeleteRequest) { + return func(r *IndicesDeleteRequest) { + r.ExpandWildcards = v + } +} + +// WithIgnoreUnavailable - ignore unavailable indexes (default: false). +func (f IndicesDelete) WithIgnoreUnavailable(v bool) func(*IndicesDeleteRequest) { + return func(r *IndicesDeleteRequest) { + r.IgnoreUnavailable = &v + } +} + +// WithMasterTimeout - specify timeout for connection to master. +func (f IndicesDelete) WithMasterTimeout(v time.Duration) func(*IndicesDeleteRequest) { + return func(r *IndicesDeleteRequest) { + r.MasterTimeout = v + } +} + +// WithTimeout - explicit operation timeout. +func (f IndicesDelete) WithTimeout(v time.Duration) func(*IndicesDeleteRequest) { + return func(r *IndicesDeleteRequest) { + r.Timeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesDelete) WithPretty() func(*IndicesDeleteRequest) { + return func(r *IndicesDeleteRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesDelete) WithHuman() func(*IndicesDeleteRequest) { + return func(r *IndicesDeleteRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesDelete) WithErrorTrace() func(*IndicesDeleteRequest) { + return func(r *IndicesDeleteRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesDelete) WithFilterPath(v ...string) func(*IndicesDeleteRequest) { + return func(r *IndicesDeleteRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesDelete) WithHeader(h map[string]string) func(*IndicesDeleteRequest) { + return func(r *IndicesDeleteRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesDelete) WithOpaqueID(s string) func(*IndicesDeleteRequest) { + return func(r *IndicesDeleteRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.delete_alias.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.delete_alias.go new file mode 100644 index 00000000..8ae182ee --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.delete_alias.go @@ -0,0 +1,229 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "errors" + "net/http" + "strings" + "time" +) + +func newIndicesDeleteAliasFunc(t Transport) IndicesDeleteAlias { + return func(index []string, name []string, o ...func(*IndicesDeleteAliasRequest)) (*Response, error) { + var r = IndicesDeleteAliasRequest{Index: index, Name: name} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesDeleteAlias deletes an alias. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html. +type IndicesDeleteAlias func(index []string, name []string, o ...func(*IndicesDeleteAliasRequest)) (*Response, error) + +// IndicesDeleteAliasRequest configures the Indices Delete Alias API request. +type IndicesDeleteAliasRequest struct { + Index []string + + Name []string + + MasterTimeout time.Duration + Timeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesDeleteAliasRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + if len(r.Index) == 0 { + return nil, errors.New("index is required and cannot be nil or empty") + } + if len(r.Name) == 0 { + return nil, errors.New("name is required and cannot be nil or empty") + } + + path.Grow(1 + len(strings.Join(r.Index, ",")) + 1 + len("_aliases") + 1 + len(strings.Join(r.Name, ","))) + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + path.WriteString("/") + path.WriteString("_aliases") + path.WriteString("/") + path.WriteString(strings.Join(r.Name, ",")) + + params = make(map[string]string) + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesDeleteAlias) WithContext(v context.Context) func(*IndicesDeleteAliasRequest) { + return func(r *IndicesDeleteAliasRequest) { + r.ctx = v + } +} + +// WithMasterTimeout - specify timeout for connection to master. +func (f IndicesDeleteAlias) WithMasterTimeout(v time.Duration) func(*IndicesDeleteAliasRequest) { + return func(r *IndicesDeleteAliasRequest) { + r.MasterTimeout = v + } +} + +// WithTimeout - explicit timestamp for the document. +func (f IndicesDeleteAlias) WithTimeout(v time.Duration) func(*IndicesDeleteAliasRequest) { + return func(r *IndicesDeleteAliasRequest) { + r.Timeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesDeleteAlias) WithPretty() func(*IndicesDeleteAliasRequest) { + return func(r *IndicesDeleteAliasRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesDeleteAlias) WithHuman() func(*IndicesDeleteAliasRequest) { + return func(r *IndicesDeleteAliasRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesDeleteAlias) WithErrorTrace() func(*IndicesDeleteAliasRequest) { + return func(r *IndicesDeleteAliasRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesDeleteAlias) WithFilterPath(v ...string) func(*IndicesDeleteAliasRequest) { + return func(r *IndicesDeleteAliasRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesDeleteAlias) WithHeader(h map[string]string) func(*IndicesDeleteAliasRequest) { + return func(r *IndicesDeleteAliasRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesDeleteAlias) WithOpaqueID(s string) func(*IndicesDeleteAliasRequest) { + return func(r *IndicesDeleteAliasRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.delete_index_template.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.delete_index_template.go new file mode 100644 index 00000000..d83e5b8e --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.delete_index_template.go @@ -0,0 +1,217 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" + "time" +) + +func newIndicesDeleteIndexTemplateFunc(t Transport) IndicesDeleteIndexTemplate { + return func(name string, o ...func(*IndicesDeleteIndexTemplateRequest)) (*Response, error) { + var r = IndicesDeleteIndexTemplateRequest{Name: name} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesDeleteIndexTemplate deletes an index template. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html. +type IndicesDeleteIndexTemplate func(name string, o ...func(*IndicesDeleteIndexTemplateRequest)) (*Response, error) + +// IndicesDeleteIndexTemplateRequest configures the Indices Delete Index Template API request. +type IndicesDeleteIndexTemplateRequest struct { + Name string + + MasterTimeout time.Duration + Timeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesDeleteIndexTemplateRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + path.Grow(1 + len("_index_template") + 1 + len(r.Name)) + path.WriteString("/") + path.WriteString("_index_template") + path.WriteString("/") + path.WriteString(r.Name) + + params = make(map[string]string) + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesDeleteIndexTemplate) WithContext(v context.Context) func(*IndicesDeleteIndexTemplateRequest) { + return func(r *IndicesDeleteIndexTemplateRequest) { + r.ctx = v + } +} + +// WithMasterTimeout - specify timeout for connection to master. +func (f IndicesDeleteIndexTemplate) WithMasterTimeout(v time.Duration) func(*IndicesDeleteIndexTemplateRequest) { + return func(r *IndicesDeleteIndexTemplateRequest) { + r.MasterTimeout = v + } +} + +// WithTimeout - explicit operation timeout. +func (f IndicesDeleteIndexTemplate) WithTimeout(v time.Duration) func(*IndicesDeleteIndexTemplateRequest) { + return func(r *IndicesDeleteIndexTemplateRequest) { + r.Timeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesDeleteIndexTemplate) WithPretty() func(*IndicesDeleteIndexTemplateRequest) { + return func(r *IndicesDeleteIndexTemplateRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesDeleteIndexTemplate) WithHuman() func(*IndicesDeleteIndexTemplateRequest) { + return func(r *IndicesDeleteIndexTemplateRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesDeleteIndexTemplate) WithErrorTrace() func(*IndicesDeleteIndexTemplateRequest) { + return func(r *IndicesDeleteIndexTemplateRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesDeleteIndexTemplate) WithFilterPath(v ...string) func(*IndicesDeleteIndexTemplateRequest) { + return func(r *IndicesDeleteIndexTemplateRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesDeleteIndexTemplate) WithHeader(h map[string]string) func(*IndicesDeleteIndexTemplateRequest) { + return func(r *IndicesDeleteIndexTemplateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesDeleteIndexTemplate) WithOpaqueID(s string) func(*IndicesDeleteIndexTemplateRequest) { + return func(r *IndicesDeleteIndexTemplateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.delete_template.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.delete_template.go new file mode 100644 index 00000000..bf6d5d93 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.delete_template.go @@ -0,0 +1,217 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" + "time" +) + +func newIndicesDeleteTemplateFunc(t Transport) IndicesDeleteTemplate { + return func(name string, o ...func(*IndicesDeleteTemplateRequest)) (*Response, error) { + var r = IndicesDeleteTemplateRequest{Name: name} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesDeleteTemplate deletes an index template. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html. +type IndicesDeleteTemplate func(name string, o ...func(*IndicesDeleteTemplateRequest)) (*Response, error) + +// IndicesDeleteTemplateRequest configures the Indices Delete Template API request. +type IndicesDeleteTemplateRequest struct { + Name string + + MasterTimeout time.Duration + Timeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesDeleteTemplateRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + path.Grow(1 + len("_template") + 1 + len(r.Name)) + path.WriteString("/") + path.WriteString("_template") + path.WriteString("/") + path.WriteString(r.Name) + + params = make(map[string]string) + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesDeleteTemplate) WithContext(v context.Context) func(*IndicesDeleteTemplateRequest) { + return func(r *IndicesDeleteTemplateRequest) { + r.ctx = v + } +} + +// WithMasterTimeout - specify timeout for connection to master. +func (f IndicesDeleteTemplate) WithMasterTimeout(v time.Duration) func(*IndicesDeleteTemplateRequest) { + return func(r *IndicesDeleteTemplateRequest) { + r.MasterTimeout = v + } +} + +// WithTimeout - explicit operation timeout. +func (f IndicesDeleteTemplate) WithTimeout(v time.Duration) func(*IndicesDeleteTemplateRequest) { + return func(r *IndicesDeleteTemplateRequest) { + r.Timeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesDeleteTemplate) WithPretty() func(*IndicesDeleteTemplateRequest) { + return func(r *IndicesDeleteTemplateRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesDeleteTemplate) WithHuman() func(*IndicesDeleteTemplateRequest) { + return func(r *IndicesDeleteTemplateRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesDeleteTemplate) WithErrorTrace() func(*IndicesDeleteTemplateRequest) { + return func(r *IndicesDeleteTemplateRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesDeleteTemplate) WithFilterPath(v ...string) func(*IndicesDeleteTemplateRequest) { + return func(r *IndicesDeleteTemplateRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesDeleteTemplate) WithHeader(h map[string]string) func(*IndicesDeleteTemplateRequest) { + return func(r *IndicesDeleteTemplateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesDeleteTemplate) WithOpaqueID(s string) func(*IndicesDeleteTemplateRequest) { + return func(r *IndicesDeleteTemplateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.disk_usage.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.disk_usage.go new file mode 100644 index 00000000..3443a7f6 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.disk_usage.go @@ -0,0 +1,255 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newIndicesDiskUsageFunc(t Transport) IndicesDiskUsage { + return func(index string, o ...func(*IndicesDiskUsageRequest)) (*Response, error) { + var r = IndicesDiskUsageRequest{Index: index} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesDiskUsage analyzes the disk usage of each field of an index or data stream +// +// This API is experimental. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-disk-usage.html. +type IndicesDiskUsage func(index string, o ...func(*IndicesDiskUsageRequest)) (*Response, error) + +// IndicesDiskUsageRequest configures the Indices Disk Usage API request. +type IndicesDiskUsageRequest struct { + Index string + + AllowNoIndices *bool + ExpandWildcards string + Flush *bool + IgnoreUnavailable *bool + RunExpensiveTasks *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesDiskUsageRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len(r.Index) + 1 + len("_disk_usage")) + path.WriteString("/") + path.WriteString(r.Index) + path.WriteString("/") + path.WriteString("_disk_usage") + + params = make(map[string]string) + + if r.AllowNoIndices != nil { + params["allow_no_indices"] = strconv.FormatBool(*r.AllowNoIndices) + } + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if r.Flush != nil { + params["flush"] = strconv.FormatBool(*r.Flush) + } + + if r.IgnoreUnavailable != nil { + params["ignore_unavailable"] = strconv.FormatBool(*r.IgnoreUnavailable) + } + + if r.RunExpensiveTasks != nil { + params["run_expensive_tasks"] = strconv.FormatBool(*r.RunExpensiveTasks) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesDiskUsage) WithContext(v context.Context) func(*IndicesDiskUsageRequest) { + return func(r *IndicesDiskUsageRequest) { + r.ctx = v + } +} + +// WithAllowNoIndices - whether to ignore if a wildcard indices expression resolves into no concrete indices. (this includes `_all` string or when no indices have been specified). +func (f IndicesDiskUsage) WithAllowNoIndices(v bool) func(*IndicesDiskUsageRequest) { + return func(r *IndicesDiskUsageRequest) { + r.AllowNoIndices = &v + } +} + +// WithExpandWildcards - whether to expand wildcard expression to concrete indices that are open, closed or both.. +func (f IndicesDiskUsage) WithExpandWildcards(v string) func(*IndicesDiskUsageRequest) { + return func(r *IndicesDiskUsageRequest) { + r.ExpandWildcards = v + } +} + +// WithFlush - whether flush or not before analyzing the index disk usage. defaults to true. +func (f IndicesDiskUsage) WithFlush(v bool) func(*IndicesDiskUsageRequest) { + return func(r *IndicesDiskUsageRequest) { + r.Flush = &v + } +} + +// WithIgnoreUnavailable - whether specified concrete indices should be ignored when unavailable (missing or closed). +func (f IndicesDiskUsage) WithIgnoreUnavailable(v bool) func(*IndicesDiskUsageRequest) { + return func(r *IndicesDiskUsageRequest) { + r.IgnoreUnavailable = &v + } +} + +// WithRunExpensiveTasks - must be set to [true] in order for the task to be performed. defaults to false.. +func (f IndicesDiskUsage) WithRunExpensiveTasks(v bool) func(*IndicesDiskUsageRequest) { + return func(r *IndicesDiskUsageRequest) { + r.RunExpensiveTasks = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesDiskUsage) WithPretty() func(*IndicesDiskUsageRequest) { + return func(r *IndicesDiskUsageRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesDiskUsage) WithHuman() func(*IndicesDiskUsageRequest) { + return func(r *IndicesDiskUsageRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesDiskUsage) WithErrorTrace() func(*IndicesDiskUsageRequest) { + return func(r *IndicesDiskUsageRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesDiskUsage) WithFilterPath(v ...string) func(*IndicesDiskUsageRequest) { + return func(r *IndicesDiskUsageRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesDiskUsage) WithHeader(h map[string]string) func(*IndicesDiskUsageRequest) { + return func(r *IndicesDiskUsageRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesDiskUsage) WithOpaqueID(s string) func(*IndicesDiskUsageRequest) { + return func(r *IndicesDiskUsageRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.exists.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.exists.go new file mode 100644 index 00000000..068f2e57 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.exists.go @@ -0,0 +1,268 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "errors" + "net/http" + "strconv" + "strings" +) + +func newIndicesExistsFunc(t Transport) IndicesExists { + return func(index []string, o ...func(*IndicesExistsRequest)) (*Response, error) { + var r = IndicesExistsRequest{Index: index} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesExists returns information about whether a particular index exists. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-exists.html. +type IndicesExists func(index []string, o ...func(*IndicesExistsRequest)) (*Response, error) + +// IndicesExistsRequest configures the Indices Exists API request. +type IndicesExistsRequest struct { + Index []string + + AllowNoIndices *bool + ExpandWildcards string + FlatSettings *bool + IgnoreUnavailable *bool + IncludeDefaults *bool + Local *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesExistsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "HEAD" + + if len(r.Index) == 0 { + return nil, errors.New("index is required and cannot be nil or empty") + } + + path.Grow(1 + len(strings.Join(r.Index, ","))) + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + + params = make(map[string]string) + + if r.AllowNoIndices != nil { + params["allow_no_indices"] = strconv.FormatBool(*r.AllowNoIndices) + } + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if r.FlatSettings != nil { + params["flat_settings"] = strconv.FormatBool(*r.FlatSettings) + } + + if r.IgnoreUnavailable != nil { + params["ignore_unavailable"] = strconv.FormatBool(*r.IgnoreUnavailable) + } + + if r.IncludeDefaults != nil { + params["include_defaults"] = strconv.FormatBool(*r.IncludeDefaults) + } + + if r.Local != nil { + params["local"] = strconv.FormatBool(*r.Local) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesExists) WithContext(v context.Context) func(*IndicesExistsRequest) { + return func(r *IndicesExistsRequest) { + r.ctx = v + } +} + +// WithAllowNoIndices - ignore if a wildcard expression resolves to no concrete indices (default: false). +func (f IndicesExists) WithAllowNoIndices(v bool) func(*IndicesExistsRequest) { + return func(r *IndicesExistsRequest) { + r.AllowNoIndices = &v + } +} + +// WithExpandWildcards - whether wildcard expressions should get expanded to open or closed indices (default: open). +func (f IndicesExists) WithExpandWildcards(v string) func(*IndicesExistsRequest) { + return func(r *IndicesExistsRequest) { + r.ExpandWildcards = v + } +} + +// WithFlatSettings - return settings in flat format (default: false). +func (f IndicesExists) WithFlatSettings(v bool) func(*IndicesExistsRequest) { + return func(r *IndicesExistsRequest) { + r.FlatSettings = &v + } +} + +// WithIgnoreUnavailable - ignore unavailable indexes (default: false). +func (f IndicesExists) WithIgnoreUnavailable(v bool) func(*IndicesExistsRequest) { + return func(r *IndicesExistsRequest) { + r.IgnoreUnavailable = &v + } +} + +// WithIncludeDefaults - whether to return all default setting for each of the indices.. +func (f IndicesExists) WithIncludeDefaults(v bool) func(*IndicesExistsRequest) { + return func(r *IndicesExistsRequest) { + r.IncludeDefaults = &v + } +} + +// WithLocal - return local information, do not retrieve the state from master node (default: false). +func (f IndicesExists) WithLocal(v bool) func(*IndicesExistsRequest) { + return func(r *IndicesExistsRequest) { + r.Local = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesExists) WithPretty() func(*IndicesExistsRequest) { + return func(r *IndicesExistsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesExists) WithHuman() func(*IndicesExistsRequest) { + return func(r *IndicesExistsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesExists) WithErrorTrace() func(*IndicesExistsRequest) { + return func(r *IndicesExistsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesExists) WithFilterPath(v ...string) func(*IndicesExistsRequest) { + return func(r *IndicesExistsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesExists) WithHeader(h map[string]string) func(*IndicesExistsRequest) { + return func(r *IndicesExistsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesExists) WithOpaqueID(s string) func(*IndicesExistsRequest) { + return func(r *IndicesExistsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.exists_alias.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.exists_alias.go new file mode 100644 index 00000000..ad15a223 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.exists_alias.go @@ -0,0 +1,259 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "errors" + "net/http" + "strconv" + "strings" +) + +func newIndicesExistsAliasFunc(t Transport) IndicesExistsAlias { + return func(name []string, o ...func(*IndicesExistsAliasRequest)) (*Response, error) { + var r = IndicesExistsAliasRequest{Name: name} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesExistsAlias returns information about whether a particular alias exists. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html. +type IndicesExistsAlias func(name []string, o ...func(*IndicesExistsAliasRequest)) (*Response, error) + +// IndicesExistsAliasRequest configures the Indices Exists Alias API request. +type IndicesExistsAliasRequest struct { + Index []string + + Name []string + + AllowNoIndices *bool + ExpandWildcards string + IgnoreUnavailable *bool + Local *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesExistsAliasRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "HEAD" + + if len(r.Name) == 0 { + return nil, errors.New("name is required and cannot be nil or empty") + } + + path.Grow(1 + len(strings.Join(r.Index, ",")) + 1 + len("_alias") + 1 + len(strings.Join(r.Name, ","))) + if len(r.Index) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + } + path.WriteString("/") + path.WriteString("_alias") + path.WriteString("/") + path.WriteString(strings.Join(r.Name, ",")) + + params = make(map[string]string) + + if r.AllowNoIndices != nil { + params["allow_no_indices"] = strconv.FormatBool(*r.AllowNoIndices) + } + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if r.IgnoreUnavailable != nil { + params["ignore_unavailable"] = strconv.FormatBool(*r.IgnoreUnavailable) + } + + if r.Local != nil { + params["local"] = strconv.FormatBool(*r.Local) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesExistsAlias) WithContext(v context.Context) func(*IndicesExistsAliasRequest) { + return func(r *IndicesExistsAliasRequest) { + r.ctx = v + } +} + +// WithIndex - a list of index names to filter aliases. +func (f IndicesExistsAlias) WithIndex(v ...string) func(*IndicesExistsAliasRequest) { + return func(r *IndicesExistsAliasRequest) { + r.Index = v + } +} + +// WithAllowNoIndices - whether to ignore if a wildcard indices expression resolves into no concrete indices. (this includes `_all` string or when no indices have been specified). +func (f IndicesExistsAlias) WithAllowNoIndices(v bool) func(*IndicesExistsAliasRequest) { + return func(r *IndicesExistsAliasRequest) { + r.AllowNoIndices = &v + } +} + +// WithExpandWildcards - whether to expand wildcard expression to concrete indices that are open, closed or both.. +func (f IndicesExistsAlias) WithExpandWildcards(v string) func(*IndicesExistsAliasRequest) { + return func(r *IndicesExistsAliasRequest) { + r.ExpandWildcards = v + } +} + +// WithIgnoreUnavailable - whether specified concrete indices should be ignored when unavailable (missing or closed). +func (f IndicesExistsAlias) WithIgnoreUnavailable(v bool) func(*IndicesExistsAliasRequest) { + return func(r *IndicesExistsAliasRequest) { + r.IgnoreUnavailable = &v + } +} + +// WithLocal - return local information, do not retrieve the state from master node (default: false). +func (f IndicesExistsAlias) WithLocal(v bool) func(*IndicesExistsAliasRequest) { + return func(r *IndicesExistsAliasRequest) { + r.Local = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesExistsAlias) WithPretty() func(*IndicesExistsAliasRequest) { + return func(r *IndicesExistsAliasRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesExistsAlias) WithHuman() func(*IndicesExistsAliasRequest) { + return func(r *IndicesExistsAliasRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesExistsAlias) WithErrorTrace() func(*IndicesExistsAliasRequest) { + return func(r *IndicesExistsAliasRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesExistsAlias) WithFilterPath(v ...string) func(*IndicesExistsAliasRequest) { + return func(r *IndicesExistsAliasRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesExistsAlias) WithHeader(h map[string]string) func(*IndicesExistsAliasRequest) { + return func(r *IndicesExistsAliasRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesExistsAlias) WithOpaqueID(s string) func(*IndicesExistsAliasRequest) { + return func(r *IndicesExistsAliasRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.exists_index_template.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.exists_index_template.go new file mode 100644 index 00000000..f2c48e01 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.exists_index_template.go @@ -0,0 +1,230 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" + "time" +) + +func newIndicesExistsIndexTemplateFunc(t Transport) IndicesExistsIndexTemplate { + return func(name string, o ...func(*IndicesExistsIndexTemplateRequest)) (*Response, error) { + var r = IndicesExistsIndexTemplateRequest{Name: name} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesExistsIndexTemplate returns information about whether a particular index template exists. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html. +type IndicesExistsIndexTemplate func(name string, o ...func(*IndicesExistsIndexTemplateRequest)) (*Response, error) + +// IndicesExistsIndexTemplateRequest configures the Indices Exists Index Template API request. +type IndicesExistsIndexTemplateRequest struct { + Name string + + FlatSettings *bool + Local *bool + MasterTimeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesExistsIndexTemplateRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "HEAD" + + path.Grow(1 + len("_index_template") + 1 + len(r.Name)) + path.WriteString("/") + path.WriteString("_index_template") + path.WriteString("/") + path.WriteString(r.Name) + + params = make(map[string]string) + + if r.FlatSettings != nil { + params["flat_settings"] = strconv.FormatBool(*r.FlatSettings) + } + + if r.Local != nil { + params["local"] = strconv.FormatBool(*r.Local) + } + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesExistsIndexTemplate) WithContext(v context.Context) func(*IndicesExistsIndexTemplateRequest) { + return func(r *IndicesExistsIndexTemplateRequest) { + r.ctx = v + } +} + +// WithFlatSettings - return settings in flat format (default: false). +func (f IndicesExistsIndexTemplate) WithFlatSettings(v bool) func(*IndicesExistsIndexTemplateRequest) { + return func(r *IndicesExistsIndexTemplateRequest) { + r.FlatSettings = &v + } +} + +// WithLocal - return local information, do not retrieve the state from master node (default: false). +func (f IndicesExistsIndexTemplate) WithLocal(v bool) func(*IndicesExistsIndexTemplateRequest) { + return func(r *IndicesExistsIndexTemplateRequest) { + r.Local = &v + } +} + +// WithMasterTimeout - explicit operation timeout for connection to master node. +func (f IndicesExistsIndexTemplate) WithMasterTimeout(v time.Duration) func(*IndicesExistsIndexTemplateRequest) { + return func(r *IndicesExistsIndexTemplateRequest) { + r.MasterTimeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesExistsIndexTemplate) WithPretty() func(*IndicesExistsIndexTemplateRequest) { + return func(r *IndicesExistsIndexTemplateRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesExistsIndexTemplate) WithHuman() func(*IndicesExistsIndexTemplateRequest) { + return func(r *IndicesExistsIndexTemplateRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesExistsIndexTemplate) WithErrorTrace() func(*IndicesExistsIndexTemplateRequest) { + return func(r *IndicesExistsIndexTemplateRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesExistsIndexTemplate) WithFilterPath(v ...string) func(*IndicesExistsIndexTemplateRequest) { + return func(r *IndicesExistsIndexTemplateRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesExistsIndexTemplate) WithHeader(h map[string]string) func(*IndicesExistsIndexTemplateRequest) { + return func(r *IndicesExistsIndexTemplateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesExistsIndexTemplate) WithOpaqueID(s string) func(*IndicesExistsIndexTemplateRequest) { + return func(r *IndicesExistsIndexTemplateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.exists_template.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.exists_template.go new file mode 100644 index 00000000..46b16348 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.exists_template.go @@ -0,0 +1,235 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "errors" + "net/http" + "strconv" + "strings" + "time" +) + +func newIndicesExistsTemplateFunc(t Transport) IndicesExistsTemplate { + return func(name []string, o ...func(*IndicesExistsTemplateRequest)) (*Response, error) { + var r = IndicesExistsTemplateRequest{Name: name} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesExistsTemplate returns information about whether a particular index template exists. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html. +type IndicesExistsTemplate func(name []string, o ...func(*IndicesExistsTemplateRequest)) (*Response, error) + +// IndicesExistsTemplateRequest configures the Indices Exists Template API request. +type IndicesExistsTemplateRequest struct { + Name []string + + FlatSettings *bool + Local *bool + MasterTimeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesExistsTemplateRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "HEAD" + + if len(r.Name) == 0 { + return nil, errors.New("name is required and cannot be nil or empty") + } + + path.Grow(1 + len("_template") + 1 + len(strings.Join(r.Name, ","))) + path.WriteString("/") + path.WriteString("_template") + path.WriteString("/") + path.WriteString(strings.Join(r.Name, ",")) + + params = make(map[string]string) + + if r.FlatSettings != nil { + params["flat_settings"] = strconv.FormatBool(*r.FlatSettings) + } + + if r.Local != nil { + params["local"] = strconv.FormatBool(*r.Local) + } + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesExistsTemplate) WithContext(v context.Context) func(*IndicesExistsTemplateRequest) { + return func(r *IndicesExistsTemplateRequest) { + r.ctx = v + } +} + +// WithFlatSettings - return settings in flat format (default: false). +func (f IndicesExistsTemplate) WithFlatSettings(v bool) func(*IndicesExistsTemplateRequest) { + return func(r *IndicesExistsTemplateRequest) { + r.FlatSettings = &v + } +} + +// WithLocal - return local information, do not retrieve the state from master node (default: false). +func (f IndicesExistsTemplate) WithLocal(v bool) func(*IndicesExistsTemplateRequest) { + return func(r *IndicesExistsTemplateRequest) { + r.Local = &v + } +} + +// WithMasterTimeout - explicit operation timeout for connection to master node. +func (f IndicesExistsTemplate) WithMasterTimeout(v time.Duration) func(*IndicesExistsTemplateRequest) { + return func(r *IndicesExistsTemplateRequest) { + r.MasterTimeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesExistsTemplate) WithPretty() func(*IndicesExistsTemplateRequest) { + return func(r *IndicesExistsTemplateRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesExistsTemplate) WithHuman() func(*IndicesExistsTemplateRequest) { + return func(r *IndicesExistsTemplateRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesExistsTemplate) WithErrorTrace() func(*IndicesExistsTemplateRequest) { + return func(r *IndicesExistsTemplateRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesExistsTemplate) WithFilterPath(v ...string) func(*IndicesExistsTemplateRequest) { + return func(r *IndicesExistsTemplateRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesExistsTemplate) WithHeader(h map[string]string) func(*IndicesExistsTemplateRequest) { + return func(r *IndicesExistsTemplateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesExistsTemplate) WithOpaqueID(s string) func(*IndicesExistsTemplateRequest) { + return func(r *IndicesExistsTemplateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.exists_type.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.exists_type.go new file mode 100644 index 00000000..a0ea7006 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.exists_type.go @@ -0,0 +1,259 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "errors" + "net/http" + "strconv" + "strings" +) + +func newIndicesExistsDocumentTypeFunc(t Transport) IndicesExistsDocumentType { + return func(index []string, o ...func(*IndicesExistsDocumentTypeRequest)) (*Response, error) { + var r = IndicesExistsDocumentTypeRequest{Index: index} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesExistsDocumentType returns information about whether a particular document type exists. (DEPRECATED) +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-types-exists.html. +type IndicesExistsDocumentType func(index []string, o ...func(*IndicesExistsDocumentTypeRequest)) (*Response, error) + +// IndicesExistsDocumentTypeRequest configures the Indices Exists Document Type API request. +type IndicesExistsDocumentTypeRequest struct { + Index []string + DocumentType []string + + AllowNoIndices *bool + ExpandWildcards string + IgnoreUnavailable *bool + Local *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesExistsDocumentTypeRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "HEAD" + + if len(r.Index) == 0 { + return nil, errors.New("index is required and cannot be nil or empty") + } + if len(r.DocumentType) == 0 { + return nil, errors.New("type is required and cannot be nil or empty") + } + + path.Grow(1 + len(strings.Join(r.Index, ",")) + 1 + len("_mapping") + 1 + len(strings.Join(r.DocumentType, ","))) + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + path.WriteString("/") + path.WriteString("_mapping") + path.WriteString("/") + path.WriteString(strings.Join(r.DocumentType, ",")) + + params = make(map[string]string) + + if r.AllowNoIndices != nil { + params["allow_no_indices"] = strconv.FormatBool(*r.AllowNoIndices) + } + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if r.IgnoreUnavailable != nil { + params["ignore_unavailable"] = strconv.FormatBool(*r.IgnoreUnavailable) + } + + if r.Local != nil { + params["local"] = strconv.FormatBool(*r.Local) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesExistsDocumentType) WithContext(v context.Context) func(*IndicesExistsDocumentTypeRequest) { + return func(r *IndicesExistsDocumentTypeRequest) { + r.ctx = v + } +} + +// WithDocumentType - a list of document types to check. +func (f IndicesExistsDocumentType) WithDocumentType(v ...string) func(*IndicesExistsDocumentTypeRequest) { + return func(r *IndicesExistsDocumentTypeRequest) { + r.DocumentType = v + } +} + +// WithAllowNoIndices - whether to ignore if a wildcard indices expression resolves into no concrete indices. (this includes `_all` string or when no indices have been specified). +func (f IndicesExistsDocumentType) WithAllowNoIndices(v bool) func(*IndicesExistsDocumentTypeRequest) { + return func(r *IndicesExistsDocumentTypeRequest) { + r.AllowNoIndices = &v + } +} + +// WithExpandWildcards - whether to expand wildcard expression to concrete indices that are open, closed or both.. +func (f IndicesExistsDocumentType) WithExpandWildcards(v string) func(*IndicesExistsDocumentTypeRequest) { + return func(r *IndicesExistsDocumentTypeRequest) { + r.ExpandWildcards = v + } +} + +// WithIgnoreUnavailable - whether specified concrete indices should be ignored when unavailable (missing or closed). +func (f IndicesExistsDocumentType) WithIgnoreUnavailable(v bool) func(*IndicesExistsDocumentTypeRequest) { + return func(r *IndicesExistsDocumentTypeRequest) { + r.IgnoreUnavailable = &v + } +} + +// WithLocal - return local information, do not retrieve the state from master node (default: false). +func (f IndicesExistsDocumentType) WithLocal(v bool) func(*IndicesExistsDocumentTypeRequest) { + return func(r *IndicesExistsDocumentTypeRequest) { + r.Local = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesExistsDocumentType) WithPretty() func(*IndicesExistsDocumentTypeRequest) { + return func(r *IndicesExistsDocumentTypeRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesExistsDocumentType) WithHuman() func(*IndicesExistsDocumentTypeRequest) { + return func(r *IndicesExistsDocumentTypeRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesExistsDocumentType) WithErrorTrace() func(*IndicesExistsDocumentTypeRequest) { + return func(r *IndicesExistsDocumentTypeRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesExistsDocumentType) WithFilterPath(v ...string) func(*IndicesExistsDocumentTypeRequest) { + return func(r *IndicesExistsDocumentTypeRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesExistsDocumentType) WithHeader(h map[string]string) func(*IndicesExistsDocumentTypeRequest) { + return func(r *IndicesExistsDocumentTypeRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesExistsDocumentType) WithOpaqueID(s string) func(*IndicesExistsDocumentTypeRequest) { + return func(r *IndicesExistsDocumentTypeRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.field_usage_stats.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.field_usage_stats.go new file mode 100644 index 00000000..05853a5f --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.field_usage_stats.go @@ -0,0 +1,243 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newIndicesFieldUsageStatsFunc(t Transport) IndicesFieldUsageStats { + return func(index string, o ...func(*IndicesFieldUsageStatsRequest)) (*Response, error) { + var r = IndicesFieldUsageStatsRequest{Index: index} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesFieldUsageStats returns the field usage stats for each field of an index +// +// This API is experimental. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/field-usage-stats.html. +type IndicesFieldUsageStats func(index string, o ...func(*IndicesFieldUsageStatsRequest)) (*Response, error) + +// IndicesFieldUsageStatsRequest configures the Indices Field Usage Stats API request. +type IndicesFieldUsageStatsRequest struct { + Index string + + AllowNoIndices *bool + ExpandWildcards string + Fields []string + IgnoreUnavailable *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesFieldUsageStatsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len(r.Index) + 1 + len("_field_usage_stats")) + path.WriteString("/") + path.WriteString(r.Index) + path.WriteString("/") + path.WriteString("_field_usage_stats") + + params = make(map[string]string) + + if r.AllowNoIndices != nil { + params["allow_no_indices"] = strconv.FormatBool(*r.AllowNoIndices) + } + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if len(r.Fields) > 0 { + params["fields"] = strings.Join(r.Fields, ",") + } + + if r.IgnoreUnavailable != nil { + params["ignore_unavailable"] = strconv.FormatBool(*r.IgnoreUnavailable) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesFieldUsageStats) WithContext(v context.Context) func(*IndicesFieldUsageStatsRequest) { + return func(r *IndicesFieldUsageStatsRequest) { + r.ctx = v + } +} + +// WithAllowNoIndices - whether to ignore if a wildcard indices expression resolves into no concrete indices. (this includes `_all` string or when no indices have been specified). +func (f IndicesFieldUsageStats) WithAllowNoIndices(v bool) func(*IndicesFieldUsageStatsRequest) { + return func(r *IndicesFieldUsageStatsRequest) { + r.AllowNoIndices = &v + } +} + +// WithExpandWildcards - whether to expand wildcard expression to concrete indices that are open, closed or both.. +func (f IndicesFieldUsageStats) WithExpandWildcards(v string) func(*IndicesFieldUsageStatsRequest) { + return func(r *IndicesFieldUsageStatsRequest) { + r.ExpandWildcards = v + } +} + +// WithFields - a list of fields to include in the stats if only a subset of fields should be returned (supports wildcards). +func (f IndicesFieldUsageStats) WithFields(v ...string) func(*IndicesFieldUsageStatsRequest) { + return func(r *IndicesFieldUsageStatsRequest) { + r.Fields = v + } +} + +// WithIgnoreUnavailable - whether specified concrete indices should be ignored when unavailable (missing or closed). +func (f IndicesFieldUsageStats) WithIgnoreUnavailable(v bool) func(*IndicesFieldUsageStatsRequest) { + return func(r *IndicesFieldUsageStatsRequest) { + r.IgnoreUnavailable = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesFieldUsageStats) WithPretty() func(*IndicesFieldUsageStatsRequest) { + return func(r *IndicesFieldUsageStatsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesFieldUsageStats) WithHuman() func(*IndicesFieldUsageStatsRequest) { + return func(r *IndicesFieldUsageStatsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesFieldUsageStats) WithErrorTrace() func(*IndicesFieldUsageStatsRequest) { + return func(r *IndicesFieldUsageStatsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesFieldUsageStats) WithFilterPath(v ...string) func(*IndicesFieldUsageStatsRequest) { + return func(r *IndicesFieldUsageStatsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesFieldUsageStats) WithHeader(h map[string]string) func(*IndicesFieldUsageStatsRequest) { + return func(r *IndicesFieldUsageStatsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesFieldUsageStats) WithOpaqueID(s string) func(*IndicesFieldUsageStatsRequest) { + return func(r *IndicesFieldUsageStatsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.flush.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.flush.go new file mode 100644 index 00000000..63ad3980 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.flush.go @@ -0,0 +1,262 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newIndicesFlushFunc(t Transport) IndicesFlush { + return func(o ...func(*IndicesFlushRequest)) (*Response, error) { + var r = IndicesFlushRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesFlush performs the flush operation on one or more indices. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-flush.html. +type IndicesFlush func(o ...func(*IndicesFlushRequest)) (*Response, error) + +// IndicesFlushRequest configures the Indices Flush API request. +type IndicesFlushRequest struct { + Index []string + + AllowNoIndices *bool + ExpandWildcards string + Force *bool + IgnoreUnavailable *bool + WaitIfOngoing *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesFlushRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len(strings.Join(r.Index, ",")) + 1 + len("_flush")) + if len(r.Index) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + } + path.WriteString("/") + path.WriteString("_flush") + + params = make(map[string]string) + + if r.AllowNoIndices != nil { + params["allow_no_indices"] = strconv.FormatBool(*r.AllowNoIndices) + } + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if r.Force != nil { + params["force"] = strconv.FormatBool(*r.Force) + } + + if r.IgnoreUnavailable != nil { + params["ignore_unavailable"] = strconv.FormatBool(*r.IgnoreUnavailable) + } + + if r.WaitIfOngoing != nil { + params["wait_if_ongoing"] = strconv.FormatBool(*r.WaitIfOngoing) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesFlush) WithContext(v context.Context) func(*IndicesFlushRequest) { + return func(r *IndicesFlushRequest) { + r.ctx = v + } +} + +// WithIndex - a list of index names; use _all for all indices. +func (f IndicesFlush) WithIndex(v ...string) func(*IndicesFlushRequest) { + return func(r *IndicesFlushRequest) { + r.Index = v + } +} + +// WithAllowNoIndices - whether to ignore if a wildcard indices expression resolves into no concrete indices. (this includes `_all` string or when no indices have been specified). +func (f IndicesFlush) WithAllowNoIndices(v bool) func(*IndicesFlushRequest) { + return func(r *IndicesFlushRequest) { + r.AllowNoIndices = &v + } +} + +// WithExpandWildcards - whether to expand wildcard expression to concrete indices that are open, closed or both.. +func (f IndicesFlush) WithExpandWildcards(v string) func(*IndicesFlushRequest) { + return func(r *IndicesFlushRequest) { + r.ExpandWildcards = v + } +} + +// WithForce - whether a flush should be forced even if it is not necessarily needed ie. if no changes will be committed to the index. this is useful if transaction log ids should be incremented even if no uncommitted changes are present. (this setting can be considered as internal). +func (f IndicesFlush) WithForce(v bool) func(*IndicesFlushRequest) { + return func(r *IndicesFlushRequest) { + r.Force = &v + } +} + +// WithIgnoreUnavailable - whether specified concrete indices should be ignored when unavailable (missing or closed). +func (f IndicesFlush) WithIgnoreUnavailable(v bool) func(*IndicesFlushRequest) { + return func(r *IndicesFlushRequest) { + r.IgnoreUnavailable = &v + } +} + +// WithWaitIfOngoing - if set to true the flush operation will block until the flush can be executed if another flush operation is already executing. the default is true. if set to false the flush will be skipped iff if another flush operation is already running.. +func (f IndicesFlush) WithWaitIfOngoing(v bool) func(*IndicesFlushRequest) { + return func(r *IndicesFlushRequest) { + r.WaitIfOngoing = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesFlush) WithPretty() func(*IndicesFlushRequest) { + return func(r *IndicesFlushRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesFlush) WithHuman() func(*IndicesFlushRequest) { + return func(r *IndicesFlushRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesFlush) WithErrorTrace() func(*IndicesFlushRequest) { + return func(r *IndicesFlushRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesFlush) WithFilterPath(v ...string) func(*IndicesFlushRequest) { + return func(r *IndicesFlushRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesFlush) WithHeader(h map[string]string) func(*IndicesFlushRequest) { + return func(r *IndicesFlushRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesFlush) WithOpaqueID(s string) func(*IndicesFlushRequest) { + return func(r *IndicesFlushRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.flush_synced.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.flush_synced.go new file mode 100644 index 00000000..dd1f8a88 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.flush_synced.go @@ -0,0 +1,240 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newIndicesFlushSyncedFunc(t Transport) IndicesFlushSynced { + return func(o ...func(*IndicesFlushSyncedRequest)) (*Response, error) { + var r = IndicesFlushSyncedRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesFlushSynced performs a synced flush operation on one or more indices. Synced flush is deprecated and will be removed in 8.0. Use flush instead +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-synced-flush-api.html. +type IndicesFlushSynced func(o ...func(*IndicesFlushSyncedRequest)) (*Response, error) + +// IndicesFlushSyncedRequest configures the Indices Flush Synced API request. +type IndicesFlushSyncedRequest struct { + Index []string + + AllowNoIndices *bool + ExpandWildcards string + IgnoreUnavailable *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesFlushSyncedRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len(strings.Join(r.Index, ",")) + 1 + len("_flush") + 1 + len("synced")) + if len(r.Index) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + } + path.WriteString("/") + path.WriteString("_flush") + path.WriteString("/") + path.WriteString("synced") + + params = make(map[string]string) + + if r.AllowNoIndices != nil { + params["allow_no_indices"] = strconv.FormatBool(*r.AllowNoIndices) + } + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if r.IgnoreUnavailable != nil { + params["ignore_unavailable"] = strconv.FormatBool(*r.IgnoreUnavailable) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesFlushSynced) WithContext(v context.Context) func(*IndicesFlushSyncedRequest) { + return func(r *IndicesFlushSyncedRequest) { + r.ctx = v + } +} + +// WithIndex - a list of index names; use _all for all indices. +func (f IndicesFlushSynced) WithIndex(v ...string) func(*IndicesFlushSyncedRequest) { + return func(r *IndicesFlushSyncedRequest) { + r.Index = v + } +} + +// WithAllowNoIndices - whether to ignore if a wildcard indices expression resolves into no concrete indices. (this includes `_all` string or when no indices have been specified). +func (f IndicesFlushSynced) WithAllowNoIndices(v bool) func(*IndicesFlushSyncedRequest) { + return func(r *IndicesFlushSyncedRequest) { + r.AllowNoIndices = &v + } +} + +// WithExpandWildcards - whether to expand wildcard expression to concrete indices that are open, closed or both.. +func (f IndicesFlushSynced) WithExpandWildcards(v string) func(*IndicesFlushSyncedRequest) { + return func(r *IndicesFlushSyncedRequest) { + r.ExpandWildcards = v + } +} + +// WithIgnoreUnavailable - whether specified concrete indices should be ignored when unavailable (missing or closed). +func (f IndicesFlushSynced) WithIgnoreUnavailable(v bool) func(*IndicesFlushSyncedRequest) { + return func(r *IndicesFlushSyncedRequest) { + r.IgnoreUnavailable = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesFlushSynced) WithPretty() func(*IndicesFlushSyncedRequest) { + return func(r *IndicesFlushSyncedRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesFlushSynced) WithHuman() func(*IndicesFlushSyncedRequest) { + return func(r *IndicesFlushSyncedRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesFlushSynced) WithErrorTrace() func(*IndicesFlushSyncedRequest) { + return func(r *IndicesFlushSyncedRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesFlushSynced) WithFilterPath(v ...string) func(*IndicesFlushSyncedRequest) { + return func(r *IndicesFlushSyncedRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesFlushSynced) WithHeader(h map[string]string) func(*IndicesFlushSyncedRequest) { + return func(r *IndicesFlushSyncedRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesFlushSynced) WithOpaqueID(s string) func(*IndicesFlushSyncedRequest) { + return func(r *IndicesFlushSyncedRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.forcemerge.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.forcemerge.go new file mode 100644 index 00000000..dc170ad1 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.forcemerge.go @@ -0,0 +1,274 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newIndicesForcemergeFunc(t Transport) IndicesForcemerge { + return func(o ...func(*IndicesForcemergeRequest)) (*Response, error) { + var r = IndicesForcemergeRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesForcemerge performs the force merge operation on one or more indices. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-forcemerge.html. +type IndicesForcemerge func(o ...func(*IndicesForcemergeRequest)) (*Response, error) + +// IndicesForcemergeRequest configures the Indices Forcemerge API request. +type IndicesForcemergeRequest struct { + Index []string + + AllowNoIndices *bool + ExpandWildcards string + Flush *bool + IgnoreUnavailable *bool + MaxNumSegments *int + OnlyExpungeDeletes *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesForcemergeRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len(strings.Join(r.Index, ",")) + 1 + len("_forcemerge")) + if len(r.Index) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + } + path.WriteString("/") + path.WriteString("_forcemerge") + + params = make(map[string]string) + + if r.AllowNoIndices != nil { + params["allow_no_indices"] = strconv.FormatBool(*r.AllowNoIndices) + } + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if r.Flush != nil { + params["flush"] = strconv.FormatBool(*r.Flush) + } + + if r.IgnoreUnavailable != nil { + params["ignore_unavailable"] = strconv.FormatBool(*r.IgnoreUnavailable) + } + + if r.MaxNumSegments != nil { + params["max_num_segments"] = strconv.FormatInt(int64(*r.MaxNumSegments), 10) + } + + if r.OnlyExpungeDeletes != nil { + params["only_expunge_deletes"] = strconv.FormatBool(*r.OnlyExpungeDeletes) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesForcemerge) WithContext(v context.Context) func(*IndicesForcemergeRequest) { + return func(r *IndicesForcemergeRequest) { + r.ctx = v + } +} + +// WithIndex - a list of index names; use _all to perform the operation on all indices. +func (f IndicesForcemerge) WithIndex(v ...string) func(*IndicesForcemergeRequest) { + return func(r *IndicesForcemergeRequest) { + r.Index = v + } +} + +// WithAllowNoIndices - whether to ignore if a wildcard indices expression resolves into no concrete indices. (this includes `_all` string or when no indices have been specified). +func (f IndicesForcemerge) WithAllowNoIndices(v bool) func(*IndicesForcemergeRequest) { + return func(r *IndicesForcemergeRequest) { + r.AllowNoIndices = &v + } +} + +// WithExpandWildcards - whether to expand wildcard expression to concrete indices that are open, closed or both.. +func (f IndicesForcemerge) WithExpandWildcards(v string) func(*IndicesForcemergeRequest) { + return func(r *IndicesForcemergeRequest) { + r.ExpandWildcards = v + } +} + +// WithFlush - specify whether the index should be flushed after performing the operation (default: true). +func (f IndicesForcemerge) WithFlush(v bool) func(*IndicesForcemergeRequest) { + return func(r *IndicesForcemergeRequest) { + r.Flush = &v + } +} + +// WithIgnoreUnavailable - whether specified concrete indices should be ignored when unavailable (missing or closed). +func (f IndicesForcemerge) WithIgnoreUnavailable(v bool) func(*IndicesForcemergeRequest) { + return func(r *IndicesForcemergeRequest) { + r.IgnoreUnavailable = &v + } +} + +// WithMaxNumSegments - the number of segments the index should be merged into (default: dynamic). +func (f IndicesForcemerge) WithMaxNumSegments(v int) func(*IndicesForcemergeRequest) { + return func(r *IndicesForcemergeRequest) { + r.MaxNumSegments = &v + } +} + +// WithOnlyExpungeDeletes - specify whether the operation should only expunge deleted documents. +func (f IndicesForcemerge) WithOnlyExpungeDeletes(v bool) func(*IndicesForcemergeRequest) { + return func(r *IndicesForcemergeRequest) { + r.OnlyExpungeDeletes = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesForcemerge) WithPretty() func(*IndicesForcemergeRequest) { + return func(r *IndicesForcemergeRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesForcemerge) WithHuman() func(*IndicesForcemergeRequest) { + return func(r *IndicesForcemergeRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesForcemerge) WithErrorTrace() func(*IndicesForcemergeRequest) { + return func(r *IndicesForcemergeRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesForcemerge) WithFilterPath(v ...string) func(*IndicesForcemergeRequest) { + return func(r *IndicesForcemergeRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesForcemerge) WithHeader(h map[string]string) func(*IndicesForcemergeRequest) { + return func(r *IndicesForcemergeRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesForcemerge) WithOpaqueID(s string) func(*IndicesForcemergeRequest) { + return func(r *IndicesForcemergeRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.get.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.get.go new file mode 100644 index 00000000..9dbf933c --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.get.go @@ -0,0 +1,293 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "errors" + "net/http" + "strconv" + "strings" + "time" +) + +func newIndicesGetFunc(t Transport) IndicesGet { + return func(index []string, o ...func(*IndicesGetRequest)) (*Response, error) { + var r = IndicesGetRequest{Index: index} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesGet returns information about one or more indices. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-index.html. +type IndicesGet func(index []string, o ...func(*IndicesGetRequest)) (*Response, error) + +// IndicesGetRequest configures the Indices Get API request. +type IndicesGetRequest struct { + Index []string + + AllowNoIndices *bool + ExpandWildcards string + FlatSettings *bool + IgnoreUnavailable *bool + IncludeDefaults *bool + IncludeTypeName *bool + Local *bool + MasterTimeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesGetRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + if len(r.Index) == 0 { + return nil, errors.New("index is required and cannot be nil or empty") + } + + path.Grow(1 + len(strings.Join(r.Index, ","))) + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + + params = make(map[string]string) + + if r.AllowNoIndices != nil { + params["allow_no_indices"] = strconv.FormatBool(*r.AllowNoIndices) + } + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if r.FlatSettings != nil { + params["flat_settings"] = strconv.FormatBool(*r.FlatSettings) + } + + if r.IgnoreUnavailable != nil { + params["ignore_unavailable"] = strconv.FormatBool(*r.IgnoreUnavailable) + } + + if r.IncludeDefaults != nil { + params["include_defaults"] = strconv.FormatBool(*r.IncludeDefaults) + } + + if r.IncludeTypeName != nil { + params["include_type_name"] = strconv.FormatBool(*r.IncludeTypeName) + } + + if r.Local != nil { + params["local"] = strconv.FormatBool(*r.Local) + } + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesGet) WithContext(v context.Context) func(*IndicesGetRequest) { + return func(r *IndicesGetRequest) { + r.ctx = v + } +} + +// WithAllowNoIndices - ignore if a wildcard expression resolves to no concrete indices (default: false). +func (f IndicesGet) WithAllowNoIndices(v bool) func(*IndicesGetRequest) { + return func(r *IndicesGetRequest) { + r.AllowNoIndices = &v + } +} + +// WithExpandWildcards - whether wildcard expressions should get expanded to open or closed indices (default: open). +func (f IndicesGet) WithExpandWildcards(v string) func(*IndicesGetRequest) { + return func(r *IndicesGetRequest) { + r.ExpandWildcards = v + } +} + +// WithFlatSettings - return settings in flat format (default: false). +func (f IndicesGet) WithFlatSettings(v bool) func(*IndicesGetRequest) { + return func(r *IndicesGetRequest) { + r.FlatSettings = &v + } +} + +// WithIgnoreUnavailable - ignore unavailable indexes (default: false). +func (f IndicesGet) WithIgnoreUnavailable(v bool) func(*IndicesGetRequest) { + return func(r *IndicesGetRequest) { + r.IgnoreUnavailable = &v + } +} + +// WithIncludeDefaults - whether to return all default setting for each of the indices.. +func (f IndicesGet) WithIncludeDefaults(v bool) func(*IndicesGetRequest) { + return func(r *IndicesGetRequest) { + r.IncludeDefaults = &v + } +} + +// WithIncludeTypeName - whether to add the type name to the response (default: false). +func (f IndicesGet) WithIncludeTypeName(v bool) func(*IndicesGetRequest) { + return func(r *IndicesGetRequest) { + r.IncludeTypeName = &v + } +} + +// WithLocal - return local information, do not retrieve the state from master node (default: false). +func (f IndicesGet) WithLocal(v bool) func(*IndicesGetRequest) { + return func(r *IndicesGetRequest) { + r.Local = &v + } +} + +// WithMasterTimeout - specify timeout for connection to master. +func (f IndicesGet) WithMasterTimeout(v time.Duration) func(*IndicesGetRequest) { + return func(r *IndicesGetRequest) { + r.MasterTimeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesGet) WithPretty() func(*IndicesGetRequest) { + return func(r *IndicesGetRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesGet) WithHuman() func(*IndicesGetRequest) { + return func(r *IndicesGetRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesGet) WithErrorTrace() func(*IndicesGetRequest) { + return func(r *IndicesGetRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesGet) WithFilterPath(v ...string) func(*IndicesGetRequest) { + return func(r *IndicesGetRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesGet) WithHeader(h map[string]string) func(*IndicesGetRequest) { + return func(r *IndicesGetRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesGet) WithOpaqueID(s string) func(*IndicesGetRequest) { + return func(r *IndicesGetRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.get_alias.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.get_alias.go new file mode 100644 index 00000000..7d60f522 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.get_alias.go @@ -0,0 +1,263 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newIndicesGetAliasFunc(t Transport) IndicesGetAlias { + return func(o ...func(*IndicesGetAliasRequest)) (*Response, error) { + var r = IndicesGetAliasRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesGetAlias returns an alias. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html. +type IndicesGetAlias func(o ...func(*IndicesGetAliasRequest)) (*Response, error) + +// IndicesGetAliasRequest configures the Indices Get Alias API request. +type IndicesGetAliasRequest struct { + Index []string + + Name []string + + AllowNoIndices *bool + ExpandWildcards string + IgnoreUnavailable *bool + Local *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesGetAliasRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len(strings.Join(r.Index, ",")) + 1 + len("_alias") + 1 + len(strings.Join(r.Name, ","))) + if len(r.Index) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + } + path.WriteString("/") + path.WriteString("_alias") + if len(r.Name) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Name, ",")) + } + + params = make(map[string]string) + + if r.AllowNoIndices != nil { + params["allow_no_indices"] = strconv.FormatBool(*r.AllowNoIndices) + } + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if r.IgnoreUnavailable != nil { + params["ignore_unavailable"] = strconv.FormatBool(*r.IgnoreUnavailable) + } + + if r.Local != nil { + params["local"] = strconv.FormatBool(*r.Local) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesGetAlias) WithContext(v context.Context) func(*IndicesGetAliasRequest) { + return func(r *IndicesGetAliasRequest) { + r.ctx = v + } +} + +// WithIndex - a list of index names to filter aliases. +func (f IndicesGetAlias) WithIndex(v ...string) func(*IndicesGetAliasRequest) { + return func(r *IndicesGetAliasRequest) { + r.Index = v + } +} + +// WithName - a list of alias names to return. +func (f IndicesGetAlias) WithName(v ...string) func(*IndicesGetAliasRequest) { + return func(r *IndicesGetAliasRequest) { + r.Name = v + } +} + +// WithAllowNoIndices - whether to ignore if a wildcard indices expression resolves into no concrete indices. (this includes `_all` string or when no indices have been specified). +func (f IndicesGetAlias) WithAllowNoIndices(v bool) func(*IndicesGetAliasRequest) { + return func(r *IndicesGetAliasRequest) { + r.AllowNoIndices = &v + } +} + +// WithExpandWildcards - whether to expand wildcard expression to concrete indices that are open, closed or both.. +func (f IndicesGetAlias) WithExpandWildcards(v string) func(*IndicesGetAliasRequest) { + return func(r *IndicesGetAliasRequest) { + r.ExpandWildcards = v + } +} + +// WithIgnoreUnavailable - whether specified concrete indices should be ignored when unavailable (missing or closed). +func (f IndicesGetAlias) WithIgnoreUnavailable(v bool) func(*IndicesGetAliasRequest) { + return func(r *IndicesGetAliasRequest) { + r.IgnoreUnavailable = &v + } +} + +// WithLocal - return local information, do not retrieve the state from master node (default: false). +func (f IndicesGetAlias) WithLocal(v bool) func(*IndicesGetAliasRequest) { + return func(r *IndicesGetAliasRequest) { + r.Local = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesGetAlias) WithPretty() func(*IndicesGetAliasRequest) { + return func(r *IndicesGetAliasRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesGetAlias) WithHuman() func(*IndicesGetAliasRequest) { + return func(r *IndicesGetAliasRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesGetAlias) WithErrorTrace() func(*IndicesGetAliasRequest) { + return func(r *IndicesGetAliasRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesGetAlias) WithFilterPath(v ...string) func(*IndicesGetAliasRequest) { + return func(r *IndicesGetAliasRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesGetAlias) WithHeader(h map[string]string) func(*IndicesGetAliasRequest) { + return func(r *IndicesGetAliasRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesGetAlias) WithOpaqueID(s string) func(*IndicesGetAliasRequest) { + return func(r *IndicesGetAliasRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.get_field_mapping.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.get_field_mapping.go new file mode 100644 index 00000000..091343ac --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.get_field_mapping.go @@ -0,0 +1,297 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "errors" + "net/http" + "strconv" + "strings" +) + +func newIndicesGetFieldMappingFunc(t Transport) IndicesGetFieldMapping { + return func(fields []string, o ...func(*IndicesGetFieldMappingRequest)) (*Response, error) { + var r = IndicesGetFieldMappingRequest{Fields: fields} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesGetFieldMapping returns mapping for one or more fields. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-field-mapping.html. +type IndicesGetFieldMapping func(fields []string, o ...func(*IndicesGetFieldMappingRequest)) (*Response, error) + +// IndicesGetFieldMappingRequest configures the Indices Get Field Mapping API request. +type IndicesGetFieldMappingRequest struct { + Index []string + DocumentType []string + + Fields []string + + AllowNoIndices *bool + ExpandWildcards string + IgnoreUnavailable *bool + IncludeDefaults *bool + IncludeTypeName *bool + Local *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesGetFieldMappingRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + if len(r.Fields) == 0 { + return nil, errors.New("fields is required and cannot be nil or empty") + } + + path.Grow(1 + len(strings.Join(r.Index, ",")) + 1 + len("_mapping") + 1 + len(strings.Join(r.DocumentType, ",")) + 1 + len("field") + 1 + len(strings.Join(r.Fields, ","))) + if len(r.Index) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + } + path.WriteString("/") + path.WriteString("_mapping") + if len(r.DocumentType) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.DocumentType, ",")) + } + path.WriteString("/") + path.WriteString("field") + path.WriteString("/") + path.WriteString(strings.Join(r.Fields, ",")) + + params = make(map[string]string) + + if r.AllowNoIndices != nil { + params["allow_no_indices"] = strconv.FormatBool(*r.AllowNoIndices) + } + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if r.IgnoreUnavailable != nil { + params["ignore_unavailable"] = strconv.FormatBool(*r.IgnoreUnavailable) + } + + if r.IncludeDefaults != nil { + params["include_defaults"] = strconv.FormatBool(*r.IncludeDefaults) + } + + if r.IncludeTypeName != nil { + params["include_type_name"] = strconv.FormatBool(*r.IncludeTypeName) + } + + if r.Local != nil { + params["local"] = strconv.FormatBool(*r.Local) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesGetFieldMapping) WithContext(v context.Context) func(*IndicesGetFieldMappingRequest) { + return func(r *IndicesGetFieldMappingRequest) { + r.ctx = v + } +} + +// WithIndex - a list of index names. +func (f IndicesGetFieldMapping) WithIndex(v ...string) func(*IndicesGetFieldMappingRequest) { + return func(r *IndicesGetFieldMappingRequest) { + r.Index = v + } +} + +// WithDocumentType - a list of document types. +func (f IndicesGetFieldMapping) WithDocumentType(v ...string) func(*IndicesGetFieldMappingRequest) { + return func(r *IndicesGetFieldMappingRequest) { + r.DocumentType = v + } +} + +// WithAllowNoIndices - whether to ignore if a wildcard indices expression resolves into no concrete indices. (this includes `_all` string or when no indices have been specified). +func (f IndicesGetFieldMapping) WithAllowNoIndices(v bool) func(*IndicesGetFieldMappingRequest) { + return func(r *IndicesGetFieldMappingRequest) { + r.AllowNoIndices = &v + } +} + +// WithExpandWildcards - whether to expand wildcard expression to concrete indices that are open, closed or both.. +func (f IndicesGetFieldMapping) WithExpandWildcards(v string) func(*IndicesGetFieldMappingRequest) { + return func(r *IndicesGetFieldMappingRequest) { + r.ExpandWildcards = v + } +} + +// WithIgnoreUnavailable - whether specified concrete indices should be ignored when unavailable (missing or closed). +func (f IndicesGetFieldMapping) WithIgnoreUnavailable(v bool) func(*IndicesGetFieldMappingRequest) { + return func(r *IndicesGetFieldMappingRequest) { + r.IgnoreUnavailable = &v + } +} + +// WithIncludeDefaults - whether the default mapping values should be returned as well. +func (f IndicesGetFieldMapping) WithIncludeDefaults(v bool) func(*IndicesGetFieldMappingRequest) { + return func(r *IndicesGetFieldMappingRequest) { + r.IncludeDefaults = &v + } +} + +// WithIncludeTypeName - whether a type should be returned in the body of the mappings.. +func (f IndicesGetFieldMapping) WithIncludeTypeName(v bool) func(*IndicesGetFieldMappingRequest) { + return func(r *IndicesGetFieldMappingRequest) { + r.IncludeTypeName = &v + } +} + +// WithLocal - return local information, do not retrieve the state from master node (default: false). +func (f IndicesGetFieldMapping) WithLocal(v bool) func(*IndicesGetFieldMappingRequest) { + return func(r *IndicesGetFieldMappingRequest) { + r.Local = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesGetFieldMapping) WithPretty() func(*IndicesGetFieldMappingRequest) { + return func(r *IndicesGetFieldMappingRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesGetFieldMapping) WithHuman() func(*IndicesGetFieldMappingRequest) { + return func(r *IndicesGetFieldMappingRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesGetFieldMapping) WithErrorTrace() func(*IndicesGetFieldMappingRequest) { + return func(r *IndicesGetFieldMappingRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesGetFieldMapping) WithFilterPath(v ...string) func(*IndicesGetFieldMappingRequest) { + return func(r *IndicesGetFieldMappingRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesGetFieldMapping) WithHeader(h map[string]string) func(*IndicesGetFieldMappingRequest) { + return func(r *IndicesGetFieldMappingRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesGetFieldMapping) WithOpaqueID(s string) func(*IndicesGetFieldMappingRequest) { + return func(r *IndicesGetFieldMappingRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.get_index_template.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.get_index_template.go new file mode 100644 index 00000000..2a7e73f7 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.get_index_template.go @@ -0,0 +1,239 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" + "time" +) + +func newIndicesGetIndexTemplateFunc(t Transport) IndicesGetIndexTemplate { + return func(o ...func(*IndicesGetIndexTemplateRequest)) (*Response, error) { + var r = IndicesGetIndexTemplateRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesGetIndexTemplate returns an index template. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html. +type IndicesGetIndexTemplate func(o ...func(*IndicesGetIndexTemplateRequest)) (*Response, error) + +// IndicesGetIndexTemplateRequest configures the Indices Get Index Template API request. +type IndicesGetIndexTemplateRequest struct { + Name string + + FlatSettings *bool + Local *bool + MasterTimeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesGetIndexTemplateRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_index_template") + 1 + len(r.Name)) + path.WriteString("/") + path.WriteString("_index_template") + if r.Name != "" { + path.WriteString("/") + path.WriteString(r.Name) + } + + params = make(map[string]string) + + if r.FlatSettings != nil { + params["flat_settings"] = strconv.FormatBool(*r.FlatSettings) + } + + if r.Local != nil { + params["local"] = strconv.FormatBool(*r.Local) + } + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesGetIndexTemplate) WithContext(v context.Context) func(*IndicesGetIndexTemplateRequest) { + return func(r *IndicesGetIndexTemplateRequest) { + r.ctx = v + } +} + +// WithName - a pattern that returned template names must match. +func (f IndicesGetIndexTemplate) WithName(v string) func(*IndicesGetIndexTemplateRequest) { + return func(r *IndicesGetIndexTemplateRequest) { + r.Name = v + } +} + +// WithFlatSettings - return settings in flat format (default: false). +func (f IndicesGetIndexTemplate) WithFlatSettings(v bool) func(*IndicesGetIndexTemplateRequest) { + return func(r *IndicesGetIndexTemplateRequest) { + r.FlatSettings = &v + } +} + +// WithLocal - return local information, do not retrieve the state from master node (default: false). +func (f IndicesGetIndexTemplate) WithLocal(v bool) func(*IndicesGetIndexTemplateRequest) { + return func(r *IndicesGetIndexTemplateRequest) { + r.Local = &v + } +} + +// WithMasterTimeout - explicit operation timeout for connection to master node. +func (f IndicesGetIndexTemplate) WithMasterTimeout(v time.Duration) func(*IndicesGetIndexTemplateRequest) { + return func(r *IndicesGetIndexTemplateRequest) { + r.MasterTimeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesGetIndexTemplate) WithPretty() func(*IndicesGetIndexTemplateRequest) { + return func(r *IndicesGetIndexTemplateRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesGetIndexTemplate) WithHuman() func(*IndicesGetIndexTemplateRequest) { + return func(r *IndicesGetIndexTemplateRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesGetIndexTemplate) WithErrorTrace() func(*IndicesGetIndexTemplateRequest) { + return func(r *IndicesGetIndexTemplateRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesGetIndexTemplate) WithFilterPath(v ...string) func(*IndicesGetIndexTemplateRequest) { + return func(r *IndicesGetIndexTemplateRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesGetIndexTemplate) WithHeader(h map[string]string) func(*IndicesGetIndexTemplateRequest) { + return func(r *IndicesGetIndexTemplateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesGetIndexTemplate) WithOpaqueID(s string) func(*IndicesGetIndexTemplateRequest) { + return func(r *IndicesGetIndexTemplateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.get_mapping.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.get_mapping.go new file mode 100644 index 00000000..6a02233f --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.get_mapping.go @@ -0,0 +1,287 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" + "time" +) + +func newIndicesGetMappingFunc(t Transport) IndicesGetMapping { + return func(o ...func(*IndicesGetMappingRequest)) (*Response, error) { + var r = IndicesGetMappingRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesGetMapping returns mappings for one or more indices. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-mapping.html. +type IndicesGetMapping func(o ...func(*IndicesGetMappingRequest)) (*Response, error) + +// IndicesGetMappingRequest configures the Indices Get Mapping API request. +type IndicesGetMappingRequest struct { + Index []string + DocumentType []string + + AllowNoIndices *bool + ExpandWildcards string + IgnoreUnavailable *bool + IncludeTypeName *bool + Local *bool + MasterTimeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesGetMappingRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len(strings.Join(r.Index, ",")) + 1 + len("_mapping") + 1 + len(strings.Join(r.DocumentType, ","))) + if len(r.Index) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + } + path.WriteString("/") + path.WriteString("_mapping") + if len(r.DocumentType) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.DocumentType, ",")) + } + + params = make(map[string]string) + + if r.AllowNoIndices != nil { + params["allow_no_indices"] = strconv.FormatBool(*r.AllowNoIndices) + } + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if r.IgnoreUnavailable != nil { + params["ignore_unavailable"] = strconv.FormatBool(*r.IgnoreUnavailable) + } + + if r.IncludeTypeName != nil { + params["include_type_name"] = strconv.FormatBool(*r.IncludeTypeName) + } + + if r.Local != nil { + params["local"] = strconv.FormatBool(*r.Local) + } + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesGetMapping) WithContext(v context.Context) func(*IndicesGetMappingRequest) { + return func(r *IndicesGetMappingRequest) { + r.ctx = v + } +} + +// WithIndex - a list of index names. +func (f IndicesGetMapping) WithIndex(v ...string) func(*IndicesGetMappingRequest) { + return func(r *IndicesGetMappingRequest) { + r.Index = v + } +} + +// WithDocumentType - a list of document types. +func (f IndicesGetMapping) WithDocumentType(v ...string) func(*IndicesGetMappingRequest) { + return func(r *IndicesGetMappingRequest) { + r.DocumentType = v + } +} + +// WithAllowNoIndices - whether to ignore if a wildcard indices expression resolves into no concrete indices. (this includes `_all` string or when no indices have been specified). +func (f IndicesGetMapping) WithAllowNoIndices(v bool) func(*IndicesGetMappingRequest) { + return func(r *IndicesGetMappingRequest) { + r.AllowNoIndices = &v + } +} + +// WithExpandWildcards - whether to expand wildcard expression to concrete indices that are open, closed or both.. +func (f IndicesGetMapping) WithExpandWildcards(v string) func(*IndicesGetMappingRequest) { + return func(r *IndicesGetMappingRequest) { + r.ExpandWildcards = v + } +} + +// WithIgnoreUnavailable - whether specified concrete indices should be ignored when unavailable (missing or closed). +func (f IndicesGetMapping) WithIgnoreUnavailable(v bool) func(*IndicesGetMappingRequest) { + return func(r *IndicesGetMappingRequest) { + r.IgnoreUnavailable = &v + } +} + +// WithIncludeTypeName - whether to add the type name to the response (default: false). +func (f IndicesGetMapping) WithIncludeTypeName(v bool) func(*IndicesGetMappingRequest) { + return func(r *IndicesGetMappingRequest) { + r.IncludeTypeName = &v + } +} + +// WithLocal - return local information, do not retrieve the state from master node (default: false). +func (f IndicesGetMapping) WithLocal(v bool) func(*IndicesGetMappingRequest) { + return func(r *IndicesGetMappingRequest) { + r.Local = &v + } +} + +// WithMasterTimeout - specify timeout for connection to master. +func (f IndicesGetMapping) WithMasterTimeout(v time.Duration) func(*IndicesGetMappingRequest) { + return func(r *IndicesGetMappingRequest) { + r.MasterTimeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesGetMapping) WithPretty() func(*IndicesGetMappingRequest) { + return func(r *IndicesGetMappingRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesGetMapping) WithHuman() func(*IndicesGetMappingRequest) { + return func(r *IndicesGetMappingRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesGetMapping) WithErrorTrace() func(*IndicesGetMappingRequest) { + return func(r *IndicesGetMappingRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesGetMapping) WithFilterPath(v ...string) func(*IndicesGetMappingRequest) { + return func(r *IndicesGetMappingRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesGetMapping) WithHeader(h map[string]string) func(*IndicesGetMappingRequest) { + return func(r *IndicesGetMappingRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesGetMapping) WithOpaqueID(s string) func(*IndicesGetMappingRequest) { + return func(r *IndicesGetMappingRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.get_settings.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.get_settings.go new file mode 100644 index 00000000..db702adb --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.get_settings.go @@ -0,0 +1,300 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" + "time" +) + +func newIndicesGetSettingsFunc(t Transport) IndicesGetSettings { + return func(o ...func(*IndicesGetSettingsRequest)) (*Response, error) { + var r = IndicesGetSettingsRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesGetSettings returns settings for one or more indices. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-settings.html. +type IndicesGetSettings func(o ...func(*IndicesGetSettingsRequest)) (*Response, error) + +// IndicesGetSettingsRequest configures the Indices Get Settings API request. +type IndicesGetSettingsRequest struct { + Index []string + + Name []string + + AllowNoIndices *bool + ExpandWildcards string + FlatSettings *bool + IgnoreUnavailable *bool + IncludeDefaults *bool + Local *bool + MasterTimeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesGetSettingsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len(strings.Join(r.Index, ",")) + 1 + len("_settings") + 1 + len(strings.Join(r.Name, ","))) + if len(r.Index) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + } + path.WriteString("/") + path.WriteString("_settings") + if len(r.Name) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Name, ",")) + } + + params = make(map[string]string) + + if r.AllowNoIndices != nil { + params["allow_no_indices"] = strconv.FormatBool(*r.AllowNoIndices) + } + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if r.FlatSettings != nil { + params["flat_settings"] = strconv.FormatBool(*r.FlatSettings) + } + + if r.IgnoreUnavailable != nil { + params["ignore_unavailable"] = strconv.FormatBool(*r.IgnoreUnavailable) + } + + if r.IncludeDefaults != nil { + params["include_defaults"] = strconv.FormatBool(*r.IncludeDefaults) + } + + if r.Local != nil { + params["local"] = strconv.FormatBool(*r.Local) + } + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesGetSettings) WithContext(v context.Context) func(*IndicesGetSettingsRequest) { + return func(r *IndicesGetSettingsRequest) { + r.ctx = v + } +} + +// WithIndex - a list of index names; use _all to perform the operation on all indices. +func (f IndicesGetSettings) WithIndex(v ...string) func(*IndicesGetSettingsRequest) { + return func(r *IndicesGetSettingsRequest) { + r.Index = v + } +} + +// WithName - the name of the settings that should be included. +func (f IndicesGetSettings) WithName(v ...string) func(*IndicesGetSettingsRequest) { + return func(r *IndicesGetSettingsRequest) { + r.Name = v + } +} + +// WithAllowNoIndices - whether to ignore if a wildcard indices expression resolves into no concrete indices. (this includes `_all` string or when no indices have been specified). +func (f IndicesGetSettings) WithAllowNoIndices(v bool) func(*IndicesGetSettingsRequest) { + return func(r *IndicesGetSettingsRequest) { + r.AllowNoIndices = &v + } +} + +// WithExpandWildcards - whether to expand wildcard expression to concrete indices that are open, closed or both.. +func (f IndicesGetSettings) WithExpandWildcards(v string) func(*IndicesGetSettingsRequest) { + return func(r *IndicesGetSettingsRequest) { + r.ExpandWildcards = v + } +} + +// WithFlatSettings - return settings in flat format (default: false). +func (f IndicesGetSettings) WithFlatSettings(v bool) func(*IndicesGetSettingsRequest) { + return func(r *IndicesGetSettingsRequest) { + r.FlatSettings = &v + } +} + +// WithIgnoreUnavailable - whether specified concrete indices should be ignored when unavailable (missing or closed). +func (f IndicesGetSettings) WithIgnoreUnavailable(v bool) func(*IndicesGetSettingsRequest) { + return func(r *IndicesGetSettingsRequest) { + r.IgnoreUnavailable = &v + } +} + +// WithIncludeDefaults - whether to return all default setting for each of the indices.. +func (f IndicesGetSettings) WithIncludeDefaults(v bool) func(*IndicesGetSettingsRequest) { + return func(r *IndicesGetSettingsRequest) { + r.IncludeDefaults = &v + } +} + +// WithLocal - return local information, do not retrieve the state from master node (default: false). +func (f IndicesGetSettings) WithLocal(v bool) func(*IndicesGetSettingsRequest) { + return func(r *IndicesGetSettingsRequest) { + r.Local = &v + } +} + +// WithMasterTimeout - specify timeout for connection to master. +func (f IndicesGetSettings) WithMasterTimeout(v time.Duration) func(*IndicesGetSettingsRequest) { + return func(r *IndicesGetSettingsRequest) { + r.MasterTimeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesGetSettings) WithPretty() func(*IndicesGetSettingsRequest) { + return func(r *IndicesGetSettingsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesGetSettings) WithHuman() func(*IndicesGetSettingsRequest) { + return func(r *IndicesGetSettingsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesGetSettings) WithErrorTrace() func(*IndicesGetSettingsRequest) { + return func(r *IndicesGetSettingsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesGetSettings) WithFilterPath(v ...string) func(*IndicesGetSettingsRequest) { + return func(r *IndicesGetSettingsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesGetSettings) WithHeader(h map[string]string) func(*IndicesGetSettingsRequest) { + return func(r *IndicesGetSettingsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesGetSettings) WithOpaqueID(s string) func(*IndicesGetSettingsRequest) { + return func(r *IndicesGetSettingsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.get_template.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.get_template.go new file mode 100644 index 00000000..a014a792 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.get_template.go @@ -0,0 +1,251 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" + "time" +) + +func newIndicesGetTemplateFunc(t Transport) IndicesGetTemplate { + return func(o ...func(*IndicesGetTemplateRequest)) (*Response, error) { + var r = IndicesGetTemplateRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesGetTemplate returns an index template. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html. +type IndicesGetTemplate func(o ...func(*IndicesGetTemplateRequest)) (*Response, error) + +// IndicesGetTemplateRequest configures the Indices Get Template API request. +type IndicesGetTemplateRequest struct { + Name []string + + FlatSettings *bool + IncludeTypeName *bool + Local *bool + MasterTimeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesGetTemplateRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_template") + 1 + len(strings.Join(r.Name, ","))) + path.WriteString("/") + path.WriteString("_template") + if len(r.Name) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Name, ",")) + } + + params = make(map[string]string) + + if r.FlatSettings != nil { + params["flat_settings"] = strconv.FormatBool(*r.FlatSettings) + } + + if r.IncludeTypeName != nil { + params["include_type_name"] = strconv.FormatBool(*r.IncludeTypeName) + } + + if r.Local != nil { + params["local"] = strconv.FormatBool(*r.Local) + } + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesGetTemplate) WithContext(v context.Context) func(*IndicesGetTemplateRequest) { + return func(r *IndicesGetTemplateRequest) { + r.ctx = v + } +} + +// WithName - the comma separated names of the index templates. +func (f IndicesGetTemplate) WithName(v ...string) func(*IndicesGetTemplateRequest) { + return func(r *IndicesGetTemplateRequest) { + r.Name = v + } +} + +// WithFlatSettings - return settings in flat format (default: false). +func (f IndicesGetTemplate) WithFlatSettings(v bool) func(*IndicesGetTemplateRequest) { + return func(r *IndicesGetTemplateRequest) { + r.FlatSettings = &v + } +} + +// WithIncludeTypeName - whether a type should be returned in the body of the mappings.. +func (f IndicesGetTemplate) WithIncludeTypeName(v bool) func(*IndicesGetTemplateRequest) { + return func(r *IndicesGetTemplateRequest) { + r.IncludeTypeName = &v + } +} + +// WithLocal - return local information, do not retrieve the state from master node (default: false). +func (f IndicesGetTemplate) WithLocal(v bool) func(*IndicesGetTemplateRequest) { + return func(r *IndicesGetTemplateRequest) { + r.Local = &v + } +} + +// WithMasterTimeout - explicit operation timeout for connection to master node. +func (f IndicesGetTemplate) WithMasterTimeout(v time.Duration) func(*IndicesGetTemplateRequest) { + return func(r *IndicesGetTemplateRequest) { + r.MasterTimeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesGetTemplate) WithPretty() func(*IndicesGetTemplateRequest) { + return func(r *IndicesGetTemplateRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesGetTemplate) WithHuman() func(*IndicesGetTemplateRequest) { + return func(r *IndicesGetTemplateRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesGetTemplate) WithErrorTrace() func(*IndicesGetTemplateRequest) { + return func(r *IndicesGetTemplateRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesGetTemplate) WithFilterPath(v ...string) func(*IndicesGetTemplateRequest) { + return func(r *IndicesGetTemplateRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesGetTemplate) WithHeader(h map[string]string) func(*IndicesGetTemplateRequest) { + return func(r *IndicesGetTemplateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesGetTemplate) WithOpaqueID(s string) func(*IndicesGetTemplateRequest) { + return func(r *IndicesGetTemplateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.get_upgrade.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.get_upgrade.go new file mode 100644 index 00000000..81e668ce --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.get_upgrade.go @@ -0,0 +1,238 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newIndicesGetUpgradeFunc(t Transport) IndicesGetUpgrade { + return func(o ...func(*IndicesGetUpgradeRequest)) (*Response, error) { + var r = IndicesGetUpgradeRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesGetUpgrade deprecated Returns a progress status of current upgrade. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-upgrade.html. +type IndicesGetUpgrade func(o ...func(*IndicesGetUpgradeRequest)) (*Response, error) + +// IndicesGetUpgradeRequest configures the Indices Get Upgrade API request. +type IndicesGetUpgradeRequest struct { + Index []string + + AllowNoIndices *bool + ExpandWildcards string + IgnoreUnavailable *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesGetUpgradeRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len(strings.Join(r.Index, ",")) + 1 + len("_upgrade")) + if len(r.Index) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + } + path.WriteString("/") + path.WriteString("_upgrade") + + params = make(map[string]string) + + if r.AllowNoIndices != nil { + params["allow_no_indices"] = strconv.FormatBool(*r.AllowNoIndices) + } + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if r.IgnoreUnavailable != nil { + params["ignore_unavailable"] = strconv.FormatBool(*r.IgnoreUnavailable) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesGetUpgrade) WithContext(v context.Context) func(*IndicesGetUpgradeRequest) { + return func(r *IndicesGetUpgradeRequest) { + r.ctx = v + } +} + +// WithIndex - a list of index names; use _all to perform the operation on all indices. +func (f IndicesGetUpgrade) WithIndex(v ...string) func(*IndicesGetUpgradeRequest) { + return func(r *IndicesGetUpgradeRequest) { + r.Index = v + } +} + +// WithAllowNoIndices - whether to ignore if a wildcard indices expression resolves into no concrete indices. (this includes `_all` string or when no indices have been specified). +func (f IndicesGetUpgrade) WithAllowNoIndices(v bool) func(*IndicesGetUpgradeRequest) { + return func(r *IndicesGetUpgradeRequest) { + r.AllowNoIndices = &v + } +} + +// WithExpandWildcards - whether to expand wildcard expression to concrete indices that are open, closed or both.. +func (f IndicesGetUpgrade) WithExpandWildcards(v string) func(*IndicesGetUpgradeRequest) { + return func(r *IndicesGetUpgradeRequest) { + r.ExpandWildcards = v + } +} + +// WithIgnoreUnavailable - whether specified concrete indices should be ignored when unavailable (missing or closed). +func (f IndicesGetUpgrade) WithIgnoreUnavailable(v bool) func(*IndicesGetUpgradeRequest) { + return func(r *IndicesGetUpgradeRequest) { + r.IgnoreUnavailable = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesGetUpgrade) WithPretty() func(*IndicesGetUpgradeRequest) { + return func(r *IndicesGetUpgradeRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesGetUpgrade) WithHuman() func(*IndicesGetUpgradeRequest) { + return func(r *IndicesGetUpgradeRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesGetUpgrade) WithErrorTrace() func(*IndicesGetUpgradeRequest) { + return func(r *IndicesGetUpgradeRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesGetUpgrade) WithFilterPath(v ...string) func(*IndicesGetUpgradeRequest) { + return func(r *IndicesGetUpgradeRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesGetUpgrade) WithHeader(h map[string]string) func(*IndicesGetUpgradeRequest) { + return func(r *IndicesGetUpgradeRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesGetUpgrade) WithOpaqueID(s string) func(*IndicesGetUpgradeRequest) { + return func(r *IndicesGetUpgradeRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.modify_data_stream.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.modify_data_stream.go new file mode 100644 index 00000000..471b344f --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.modify_data_stream.go @@ -0,0 +1,193 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newIndicesModifyDataStreamFunc(t Transport) IndicesModifyDataStream { + return func(body io.Reader, o ...func(*IndicesModifyDataStreamRequest)) (*Response, error) { + var r = IndicesModifyDataStreamRequest{Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesModifyDataStream modifies a data stream +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html. +type IndicesModifyDataStream func(body io.Reader, o ...func(*IndicesModifyDataStreamRequest)) (*Response, error) + +// IndicesModifyDataStreamRequest configures the Indices Modify Data Stream API request. +type IndicesModifyDataStreamRequest struct { + Body io.Reader + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesModifyDataStreamRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(len("/_data_stream/_modify")) + path.WriteString("/_data_stream/_modify") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesModifyDataStream) WithContext(v context.Context) func(*IndicesModifyDataStreamRequest) { + return func(r *IndicesModifyDataStreamRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesModifyDataStream) WithPretty() func(*IndicesModifyDataStreamRequest) { + return func(r *IndicesModifyDataStreamRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesModifyDataStream) WithHuman() func(*IndicesModifyDataStreamRequest) { + return func(r *IndicesModifyDataStreamRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesModifyDataStream) WithErrorTrace() func(*IndicesModifyDataStreamRequest) { + return func(r *IndicesModifyDataStreamRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesModifyDataStream) WithFilterPath(v ...string) func(*IndicesModifyDataStreamRequest) { + return func(r *IndicesModifyDataStreamRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesModifyDataStream) WithHeader(h map[string]string) func(*IndicesModifyDataStreamRequest) { + return func(r *IndicesModifyDataStreamRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesModifyDataStream) WithOpaqueID(s string) func(*IndicesModifyDataStreamRequest) { + return func(r *IndicesModifyDataStreamRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.open.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.open.go new file mode 100644 index 00000000..c26c2a61 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.open.go @@ -0,0 +1,271 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "errors" + "net/http" + "strconv" + "strings" + "time" +) + +func newIndicesOpenFunc(t Transport) IndicesOpen { + return func(index []string, o ...func(*IndicesOpenRequest)) (*Response, error) { + var r = IndicesOpenRequest{Index: index} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesOpen opens an index. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-open-close.html. +type IndicesOpen func(index []string, o ...func(*IndicesOpenRequest)) (*Response, error) + +// IndicesOpenRequest configures the Indices Open API request. +type IndicesOpenRequest struct { + Index []string + + AllowNoIndices *bool + ExpandWildcards string + IgnoreUnavailable *bool + MasterTimeout time.Duration + Timeout time.Duration + WaitForActiveShards string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesOpenRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + if len(r.Index) == 0 { + return nil, errors.New("index is required and cannot be nil or empty") + } + + path.Grow(1 + len(strings.Join(r.Index, ",")) + 1 + len("_open")) + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + path.WriteString("/") + path.WriteString("_open") + + params = make(map[string]string) + + if r.AllowNoIndices != nil { + params["allow_no_indices"] = strconv.FormatBool(*r.AllowNoIndices) + } + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if r.IgnoreUnavailable != nil { + params["ignore_unavailable"] = strconv.FormatBool(*r.IgnoreUnavailable) + } + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.WaitForActiveShards != "" { + params["wait_for_active_shards"] = r.WaitForActiveShards + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesOpen) WithContext(v context.Context) func(*IndicesOpenRequest) { + return func(r *IndicesOpenRequest) { + r.ctx = v + } +} + +// WithAllowNoIndices - whether to ignore if a wildcard indices expression resolves into no concrete indices. (this includes `_all` string or when no indices have been specified). +func (f IndicesOpen) WithAllowNoIndices(v bool) func(*IndicesOpenRequest) { + return func(r *IndicesOpenRequest) { + r.AllowNoIndices = &v + } +} + +// WithExpandWildcards - whether to expand wildcard expression to concrete indices that are open, closed or both.. +func (f IndicesOpen) WithExpandWildcards(v string) func(*IndicesOpenRequest) { + return func(r *IndicesOpenRequest) { + r.ExpandWildcards = v + } +} + +// WithIgnoreUnavailable - whether specified concrete indices should be ignored when unavailable (missing or closed). +func (f IndicesOpen) WithIgnoreUnavailable(v bool) func(*IndicesOpenRequest) { + return func(r *IndicesOpenRequest) { + r.IgnoreUnavailable = &v + } +} + +// WithMasterTimeout - specify timeout for connection to master. +func (f IndicesOpen) WithMasterTimeout(v time.Duration) func(*IndicesOpenRequest) { + return func(r *IndicesOpenRequest) { + r.MasterTimeout = v + } +} + +// WithTimeout - explicit operation timeout. +func (f IndicesOpen) WithTimeout(v time.Duration) func(*IndicesOpenRequest) { + return func(r *IndicesOpenRequest) { + r.Timeout = v + } +} + +// WithWaitForActiveShards - sets the number of active shards to wait for before the operation returns.. +func (f IndicesOpen) WithWaitForActiveShards(v string) func(*IndicesOpenRequest) { + return func(r *IndicesOpenRequest) { + r.WaitForActiveShards = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesOpen) WithPretty() func(*IndicesOpenRequest) { + return func(r *IndicesOpenRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesOpen) WithHuman() func(*IndicesOpenRequest) { + return func(r *IndicesOpenRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesOpen) WithErrorTrace() func(*IndicesOpenRequest) { + return func(r *IndicesOpenRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesOpen) WithFilterPath(v ...string) func(*IndicesOpenRequest) { + return func(r *IndicesOpenRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesOpen) WithHeader(h map[string]string) func(*IndicesOpenRequest) { + return func(r *IndicesOpenRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesOpen) WithOpaqueID(s string) func(*IndicesOpenRequest) { + return func(r *IndicesOpenRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.put_alias.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.put_alias.go new file mode 100644 index 00000000..0ae340e0 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.put_alias.go @@ -0,0 +1,240 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "errors" + "io" + "net/http" + "strings" + "time" +) + +func newIndicesPutAliasFunc(t Transport) IndicesPutAlias { + return func(index []string, name string, o ...func(*IndicesPutAliasRequest)) (*Response, error) { + var r = IndicesPutAliasRequest{Index: index, Name: name} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesPutAlias creates or updates an alias. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html. +type IndicesPutAlias func(index []string, name string, o ...func(*IndicesPutAliasRequest)) (*Response, error) + +// IndicesPutAliasRequest configures the Indices Put Alias API request. +type IndicesPutAliasRequest struct { + Index []string + + Body io.Reader + + Name string + + MasterTimeout time.Duration + Timeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesPutAliasRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + if len(r.Index) == 0 { + return nil, errors.New("index is required and cannot be nil or empty") + } + + path.Grow(1 + len(strings.Join(r.Index, ",")) + 1 + len("_aliases") + 1 + len(r.Name)) + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + path.WriteString("/") + path.WriteString("_aliases") + path.WriteString("/") + path.WriteString(r.Name) + + params = make(map[string]string) + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesPutAlias) WithContext(v context.Context) func(*IndicesPutAliasRequest) { + return func(r *IndicesPutAliasRequest) { + r.ctx = v + } +} + +// WithBody - The settings for the alias, such as `routing` or `filter`. +func (f IndicesPutAlias) WithBody(v io.Reader) func(*IndicesPutAliasRequest) { + return func(r *IndicesPutAliasRequest) { + r.Body = v + } +} + +// WithMasterTimeout - specify timeout for connection to master. +func (f IndicesPutAlias) WithMasterTimeout(v time.Duration) func(*IndicesPutAliasRequest) { + return func(r *IndicesPutAliasRequest) { + r.MasterTimeout = v + } +} + +// WithTimeout - explicit timestamp for the document. +func (f IndicesPutAlias) WithTimeout(v time.Duration) func(*IndicesPutAliasRequest) { + return func(r *IndicesPutAliasRequest) { + r.Timeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesPutAlias) WithPretty() func(*IndicesPutAliasRequest) { + return func(r *IndicesPutAliasRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesPutAlias) WithHuman() func(*IndicesPutAliasRequest) { + return func(r *IndicesPutAliasRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesPutAlias) WithErrorTrace() func(*IndicesPutAliasRequest) { + return func(r *IndicesPutAliasRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesPutAlias) WithFilterPath(v ...string) func(*IndicesPutAliasRequest) { + return func(r *IndicesPutAliasRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesPutAlias) WithHeader(h map[string]string) func(*IndicesPutAliasRequest) { + return func(r *IndicesPutAliasRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesPutAlias) WithOpaqueID(s string) func(*IndicesPutAliasRequest) { + return func(r *IndicesPutAliasRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.put_index_template.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.put_index_template.go new file mode 100644 index 00000000..1eecec28 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.put_index_template.go @@ -0,0 +1,237 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" + "time" +) + +func newIndicesPutIndexTemplateFunc(t Transport) IndicesPutIndexTemplate { + return func(name string, body io.Reader, o ...func(*IndicesPutIndexTemplateRequest)) (*Response, error) { + var r = IndicesPutIndexTemplateRequest{Name: name, Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesPutIndexTemplate creates or updates an index template. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html. +type IndicesPutIndexTemplate func(name string, body io.Reader, o ...func(*IndicesPutIndexTemplateRequest)) (*Response, error) + +// IndicesPutIndexTemplateRequest configures the Indices Put Index Template API request. +type IndicesPutIndexTemplateRequest struct { + Body io.Reader + + Name string + + Cause string + Create *bool + MasterTimeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesPutIndexTemplateRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(1 + len("_index_template") + 1 + len(r.Name)) + path.WriteString("/") + path.WriteString("_index_template") + path.WriteString("/") + path.WriteString(r.Name) + + params = make(map[string]string) + + if r.Cause != "" { + params["cause"] = r.Cause + } + + if r.Create != nil { + params["create"] = strconv.FormatBool(*r.Create) + } + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesPutIndexTemplate) WithContext(v context.Context) func(*IndicesPutIndexTemplateRequest) { + return func(r *IndicesPutIndexTemplateRequest) { + r.ctx = v + } +} + +// WithCause - user defined reason for creating/updating the index template. +func (f IndicesPutIndexTemplate) WithCause(v string) func(*IndicesPutIndexTemplateRequest) { + return func(r *IndicesPutIndexTemplateRequest) { + r.Cause = v + } +} + +// WithCreate - whether the index template should only be added if new or can also replace an existing one. +func (f IndicesPutIndexTemplate) WithCreate(v bool) func(*IndicesPutIndexTemplateRequest) { + return func(r *IndicesPutIndexTemplateRequest) { + r.Create = &v + } +} + +// WithMasterTimeout - specify timeout for connection to master. +func (f IndicesPutIndexTemplate) WithMasterTimeout(v time.Duration) func(*IndicesPutIndexTemplateRequest) { + return func(r *IndicesPutIndexTemplateRequest) { + r.MasterTimeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesPutIndexTemplate) WithPretty() func(*IndicesPutIndexTemplateRequest) { + return func(r *IndicesPutIndexTemplateRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesPutIndexTemplate) WithHuman() func(*IndicesPutIndexTemplateRequest) { + return func(r *IndicesPutIndexTemplateRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesPutIndexTemplate) WithErrorTrace() func(*IndicesPutIndexTemplateRequest) { + return func(r *IndicesPutIndexTemplateRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesPutIndexTemplate) WithFilterPath(v ...string) func(*IndicesPutIndexTemplateRequest) { + return func(r *IndicesPutIndexTemplateRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesPutIndexTemplate) WithHeader(h map[string]string) func(*IndicesPutIndexTemplateRequest) { + return func(r *IndicesPutIndexTemplateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesPutIndexTemplate) WithOpaqueID(s string) func(*IndicesPutIndexTemplateRequest) { + return func(r *IndicesPutIndexTemplateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.put_mapping.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.put_mapping.go new file mode 100644 index 00000000..ef1c0f27 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.put_mapping.go @@ -0,0 +1,306 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" + "time" +) + +func newIndicesPutMappingFunc(t Transport) IndicesPutMapping { + return func(body io.Reader, o ...func(*IndicesPutMappingRequest)) (*Response, error) { + var r = IndicesPutMappingRequest{Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesPutMapping updates the index mappings. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-put-mapping.html. +type IndicesPutMapping func(body io.Reader, o ...func(*IndicesPutMappingRequest)) (*Response, error) + +// IndicesPutMappingRequest configures the Indices Put Mapping API request. +type IndicesPutMappingRequest struct { + Index []string + DocumentType string + + Body io.Reader + + AllowNoIndices *bool + ExpandWildcards string + IgnoreUnavailable *bool + IncludeTypeName *bool + MasterTimeout time.Duration + Timeout time.Duration + WriteIndexOnly *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesPutMappingRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(len(strings.Join(r.Index, ",")) + len("/_mapping") + len(r.DocumentType) + 2) + if len(r.Index) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + } + path.WriteString("/") + path.WriteString("_mapping") + if r.DocumentType != "" { + path.WriteString("/") + path.WriteString(r.DocumentType) + } + + params = make(map[string]string) + + if r.AllowNoIndices != nil { + params["allow_no_indices"] = strconv.FormatBool(*r.AllowNoIndices) + } + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if r.IgnoreUnavailable != nil { + params["ignore_unavailable"] = strconv.FormatBool(*r.IgnoreUnavailable) + } + + if r.IncludeTypeName != nil { + params["include_type_name"] = strconv.FormatBool(*r.IncludeTypeName) + } + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.WriteIndexOnly != nil { + params["write_index_only"] = strconv.FormatBool(*r.WriteIndexOnly) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesPutMapping) WithContext(v context.Context) func(*IndicesPutMappingRequest) { + return func(r *IndicesPutMappingRequest) { + r.ctx = v + } +} + +// WithIndex - a list of index names the mapping should be added to (supports wildcards); use `_all` or omit to add the mapping on all indices.. +func (f IndicesPutMapping) WithIndex(v ...string) func(*IndicesPutMappingRequest) { + return func(r *IndicesPutMappingRequest) { + r.Index = v + } +} + +// WithDocumentType - the name of the document type. +func (f IndicesPutMapping) WithDocumentType(v string) func(*IndicesPutMappingRequest) { + return func(r *IndicesPutMappingRequest) { + r.DocumentType = v + } +} + +// WithAllowNoIndices - whether to ignore if a wildcard indices expression resolves into no concrete indices. (this includes `_all` string or when no indices have been specified). +func (f IndicesPutMapping) WithAllowNoIndices(v bool) func(*IndicesPutMappingRequest) { + return func(r *IndicesPutMappingRequest) { + r.AllowNoIndices = &v + } +} + +// WithExpandWildcards - whether to expand wildcard expression to concrete indices that are open, closed or both.. +func (f IndicesPutMapping) WithExpandWildcards(v string) func(*IndicesPutMappingRequest) { + return func(r *IndicesPutMappingRequest) { + r.ExpandWildcards = v + } +} + +// WithIgnoreUnavailable - whether specified concrete indices should be ignored when unavailable (missing or closed). +func (f IndicesPutMapping) WithIgnoreUnavailable(v bool) func(*IndicesPutMappingRequest) { + return func(r *IndicesPutMappingRequest) { + r.IgnoreUnavailable = &v + } +} + +// WithIncludeTypeName - whether a type should be expected in the body of the mappings.. +func (f IndicesPutMapping) WithIncludeTypeName(v bool) func(*IndicesPutMappingRequest) { + return func(r *IndicesPutMappingRequest) { + r.IncludeTypeName = &v + } +} + +// WithMasterTimeout - specify timeout for connection to master. +func (f IndicesPutMapping) WithMasterTimeout(v time.Duration) func(*IndicesPutMappingRequest) { + return func(r *IndicesPutMappingRequest) { + r.MasterTimeout = v + } +} + +// WithTimeout - explicit operation timeout. +func (f IndicesPutMapping) WithTimeout(v time.Duration) func(*IndicesPutMappingRequest) { + return func(r *IndicesPutMappingRequest) { + r.Timeout = v + } +} + +// WithWriteIndexOnly - when true, applies mappings only to the write index of an alias or data stream. +func (f IndicesPutMapping) WithWriteIndexOnly(v bool) func(*IndicesPutMappingRequest) { + return func(r *IndicesPutMappingRequest) { + r.WriteIndexOnly = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesPutMapping) WithPretty() func(*IndicesPutMappingRequest) { + return func(r *IndicesPutMappingRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesPutMapping) WithHuman() func(*IndicesPutMappingRequest) { + return func(r *IndicesPutMappingRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesPutMapping) WithErrorTrace() func(*IndicesPutMappingRequest) { + return func(r *IndicesPutMappingRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesPutMapping) WithFilterPath(v ...string) func(*IndicesPutMappingRequest) { + return func(r *IndicesPutMappingRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesPutMapping) WithHeader(h map[string]string) func(*IndicesPutMappingRequest) { + return func(r *IndicesPutMappingRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesPutMapping) WithOpaqueID(s string) func(*IndicesPutMappingRequest) { + return func(r *IndicesPutMappingRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.put_settings.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.put_settings.go new file mode 100644 index 00000000..56b05c08 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.put_settings.go @@ -0,0 +1,294 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" + "time" +) + +func newIndicesPutSettingsFunc(t Transport) IndicesPutSettings { + return func(body io.Reader, o ...func(*IndicesPutSettingsRequest)) (*Response, error) { + var r = IndicesPutSettingsRequest{Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesPutSettings updates the index settings. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-update-settings.html. +type IndicesPutSettings func(body io.Reader, o ...func(*IndicesPutSettingsRequest)) (*Response, error) + +// IndicesPutSettingsRequest configures the Indices Put Settings API request. +type IndicesPutSettingsRequest struct { + Index []string + + Body io.Reader + + AllowNoIndices *bool + ExpandWildcards string + FlatSettings *bool + IgnoreUnavailable *bool + MasterTimeout time.Duration + PreserveExisting *bool + Timeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesPutSettingsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(1 + len(strings.Join(r.Index, ",")) + 1 + len("_settings")) + if len(r.Index) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + } + path.WriteString("/") + path.WriteString("_settings") + + params = make(map[string]string) + + if r.AllowNoIndices != nil { + params["allow_no_indices"] = strconv.FormatBool(*r.AllowNoIndices) + } + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if r.FlatSettings != nil { + params["flat_settings"] = strconv.FormatBool(*r.FlatSettings) + } + + if r.IgnoreUnavailable != nil { + params["ignore_unavailable"] = strconv.FormatBool(*r.IgnoreUnavailable) + } + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.PreserveExisting != nil { + params["preserve_existing"] = strconv.FormatBool(*r.PreserveExisting) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesPutSettings) WithContext(v context.Context) func(*IndicesPutSettingsRequest) { + return func(r *IndicesPutSettingsRequest) { + r.ctx = v + } +} + +// WithIndex - a list of index names; use _all to perform the operation on all indices. +func (f IndicesPutSettings) WithIndex(v ...string) func(*IndicesPutSettingsRequest) { + return func(r *IndicesPutSettingsRequest) { + r.Index = v + } +} + +// WithAllowNoIndices - whether to ignore if a wildcard indices expression resolves into no concrete indices. (this includes `_all` string or when no indices have been specified). +func (f IndicesPutSettings) WithAllowNoIndices(v bool) func(*IndicesPutSettingsRequest) { + return func(r *IndicesPutSettingsRequest) { + r.AllowNoIndices = &v + } +} + +// WithExpandWildcards - whether to expand wildcard expression to concrete indices that are open, closed or both.. +func (f IndicesPutSettings) WithExpandWildcards(v string) func(*IndicesPutSettingsRequest) { + return func(r *IndicesPutSettingsRequest) { + r.ExpandWildcards = v + } +} + +// WithFlatSettings - return settings in flat format (default: false). +func (f IndicesPutSettings) WithFlatSettings(v bool) func(*IndicesPutSettingsRequest) { + return func(r *IndicesPutSettingsRequest) { + r.FlatSettings = &v + } +} + +// WithIgnoreUnavailable - whether specified concrete indices should be ignored when unavailable (missing or closed). +func (f IndicesPutSettings) WithIgnoreUnavailable(v bool) func(*IndicesPutSettingsRequest) { + return func(r *IndicesPutSettingsRequest) { + r.IgnoreUnavailable = &v + } +} + +// WithMasterTimeout - specify timeout for connection to master. +func (f IndicesPutSettings) WithMasterTimeout(v time.Duration) func(*IndicesPutSettingsRequest) { + return func(r *IndicesPutSettingsRequest) { + r.MasterTimeout = v + } +} + +// WithPreserveExisting - whether to update existing settings. if set to `true` existing settings on an index remain unchanged, the default is `false`. +func (f IndicesPutSettings) WithPreserveExisting(v bool) func(*IndicesPutSettingsRequest) { + return func(r *IndicesPutSettingsRequest) { + r.PreserveExisting = &v + } +} + +// WithTimeout - explicit operation timeout. +func (f IndicesPutSettings) WithTimeout(v time.Duration) func(*IndicesPutSettingsRequest) { + return func(r *IndicesPutSettingsRequest) { + r.Timeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesPutSettings) WithPretty() func(*IndicesPutSettingsRequest) { + return func(r *IndicesPutSettingsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesPutSettings) WithHuman() func(*IndicesPutSettingsRequest) { + return func(r *IndicesPutSettingsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesPutSettings) WithErrorTrace() func(*IndicesPutSettingsRequest) { + return func(r *IndicesPutSettingsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesPutSettings) WithFilterPath(v ...string) func(*IndicesPutSettingsRequest) { + return func(r *IndicesPutSettingsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesPutSettings) WithHeader(h map[string]string) func(*IndicesPutSettingsRequest) { + return func(r *IndicesPutSettingsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesPutSettings) WithOpaqueID(s string) func(*IndicesPutSettingsRequest) { + return func(r *IndicesPutSettingsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.put_template.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.put_template.go new file mode 100644 index 00000000..39ef948a --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.put_template.go @@ -0,0 +1,249 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" + "time" +) + +func newIndicesPutTemplateFunc(t Transport) IndicesPutTemplate { + return func(name string, body io.Reader, o ...func(*IndicesPutTemplateRequest)) (*Response, error) { + var r = IndicesPutTemplateRequest{Name: name, Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesPutTemplate creates or updates an index template. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html. +type IndicesPutTemplate func(name string, body io.Reader, o ...func(*IndicesPutTemplateRequest)) (*Response, error) + +// IndicesPutTemplateRequest configures the Indices Put Template API request. +type IndicesPutTemplateRequest struct { + Body io.Reader + + Name string + + Create *bool + IncludeTypeName *bool + MasterTimeout time.Duration + Order *int + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesPutTemplateRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(1 + len("_template") + 1 + len(r.Name)) + path.WriteString("/") + path.WriteString("_template") + path.WriteString("/") + path.WriteString(r.Name) + + params = make(map[string]string) + + if r.Create != nil { + params["create"] = strconv.FormatBool(*r.Create) + } + + if r.IncludeTypeName != nil { + params["include_type_name"] = strconv.FormatBool(*r.IncludeTypeName) + } + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Order != nil { + params["order"] = strconv.FormatInt(int64(*r.Order), 10) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesPutTemplate) WithContext(v context.Context) func(*IndicesPutTemplateRequest) { + return func(r *IndicesPutTemplateRequest) { + r.ctx = v + } +} + +// WithCreate - whether the index template should only be added if new or can also replace an existing one. +func (f IndicesPutTemplate) WithCreate(v bool) func(*IndicesPutTemplateRequest) { + return func(r *IndicesPutTemplateRequest) { + r.Create = &v + } +} + +// WithIncludeTypeName - whether a type should be returned in the body of the mappings.. +func (f IndicesPutTemplate) WithIncludeTypeName(v bool) func(*IndicesPutTemplateRequest) { + return func(r *IndicesPutTemplateRequest) { + r.IncludeTypeName = &v + } +} + +// WithMasterTimeout - specify timeout for connection to master. +func (f IndicesPutTemplate) WithMasterTimeout(v time.Duration) func(*IndicesPutTemplateRequest) { + return func(r *IndicesPutTemplateRequest) { + r.MasterTimeout = v + } +} + +// WithOrder - the order for this template when merging multiple matching ones (higher numbers are merged later, overriding the lower numbers). +func (f IndicesPutTemplate) WithOrder(v int) func(*IndicesPutTemplateRequest) { + return func(r *IndicesPutTemplateRequest) { + r.Order = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesPutTemplate) WithPretty() func(*IndicesPutTemplateRequest) { + return func(r *IndicesPutTemplateRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesPutTemplate) WithHuman() func(*IndicesPutTemplateRequest) { + return func(r *IndicesPutTemplateRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesPutTemplate) WithErrorTrace() func(*IndicesPutTemplateRequest) { + return func(r *IndicesPutTemplateRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesPutTemplate) WithFilterPath(v ...string) func(*IndicesPutTemplateRequest) { + return func(r *IndicesPutTemplateRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesPutTemplate) WithHeader(h map[string]string) func(*IndicesPutTemplateRequest) { + return func(r *IndicesPutTemplateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesPutTemplate) WithOpaqueID(s string) func(*IndicesPutTemplateRequest) { + return func(r *IndicesPutTemplateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.recovery.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.recovery.go new file mode 100644 index 00000000..ddeb654f --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.recovery.go @@ -0,0 +1,226 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newIndicesRecoveryFunc(t Transport) IndicesRecovery { + return func(o ...func(*IndicesRecoveryRequest)) (*Response, error) { + var r = IndicesRecoveryRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesRecovery returns information about ongoing index shard recoveries. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-recovery.html. +type IndicesRecovery func(o ...func(*IndicesRecoveryRequest)) (*Response, error) + +// IndicesRecoveryRequest configures the Indices Recovery API request. +type IndicesRecoveryRequest struct { + Index []string + + ActiveOnly *bool + Detailed *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesRecoveryRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len(strings.Join(r.Index, ",")) + 1 + len("_recovery")) + if len(r.Index) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + } + path.WriteString("/") + path.WriteString("_recovery") + + params = make(map[string]string) + + if r.ActiveOnly != nil { + params["active_only"] = strconv.FormatBool(*r.ActiveOnly) + } + + if r.Detailed != nil { + params["detailed"] = strconv.FormatBool(*r.Detailed) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesRecovery) WithContext(v context.Context) func(*IndicesRecoveryRequest) { + return func(r *IndicesRecoveryRequest) { + r.ctx = v + } +} + +// WithIndex - a list of index names; use _all to perform the operation on all indices. +func (f IndicesRecovery) WithIndex(v ...string) func(*IndicesRecoveryRequest) { + return func(r *IndicesRecoveryRequest) { + r.Index = v + } +} + +// WithActiveOnly - display only those recoveries that are currently on-going. +func (f IndicesRecovery) WithActiveOnly(v bool) func(*IndicesRecoveryRequest) { + return func(r *IndicesRecoveryRequest) { + r.ActiveOnly = &v + } +} + +// WithDetailed - whether to display detailed information about shard recovery. +func (f IndicesRecovery) WithDetailed(v bool) func(*IndicesRecoveryRequest) { + return func(r *IndicesRecoveryRequest) { + r.Detailed = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesRecovery) WithPretty() func(*IndicesRecoveryRequest) { + return func(r *IndicesRecoveryRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesRecovery) WithHuman() func(*IndicesRecoveryRequest) { + return func(r *IndicesRecoveryRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesRecovery) WithErrorTrace() func(*IndicesRecoveryRequest) { + return func(r *IndicesRecoveryRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesRecovery) WithFilterPath(v ...string) func(*IndicesRecoveryRequest) { + return func(r *IndicesRecoveryRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesRecovery) WithHeader(h map[string]string) func(*IndicesRecoveryRequest) { + return func(r *IndicesRecoveryRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesRecovery) WithOpaqueID(s string) func(*IndicesRecoveryRequest) { + return func(r *IndicesRecoveryRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.refresh.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.refresh.go new file mode 100644 index 00000000..8c450444 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.refresh.go @@ -0,0 +1,238 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newIndicesRefreshFunc(t Transport) IndicesRefresh { + return func(o ...func(*IndicesRefreshRequest)) (*Response, error) { + var r = IndicesRefreshRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesRefresh performs the refresh operation in one or more indices. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-refresh.html. +type IndicesRefresh func(o ...func(*IndicesRefreshRequest)) (*Response, error) + +// IndicesRefreshRequest configures the Indices Refresh API request. +type IndicesRefreshRequest struct { + Index []string + + AllowNoIndices *bool + ExpandWildcards string + IgnoreUnavailable *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesRefreshRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len(strings.Join(r.Index, ",")) + 1 + len("_refresh")) + if len(r.Index) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + } + path.WriteString("/") + path.WriteString("_refresh") + + params = make(map[string]string) + + if r.AllowNoIndices != nil { + params["allow_no_indices"] = strconv.FormatBool(*r.AllowNoIndices) + } + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if r.IgnoreUnavailable != nil { + params["ignore_unavailable"] = strconv.FormatBool(*r.IgnoreUnavailable) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesRefresh) WithContext(v context.Context) func(*IndicesRefreshRequest) { + return func(r *IndicesRefreshRequest) { + r.ctx = v + } +} + +// WithIndex - a list of index names; use _all to perform the operation on all indices. +func (f IndicesRefresh) WithIndex(v ...string) func(*IndicesRefreshRequest) { + return func(r *IndicesRefreshRequest) { + r.Index = v + } +} + +// WithAllowNoIndices - whether to ignore if a wildcard indices expression resolves into no concrete indices. (this includes `_all` string or when no indices have been specified). +func (f IndicesRefresh) WithAllowNoIndices(v bool) func(*IndicesRefreshRequest) { + return func(r *IndicesRefreshRequest) { + r.AllowNoIndices = &v + } +} + +// WithExpandWildcards - whether to expand wildcard expression to concrete indices that are open, closed or both.. +func (f IndicesRefresh) WithExpandWildcards(v string) func(*IndicesRefreshRequest) { + return func(r *IndicesRefreshRequest) { + r.ExpandWildcards = v + } +} + +// WithIgnoreUnavailable - whether specified concrete indices should be ignored when unavailable (missing or closed). +func (f IndicesRefresh) WithIgnoreUnavailable(v bool) func(*IndicesRefreshRequest) { + return func(r *IndicesRefreshRequest) { + r.IgnoreUnavailable = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesRefresh) WithPretty() func(*IndicesRefreshRequest) { + return func(r *IndicesRefreshRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesRefresh) WithHuman() func(*IndicesRefreshRequest) { + return func(r *IndicesRefreshRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesRefresh) WithErrorTrace() func(*IndicesRefreshRequest) { + return func(r *IndicesRefreshRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesRefresh) WithFilterPath(v ...string) func(*IndicesRefreshRequest) { + return func(r *IndicesRefreshRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesRefresh) WithHeader(h map[string]string) func(*IndicesRefreshRequest) { + return func(r *IndicesRefreshRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesRefresh) WithOpaqueID(s string) func(*IndicesRefreshRequest) { + return func(r *IndicesRefreshRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.resolve_index.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.resolve_index.go new file mode 100644 index 00000000..34d3356f --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.resolve_index.go @@ -0,0 +1,211 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "errors" + "net/http" + "strings" +) + +func newIndicesResolveIndexFunc(t Transport) IndicesResolveIndex { + return func(name []string, o ...func(*IndicesResolveIndexRequest)) (*Response, error) { + var r = IndicesResolveIndexRequest{Name: name} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesResolveIndex returns information about any matching indices, aliases, and data streams +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-resolve-index-api.html. +type IndicesResolveIndex func(name []string, o ...func(*IndicesResolveIndexRequest)) (*Response, error) + +// IndicesResolveIndexRequest configures the Indices Resolve Index API request. +type IndicesResolveIndexRequest struct { + Name []string + + ExpandWildcards string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesResolveIndexRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + if len(r.Name) == 0 { + return nil, errors.New("name is required and cannot be nil or empty") + } + + path.Grow(1 + len("_resolve") + 1 + len("index") + 1 + len(strings.Join(r.Name, ","))) + path.WriteString("/") + path.WriteString("_resolve") + path.WriteString("/") + path.WriteString("index") + path.WriteString("/") + path.WriteString(strings.Join(r.Name, ",")) + + params = make(map[string]string) + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesResolveIndex) WithContext(v context.Context) func(*IndicesResolveIndexRequest) { + return func(r *IndicesResolveIndexRequest) { + r.ctx = v + } +} + +// WithExpandWildcards - whether wildcard expressions should get expanded to open or closed indices (default: open). +func (f IndicesResolveIndex) WithExpandWildcards(v string) func(*IndicesResolveIndexRequest) { + return func(r *IndicesResolveIndexRequest) { + r.ExpandWildcards = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesResolveIndex) WithPretty() func(*IndicesResolveIndexRequest) { + return func(r *IndicesResolveIndexRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesResolveIndex) WithHuman() func(*IndicesResolveIndexRequest) { + return func(r *IndicesResolveIndexRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesResolveIndex) WithErrorTrace() func(*IndicesResolveIndexRequest) { + return func(r *IndicesResolveIndexRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesResolveIndex) WithFilterPath(v ...string) func(*IndicesResolveIndexRequest) { + return func(r *IndicesResolveIndexRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesResolveIndex) WithHeader(h map[string]string) func(*IndicesResolveIndexRequest) { + return func(r *IndicesResolveIndexRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesResolveIndex) WithOpaqueID(s string) func(*IndicesResolveIndexRequest) { + return func(r *IndicesResolveIndexRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.rollover.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.rollover.go new file mode 100644 index 00000000..a9f3efa2 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.rollover.go @@ -0,0 +1,281 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" + "time" +) + +func newIndicesRolloverFunc(t Transport) IndicesRollover { + return func(alias string, o ...func(*IndicesRolloverRequest)) (*Response, error) { + var r = IndicesRolloverRequest{Alias: alias} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesRollover updates an alias to point to a new index when the existing index +// is considered to be too large or too old. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-rollover-index.html. +type IndicesRollover func(alias string, o ...func(*IndicesRolloverRequest)) (*Response, error) + +// IndicesRolloverRequest configures the Indices Rollover API request. +type IndicesRolloverRequest struct { + Body io.Reader + + Alias string + NewIndex string + + DryRun *bool + IncludeTypeName *bool + MasterTimeout time.Duration + Timeout time.Duration + WaitForActiveShards string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesRolloverRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len(r.Alias) + 1 + len("_rollover") + 1 + len(r.NewIndex)) + path.WriteString("/") + path.WriteString(r.Alias) + path.WriteString("/") + path.WriteString("_rollover") + if r.NewIndex != "" { + path.WriteString("/") + path.WriteString(r.NewIndex) + } + + params = make(map[string]string) + + if r.DryRun != nil { + params["dry_run"] = strconv.FormatBool(*r.DryRun) + } + + if r.IncludeTypeName != nil { + params["include_type_name"] = strconv.FormatBool(*r.IncludeTypeName) + } + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.WaitForActiveShards != "" { + params["wait_for_active_shards"] = r.WaitForActiveShards + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesRollover) WithContext(v context.Context) func(*IndicesRolloverRequest) { + return func(r *IndicesRolloverRequest) { + r.ctx = v + } +} + +// WithBody - The conditions that needs to be met for executing rollover. +func (f IndicesRollover) WithBody(v io.Reader) func(*IndicesRolloverRequest) { + return func(r *IndicesRolloverRequest) { + r.Body = v + } +} + +// WithNewIndex - the name of the rollover index. +func (f IndicesRollover) WithNewIndex(v string) func(*IndicesRolloverRequest) { + return func(r *IndicesRolloverRequest) { + r.NewIndex = v + } +} + +// WithDryRun - if set to true the rollover action will only be validated but not actually performed even if a condition matches. the default is false. +func (f IndicesRollover) WithDryRun(v bool) func(*IndicesRolloverRequest) { + return func(r *IndicesRolloverRequest) { + r.DryRun = &v + } +} + +// WithIncludeTypeName - whether a type should be included in the body of the mappings.. +func (f IndicesRollover) WithIncludeTypeName(v bool) func(*IndicesRolloverRequest) { + return func(r *IndicesRolloverRequest) { + r.IncludeTypeName = &v + } +} + +// WithMasterTimeout - specify timeout for connection to master. +func (f IndicesRollover) WithMasterTimeout(v time.Duration) func(*IndicesRolloverRequest) { + return func(r *IndicesRolloverRequest) { + r.MasterTimeout = v + } +} + +// WithTimeout - explicit operation timeout. +func (f IndicesRollover) WithTimeout(v time.Duration) func(*IndicesRolloverRequest) { + return func(r *IndicesRolloverRequest) { + r.Timeout = v + } +} + +// WithWaitForActiveShards - set the number of active shards to wait for on the newly created rollover index before the operation returns.. +func (f IndicesRollover) WithWaitForActiveShards(v string) func(*IndicesRolloverRequest) { + return func(r *IndicesRolloverRequest) { + r.WaitForActiveShards = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesRollover) WithPretty() func(*IndicesRolloverRequest) { + return func(r *IndicesRolloverRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesRollover) WithHuman() func(*IndicesRolloverRequest) { + return func(r *IndicesRolloverRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesRollover) WithErrorTrace() func(*IndicesRolloverRequest) { + return func(r *IndicesRolloverRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesRollover) WithFilterPath(v ...string) func(*IndicesRolloverRequest) { + return func(r *IndicesRolloverRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesRollover) WithHeader(h map[string]string) func(*IndicesRolloverRequest) { + return func(r *IndicesRolloverRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesRollover) WithOpaqueID(s string) func(*IndicesRolloverRequest) { + return func(r *IndicesRolloverRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.segments.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.segments.go new file mode 100644 index 00000000..8da7f6c1 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.segments.go @@ -0,0 +1,250 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newIndicesSegmentsFunc(t Transport) IndicesSegments { + return func(o ...func(*IndicesSegmentsRequest)) (*Response, error) { + var r = IndicesSegmentsRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesSegments provides low-level information about segments in a Lucene index. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-segments.html. +type IndicesSegments func(o ...func(*IndicesSegmentsRequest)) (*Response, error) + +// IndicesSegmentsRequest configures the Indices Segments API request. +type IndicesSegmentsRequest struct { + Index []string + + AllowNoIndices *bool + ExpandWildcards string + IgnoreUnavailable *bool + Verbose *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesSegmentsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len(strings.Join(r.Index, ",")) + 1 + len("_segments")) + if len(r.Index) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + } + path.WriteString("/") + path.WriteString("_segments") + + params = make(map[string]string) + + if r.AllowNoIndices != nil { + params["allow_no_indices"] = strconv.FormatBool(*r.AllowNoIndices) + } + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if r.IgnoreUnavailable != nil { + params["ignore_unavailable"] = strconv.FormatBool(*r.IgnoreUnavailable) + } + + if r.Verbose != nil { + params["verbose"] = strconv.FormatBool(*r.Verbose) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesSegments) WithContext(v context.Context) func(*IndicesSegmentsRequest) { + return func(r *IndicesSegmentsRequest) { + r.ctx = v + } +} + +// WithIndex - a list of index names; use _all to perform the operation on all indices. +func (f IndicesSegments) WithIndex(v ...string) func(*IndicesSegmentsRequest) { + return func(r *IndicesSegmentsRequest) { + r.Index = v + } +} + +// WithAllowNoIndices - whether to ignore if a wildcard indices expression resolves into no concrete indices. (this includes `_all` string or when no indices have been specified). +func (f IndicesSegments) WithAllowNoIndices(v bool) func(*IndicesSegmentsRequest) { + return func(r *IndicesSegmentsRequest) { + r.AllowNoIndices = &v + } +} + +// WithExpandWildcards - whether to expand wildcard expression to concrete indices that are open, closed or both.. +func (f IndicesSegments) WithExpandWildcards(v string) func(*IndicesSegmentsRequest) { + return func(r *IndicesSegmentsRequest) { + r.ExpandWildcards = v + } +} + +// WithIgnoreUnavailable - whether specified concrete indices should be ignored when unavailable (missing or closed). +func (f IndicesSegments) WithIgnoreUnavailable(v bool) func(*IndicesSegmentsRequest) { + return func(r *IndicesSegmentsRequest) { + r.IgnoreUnavailable = &v + } +} + +// WithVerbose - includes detailed memory usage by lucene.. +func (f IndicesSegments) WithVerbose(v bool) func(*IndicesSegmentsRequest) { + return func(r *IndicesSegmentsRequest) { + r.Verbose = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesSegments) WithPretty() func(*IndicesSegmentsRequest) { + return func(r *IndicesSegmentsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesSegments) WithHuman() func(*IndicesSegmentsRequest) { + return func(r *IndicesSegmentsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesSegments) WithErrorTrace() func(*IndicesSegmentsRequest) { + return func(r *IndicesSegmentsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesSegments) WithFilterPath(v ...string) func(*IndicesSegmentsRequest) { + return func(r *IndicesSegmentsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesSegments) WithHeader(h map[string]string) func(*IndicesSegmentsRequest) { + return func(r *IndicesSegmentsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesSegments) WithOpaqueID(s string) func(*IndicesSegmentsRequest) { + return func(r *IndicesSegmentsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.shard_stores.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.shard_stores.go new file mode 100644 index 00000000..cbf35488 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.shard_stores.go @@ -0,0 +1,250 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newIndicesShardStoresFunc(t Transport) IndicesShardStores { + return func(o ...func(*IndicesShardStoresRequest)) (*Response, error) { + var r = IndicesShardStoresRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesShardStores provides store information for shard copies of indices. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-shards-stores.html. +type IndicesShardStores func(o ...func(*IndicesShardStoresRequest)) (*Response, error) + +// IndicesShardStoresRequest configures the Indices Shard Stores API request. +type IndicesShardStoresRequest struct { + Index []string + + AllowNoIndices *bool + ExpandWildcards string + IgnoreUnavailable *bool + Status []string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesShardStoresRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len(strings.Join(r.Index, ",")) + 1 + len("_shard_stores")) + if len(r.Index) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + } + path.WriteString("/") + path.WriteString("_shard_stores") + + params = make(map[string]string) + + if r.AllowNoIndices != nil { + params["allow_no_indices"] = strconv.FormatBool(*r.AllowNoIndices) + } + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if r.IgnoreUnavailable != nil { + params["ignore_unavailable"] = strconv.FormatBool(*r.IgnoreUnavailable) + } + + if len(r.Status) > 0 { + params["status"] = strings.Join(r.Status, ",") + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesShardStores) WithContext(v context.Context) func(*IndicesShardStoresRequest) { + return func(r *IndicesShardStoresRequest) { + r.ctx = v + } +} + +// WithIndex - a list of index names; use _all to perform the operation on all indices. +func (f IndicesShardStores) WithIndex(v ...string) func(*IndicesShardStoresRequest) { + return func(r *IndicesShardStoresRequest) { + r.Index = v + } +} + +// WithAllowNoIndices - whether to ignore if a wildcard indices expression resolves into no concrete indices. (this includes `_all` string or when no indices have been specified). +func (f IndicesShardStores) WithAllowNoIndices(v bool) func(*IndicesShardStoresRequest) { + return func(r *IndicesShardStoresRequest) { + r.AllowNoIndices = &v + } +} + +// WithExpandWildcards - whether to expand wildcard expression to concrete indices that are open, closed or both.. +func (f IndicesShardStores) WithExpandWildcards(v string) func(*IndicesShardStoresRequest) { + return func(r *IndicesShardStoresRequest) { + r.ExpandWildcards = v + } +} + +// WithIgnoreUnavailable - whether specified concrete indices should be ignored when unavailable (missing or closed). +func (f IndicesShardStores) WithIgnoreUnavailable(v bool) func(*IndicesShardStoresRequest) { + return func(r *IndicesShardStoresRequest) { + r.IgnoreUnavailable = &v + } +} + +// WithStatus - a list of statuses used to filter on shards to get store information for. +func (f IndicesShardStores) WithStatus(v ...string) func(*IndicesShardStoresRequest) { + return func(r *IndicesShardStoresRequest) { + r.Status = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesShardStores) WithPretty() func(*IndicesShardStoresRequest) { + return func(r *IndicesShardStoresRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesShardStores) WithHuman() func(*IndicesShardStoresRequest) { + return func(r *IndicesShardStoresRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesShardStores) WithErrorTrace() func(*IndicesShardStoresRequest) { + return func(r *IndicesShardStoresRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesShardStores) WithFilterPath(v ...string) func(*IndicesShardStoresRequest) { + return func(r *IndicesShardStoresRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesShardStores) WithHeader(h map[string]string) func(*IndicesShardStoresRequest) { + return func(r *IndicesShardStoresRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesShardStores) WithOpaqueID(s string) func(*IndicesShardStoresRequest) { + return func(r *IndicesShardStoresRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.shrink.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.shrink.go new file mode 100644 index 00000000..09512e2c --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.shrink.go @@ -0,0 +1,260 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" + "time" +) + +func newIndicesShrinkFunc(t Transport) IndicesShrink { + return func(index string, target string, o ...func(*IndicesShrinkRequest)) (*Response, error) { + var r = IndicesShrinkRequest{Index: index, Target: target} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesShrink allow to shrink an existing index into a new index with fewer primary shards. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-shrink-index.html. +type IndicesShrink func(index string, target string, o ...func(*IndicesShrinkRequest)) (*Response, error) + +// IndicesShrinkRequest configures the Indices Shrink API request. +type IndicesShrinkRequest struct { + Index string + + Body io.Reader + + Target string + + CopySettings *bool + MasterTimeout time.Duration + Timeout time.Duration + WaitForActiveShards string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesShrinkRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(1 + len(r.Index) + 1 + len("_shrink") + 1 + len(r.Target)) + path.WriteString("/") + path.WriteString(r.Index) + path.WriteString("/") + path.WriteString("_shrink") + path.WriteString("/") + path.WriteString(r.Target) + + params = make(map[string]string) + + if r.CopySettings != nil { + params["copy_settings"] = strconv.FormatBool(*r.CopySettings) + } + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.WaitForActiveShards != "" { + params["wait_for_active_shards"] = r.WaitForActiveShards + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesShrink) WithContext(v context.Context) func(*IndicesShrinkRequest) { + return func(r *IndicesShrinkRequest) { + r.ctx = v + } +} + +// WithBody - The configuration for the target index (`settings` and `aliases`). +func (f IndicesShrink) WithBody(v io.Reader) func(*IndicesShrinkRequest) { + return func(r *IndicesShrinkRequest) { + r.Body = v + } +} + +// WithCopySettings - whether or not to copy settings from the source index (defaults to false). +func (f IndicesShrink) WithCopySettings(v bool) func(*IndicesShrinkRequest) { + return func(r *IndicesShrinkRequest) { + r.CopySettings = &v + } +} + +// WithMasterTimeout - specify timeout for connection to master. +func (f IndicesShrink) WithMasterTimeout(v time.Duration) func(*IndicesShrinkRequest) { + return func(r *IndicesShrinkRequest) { + r.MasterTimeout = v + } +} + +// WithTimeout - explicit operation timeout. +func (f IndicesShrink) WithTimeout(v time.Duration) func(*IndicesShrinkRequest) { + return func(r *IndicesShrinkRequest) { + r.Timeout = v + } +} + +// WithWaitForActiveShards - set the number of active shards to wait for on the shrunken index before the operation returns.. +func (f IndicesShrink) WithWaitForActiveShards(v string) func(*IndicesShrinkRequest) { + return func(r *IndicesShrinkRequest) { + r.WaitForActiveShards = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesShrink) WithPretty() func(*IndicesShrinkRequest) { + return func(r *IndicesShrinkRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesShrink) WithHuman() func(*IndicesShrinkRequest) { + return func(r *IndicesShrinkRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesShrink) WithErrorTrace() func(*IndicesShrinkRequest) { + return func(r *IndicesShrinkRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesShrink) WithFilterPath(v ...string) func(*IndicesShrinkRequest) { + return func(r *IndicesShrinkRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesShrink) WithHeader(h map[string]string) func(*IndicesShrinkRequest) { + return func(r *IndicesShrinkRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesShrink) WithOpaqueID(s string) func(*IndicesShrinkRequest) { + return func(r *IndicesShrinkRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.simulate_index_template.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.simulate_index_template.go new file mode 100644 index 00000000..e029a479 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.simulate_index_template.go @@ -0,0 +1,246 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" + "time" +) + +func newIndicesSimulateIndexTemplateFunc(t Transport) IndicesSimulateIndexTemplate { + return func(name string, o ...func(*IndicesSimulateIndexTemplateRequest)) (*Response, error) { + var r = IndicesSimulateIndexTemplateRequest{Name: name} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesSimulateIndexTemplate simulate matching the given index name against the index templates in the system +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html. +type IndicesSimulateIndexTemplate func(name string, o ...func(*IndicesSimulateIndexTemplateRequest)) (*Response, error) + +// IndicesSimulateIndexTemplateRequest configures the Indices Simulate Index Template API request. +type IndicesSimulateIndexTemplateRequest struct { + Body io.Reader + + Name string + + Cause string + Create *bool + MasterTimeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesSimulateIndexTemplateRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_index_template") + 1 + len("_simulate_index") + 1 + len(r.Name)) + path.WriteString("/") + path.WriteString("_index_template") + path.WriteString("/") + path.WriteString("_simulate_index") + path.WriteString("/") + path.WriteString(r.Name) + + params = make(map[string]string) + + if r.Cause != "" { + params["cause"] = r.Cause + } + + if r.Create != nil { + params["create"] = strconv.FormatBool(*r.Create) + } + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesSimulateIndexTemplate) WithContext(v context.Context) func(*IndicesSimulateIndexTemplateRequest) { + return func(r *IndicesSimulateIndexTemplateRequest) { + r.ctx = v + } +} + +// WithBody - New index template definition, which will be included in the simulation, as if it already exists in the system. +func (f IndicesSimulateIndexTemplate) WithBody(v io.Reader) func(*IndicesSimulateIndexTemplateRequest) { + return func(r *IndicesSimulateIndexTemplateRequest) { + r.Body = v + } +} + +// WithCause - user defined reason for dry-run creating the new template for simulation purposes. +func (f IndicesSimulateIndexTemplate) WithCause(v string) func(*IndicesSimulateIndexTemplateRequest) { + return func(r *IndicesSimulateIndexTemplateRequest) { + r.Cause = v + } +} + +// WithCreate - whether the index template we optionally defined in the body should only be dry-run added if new or can also replace an existing one. +func (f IndicesSimulateIndexTemplate) WithCreate(v bool) func(*IndicesSimulateIndexTemplateRequest) { + return func(r *IndicesSimulateIndexTemplateRequest) { + r.Create = &v + } +} + +// WithMasterTimeout - specify timeout for connection to master. +func (f IndicesSimulateIndexTemplate) WithMasterTimeout(v time.Duration) func(*IndicesSimulateIndexTemplateRequest) { + return func(r *IndicesSimulateIndexTemplateRequest) { + r.MasterTimeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesSimulateIndexTemplate) WithPretty() func(*IndicesSimulateIndexTemplateRequest) { + return func(r *IndicesSimulateIndexTemplateRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesSimulateIndexTemplate) WithHuman() func(*IndicesSimulateIndexTemplateRequest) { + return func(r *IndicesSimulateIndexTemplateRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesSimulateIndexTemplate) WithErrorTrace() func(*IndicesSimulateIndexTemplateRequest) { + return func(r *IndicesSimulateIndexTemplateRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesSimulateIndexTemplate) WithFilterPath(v ...string) func(*IndicesSimulateIndexTemplateRequest) { + return func(r *IndicesSimulateIndexTemplateRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesSimulateIndexTemplate) WithHeader(h map[string]string) func(*IndicesSimulateIndexTemplateRequest) { + return func(r *IndicesSimulateIndexTemplateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesSimulateIndexTemplate) WithOpaqueID(s string) func(*IndicesSimulateIndexTemplateRequest) { + return func(r *IndicesSimulateIndexTemplateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.simulate_template.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.simulate_template.go new file mode 100644 index 00000000..92f9e017 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.simulate_template.go @@ -0,0 +1,255 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" + "time" +) + +func newIndicesSimulateTemplateFunc(t Transport) IndicesSimulateTemplate { + return func(o ...func(*IndicesSimulateTemplateRequest)) (*Response, error) { + var r = IndicesSimulateTemplateRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesSimulateTemplate simulate resolving the given template name or body +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html. +type IndicesSimulateTemplate func(o ...func(*IndicesSimulateTemplateRequest)) (*Response, error) + +// IndicesSimulateTemplateRequest configures the Indices Simulate Template API request. +type IndicesSimulateTemplateRequest struct { + Body io.Reader + + Name string + + Cause string + Create *bool + MasterTimeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesSimulateTemplateRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_index_template") + 1 + len("_simulate") + 1 + len(r.Name)) + path.WriteString("/") + path.WriteString("_index_template") + path.WriteString("/") + path.WriteString("_simulate") + if r.Name != "" { + path.WriteString("/") + path.WriteString(r.Name) + } + + params = make(map[string]string) + + if r.Cause != "" { + params["cause"] = r.Cause + } + + if r.Create != nil { + params["create"] = strconv.FormatBool(*r.Create) + } + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesSimulateTemplate) WithContext(v context.Context) func(*IndicesSimulateTemplateRequest) { + return func(r *IndicesSimulateTemplateRequest) { + r.ctx = v + } +} + +// WithBody - New index template definition to be simulated, if no index template name is specified. +func (f IndicesSimulateTemplate) WithBody(v io.Reader) func(*IndicesSimulateTemplateRequest) { + return func(r *IndicesSimulateTemplateRequest) { + r.Body = v + } +} + +// WithName - the name of the index template. +func (f IndicesSimulateTemplate) WithName(v string) func(*IndicesSimulateTemplateRequest) { + return func(r *IndicesSimulateTemplateRequest) { + r.Name = v + } +} + +// WithCause - user defined reason for dry-run creating the new template for simulation purposes. +func (f IndicesSimulateTemplate) WithCause(v string) func(*IndicesSimulateTemplateRequest) { + return func(r *IndicesSimulateTemplateRequest) { + r.Cause = v + } +} + +// WithCreate - whether the index template we optionally defined in the body should only be dry-run added if new or can also replace an existing one. +func (f IndicesSimulateTemplate) WithCreate(v bool) func(*IndicesSimulateTemplateRequest) { + return func(r *IndicesSimulateTemplateRequest) { + r.Create = &v + } +} + +// WithMasterTimeout - specify timeout for connection to master. +func (f IndicesSimulateTemplate) WithMasterTimeout(v time.Duration) func(*IndicesSimulateTemplateRequest) { + return func(r *IndicesSimulateTemplateRequest) { + r.MasterTimeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesSimulateTemplate) WithPretty() func(*IndicesSimulateTemplateRequest) { + return func(r *IndicesSimulateTemplateRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesSimulateTemplate) WithHuman() func(*IndicesSimulateTemplateRequest) { + return func(r *IndicesSimulateTemplateRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesSimulateTemplate) WithErrorTrace() func(*IndicesSimulateTemplateRequest) { + return func(r *IndicesSimulateTemplateRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesSimulateTemplate) WithFilterPath(v ...string) func(*IndicesSimulateTemplateRequest) { + return func(r *IndicesSimulateTemplateRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesSimulateTemplate) WithHeader(h map[string]string) func(*IndicesSimulateTemplateRequest) { + return func(r *IndicesSimulateTemplateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesSimulateTemplate) WithOpaqueID(s string) func(*IndicesSimulateTemplateRequest) { + return func(r *IndicesSimulateTemplateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.split.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.split.go new file mode 100644 index 00000000..a4502162 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.split.go @@ -0,0 +1,260 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" + "time" +) + +func newIndicesSplitFunc(t Transport) IndicesSplit { + return func(index string, target string, o ...func(*IndicesSplitRequest)) (*Response, error) { + var r = IndicesSplitRequest{Index: index, Target: target} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesSplit allows you to split an existing index into a new index with more primary shards. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-split-index.html. +type IndicesSplit func(index string, target string, o ...func(*IndicesSplitRequest)) (*Response, error) + +// IndicesSplitRequest configures the Indices Split API request. +type IndicesSplitRequest struct { + Index string + + Body io.Reader + + Target string + + CopySettings *bool + MasterTimeout time.Duration + Timeout time.Duration + WaitForActiveShards string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesSplitRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(1 + len(r.Index) + 1 + len("_split") + 1 + len(r.Target)) + path.WriteString("/") + path.WriteString(r.Index) + path.WriteString("/") + path.WriteString("_split") + path.WriteString("/") + path.WriteString(r.Target) + + params = make(map[string]string) + + if r.CopySettings != nil { + params["copy_settings"] = strconv.FormatBool(*r.CopySettings) + } + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.WaitForActiveShards != "" { + params["wait_for_active_shards"] = r.WaitForActiveShards + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesSplit) WithContext(v context.Context) func(*IndicesSplitRequest) { + return func(r *IndicesSplitRequest) { + r.ctx = v + } +} + +// WithBody - The configuration for the target index (`settings` and `aliases`). +func (f IndicesSplit) WithBody(v io.Reader) func(*IndicesSplitRequest) { + return func(r *IndicesSplitRequest) { + r.Body = v + } +} + +// WithCopySettings - whether or not to copy settings from the source index (defaults to false). +func (f IndicesSplit) WithCopySettings(v bool) func(*IndicesSplitRequest) { + return func(r *IndicesSplitRequest) { + r.CopySettings = &v + } +} + +// WithMasterTimeout - specify timeout for connection to master. +func (f IndicesSplit) WithMasterTimeout(v time.Duration) func(*IndicesSplitRequest) { + return func(r *IndicesSplitRequest) { + r.MasterTimeout = v + } +} + +// WithTimeout - explicit operation timeout. +func (f IndicesSplit) WithTimeout(v time.Duration) func(*IndicesSplitRequest) { + return func(r *IndicesSplitRequest) { + r.Timeout = v + } +} + +// WithWaitForActiveShards - set the number of active shards to wait for on the shrunken index before the operation returns.. +func (f IndicesSplit) WithWaitForActiveShards(v string) func(*IndicesSplitRequest) { + return func(r *IndicesSplitRequest) { + r.WaitForActiveShards = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesSplit) WithPretty() func(*IndicesSplitRequest) { + return func(r *IndicesSplitRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesSplit) WithHuman() func(*IndicesSplitRequest) { + return func(r *IndicesSplitRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesSplit) WithErrorTrace() func(*IndicesSplitRequest) { + return func(r *IndicesSplitRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesSplit) WithFilterPath(v ...string) func(*IndicesSplitRequest) { + return func(r *IndicesSplitRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesSplit) WithHeader(h map[string]string) func(*IndicesSplitRequest) { + return func(r *IndicesSplitRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesSplit) WithOpaqueID(s string) func(*IndicesSplitRequest) { + return func(r *IndicesSplitRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.stats.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.stats.go new file mode 100644 index 00000000..a38b3738 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.stats.go @@ -0,0 +1,335 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newIndicesStatsFunc(t Transport) IndicesStats { + return func(o ...func(*IndicesStatsRequest)) (*Response, error) { + var r = IndicesStatsRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesStats provides statistics on operations happening in an index. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-stats.html. +type IndicesStats func(o ...func(*IndicesStatsRequest)) (*Response, error) + +// IndicesStatsRequest configures the Indices Stats API request. +type IndicesStatsRequest struct { + Index []string + + Metric []string + + CompletionFields []string + ExpandWildcards string + FielddataFields []string + Fields []string + ForbidClosedIndices *bool + Groups []string + IncludeSegmentFileSizes *bool + IncludeUnloadedSegments *bool + Level string + Types []string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesStatsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len(strings.Join(r.Index, ",")) + 1 + len("_stats") + 1 + len(strings.Join(r.Metric, ","))) + if len(r.Index) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + } + path.WriteString("/") + path.WriteString("_stats") + if len(r.Metric) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Metric, ",")) + } + + params = make(map[string]string) + + if len(r.CompletionFields) > 0 { + params["completion_fields"] = strings.Join(r.CompletionFields, ",") + } + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if len(r.FielddataFields) > 0 { + params["fielddata_fields"] = strings.Join(r.FielddataFields, ",") + } + + if len(r.Fields) > 0 { + params["fields"] = strings.Join(r.Fields, ",") + } + + if r.ForbidClosedIndices != nil { + params["forbid_closed_indices"] = strconv.FormatBool(*r.ForbidClosedIndices) + } + + if len(r.Groups) > 0 { + params["groups"] = strings.Join(r.Groups, ",") + } + + if r.IncludeSegmentFileSizes != nil { + params["include_segment_file_sizes"] = strconv.FormatBool(*r.IncludeSegmentFileSizes) + } + + if r.IncludeUnloadedSegments != nil { + params["include_unloaded_segments"] = strconv.FormatBool(*r.IncludeUnloadedSegments) + } + + if r.Level != "" { + params["level"] = r.Level + } + + if len(r.Types) > 0 { + params["types"] = strings.Join(r.Types, ",") + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesStats) WithContext(v context.Context) func(*IndicesStatsRequest) { + return func(r *IndicesStatsRequest) { + r.ctx = v + } +} + +// WithIndex - a list of index names; use _all to perform the operation on all indices. +func (f IndicesStats) WithIndex(v ...string) func(*IndicesStatsRequest) { + return func(r *IndicesStatsRequest) { + r.Index = v + } +} + +// WithMetric - limit the information returned the specific metrics.. +func (f IndicesStats) WithMetric(v ...string) func(*IndicesStatsRequest) { + return func(r *IndicesStatsRequest) { + r.Metric = v + } +} + +// WithCompletionFields - a list of fields for `fielddata` and `suggest` index metric (supports wildcards). +func (f IndicesStats) WithCompletionFields(v ...string) func(*IndicesStatsRequest) { + return func(r *IndicesStatsRequest) { + r.CompletionFields = v + } +} + +// WithExpandWildcards - whether to expand wildcard expression to concrete indices that are open, closed or both.. +func (f IndicesStats) WithExpandWildcards(v string) func(*IndicesStatsRequest) { + return func(r *IndicesStatsRequest) { + r.ExpandWildcards = v + } +} + +// WithFielddataFields - a list of fields for `fielddata` index metric (supports wildcards). +func (f IndicesStats) WithFielddataFields(v ...string) func(*IndicesStatsRequest) { + return func(r *IndicesStatsRequest) { + r.FielddataFields = v + } +} + +// WithFields - a list of fields for `fielddata` and `completion` index metric (supports wildcards). +func (f IndicesStats) WithFields(v ...string) func(*IndicesStatsRequest) { + return func(r *IndicesStatsRequest) { + r.Fields = v + } +} + +// WithForbidClosedIndices - if set to false stats will also collected from closed indices if explicitly specified or if expand_wildcards expands to closed indices. +func (f IndicesStats) WithForbidClosedIndices(v bool) func(*IndicesStatsRequest) { + return func(r *IndicesStatsRequest) { + r.ForbidClosedIndices = &v + } +} + +// WithGroups - a list of search groups for `search` index metric. +func (f IndicesStats) WithGroups(v ...string) func(*IndicesStatsRequest) { + return func(r *IndicesStatsRequest) { + r.Groups = v + } +} + +// WithIncludeSegmentFileSizes - whether to report the aggregated disk usage of each one of the lucene index files (only applies if segment stats are requested). +func (f IndicesStats) WithIncludeSegmentFileSizes(v bool) func(*IndicesStatsRequest) { + return func(r *IndicesStatsRequest) { + r.IncludeSegmentFileSizes = &v + } +} + +// WithIncludeUnloadedSegments - if set to true segment stats will include stats for segments that are not currently loaded into memory. +func (f IndicesStats) WithIncludeUnloadedSegments(v bool) func(*IndicesStatsRequest) { + return func(r *IndicesStatsRequest) { + r.IncludeUnloadedSegments = &v + } +} + +// WithLevel - return stats aggregated at cluster, index or shard level. +func (f IndicesStats) WithLevel(v string) func(*IndicesStatsRequest) { + return func(r *IndicesStatsRequest) { + r.Level = v + } +} + +// WithTypes - a list of document types for the `indexing` index metric. +func (f IndicesStats) WithTypes(v ...string) func(*IndicesStatsRequest) { + return func(r *IndicesStatsRequest) { + r.Types = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesStats) WithPretty() func(*IndicesStatsRequest) { + return func(r *IndicesStatsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesStats) WithHuman() func(*IndicesStatsRequest) { + return func(r *IndicesStatsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesStats) WithErrorTrace() func(*IndicesStatsRequest) { + return func(r *IndicesStatsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesStats) WithFilterPath(v ...string) func(*IndicesStatsRequest) { + return func(r *IndicesStatsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesStats) WithHeader(h map[string]string) func(*IndicesStatsRequest) { + return func(r *IndicesStatsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesStats) WithOpaqueID(s string) func(*IndicesStatsRequest) { + return func(r *IndicesStatsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.update_aliases.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.update_aliases.go new file mode 100644 index 00000000..1e9431ce --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.update_aliases.go @@ -0,0 +1,219 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" + "time" +) + +func newIndicesUpdateAliasesFunc(t Transport) IndicesUpdateAliases { + return func(body io.Reader, o ...func(*IndicesUpdateAliasesRequest)) (*Response, error) { + var r = IndicesUpdateAliasesRequest{Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesUpdateAliases updates index aliases. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html. +type IndicesUpdateAliases func(body io.Reader, o ...func(*IndicesUpdateAliasesRequest)) (*Response, error) + +// IndicesUpdateAliasesRequest configures the Indices Update Aliases API request. +type IndicesUpdateAliasesRequest struct { + Body io.Reader + + MasterTimeout time.Duration + Timeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesUpdateAliasesRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(len("/_aliases")) + path.WriteString("/_aliases") + + params = make(map[string]string) + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesUpdateAliases) WithContext(v context.Context) func(*IndicesUpdateAliasesRequest) { + return func(r *IndicesUpdateAliasesRequest) { + r.ctx = v + } +} + +// WithMasterTimeout - specify timeout for connection to master. +func (f IndicesUpdateAliases) WithMasterTimeout(v time.Duration) func(*IndicesUpdateAliasesRequest) { + return func(r *IndicesUpdateAliasesRequest) { + r.MasterTimeout = v + } +} + +// WithTimeout - request timeout. +func (f IndicesUpdateAliases) WithTimeout(v time.Duration) func(*IndicesUpdateAliasesRequest) { + return func(r *IndicesUpdateAliasesRequest) { + r.Timeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesUpdateAliases) WithPretty() func(*IndicesUpdateAliasesRequest) { + return func(r *IndicesUpdateAliasesRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesUpdateAliases) WithHuman() func(*IndicesUpdateAliasesRequest) { + return func(r *IndicesUpdateAliasesRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesUpdateAliases) WithErrorTrace() func(*IndicesUpdateAliasesRequest) { + return func(r *IndicesUpdateAliasesRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesUpdateAliases) WithFilterPath(v ...string) func(*IndicesUpdateAliasesRequest) { + return func(r *IndicesUpdateAliasesRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesUpdateAliases) WithHeader(h map[string]string) func(*IndicesUpdateAliasesRequest) { + return func(r *IndicesUpdateAliasesRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesUpdateAliases) WithOpaqueID(s string) func(*IndicesUpdateAliasesRequest) { + return func(r *IndicesUpdateAliasesRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.upgrade.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.upgrade.go new file mode 100644 index 00000000..1c7d0e56 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.upgrade.go @@ -0,0 +1,262 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newIndicesUpgradeFunc(t Transport) IndicesUpgrade { + return func(o ...func(*IndicesUpgradeRequest)) (*Response, error) { + var r = IndicesUpgradeRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesUpgrade deprecated Upgrades to the current version of Lucene. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-upgrade.html. +type IndicesUpgrade func(o ...func(*IndicesUpgradeRequest)) (*Response, error) + +// IndicesUpgradeRequest configures the Indices Upgrade API request. +type IndicesUpgradeRequest struct { + Index []string + + AllowNoIndices *bool + ExpandWildcards string + IgnoreUnavailable *bool + OnlyAncientSegments *bool + WaitForCompletion *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesUpgradeRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len(strings.Join(r.Index, ",")) + 1 + len("_upgrade")) + if len(r.Index) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + } + path.WriteString("/") + path.WriteString("_upgrade") + + params = make(map[string]string) + + if r.AllowNoIndices != nil { + params["allow_no_indices"] = strconv.FormatBool(*r.AllowNoIndices) + } + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if r.IgnoreUnavailable != nil { + params["ignore_unavailable"] = strconv.FormatBool(*r.IgnoreUnavailable) + } + + if r.OnlyAncientSegments != nil { + params["only_ancient_segments"] = strconv.FormatBool(*r.OnlyAncientSegments) + } + + if r.WaitForCompletion != nil { + params["wait_for_completion"] = strconv.FormatBool(*r.WaitForCompletion) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesUpgrade) WithContext(v context.Context) func(*IndicesUpgradeRequest) { + return func(r *IndicesUpgradeRequest) { + r.ctx = v + } +} + +// WithIndex - a list of index names; use _all to perform the operation on all indices. +func (f IndicesUpgrade) WithIndex(v ...string) func(*IndicesUpgradeRequest) { + return func(r *IndicesUpgradeRequest) { + r.Index = v + } +} + +// WithAllowNoIndices - whether to ignore if a wildcard indices expression resolves into no concrete indices. (this includes `_all` string or when no indices have been specified). +func (f IndicesUpgrade) WithAllowNoIndices(v bool) func(*IndicesUpgradeRequest) { + return func(r *IndicesUpgradeRequest) { + r.AllowNoIndices = &v + } +} + +// WithExpandWildcards - whether to expand wildcard expression to concrete indices that are open, closed or both.. +func (f IndicesUpgrade) WithExpandWildcards(v string) func(*IndicesUpgradeRequest) { + return func(r *IndicesUpgradeRequest) { + r.ExpandWildcards = v + } +} + +// WithIgnoreUnavailable - whether specified concrete indices should be ignored when unavailable (missing or closed). +func (f IndicesUpgrade) WithIgnoreUnavailable(v bool) func(*IndicesUpgradeRequest) { + return func(r *IndicesUpgradeRequest) { + r.IgnoreUnavailable = &v + } +} + +// WithOnlyAncientSegments - if true, only ancient (an older lucene major release) segments will be upgraded. +func (f IndicesUpgrade) WithOnlyAncientSegments(v bool) func(*IndicesUpgradeRequest) { + return func(r *IndicesUpgradeRequest) { + r.OnlyAncientSegments = &v + } +} + +// WithWaitForCompletion - specify whether the request should block until the all segments are upgraded (default: false). +func (f IndicesUpgrade) WithWaitForCompletion(v bool) func(*IndicesUpgradeRequest) { + return func(r *IndicesUpgradeRequest) { + r.WaitForCompletion = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesUpgrade) WithPretty() func(*IndicesUpgradeRequest) { + return func(r *IndicesUpgradeRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesUpgrade) WithHuman() func(*IndicesUpgradeRequest) { + return func(r *IndicesUpgradeRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesUpgrade) WithErrorTrace() func(*IndicesUpgradeRequest) { + return func(r *IndicesUpgradeRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesUpgrade) WithFilterPath(v ...string) func(*IndicesUpgradeRequest) { + return func(r *IndicesUpgradeRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesUpgrade) WithHeader(h map[string]string) func(*IndicesUpgradeRequest) { + return func(r *IndicesUpgradeRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesUpgrade) WithOpaqueID(s string) func(*IndicesUpgradeRequest) { + return func(r *IndicesUpgradeRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.validate_query.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.validate_query.go new file mode 100644 index 00000000..c91fabfa --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.indices.validate_query.go @@ -0,0 +1,374 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" +) + +func newIndicesValidateQueryFunc(t Transport) IndicesValidateQuery { + return func(o ...func(*IndicesValidateQueryRequest)) (*Response, error) { + var r = IndicesValidateQueryRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesValidateQuery allows a user to validate a potentially expensive query without executing it. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/search-validate.html. +type IndicesValidateQuery func(o ...func(*IndicesValidateQueryRequest)) (*Response, error) + +// IndicesValidateQueryRequest configures the Indices Validate Query API request. +type IndicesValidateQueryRequest struct { + Index []string + DocumentType []string + + Body io.Reader + + AllowNoIndices *bool + AllShards *bool + Analyzer string + AnalyzeWildcard *bool + DefaultOperator string + Df string + ExpandWildcards string + Explain *bool + IgnoreUnavailable *bool + Lenient *bool + Query string + Rewrite *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesValidateQueryRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len(strings.Join(r.Index, ",")) + 1 + len(strings.Join(r.DocumentType, ",")) + 1 + len("_validate") + 1 + len("query")) + if len(r.Index) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + } + if len(r.DocumentType) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.DocumentType, ",")) + } + path.WriteString("/") + path.WriteString("_validate") + path.WriteString("/") + path.WriteString("query") + + params = make(map[string]string) + + if r.AllowNoIndices != nil { + params["allow_no_indices"] = strconv.FormatBool(*r.AllowNoIndices) + } + + if r.AllShards != nil { + params["all_shards"] = strconv.FormatBool(*r.AllShards) + } + + if r.Analyzer != "" { + params["analyzer"] = r.Analyzer + } + + if r.AnalyzeWildcard != nil { + params["analyze_wildcard"] = strconv.FormatBool(*r.AnalyzeWildcard) + } + + if r.DefaultOperator != "" { + params["default_operator"] = r.DefaultOperator + } + + if r.Df != "" { + params["df"] = r.Df + } + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if r.Explain != nil { + params["explain"] = strconv.FormatBool(*r.Explain) + } + + if r.IgnoreUnavailable != nil { + params["ignore_unavailable"] = strconv.FormatBool(*r.IgnoreUnavailable) + } + + if r.Lenient != nil { + params["lenient"] = strconv.FormatBool(*r.Lenient) + } + + if r.Query != "" { + params["q"] = r.Query + } + + if r.Rewrite != nil { + params["rewrite"] = strconv.FormatBool(*r.Rewrite) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesValidateQuery) WithContext(v context.Context) func(*IndicesValidateQueryRequest) { + return func(r *IndicesValidateQueryRequest) { + r.ctx = v + } +} + +// WithBody - The query definition specified with the Query DSL. +func (f IndicesValidateQuery) WithBody(v io.Reader) func(*IndicesValidateQueryRequest) { + return func(r *IndicesValidateQueryRequest) { + r.Body = v + } +} + +// WithIndex - a list of index names to restrict the operation; use _all to perform the operation on all indices. +func (f IndicesValidateQuery) WithIndex(v ...string) func(*IndicesValidateQueryRequest) { + return func(r *IndicesValidateQueryRequest) { + r.Index = v + } +} + +// WithDocumentType - a list of document types to restrict the operation; leave empty to perform the operation on all types. +func (f IndicesValidateQuery) WithDocumentType(v ...string) func(*IndicesValidateQueryRequest) { + return func(r *IndicesValidateQueryRequest) { + r.DocumentType = v + } +} + +// WithAllowNoIndices - whether to ignore if a wildcard indices expression resolves into no concrete indices. (this includes `_all` string or when no indices have been specified). +func (f IndicesValidateQuery) WithAllowNoIndices(v bool) func(*IndicesValidateQueryRequest) { + return func(r *IndicesValidateQueryRequest) { + r.AllowNoIndices = &v + } +} + +// WithAllShards - execute validation on all shards instead of one random shard per index. +func (f IndicesValidateQuery) WithAllShards(v bool) func(*IndicesValidateQueryRequest) { + return func(r *IndicesValidateQueryRequest) { + r.AllShards = &v + } +} + +// WithAnalyzer - the analyzer to use for the query string. +func (f IndicesValidateQuery) WithAnalyzer(v string) func(*IndicesValidateQueryRequest) { + return func(r *IndicesValidateQueryRequest) { + r.Analyzer = v + } +} + +// WithAnalyzeWildcard - specify whether wildcard and prefix queries should be analyzed (default: false). +func (f IndicesValidateQuery) WithAnalyzeWildcard(v bool) func(*IndicesValidateQueryRequest) { + return func(r *IndicesValidateQueryRequest) { + r.AnalyzeWildcard = &v + } +} + +// WithDefaultOperator - the default operator for query string query (and or or). +func (f IndicesValidateQuery) WithDefaultOperator(v string) func(*IndicesValidateQueryRequest) { + return func(r *IndicesValidateQueryRequest) { + r.DefaultOperator = v + } +} + +// WithDf - the field to use as default where no field prefix is given in the query string. +func (f IndicesValidateQuery) WithDf(v string) func(*IndicesValidateQueryRequest) { + return func(r *IndicesValidateQueryRequest) { + r.Df = v + } +} + +// WithExpandWildcards - whether to expand wildcard expression to concrete indices that are open, closed or both.. +func (f IndicesValidateQuery) WithExpandWildcards(v string) func(*IndicesValidateQueryRequest) { + return func(r *IndicesValidateQueryRequest) { + r.ExpandWildcards = v + } +} + +// WithExplain - return detailed information about the error. +func (f IndicesValidateQuery) WithExplain(v bool) func(*IndicesValidateQueryRequest) { + return func(r *IndicesValidateQueryRequest) { + r.Explain = &v + } +} + +// WithIgnoreUnavailable - whether specified concrete indices should be ignored when unavailable (missing or closed). +func (f IndicesValidateQuery) WithIgnoreUnavailable(v bool) func(*IndicesValidateQueryRequest) { + return func(r *IndicesValidateQueryRequest) { + r.IgnoreUnavailable = &v + } +} + +// WithLenient - specify whether format-based query failures (such as providing text to a numeric field) should be ignored. +func (f IndicesValidateQuery) WithLenient(v bool) func(*IndicesValidateQueryRequest) { + return func(r *IndicesValidateQueryRequest) { + r.Lenient = &v + } +} + +// WithQuery - query in the lucene query string syntax. +func (f IndicesValidateQuery) WithQuery(v string) func(*IndicesValidateQueryRequest) { + return func(r *IndicesValidateQueryRequest) { + r.Query = v + } +} + +// WithRewrite - provide a more detailed explanation showing the actual lucene query that will be executed.. +func (f IndicesValidateQuery) WithRewrite(v bool) func(*IndicesValidateQueryRequest) { + return func(r *IndicesValidateQueryRequest) { + r.Rewrite = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesValidateQuery) WithPretty() func(*IndicesValidateQueryRequest) { + return func(r *IndicesValidateQueryRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesValidateQuery) WithHuman() func(*IndicesValidateQueryRequest) { + return func(r *IndicesValidateQueryRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesValidateQuery) WithErrorTrace() func(*IndicesValidateQueryRequest) { + return func(r *IndicesValidateQueryRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesValidateQuery) WithFilterPath(v ...string) func(*IndicesValidateQueryRequest) { + return func(r *IndicesValidateQueryRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesValidateQuery) WithHeader(h map[string]string) func(*IndicesValidateQueryRequest) { + return func(r *IndicesValidateQueryRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesValidateQuery) WithOpaqueID(s string) func(*IndicesValidateQueryRequest) { + return func(r *IndicesValidateQueryRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.info.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.info.go new file mode 100644 index 00000000..56a7dc54 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.info.go @@ -0,0 +1,179 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newInfoFunc(t Transport) Info { + return func(o ...func(*InfoRequest)) (*Response, error) { + var r = InfoRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// Info returns basic information about the cluster. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html. +type Info func(o ...func(*InfoRequest)) (*Response, error) + +// InfoRequest configures the Info API request. +type InfoRequest struct { + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r InfoRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(len("/")) + path.WriteString("/") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f Info) WithContext(v context.Context) func(*InfoRequest) { + return func(r *InfoRequest) { + r.ctx = v + } +} + +// WithHuman makes statistical values human-readable. +func (f Info) WithHuman() func(*InfoRequest) { + return func(r *InfoRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f Info) WithErrorTrace() func(*InfoRequest) { + return func(r *InfoRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f Info) WithFilterPath(v ...string) func(*InfoRequest) { + return func(r *InfoRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f Info) WithHeader(h map[string]string) func(*InfoRequest) { + return func(r *InfoRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f Info) WithOpaqueID(s string) func(*InfoRequest) { + return func(r *InfoRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.ingest.delete_pipeline.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.ingest.delete_pipeline.go new file mode 100644 index 00000000..06b5cf52 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.ingest.delete_pipeline.go @@ -0,0 +1,219 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" + "time" +) + +func newIngestDeletePipelineFunc(t Transport) IngestDeletePipeline { + return func(id string, o ...func(*IngestDeletePipelineRequest)) (*Response, error) { + var r = IngestDeletePipelineRequest{PipelineID: id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IngestDeletePipeline deletes a pipeline. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-pipeline-api.html. +type IngestDeletePipeline func(id string, o ...func(*IngestDeletePipelineRequest)) (*Response, error) + +// IngestDeletePipelineRequest configures the Ingest Delete Pipeline API request. +type IngestDeletePipelineRequest struct { + PipelineID string + + MasterTimeout time.Duration + Timeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IngestDeletePipelineRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + path.Grow(1 + len("_ingest") + 1 + len("pipeline") + 1 + len(r.PipelineID)) + path.WriteString("/") + path.WriteString("_ingest") + path.WriteString("/") + path.WriteString("pipeline") + path.WriteString("/") + path.WriteString(r.PipelineID) + + params = make(map[string]string) + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IngestDeletePipeline) WithContext(v context.Context) func(*IngestDeletePipelineRequest) { + return func(r *IngestDeletePipelineRequest) { + r.ctx = v + } +} + +// WithMasterTimeout - explicit operation timeout for connection to master node. +func (f IngestDeletePipeline) WithMasterTimeout(v time.Duration) func(*IngestDeletePipelineRequest) { + return func(r *IngestDeletePipelineRequest) { + r.MasterTimeout = v + } +} + +// WithTimeout - explicit operation timeout. +func (f IngestDeletePipeline) WithTimeout(v time.Duration) func(*IngestDeletePipelineRequest) { + return func(r *IngestDeletePipelineRequest) { + r.Timeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IngestDeletePipeline) WithPretty() func(*IngestDeletePipelineRequest) { + return func(r *IngestDeletePipelineRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IngestDeletePipeline) WithHuman() func(*IngestDeletePipelineRequest) { + return func(r *IngestDeletePipelineRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IngestDeletePipeline) WithErrorTrace() func(*IngestDeletePipelineRequest) { + return func(r *IngestDeletePipelineRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IngestDeletePipeline) WithFilterPath(v ...string) func(*IngestDeletePipelineRequest) { + return func(r *IngestDeletePipelineRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IngestDeletePipeline) WithHeader(h map[string]string) func(*IngestDeletePipelineRequest) { + return func(r *IngestDeletePipelineRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IngestDeletePipeline) WithOpaqueID(s string) func(*IngestDeletePipelineRequest) { + return func(r *IngestDeletePipelineRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.ingest.geo_ip_stats.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.ingest.geo_ip_stats.go new file mode 100644 index 00000000..e6088ebf --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.ingest.geo_ip_stats.go @@ -0,0 +1,186 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newIngestGeoIPStatsFunc(t Transport) IngestGeoIPStats { + return func(o ...func(*IngestGeoIPStatsRequest)) (*Response, error) { + var r = IngestGeoIPStatsRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IngestGeoIPStats returns statistical information about geoip databases +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/geoip-stats-api.html. +type IngestGeoIPStats func(o ...func(*IngestGeoIPStatsRequest)) (*Response, error) + +// IngestGeoIPStatsRequest configures the Ingest GeoIP Stats API request. +type IngestGeoIPStatsRequest struct { + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IngestGeoIPStatsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(len("/_ingest/geoip/stats")) + path.WriteString("/_ingest/geoip/stats") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IngestGeoIPStats) WithContext(v context.Context) func(*IngestGeoIPStatsRequest) { + return func(r *IngestGeoIPStatsRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IngestGeoIPStats) WithPretty() func(*IngestGeoIPStatsRequest) { + return func(r *IngestGeoIPStatsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IngestGeoIPStats) WithHuman() func(*IngestGeoIPStatsRequest) { + return func(r *IngestGeoIPStatsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IngestGeoIPStats) WithErrorTrace() func(*IngestGeoIPStatsRequest) { + return func(r *IngestGeoIPStatsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IngestGeoIPStats) WithFilterPath(v ...string) func(*IngestGeoIPStatsRequest) { + return func(r *IngestGeoIPStatsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IngestGeoIPStats) WithHeader(h map[string]string) func(*IngestGeoIPStatsRequest) { + return func(r *IngestGeoIPStatsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IngestGeoIPStats) WithOpaqueID(s string) func(*IngestGeoIPStatsRequest) { + return func(r *IngestGeoIPStatsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.ingest.get_pipeline.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.ingest.get_pipeline.go new file mode 100644 index 00000000..e5e7c21d --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.ingest.get_pipeline.go @@ -0,0 +1,229 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" + "time" +) + +func newIngestGetPipelineFunc(t Transport) IngestGetPipeline { + return func(o ...func(*IngestGetPipelineRequest)) (*Response, error) { + var r = IngestGetPipelineRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IngestGetPipeline returns a pipeline. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/get-pipeline-api.html. +type IngestGetPipeline func(o ...func(*IngestGetPipelineRequest)) (*Response, error) + +// IngestGetPipelineRequest configures the Ingest Get Pipeline API request. +type IngestGetPipelineRequest struct { + PipelineID string + + MasterTimeout time.Duration + Summary *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IngestGetPipelineRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_ingest") + 1 + len("pipeline") + 1 + len(r.PipelineID)) + path.WriteString("/") + path.WriteString("_ingest") + path.WriteString("/") + path.WriteString("pipeline") + if r.PipelineID != "" { + path.WriteString("/") + path.WriteString(r.PipelineID) + } + + params = make(map[string]string) + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Summary != nil { + params["summary"] = strconv.FormatBool(*r.Summary) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IngestGetPipeline) WithContext(v context.Context) func(*IngestGetPipelineRequest) { + return func(r *IngestGetPipelineRequest) { + r.ctx = v + } +} + +// WithPipelineID - comma separated list of pipeline ids. wildcards supported. +func (f IngestGetPipeline) WithPipelineID(v string) func(*IngestGetPipelineRequest) { + return func(r *IngestGetPipelineRequest) { + r.PipelineID = v + } +} + +// WithMasterTimeout - explicit operation timeout for connection to master node. +func (f IngestGetPipeline) WithMasterTimeout(v time.Duration) func(*IngestGetPipelineRequest) { + return func(r *IngestGetPipelineRequest) { + r.MasterTimeout = v + } +} + +// WithSummary - return pipelines without their definitions (default: false). +func (f IngestGetPipeline) WithSummary(v bool) func(*IngestGetPipelineRequest) { + return func(r *IngestGetPipelineRequest) { + r.Summary = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IngestGetPipeline) WithPretty() func(*IngestGetPipelineRequest) { + return func(r *IngestGetPipelineRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IngestGetPipeline) WithHuman() func(*IngestGetPipelineRequest) { + return func(r *IngestGetPipelineRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IngestGetPipeline) WithErrorTrace() func(*IngestGetPipelineRequest) { + return func(r *IngestGetPipelineRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IngestGetPipeline) WithFilterPath(v ...string) func(*IngestGetPipelineRequest) { + return func(r *IngestGetPipelineRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IngestGetPipeline) WithHeader(h map[string]string) func(*IngestGetPipelineRequest) { + return func(r *IngestGetPipelineRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IngestGetPipeline) WithOpaqueID(s string) func(*IngestGetPipelineRequest) { + return func(r *IngestGetPipelineRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.ingest.processor_grok.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.ingest.processor_grok.go new file mode 100644 index 00000000..c3fe3c2d --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.ingest.processor_grok.go @@ -0,0 +1,186 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newIngestProcessorGrokFunc(t Transport) IngestProcessorGrok { + return func(o ...func(*IngestProcessorGrokRequest)) (*Response, error) { + var r = IngestProcessorGrokRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IngestProcessorGrok returns a list of the built-in patterns. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/grok-processor.html#grok-processor-rest-get. +type IngestProcessorGrok func(o ...func(*IngestProcessorGrokRequest)) (*Response, error) + +// IngestProcessorGrokRequest configures the Ingest Processor Grok API request. +type IngestProcessorGrokRequest struct { + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IngestProcessorGrokRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(len("/_ingest/processor/grok")) + path.WriteString("/_ingest/processor/grok") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IngestProcessorGrok) WithContext(v context.Context) func(*IngestProcessorGrokRequest) { + return func(r *IngestProcessorGrokRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IngestProcessorGrok) WithPretty() func(*IngestProcessorGrokRequest) { + return func(r *IngestProcessorGrokRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IngestProcessorGrok) WithHuman() func(*IngestProcessorGrokRequest) { + return func(r *IngestProcessorGrokRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IngestProcessorGrok) WithErrorTrace() func(*IngestProcessorGrokRequest) { + return func(r *IngestProcessorGrokRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IngestProcessorGrok) WithFilterPath(v ...string) func(*IngestProcessorGrokRequest) { + return func(r *IngestProcessorGrokRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IngestProcessorGrok) WithHeader(h map[string]string) func(*IngestProcessorGrokRequest) { + return func(r *IngestProcessorGrokRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IngestProcessorGrok) WithOpaqueID(s string) func(*IngestProcessorGrokRequest) { + return func(r *IngestProcessorGrokRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.ingest.put_pipeline.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.ingest.put_pipeline.go new file mode 100644 index 00000000..0a7a518b --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.ingest.put_pipeline.go @@ -0,0 +1,239 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" + "time" +) + +func newIngestPutPipelineFunc(t Transport) IngestPutPipeline { + return func(id string, body io.Reader, o ...func(*IngestPutPipelineRequest)) (*Response, error) { + var r = IngestPutPipelineRequest{PipelineID: id, Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IngestPutPipeline creates or updates a pipeline. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/put-pipeline-api.html. +type IngestPutPipeline func(id string, body io.Reader, o ...func(*IngestPutPipelineRequest)) (*Response, error) + +// IngestPutPipelineRequest configures the Ingest Put Pipeline API request. +type IngestPutPipelineRequest struct { + PipelineID string + + Body io.Reader + + IfVersion *int + MasterTimeout time.Duration + Timeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IngestPutPipelineRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(1 + len("_ingest") + 1 + len("pipeline") + 1 + len(r.PipelineID)) + path.WriteString("/") + path.WriteString("_ingest") + path.WriteString("/") + path.WriteString("pipeline") + path.WriteString("/") + path.WriteString(r.PipelineID) + + params = make(map[string]string) + + if r.IfVersion != nil { + params["if_version"] = strconv.FormatInt(int64(*r.IfVersion), 10) + } + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IngestPutPipeline) WithContext(v context.Context) func(*IngestPutPipelineRequest) { + return func(r *IngestPutPipelineRequest) { + r.ctx = v + } +} + +// WithIfVersion - required version for optimistic concurrency control for pipeline updates. +func (f IngestPutPipeline) WithIfVersion(v int) func(*IngestPutPipelineRequest) { + return func(r *IngestPutPipelineRequest) { + r.IfVersion = &v + } +} + +// WithMasterTimeout - explicit operation timeout for connection to master node. +func (f IngestPutPipeline) WithMasterTimeout(v time.Duration) func(*IngestPutPipelineRequest) { + return func(r *IngestPutPipelineRequest) { + r.MasterTimeout = v + } +} + +// WithTimeout - explicit operation timeout. +func (f IngestPutPipeline) WithTimeout(v time.Duration) func(*IngestPutPipelineRequest) { + return func(r *IngestPutPipelineRequest) { + r.Timeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IngestPutPipeline) WithPretty() func(*IngestPutPipelineRequest) { + return func(r *IngestPutPipelineRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IngestPutPipeline) WithHuman() func(*IngestPutPipelineRequest) { + return func(r *IngestPutPipelineRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IngestPutPipeline) WithErrorTrace() func(*IngestPutPipelineRequest) { + return func(r *IngestPutPipelineRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IngestPutPipeline) WithFilterPath(v ...string) func(*IngestPutPipelineRequest) { + return func(r *IngestPutPipelineRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IngestPutPipeline) WithHeader(h map[string]string) func(*IngestPutPipelineRequest) { + return func(r *IngestPutPipelineRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IngestPutPipeline) WithOpaqueID(s string) func(*IngestPutPipelineRequest) { + return func(r *IngestPutPipelineRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.ingest.simulate.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.ingest.simulate.go new file mode 100644 index 00000000..c61b6a6a --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.ingest.simulate.go @@ -0,0 +1,225 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" +) + +func newIngestSimulateFunc(t Transport) IngestSimulate { + return func(body io.Reader, o ...func(*IngestSimulateRequest)) (*Response, error) { + var r = IngestSimulateRequest{Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IngestSimulate allows to simulate a pipeline with example documents. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/simulate-pipeline-api.html. +type IngestSimulate func(body io.Reader, o ...func(*IngestSimulateRequest)) (*Response, error) + +// IngestSimulateRequest configures the Ingest Simulate API request. +type IngestSimulateRequest struct { + PipelineID string + + Body io.Reader + + Verbose *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IngestSimulateRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_ingest") + 1 + len("pipeline") + 1 + len(r.PipelineID) + 1 + len("_simulate")) + path.WriteString("/") + path.WriteString("_ingest") + path.WriteString("/") + path.WriteString("pipeline") + if r.PipelineID != "" { + path.WriteString("/") + path.WriteString(r.PipelineID) + } + path.WriteString("/") + path.WriteString("_simulate") + + params = make(map[string]string) + + if r.Verbose != nil { + params["verbose"] = strconv.FormatBool(*r.Verbose) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IngestSimulate) WithContext(v context.Context) func(*IngestSimulateRequest) { + return func(r *IngestSimulateRequest) { + r.ctx = v + } +} + +// WithPipelineID - pipeline ID. +func (f IngestSimulate) WithPipelineID(v string) func(*IngestSimulateRequest) { + return func(r *IngestSimulateRequest) { + r.PipelineID = v + } +} + +// WithVerbose - verbose mode. display data output for each processor in executed pipeline. +func (f IngestSimulate) WithVerbose(v bool) func(*IngestSimulateRequest) { + return func(r *IngestSimulateRequest) { + r.Verbose = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IngestSimulate) WithPretty() func(*IngestSimulateRequest) { + return func(r *IngestSimulateRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IngestSimulate) WithHuman() func(*IngestSimulateRequest) { + return func(r *IngestSimulateRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IngestSimulate) WithErrorTrace() func(*IngestSimulateRequest) { + return func(r *IngestSimulateRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IngestSimulate) WithFilterPath(v ...string) func(*IngestSimulateRequest) { + return func(r *IngestSimulateRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IngestSimulate) WithHeader(h map[string]string) func(*IngestSimulateRequest) { + return func(r *IngestSimulateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IngestSimulate) WithOpaqueID(s string) func(*IngestSimulateRequest) { + return func(r *IngestSimulateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.mget.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.mget.go new file mode 100644 index 00000000..5e3a3e59 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.mget.go @@ -0,0 +1,317 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" +) + +func newMgetFunc(t Transport) Mget { + return func(body io.Reader, o ...func(*MgetRequest)) (*Response, error) { + var r = MgetRequest{Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// Mget allows to get multiple documents in one request. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-multi-get.html. +type Mget func(body io.Reader, o ...func(*MgetRequest)) (*Response, error) + +// MgetRequest configures the Mget API request. +type MgetRequest struct { + Index string + DocumentType string + + Body io.Reader + + Preference string + Realtime *bool + Refresh *bool + Routing string + Source []string + SourceExcludes []string + SourceIncludes []string + StoredFields []string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MgetRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len(r.Index) + 1 + len(r.DocumentType) + 1 + len("_mget")) + if r.Index != "" { + path.WriteString("/") + path.WriteString(r.Index) + } + if r.DocumentType != "" { + path.WriteString("/") + path.WriteString(r.DocumentType) + } + path.WriteString("/") + path.WriteString("_mget") + + params = make(map[string]string) + + if r.Preference != "" { + params["preference"] = r.Preference + } + + if r.Realtime != nil { + params["realtime"] = strconv.FormatBool(*r.Realtime) + } + + if r.Refresh != nil { + params["refresh"] = strconv.FormatBool(*r.Refresh) + } + + if r.Routing != "" { + params["routing"] = r.Routing + } + + if len(r.Source) > 0 { + params["_source"] = strings.Join(r.Source, ",") + } + + if len(r.SourceExcludes) > 0 { + params["_source_excludes"] = strings.Join(r.SourceExcludes, ",") + } + + if len(r.SourceIncludes) > 0 { + params["_source_includes"] = strings.Join(r.SourceIncludes, ",") + } + + if len(r.StoredFields) > 0 { + params["stored_fields"] = strings.Join(r.StoredFields, ",") + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f Mget) WithContext(v context.Context) func(*MgetRequest) { + return func(r *MgetRequest) { + r.ctx = v + } +} + +// WithIndex - the name of the index. +func (f Mget) WithIndex(v string) func(*MgetRequest) { + return func(r *MgetRequest) { + r.Index = v + } +} + +// WithDocumentType - the type of the document. +func (f Mget) WithDocumentType(v string) func(*MgetRequest) { + return func(r *MgetRequest) { + r.DocumentType = v + } +} + +// WithPreference - specify the node or shard the operation should be performed on (default: random). +func (f Mget) WithPreference(v string) func(*MgetRequest) { + return func(r *MgetRequest) { + r.Preference = v + } +} + +// WithRealtime - specify whether to perform the operation in realtime or search mode. +func (f Mget) WithRealtime(v bool) func(*MgetRequest) { + return func(r *MgetRequest) { + r.Realtime = &v + } +} + +// WithRefresh - refresh the shard containing the document before performing the operation. +func (f Mget) WithRefresh(v bool) func(*MgetRequest) { + return func(r *MgetRequest) { + r.Refresh = &v + } +} + +// WithRouting - specific routing value. +func (f Mget) WithRouting(v string) func(*MgetRequest) { + return func(r *MgetRequest) { + r.Routing = v + } +} + +// WithSource - true or false to return the _source field or not, or a list of fields to return. +func (f Mget) WithSource(v ...string) func(*MgetRequest) { + return func(r *MgetRequest) { + r.Source = v + } +} + +// WithSourceExcludes - a list of fields to exclude from the returned _source field. +func (f Mget) WithSourceExcludes(v ...string) func(*MgetRequest) { + return func(r *MgetRequest) { + r.SourceExcludes = v + } +} + +// WithSourceIncludes - a list of fields to extract and return from the _source field. +func (f Mget) WithSourceIncludes(v ...string) func(*MgetRequest) { + return func(r *MgetRequest) { + r.SourceIncludes = v + } +} + +// WithStoredFields - a list of stored fields to return in the response. +func (f Mget) WithStoredFields(v ...string) func(*MgetRequest) { + return func(r *MgetRequest) { + r.StoredFields = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f Mget) WithPretty() func(*MgetRequest) { + return func(r *MgetRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f Mget) WithHuman() func(*MgetRequest) { + return func(r *MgetRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f Mget) WithErrorTrace() func(*MgetRequest) { + return func(r *MgetRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f Mget) WithFilterPath(v ...string) func(*MgetRequest) { + return func(r *MgetRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f Mget) WithHeader(h map[string]string) func(*MgetRequest) { + return func(r *MgetRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f Mget) WithOpaqueID(s string) func(*MgetRequest) { + return func(r *MgetRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.msearch.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.msearch.go new file mode 100644 index 00000000..44b6cd9a --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.msearch.go @@ -0,0 +1,305 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" +) + +func newMsearchFunc(t Transport) Msearch { + return func(body io.Reader, o ...func(*MsearchRequest)) (*Response, error) { + var r = MsearchRequest{Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// Msearch allows to execute several search operations in one request. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/search-multi-search.html. +type Msearch func(body io.Reader, o ...func(*MsearchRequest)) (*Response, error) + +// MsearchRequest configures the Msearch API request. +type MsearchRequest struct { + Index []string + DocumentType []string + + Body io.Reader + + CcsMinimizeRoundtrips *bool + MaxConcurrentSearches *int + MaxConcurrentShardRequests *int + PreFilterShardSize *int + RestTotalHitsAsInt *bool + SearchType string + TypedKeys *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MsearchRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len(strings.Join(r.Index, ",")) + 1 + len(strings.Join(r.DocumentType, ",")) + 1 + len("_msearch")) + if len(r.Index) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + } + if len(r.DocumentType) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.DocumentType, ",")) + } + path.WriteString("/") + path.WriteString("_msearch") + + params = make(map[string]string) + + if r.CcsMinimizeRoundtrips != nil { + params["ccs_minimize_roundtrips"] = strconv.FormatBool(*r.CcsMinimizeRoundtrips) + } + + if r.MaxConcurrentSearches != nil { + params["max_concurrent_searches"] = strconv.FormatInt(int64(*r.MaxConcurrentSearches), 10) + } + + if r.MaxConcurrentShardRequests != nil { + params["max_concurrent_shard_requests"] = strconv.FormatInt(int64(*r.MaxConcurrentShardRequests), 10) + } + + if r.PreFilterShardSize != nil { + params["pre_filter_shard_size"] = strconv.FormatInt(int64(*r.PreFilterShardSize), 10) + } + + if r.RestTotalHitsAsInt != nil { + params["rest_total_hits_as_int"] = strconv.FormatBool(*r.RestTotalHitsAsInt) + } + + if r.SearchType != "" { + params["search_type"] = r.SearchType + } + + if r.TypedKeys != nil { + params["typed_keys"] = strconv.FormatBool(*r.TypedKeys) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f Msearch) WithContext(v context.Context) func(*MsearchRequest) { + return func(r *MsearchRequest) { + r.ctx = v + } +} + +// WithIndex - a list of index names to use as default. +func (f Msearch) WithIndex(v ...string) func(*MsearchRequest) { + return func(r *MsearchRequest) { + r.Index = v + } +} + +// WithDocumentType - a list of document types to use as default. +func (f Msearch) WithDocumentType(v ...string) func(*MsearchRequest) { + return func(r *MsearchRequest) { + r.DocumentType = v + } +} + +// WithCcsMinimizeRoundtrips - indicates whether network round-trips should be minimized as part of cross-cluster search requests execution. +func (f Msearch) WithCcsMinimizeRoundtrips(v bool) func(*MsearchRequest) { + return func(r *MsearchRequest) { + r.CcsMinimizeRoundtrips = &v + } +} + +// WithMaxConcurrentSearches - controls the maximum number of concurrent searches the multi search api will execute. +func (f Msearch) WithMaxConcurrentSearches(v int) func(*MsearchRequest) { + return func(r *MsearchRequest) { + r.MaxConcurrentSearches = &v + } +} + +// WithMaxConcurrentShardRequests - the number of concurrent shard requests each sub search executes concurrently per node. this value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests. +func (f Msearch) WithMaxConcurrentShardRequests(v int) func(*MsearchRequest) { + return func(r *MsearchRequest) { + r.MaxConcurrentShardRequests = &v + } +} + +// WithPreFilterShardSize - a threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. this filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on its rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint.. +func (f Msearch) WithPreFilterShardSize(v int) func(*MsearchRequest) { + return func(r *MsearchRequest) { + r.PreFilterShardSize = &v + } +} + +// WithRestTotalHitsAsInt - indicates whether hits.total should be rendered as an integer or an object in the rest search response. +func (f Msearch) WithRestTotalHitsAsInt(v bool) func(*MsearchRequest) { + return func(r *MsearchRequest) { + r.RestTotalHitsAsInt = &v + } +} + +// WithSearchType - search operation type. +func (f Msearch) WithSearchType(v string) func(*MsearchRequest) { + return func(r *MsearchRequest) { + r.SearchType = v + } +} + +// WithTypedKeys - specify whether aggregation and suggester names should be prefixed by their respective types in the response. +func (f Msearch) WithTypedKeys(v bool) func(*MsearchRequest) { + return func(r *MsearchRequest) { + r.TypedKeys = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f Msearch) WithPretty() func(*MsearchRequest) { + return func(r *MsearchRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f Msearch) WithHuman() func(*MsearchRequest) { + return func(r *MsearchRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f Msearch) WithErrorTrace() func(*MsearchRequest) { + return func(r *MsearchRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f Msearch) WithFilterPath(v ...string) func(*MsearchRequest) { + return func(r *MsearchRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f Msearch) WithHeader(h map[string]string) func(*MsearchRequest) { + return func(r *MsearchRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f Msearch) WithOpaqueID(s string) func(*MsearchRequest) { + return func(r *MsearchRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.msearch_template.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.msearch_template.go new file mode 100644 index 00000000..9ac2fe30 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.msearch_template.go @@ -0,0 +1,283 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" +) + +func newMsearchTemplateFunc(t Transport) MsearchTemplate { + return func(body io.Reader, o ...func(*MsearchTemplateRequest)) (*Response, error) { + var r = MsearchTemplateRequest{Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MsearchTemplate allows to execute several search template operations in one request. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html. +type MsearchTemplate func(body io.Reader, o ...func(*MsearchTemplateRequest)) (*Response, error) + +// MsearchTemplateRequest configures the Msearch Template API request. +type MsearchTemplateRequest struct { + Index []string + DocumentType []string + + Body io.Reader + + CcsMinimizeRoundtrips *bool + MaxConcurrentSearches *int + RestTotalHitsAsInt *bool + SearchType string + TypedKeys *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MsearchTemplateRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len(strings.Join(r.Index, ",")) + 1 + len(strings.Join(r.DocumentType, ",")) + 1 + len("_msearch") + 1 + len("template")) + if len(r.Index) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + } + if len(r.DocumentType) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.DocumentType, ",")) + } + path.WriteString("/") + path.WriteString("_msearch") + path.WriteString("/") + path.WriteString("template") + + params = make(map[string]string) + + if r.CcsMinimizeRoundtrips != nil { + params["ccs_minimize_roundtrips"] = strconv.FormatBool(*r.CcsMinimizeRoundtrips) + } + + if r.MaxConcurrentSearches != nil { + params["max_concurrent_searches"] = strconv.FormatInt(int64(*r.MaxConcurrentSearches), 10) + } + + if r.RestTotalHitsAsInt != nil { + params["rest_total_hits_as_int"] = strconv.FormatBool(*r.RestTotalHitsAsInt) + } + + if r.SearchType != "" { + params["search_type"] = r.SearchType + } + + if r.TypedKeys != nil { + params["typed_keys"] = strconv.FormatBool(*r.TypedKeys) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MsearchTemplate) WithContext(v context.Context) func(*MsearchTemplateRequest) { + return func(r *MsearchTemplateRequest) { + r.ctx = v + } +} + +// WithIndex - a list of index names to use as default. +func (f MsearchTemplate) WithIndex(v ...string) func(*MsearchTemplateRequest) { + return func(r *MsearchTemplateRequest) { + r.Index = v + } +} + +// WithDocumentType - a list of document types to use as default. +func (f MsearchTemplate) WithDocumentType(v ...string) func(*MsearchTemplateRequest) { + return func(r *MsearchTemplateRequest) { + r.DocumentType = v + } +} + +// WithCcsMinimizeRoundtrips - indicates whether network round-trips should be minimized as part of cross-cluster search requests execution. +func (f MsearchTemplate) WithCcsMinimizeRoundtrips(v bool) func(*MsearchTemplateRequest) { + return func(r *MsearchTemplateRequest) { + r.CcsMinimizeRoundtrips = &v + } +} + +// WithMaxConcurrentSearches - controls the maximum number of concurrent searches the multi search api will execute. +func (f MsearchTemplate) WithMaxConcurrentSearches(v int) func(*MsearchTemplateRequest) { + return func(r *MsearchTemplateRequest) { + r.MaxConcurrentSearches = &v + } +} + +// WithRestTotalHitsAsInt - indicates whether hits.total should be rendered as an integer or an object in the rest search response. +func (f MsearchTemplate) WithRestTotalHitsAsInt(v bool) func(*MsearchTemplateRequest) { + return func(r *MsearchTemplateRequest) { + r.RestTotalHitsAsInt = &v + } +} + +// WithSearchType - search operation type. +func (f MsearchTemplate) WithSearchType(v string) func(*MsearchTemplateRequest) { + return func(r *MsearchTemplateRequest) { + r.SearchType = v + } +} + +// WithTypedKeys - specify whether aggregation and suggester names should be prefixed by their respective types in the response. +func (f MsearchTemplate) WithTypedKeys(v bool) func(*MsearchTemplateRequest) { + return func(r *MsearchTemplateRequest) { + r.TypedKeys = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MsearchTemplate) WithPretty() func(*MsearchTemplateRequest) { + return func(r *MsearchTemplateRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MsearchTemplate) WithHuman() func(*MsearchTemplateRequest) { + return func(r *MsearchTemplateRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MsearchTemplate) WithErrorTrace() func(*MsearchTemplateRequest) { + return func(r *MsearchTemplateRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MsearchTemplate) WithFilterPath(v ...string) func(*MsearchTemplateRequest) { + return func(r *MsearchTemplateRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MsearchTemplate) WithHeader(h map[string]string) func(*MsearchTemplateRequest) { + return func(r *MsearchTemplateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MsearchTemplate) WithOpaqueID(s string) func(*MsearchTemplateRequest) { + return func(r *MsearchTemplateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.mtermvectors.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.mtermvectors.go new file mode 100644 index 00000000..939492c3 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.mtermvectors.go @@ -0,0 +1,372 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" +) + +func newMtermvectorsFunc(t Transport) Mtermvectors { + return func(o ...func(*MtermvectorsRequest)) (*Response, error) { + var r = MtermvectorsRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// Mtermvectors returns multiple termvectors in one request. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-multi-termvectors.html. +type Mtermvectors func(o ...func(*MtermvectorsRequest)) (*Response, error) + +// MtermvectorsRequest configures the Mtermvectors API request. +type MtermvectorsRequest struct { + Index string + DocumentType string + + Body io.Reader + + Fields []string + FieldStatistics *bool + Ids []string + Offsets *bool + Payloads *bool + Positions *bool + Preference string + Realtime *bool + Routing string + TermStatistics *bool + Version *int + VersionType string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MtermvectorsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len(r.Index) + 1 + len(r.DocumentType) + 1 + len("_mtermvectors")) + if r.Index != "" { + path.WriteString("/") + path.WriteString(r.Index) + } + if r.DocumentType != "" { + path.WriteString("/") + path.WriteString(r.DocumentType) + } + path.WriteString("/") + path.WriteString("_mtermvectors") + + params = make(map[string]string) + + if len(r.Fields) > 0 { + params["fields"] = strings.Join(r.Fields, ",") + } + + if r.FieldStatistics != nil { + params["field_statistics"] = strconv.FormatBool(*r.FieldStatistics) + } + + if len(r.Ids) > 0 { + params["ids"] = strings.Join(r.Ids, ",") + } + + if r.Offsets != nil { + params["offsets"] = strconv.FormatBool(*r.Offsets) + } + + if r.Payloads != nil { + params["payloads"] = strconv.FormatBool(*r.Payloads) + } + + if r.Positions != nil { + params["positions"] = strconv.FormatBool(*r.Positions) + } + + if r.Preference != "" { + params["preference"] = r.Preference + } + + if r.Realtime != nil { + params["realtime"] = strconv.FormatBool(*r.Realtime) + } + + if r.Routing != "" { + params["routing"] = r.Routing + } + + if r.TermStatistics != nil { + params["term_statistics"] = strconv.FormatBool(*r.TermStatistics) + } + + if r.Version != nil { + params["version"] = strconv.FormatInt(int64(*r.Version), 10) + } + + if r.VersionType != "" { + params["version_type"] = r.VersionType + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f Mtermvectors) WithContext(v context.Context) func(*MtermvectorsRequest) { + return func(r *MtermvectorsRequest) { + r.ctx = v + } +} + +// WithBody - Define ids, documents, parameters or a list of parameters per document here. You must at least provide a list of document ids. See documentation.. +func (f Mtermvectors) WithBody(v io.Reader) func(*MtermvectorsRequest) { + return func(r *MtermvectorsRequest) { + r.Body = v + } +} + +// WithIndex - the index in which the document resides.. +func (f Mtermvectors) WithIndex(v string) func(*MtermvectorsRequest) { + return func(r *MtermvectorsRequest) { + r.Index = v + } +} + +// WithDocumentType - the type of the document.. +func (f Mtermvectors) WithDocumentType(v string) func(*MtermvectorsRequest) { + return func(r *MtermvectorsRequest) { + r.DocumentType = v + } +} + +// WithFields - a list of fields to return. applies to all returned documents unless otherwise specified in body "params" or "docs".. +func (f Mtermvectors) WithFields(v ...string) func(*MtermvectorsRequest) { + return func(r *MtermvectorsRequest) { + r.Fields = v + } +} + +// WithFieldStatistics - specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. applies to all returned documents unless otherwise specified in body "params" or "docs".. +func (f Mtermvectors) WithFieldStatistics(v bool) func(*MtermvectorsRequest) { + return func(r *MtermvectorsRequest) { + r.FieldStatistics = &v + } +} + +// WithIds - a list of documents ids. you must define ids as parameter or set "ids" or "docs" in the request body. +func (f Mtermvectors) WithIds(v ...string) func(*MtermvectorsRequest) { + return func(r *MtermvectorsRequest) { + r.Ids = v + } +} + +// WithOffsets - specifies if term offsets should be returned. applies to all returned documents unless otherwise specified in body "params" or "docs".. +func (f Mtermvectors) WithOffsets(v bool) func(*MtermvectorsRequest) { + return func(r *MtermvectorsRequest) { + r.Offsets = &v + } +} + +// WithPayloads - specifies if term payloads should be returned. applies to all returned documents unless otherwise specified in body "params" or "docs".. +func (f Mtermvectors) WithPayloads(v bool) func(*MtermvectorsRequest) { + return func(r *MtermvectorsRequest) { + r.Payloads = &v + } +} + +// WithPositions - specifies if term positions should be returned. applies to all returned documents unless otherwise specified in body "params" or "docs".. +func (f Mtermvectors) WithPositions(v bool) func(*MtermvectorsRequest) { + return func(r *MtermvectorsRequest) { + r.Positions = &v + } +} + +// WithPreference - specify the node or shard the operation should be performed on (default: random) .applies to all returned documents unless otherwise specified in body "params" or "docs".. +func (f Mtermvectors) WithPreference(v string) func(*MtermvectorsRequest) { + return func(r *MtermvectorsRequest) { + r.Preference = v + } +} + +// WithRealtime - specifies if requests are real-time as opposed to near-real-time (default: true).. +func (f Mtermvectors) WithRealtime(v bool) func(*MtermvectorsRequest) { + return func(r *MtermvectorsRequest) { + r.Realtime = &v + } +} + +// WithRouting - specific routing value. applies to all returned documents unless otherwise specified in body "params" or "docs".. +func (f Mtermvectors) WithRouting(v string) func(*MtermvectorsRequest) { + return func(r *MtermvectorsRequest) { + r.Routing = v + } +} + +// WithTermStatistics - specifies if total term frequency and document frequency should be returned. applies to all returned documents unless otherwise specified in body "params" or "docs".. +func (f Mtermvectors) WithTermStatistics(v bool) func(*MtermvectorsRequest) { + return func(r *MtermvectorsRequest) { + r.TermStatistics = &v + } +} + +// WithVersion - explicit version number for concurrency control. +func (f Mtermvectors) WithVersion(v int) func(*MtermvectorsRequest) { + return func(r *MtermvectorsRequest) { + r.Version = &v + } +} + +// WithVersionType - specific version type. +func (f Mtermvectors) WithVersionType(v string) func(*MtermvectorsRequest) { + return func(r *MtermvectorsRequest) { + r.VersionType = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f Mtermvectors) WithPretty() func(*MtermvectorsRequest) { + return func(r *MtermvectorsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f Mtermvectors) WithHuman() func(*MtermvectorsRequest) { + return func(r *MtermvectorsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f Mtermvectors) WithErrorTrace() func(*MtermvectorsRequest) { + return func(r *MtermvectorsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f Mtermvectors) WithFilterPath(v ...string) func(*MtermvectorsRequest) { + return func(r *MtermvectorsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f Mtermvectors) WithHeader(h map[string]string) func(*MtermvectorsRequest) { + return func(r *MtermvectorsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f Mtermvectors) WithOpaqueID(s string) func(*MtermvectorsRequest) { + return func(r *MtermvectorsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.nodes.clear_metering_archive.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.nodes.clear_metering_archive.go new file mode 100644 index 00000000..9208e183 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.nodes.clear_metering_archive.go @@ -0,0 +1,209 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.x: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newNodesClearMeteringArchiveFunc(t Transport) NodesClearMeteringArchive { + return func(max_archive_version *int, node_id []string, o ...func(*NodesClearMeteringArchiveRequest)) (*Response, error) { + var r = NodesClearMeteringArchiveRequest{NodeID: node_id, MaxArchiveVersion: max_archive_version} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// NodesClearMeteringArchive removes the archived repositories metering information present in the cluster. +// +// This API is experimental. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/clear-repositories-metering-archive-api.html. +// +type NodesClearMeteringArchive func(max_archive_version *int, node_id []string, o ...func(*NodesClearMeteringArchiveRequest)) (*Response, error) + +// NodesClearMeteringArchiveRequest configures the Nodes Clear Metering Archive API request. +// +type NodesClearMeteringArchiveRequest struct { + MaxArchiveVersion *int + NodeID []string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +// +func (r NodesClearMeteringArchiveRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + path.Grow(1 + len("_nodes") + 1 + len(strings.Join(r.NodeID, ",")) + 1 + len("_repositories_metering") + 1 + len(strconv.Itoa(*r.MaxArchiveVersion))) + path.WriteString("/") + path.WriteString("_nodes") + path.WriteString("/") + path.WriteString(strings.Join(r.NodeID, ",")) + path.WriteString("/") + path.WriteString("_repositories_metering") + path.WriteString("/") + path.WriteString(strconv.Itoa(*r.MaxArchiveVersion)) + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +// +func (f NodesClearMeteringArchive) WithContext(v context.Context) func(*NodesClearMeteringArchiveRequest) { + return func(r *NodesClearMeteringArchiveRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +// +func (f NodesClearMeteringArchive) WithPretty() func(*NodesClearMeteringArchiveRequest) { + return func(r *NodesClearMeteringArchiveRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +// +func (f NodesClearMeteringArchive) WithHuman() func(*NodesClearMeteringArchiveRequest) { + return func(r *NodesClearMeteringArchiveRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +// +func (f NodesClearMeteringArchive) WithErrorTrace() func(*NodesClearMeteringArchiveRequest) { + return func(r *NodesClearMeteringArchiveRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +// +func (f NodesClearMeteringArchive) WithFilterPath(v ...string) func(*NodesClearMeteringArchiveRequest) { + return func(r *NodesClearMeteringArchiveRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +// +func (f NodesClearMeteringArchive) WithHeader(h map[string]string) func(*NodesClearMeteringArchiveRequest) { + return func(r *NodesClearMeteringArchiveRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +// +func (f NodesClearMeteringArchive) WithOpaqueID(s string) func(*NodesClearMeteringArchiveRequest) { + return func(r *NodesClearMeteringArchiveRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.nodes.clear_repositories_metering_archive.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.nodes.clear_repositories_metering_archive.go new file mode 100644 index 00000000..539f8e8b --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.nodes.clear_repositories_metering_archive.go @@ -0,0 +1,207 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "errors" + "net/http" + "strconv" + "strings" +) + +func newNodesClearRepositoriesMeteringArchiveFunc(t Transport) NodesClearRepositoriesMeteringArchive { + return func(node_id []string, max_archive_version *int, o ...func(*NodesClearRepositoriesMeteringArchiveRequest)) (*Response, error) { + var r = NodesClearRepositoriesMeteringArchiveRequest{NodeID: node_id, MaxArchiveVersion: max_archive_version} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// NodesClearRepositoriesMeteringArchive removes the archived repositories metering information present in the cluster. +// +// This API is experimental. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/clear-repositories-metering-archive-api.html. +type NodesClearRepositoriesMeteringArchive func(node_id []string, max_archive_version *int, o ...func(*NodesClearRepositoriesMeteringArchiveRequest)) (*Response, error) + +// NodesClearRepositoriesMeteringArchiveRequest configures the Nodes Clear Repositories Metering Archive API request. +type NodesClearRepositoriesMeteringArchiveRequest struct { + MaxArchiveVersion *int + NodeID []string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r NodesClearRepositoriesMeteringArchiveRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + if len(r.NodeID) == 0 { + return nil, errors.New("node_id is required and cannot be nil or empty") + } + if r.MaxArchiveVersion == nil { + return nil, errors.New("max_archive_version is required and cannot be nil") + } + + path.Grow(1 + len("_nodes") + 1 + len(strings.Join(r.NodeID, ",")) + 1 + len("_repositories_metering") + 1 + len(strconv.Itoa(*r.MaxArchiveVersion))) + path.WriteString("/") + path.WriteString("_nodes") + path.WriteString("/") + path.WriteString(strings.Join(r.NodeID, ",")) + path.WriteString("/") + path.WriteString("_repositories_metering") + path.WriteString("/") + path.WriteString(strconv.Itoa(*r.MaxArchiveVersion)) + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f NodesClearRepositoriesMeteringArchive) WithContext(v context.Context) func(*NodesClearRepositoriesMeteringArchiveRequest) { + return func(r *NodesClearRepositoriesMeteringArchiveRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f NodesClearRepositoriesMeteringArchive) WithPretty() func(*NodesClearRepositoriesMeteringArchiveRequest) { + return func(r *NodesClearRepositoriesMeteringArchiveRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f NodesClearRepositoriesMeteringArchive) WithHuman() func(*NodesClearRepositoriesMeteringArchiveRequest) { + return func(r *NodesClearRepositoriesMeteringArchiveRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f NodesClearRepositoriesMeteringArchive) WithErrorTrace() func(*NodesClearRepositoriesMeteringArchiveRequest) { + return func(r *NodesClearRepositoriesMeteringArchiveRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f NodesClearRepositoriesMeteringArchive) WithFilterPath(v ...string) func(*NodesClearRepositoriesMeteringArchiveRequest) { + return func(r *NodesClearRepositoriesMeteringArchiveRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f NodesClearRepositoriesMeteringArchive) WithHeader(h map[string]string) func(*NodesClearRepositoriesMeteringArchiveRequest) { + return func(r *NodesClearRepositoriesMeteringArchiveRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f NodesClearRepositoriesMeteringArchive) WithOpaqueID(s string) func(*NodesClearRepositoriesMeteringArchiveRequest) { + return func(r *NodesClearRepositoriesMeteringArchiveRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.nodes.get_metering_info.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.nodes.get_metering_info.go new file mode 100644 index 00000000..2366a88a --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.nodes.get_metering_info.go @@ -0,0 +1,205 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.x: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newNodesGetMeteringInfoFunc(t Transport) NodesGetMeteringInfo { + return func(node_id []string, o ...func(*NodesGetMeteringInfoRequest)) (*Response, error) { + var r = NodesGetMeteringInfoRequest{NodeID: node_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// NodesGetMeteringInfo returns cluster repositories metering information. +// +// This API is experimental. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/get-repositories-metering-api.html. +// +type NodesGetMeteringInfo func(node_id []string, o ...func(*NodesGetMeteringInfoRequest)) (*Response, error) + +// NodesGetMeteringInfoRequest configures the Nodes Get Metering Info API request. +// +type NodesGetMeteringInfoRequest struct { + NodeID []string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +// +func (r NodesGetMeteringInfoRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_nodes") + 1 + len(strings.Join(r.NodeID, ",")) + 1 + len("_repositories_metering")) + path.WriteString("/") + path.WriteString("_nodes") + path.WriteString("/") + path.WriteString(strings.Join(r.NodeID, ",")) + path.WriteString("/") + path.WriteString("_repositories_metering") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +// +func (f NodesGetMeteringInfo) WithContext(v context.Context) func(*NodesGetMeteringInfoRequest) { + return func(r *NodesGetMeteringInfoRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +// +func (f NodesGetMeteringInfo) WithPretty() func(*NodesGetMeteringInfoRequest) { + return func(r *NodesGetMeteringInfoRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +// +func (f NodesGetMeteringInfo) WithHuman() func(*NodesGetMeteringInfoRequest) { + return func(r *NodesGetMeteringInfoRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +// +func (f NodesGetMeteringInfo) WithErrorTrace() func(*NodesGetMeteringInfoRequest) { + return func(r *NodesGetMeteringInfoRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +// +func (f NodesGetMeteringInfo) WithFilterPath(v ...string) func(*NodesGetMeteringInfoRequest) { + return func(r *NodesGetMeteringInfoRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +// +func (f NodesGetMeteringInfo) WithHeader(h map[string]string) func(*NodesGetMeteringInfoRequest) { + return func(r *NodesGetMeteringInfoRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +// +func (f NodesGetMeteringInfo) WithOpaqueID(s string) func(*NodesGetMeteringInfoRequest) { + return func(r *NodesGetMeteringInfoRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.nodes.get_repositories_metering_info.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.nodes.get_repositories_metering_info.go new file mode 100644 index 00000000..5c01753c --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.nodes.get_repositories_metering_info.go @@ -0,0 +1,200 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "errors" + "net/http" + "strings" +) + +func newNodesGetRepositoriesMeteringInfoFunc(t Transport) NodesGetRepositoriesMeteringInfo { + return func(node_id []string, o ...func(*NodesGetRepositoriesMeteringInfoRequest)) (*Response, error) { + var r = NodesGetRepositoriesMeteringInfoRequest{NodeID: node_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// NodesGetRepositoriesMeteringInfo returns cluster repositories metering information. +// +// This API is experimental. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/get-repositories-metering-api.html. +type NodesGetRepositoriesMeteringInfo func(node_id []string, o ...func(*NodesGetRepositoriesMeteringInfoRequest)) (*Response, error) + +// NodesGetRepositoriesMeteringInfoRequest configures the Nodes Get Repositories Metering Info API request. +type NodesGetRepositoriesMeteringInfoRequest struct { + NodeID []string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r NodesGetRepositoriesMeteringInfoRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + if len(r.NodeID) == 0 { + return nil, errors.New("node_id is required and cannot be nil or empty") + } + + path.Grow(1 + len("_nodes") + 1 + len(strings.Join(r.NodeID, ",")) + 1 + len("_repositories_metering")) + path.WriteString("/") + path.WriteString("_nodes") + path.WriteString("/") + path.WriteString(strings.Join(r.NodeID, ",")) + path.WriteString("/") + path.WriteString("_repositories_metering") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f NodesGetRepositoriesMeteringInfo) WithContext(v context.Context) func(*NodesGetRepositoriesMeteringInfoRequest) { + return func(r *NodesGetRepositoriesMeteringInfoRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f NodesGetRepositoriesMeteringInfo) WithPretty() func(*NodesGetRepositoriesMeteringInfoRequest) { + return func(r *NodesGetRepositoriesMeteringInfoRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f NodesGetRepositoriesMeteringInfo) WithHuman() func(*NodesGetRepositoriesMeteringInfoRequest) { + return func(r *NodesGetRepositoriesMeteringInfoRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f NodesGetRepositoriesMeteringInfo) WithErrorTrace() func(*NodesGetRepositoriesMeteringInfoRequest) { + return func(r *NodesGetRepositoriesMeteringInfoRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f NodesGetRepositoriesMeteringInfo) WithFilterPath(v ...string) func(*NodesGetRepositoriesMeteringInfoRequest) { + return func(r *NodesGetRepositoriesMeteringInfoRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f NodesGetRepositoriesMeteringInfo) WithHeader(h map[string]string) func(*NodesGetRepositoriesMeteringInfoRequest) { + return func(r *NodesGetRepositoriesMeteringInfoRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f NodesGetRepositoriesMeteringInfo) WithOpaqueID(s string) func(*NodesGetRepositoriesMeteringInfoRequest) { + return func(r *NodesGetRepositoriesMeteringInfoRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.nodes.hot_threads.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.nodes.hot_threads.go new file mode 100644 index 00000000..912bcfd6 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.nodes.hot_threads.go @@ -0,0 +1,291 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" + "time" +) + +func newNodesHotThreadsFunc(t Transport) NodesHotThreads { + return func(o ...func(*NodesHotThreadsRequest)) (*Response, error) { + var r = NodesHotThreadsRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// NodesHotThreads returns information about hot threads on each node in the cluster. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-hot-threads.html. +type NodesHotThreads func(o ...func(*NodesHotThreadsRequest)) (*Response, error) + +// NodesHotThreadsRequest configures the Nodes Hot Threads API request. +type NodesHotThreadsRequest struct { + NodeID []string + + IgnoreIdleThreads *bool + Interval time.Duration + Snapshots *int + Sort string + Threads *int + Timeout time.Duration + DocumentType string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r NodesHotThreadsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_cluster") + 1 + len("nodes") + 1 + len(strings.Join(r.NodeID, ",")) + 1 + len("hot_threads")) + path.WriteString("/") + path.WriteString("_cluster") + path.WriteString("/") + path.WriteString("nodes") + if len(r.NodeID) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.NodeID, ",")) + } + path.WriteString("/") + path.WriteString("hot_threads") + + params = make(map[string]string) + + if r.IgnoreIdleThreads != nil { + params["ignore_idle_threads"] = strconv.FormatBool(*r.IgnoreIdleThreads) + } + + if r.Interval != 0 { + params["interval"] = formatDuration(r.Interval) + } + + if r.Snapshots != nil { + params["snapshots"] = strconv.FormatInt(int64(*r.Snapshots), 10) + } + + if r.Sort != "" { + params["sort"] = r.Sort + } + + if r.Threads != nil { + params["threads"] = strconv.FormatInt(int64(*r.Threads), 10) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.DocumentType != "" { + params["type"] = r.DocumentType + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f NodesHotThreads) WithContext(v context.Context) func(*NodesHotThreadsRequest) { + return func(r *NodesHotThreadsRequest) { + r.ctx = v + } +} + +// WithNodeID - a list of node ids or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes. +func (f NodesHotThreads) WithNodeID(v ...string) func(*NodesHotThreadsRequest) { + return func(r *NodesHotThreadsRequest) { + r.NodeID = v + } +} + +// WithIgnoreIdleThreads - don't show threads that are in known-idle places, such as waiting on a socket select or pulling from an empty task queue (default: true). +func (f NodesHotThreads) WithIgnoreIdleThreads(v bool) func(*NodesHotThreadsRequest) { + return func(r *NodesHotThreadsRequest) { + r.IgnoreIdleThreads = &v + } +} + +// WithInterval - the interval for the second sampling of threads. +func (f NodesHotThreads) WithInterval(v time.Duration) func(*NodesHotThreadsRequest) { + return func(r *NodesHotThreadsRequest) { + r.Interval = v + } +} + +// WithSnapshots - number of samples of thread stacktrace (default: 10). +func (f NodesHotThreads) WithSnapshots(v int) func(*NodesHotThreadsRequest) { + return func(r *NodesHotThreadsRequest) { + r.Snapshots = &v + } +} + +// WithSort - the sort order for 'cpu' type (default: total). +func (f NodesHotThreads) WithSort(v string) func(*NodesHotThreadsRequest) { + return func(r *NodesHotThreadsRequest) { + r.Sort = v + } +} + +// WithThreads - specify the number of threads to provide information for (default: 3). +func (f NodesHotThreads) WithThreads(v int) func(*NodesHotThreadsRequest) { + return func(r *NodesHotThreadsRequest) { + r.Threads = &v + } +} + +// WithTimeout - explicit operation timeout. +func (f NodesHotThreads) WithTimeout(v time.Duration) func(*NodesHotThreadsRequest) { + return func(r *NodesHotThreadsRequest) { + r.Timeout = v + } +} + +// WithDocumentType - the type to sample (default: cpu). +func (f NodesHotThreads) WithDocumentType(v string) func(*NodesHotThreadsRequest) { + return func(r *NodesHotThreadsRequest) { + r.DocumentType = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f NodesHotThreads) WithPretty() func(*NodesHotThreadsRequest) { + return func(r *NodesHotThreadsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f NodesHotThreads) WithHuman() func(*NodesHotThreadsRequest) { + return func(r *NodesHotThreadsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f NodesHotThreads) WithErrorTrace() func(*NodesHotThreadsRequest) { + return func(r *NodesHotThreadsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f NodesHotThreads) WithFilterPath(v ...string) func(*NodesHotThreadsRequest) { + return func(r *NodesHotThreadsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f NodesHotThreads) WithHeader(h map[string]string) func(*NodesHotThreadsRequest) { + return func(r *NodesHotThreadsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f NodesHotThreads) WithOpaqueID(s string) func(*NodesHotThreadsRequest) { + return func(r *NodesHotThreadsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.nodes.info.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.nodes.info.go new file mode 100644 index 00000000..5812e2e1 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.nodes.info.go @@ -0,0 +1,239 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" + "time" +) + +func newNodesInfoFunc(t Transport) NodesInfo { + return func(o ...func(*NodesInfoRequest)) (*Response, error) { + var r = NodesInfoRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// NodesInfo returns information about nodes in the cluster. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-info.html. +type NodesInfo func(o ...func(*NodesInfoRequest)) (*Response, error) + +// NodesInfoRequest configures the Nodes Info API request. +type NodesInfoRequest struct { + Metric []string + NodeID []string + + FlatSettings *bool + Timeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r NodesInfoRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_nodes") + 1 + len(strings.Join(r.NodeID, ",")) + 1 + len(strings.Join(r.Metric, ","))) + path.WriteString("/") + path.WriteString("_nodes") + if len(r.NodeID) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.NodeID, ",")) + } + if len(r.Metric) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Metric, ",")) + } + + params = make(map[string]string) + + if r.FlatSettings != nil { + params["flat_settings"] = strconv.FormatBool(*r.FlatSettings) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f NodesInfo) WithContext(v context.Context) func(*NodesInfoRequest) { + return func(r *NodesInfoRequest) { + r.ctx = v + } +} + +// WithMetric - a list of metrics you wish returned. leave empty to return all metrics.. +func (f NodesInfo) WithMetric(v ...string) func(*NodesInfoRequest) { + return func(r *NodesInfoRequest) { + r.Metric = v + } +} + +// WithNodeID - a list of node ids or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes. +func (f NodesInfo) WithNodeID(v ...string) func(*NodesInfoRequest) { + return func(r *NodesInfoRequest) { + r.NodeID = v + } +} + +// WithFlatSettings - return settings in flat format (default: false). +func (f NodesInfo) WithFlatSettings(v bool) func(*NodesInfoRequest) { + return func(r *NodesInfoRequest) { + r.FlatSettings = &v + } +} + +// WithTimeout - explicit operation timeout. +func (f NodesInfo) WithTimeout(v time.Duration) func(*NodesInfoRequest) { + return func(r *NodesInfoRequest) { + r.Timeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f NodesInfo) WithPretty() func(*NodesInfoRequest) { + return func(r *NodesInfoRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f NodesInfo) WithHuman() func(*NodesInfoRequest) { + return func(r *NodesInfoRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f NodesInfo) WithErrorTrace() func(*NodesInfoRequest) { + return func(r *NodesInfoRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f NodesInfo) WithFilterPath(v ...string) func(*NodesInfoRequest) { + return func(r *NodesInfoRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f NodesInfo) WithHeader(h map[string]string) func(*NodesInfoRequest) { + return func(r *NodesInfoRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f NodesInfo) WithOpaqueID(s string) func(*NodesInfoRequest) { + return func(r *NodesInfoRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.nodes.reload_secure_settings.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.nodes.reload_secure_settings.go new file mode 100644 index 00000000..4a5dea63 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.nodes.reload_secure_settings.go @@ -0,0 +1,230 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" + "time" +) + +func newNodesReloadSecureSettingsFunc(t Transport) NodesReloadSecureSettings { + return func(o ...func(*NodesReloadSecureSettingsRequest)) (*Response, error) { + var r = NodesReloadSecureSettingsRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// NodesReloadSecureSettings reloads secure settings. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/secure-settings.html#reloadable-secure-settings. +type NodesReloadSecureSettings func(o ...func(*NodesReloadSecureSettingsRequest)) (*Response, error) + +// NodesReloadSecureSettingsRequest configures the Nodes Reload Secure Settings API request. +type NodesReloadSecureSettingsRequest struct { + Body io.Reader + + NodeID []string + + Timeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r NodesReloadSecureSettingsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_nodes") + 1 + len(strings.Join(r.NodeID, ",")) + 1 + len("reload_secure_settings")) + path.WriteString("/") + path.WriteString("_nodes") + if len(r.NodeID) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.NodeID, ",")) + } + path.WriteString("/") + path.WriteString("reload_secure_settings") + + params = make(map[string]string) + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f NodesReloadSecureSettings) WithContext(v context.Context) func(*NodesReloadSecureSettingsRequest) { + return func(r *NodesReloadSecureSettingsRequest) { + r.ctx = v + } +} + +// WithBody - An object containing the password for the elasticsearch keystore. +func (f NodesReloadSecureSettings) WithBody(v io.Reader) func(*NodesReloadSecureSettingsRequest) { + return func(r *NodesReloadSecureSettingsRequest) { + r.Body = v + } +} + +// WithNodeID - a list of node ids to span the reload/reinit call. should stay empty because reloading usually involves all cluster nodes.. +func (f NodesReloadSecureSettings) WithNodeID(v ...string) func(*NodesReloadSecureSettingsRequest) { + return func(r *NodesReloadSecureSettingsRequest) { + r.NodeID = v + } +} + +// WithTimeout - explicit operation timeout. +func (f NodesReloadSecureSettings) WithTimeout(v time.Duration) func(*NodesReloadSecureSettingsRequest) { + return func(r *NodesReloadSecureSettingsRequest) { + r.Timeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f NodesReloadSecureSettings) WithPretty() func(*NodesReloadSecureSettingsRequest) { + return func(r *NodesReloadSecureSettingsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f NodesReloadSecureSettings) WithHuman() func(*NodesReloadSecureSettingsRequest) { + return func(r *NodesReloadSecureSettingsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f NodesReloadSecureSettings) WithErrorTrace() func(*NodesReloadSecureSettingsRequest) { + return func(r *NodesReloadSecureSettingsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f NodesReloadSecureSettings) WithFilterPath(v ...string) func(*NodesReloadSecureSettingsRequest) { + return func(r *NodesReloadSecureSettingsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f NodesReloadSecureSettings) WithHeader(h map[string]string) func(*NodesReloadSecureSettingsRequest) { + return func(r *NodesReloadSecureSettingsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f NodesReloadSecureSettings) WithOpaqueID(s string) func(*NodesReloadSecureSettingsRequest) { + return func(r *NodesReloadSecureSettingsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.nodes.stats.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.nodes.stats.go new file mode 100644 index 00000000..fab78209 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.nodes.stats.go @@ -0,0 +1,337 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" + "time" +) + +func newNodesStatsFunc(t Transport) NodesStats { + return func(o ...func(*NodesStatsRequest)) (*Response, error) { + var r = NodesStatsRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// NodesStats returns statistical information about nodes in the cluster. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-stats.html. +type NodesStats func(o ...func(*NodesStatsRequest)) (*Response, error) + +// NodesStatsRequest configures the Nodes Stats API request. +type NodesStatsRequest struct { + IndexMetric []string + Metric []string + NodeID []string + + CompletionFields []string + FielddataFields []string + Fields []string + Groups *bool + IncludeSegmentFileSizes *bool + IncludeUnloadedSegments *bool + Level string + Timeout time.Duration + Types []string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r NodesStatsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_nodes") + 1 + len(strings.Join(r.NodeID, ",")) + 1 + len("stats") + 1 + len(strings.Join(r.Metric, ",")) + 1 + len(strings.Join(r.IndexMetric, ","))) + path.WriteString("/") + path.WriteString("_nodes") + if len(r.NodeID) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.NodeID, ",")) + } + path.WriteString("/") + path.WriteString("stats") + if len(r.Metric) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Metric, ",")) + } + if len(r.IndexMetric) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.IndexMetric, ",")) + } + + params = make(map[string]string) + + if len(r.CompletionFields) > 0 { + params["completion_fields"] = strings.Join(r.CompletionFields, ",") + } + + if len(r.FielddataFields) > 0 { + params["fielddata_fields"] = strings.Join(r.FielddataFields, ",") + } + + if len(r.Fields) > 0 { + params["fields"] = strings.Join(r.Fields, ",") + } + + if r.Groups != nil { + params["groups"] = strconv.FormatBool(*r.Groups) + } + + if r.IncludeSegmentFileSizes != nil { + params["include_segment_file_sizes"] = strconv.FormatBool(*r.IncludeSegmentFileSizes) + } + + if r.IncludeUnloadedSegments != nil { + params["include_unloaded_segments"] = strconv.FormatBool(*r.IncludeUnloadedSegments) + } + + if r.Level != "" { + params["level"] = r.Level + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if len(r.Types) > 0 { + params["types"] = strings.Join(r.Types, ",") + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f NodesStats) WithContext(v context.Context) func(*NodesStatsRequest) { + return func(r *NodesStatsRequest) { + r.ctx = v + } +} + +// WithIndexMetric - limit the information returned for `indices` metric to the specific index metrics. isn't used if `indices` (or `all`) metric isn't specified.. +func (f NodesStats) WithIndexMetric(v ...string) func(*NodesStatsRequest) { + return func(r *NodesStatsRequest) { + r.IndexMetric = v + } +} + +// WithMetric - limit the information returned to the specified metrics. +func (f NodesStats) WithMetric(v ...string) func(*NodesStatsRequest) { + return func(r *NodesStatsRequest) { + r.Metric = v + } +} + +// WithNodeID - a list of node ids or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes. +func (f NodesStats) WithNodeID(v ...string) func(*NodesStatsRequest) { + return func(r *NodesStatsRequest) { + r.NodeID = v + } +} + +// WithCompletionFields - a list of fields for `fielddata` and `suggest` index metric (supports wildcards). +func (f NodesStats) WithCompletionFields(v ...string) func(*NodesStatsRequest) { + return func(r *NodesStatsRequest) { + r.CompletionFields = v + } +} + +// WithFielddataFields - a list of fields for `fielddata` index metric (supports wildcards). +func (f NodesStats) WithFielddataFields(v ...string) func(*NodesStatsRequest) { + return func(r *NodesStatsRequest) { + r.FielddataFields = v + } +} + +// WithFields - a list of fields for `fielddata` and `completion` index metric (supports wildcards). +func (f NodesStats) WithFields(v ...string) func(*NodesStatsRequest) { + return func(r *NodesStatsRequest) { + r.Fields = v + } +} + +// WithGroups - a list of search groups for `search` index metric. +func (f NodesStats) WithGroups(v bool) func(*NodesStatsRequest) { + return func(r *NodesStatsRequest) { + r.Groups = &v + } +} + +// WithIncludeSegmentFileSizes - whether to report the aggregated disk usage of each one of the lucene index files (only applies if segment stats are requested). +func (f NodesStats) WithIncludeSegmentFileSizes(v bool) func(*NodesStatsRequest) { + return func(r *NodesStatsRequest) { + r.IncludeSegmentFileSizes = &v + } +} + +// WithIncludeUnloadedSegments - if set to true segment stats will include stats for segments that are not currently loaded into memory. +func (f NodesStats) WithIncludeUnloadedSegments(v bool) func(*NodesStatsRequest) { + return func(r *NodesStatsRequest) { + r.IncludeUnloadedSegments = &v + } +} + +// WithLevel - return indices stats aggregated at index, node or shard level. +func (f NodesStats) WithLevel(v string) func(*NodesStatsRequest) { + return func(r *NodesStatsRequest) { + r.Level = v + } +} + +// WithTimeout - explicit operation timeout. +func (f NodesStats) WithTimeout(v time.Duration) func(*NodesStatsRequest) { + return func(r *NodesStatsRequest) { + r.Timeout = v + } +} + +// WithTypes - a list of document types for the `indexing` index metric. +func (f NodesStats) WithTypes(v ...string) func(*NodesStatsRequest) { + return func(r *NodesStatsRequest) { + r.Types = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f NodesStats) WithPretty() func(*NodesStatsRequest) { + return func(r *NodesStatsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f NodesStats) WithHuman() func(*NodesStatsRequest) { + return func(r *NodesStatsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f NodesStats) WithErrorTrace() func(*NodesStatsRequest) { + return func(r *NodesStatsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f NodesStats) WithFilterPath(v ...string) func(*NodesStatsRequest) { + return func(r *NodesStatsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f NodesStats) WithHeader(h map[string]string) func(*NodesStatsRequest) { + return func(r *NodesStatsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f NodesStats) WithOpaqueID(s string) func(*NodesStatsRequest) { + return func(r *NodesStatsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.nodes.usage.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.nodes.usage.go new file mode 100644 index 00000000..2519089a --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.nodes.usage.go @@ -0,0 +1,228 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" + "time" +) + +func newNodesUsageFunc(t Transport) NodesUsage { + return func(o ...func(*NodesUsageRequest)) (*Response, error) { + var r = NodesUsageRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// NodesUsage returns low-level information about REST actions usage on nodes. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-usage.html. +type NodesUsage func(o ...func(*NodesUsageRequest)) (*Response, error) + +// NodesUsageRequest configures the Nodes Usage API request. +type NodesUsageRequest struct { + Metric []string + NodeID []string + + Timeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r NodesUsageRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_nodes") + 1 + len(strings.Join(r.NodeID, ",")) + 1 + len("usage") + 1 + len(strings.Join(r.Metric, ","))) + path.WriteString("/") + path.WriteString("_nodes") + if len(r.NodeID) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.NodeID, ",")) + } + path.WriteString("/") + path.WriteString("usage") + if len(r.Metric) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Metric, ",")) + } + + params = make(map[string]string) + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f NodesUsage) WithContext(v context.Context) func(*NodesUsageRequest) { + return func(r *NodesUsageRequest) { + r.ctx = v + } +} + +// WithMetric - limit the information returned to the specified metrics. +func (f NodesUsage) WithMetric(v ...string) func(*NodesUsageRequest) { + return func(r *NodesUsageRequest) { + r.Metric = v + } +} + +// WithNodeID - a list of node ids or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes. +func (f NodesUsage) WithNodeID(v ...string) func(*NodesUsageRequest) { + return func(r *NodesUsageRequest) { + r.NodeID = v + } +} + +// WithTimeout - explicit operation timeout. +func (f NodesUsage) WithTimeout(v time.Duration) func(*NodesUsageRequest) { + return func(r *NodesUsageRequest) { + r.Timeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f NodesUsage) WithPretty() func(*NodesUsageRequest) { + return func(r *NodesUsageRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f NodesUsage) WithHuman() func(*NodesUsageRequest) { + return func(r *NodesUsageRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f NodesUsage) WithErrorTrace() func(*NodesUsageRequest) { + return func(r *NodesUsageRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f NodesUsage) WithFilterPath(v ...string) func(*NodesUsageRequest) { + return func(r *NodesUsageRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f NodesUsage) WithHeader(h map[string]string) func(*NodesUsageRequest) { + return func(r *NodesUsageRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f NodesUsage) WithOpaqueID(s string) func(*NodesUsageRequest) { + return func(r *NodesUsageRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.ping.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.ping.go new file mode 100644 index 00000000..d106b1e2 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.ping.go @@ -0,0 +1,186 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newPingFunc(t Transport) Ping { + return func(o ...func(*PingRequest)) (*Response, error) { + var r = PingRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// Ping returns whether the cluster is running. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html. +type Ping func(o ...func(*PingRequest)) (*Response, error) + +// PingRequest configures the Ping API request. +type PingRequest struct { + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r PingRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "HEAD" + + path.Grow(len("/")) + path.WriteString("/") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f Ping) WithContext(v context.Context) func(*PingRequest) { + return func(r *PingRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f Ping) WithPretty() func(*PingRequest) { + return func(r *PingRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f Ping) WithHuman() func(*PingRequest) { + return func(r *PingRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f Ping) WithErrorTrace() func(*PingRequest) { + return func(r *PingRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f Ping) WithFilterPath(v ...string) func(*PingRequest) { + return func(r *PingRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f Ping) WithHeader(h map[string]string) func(*PingRequest) { + return func(r *PingRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f Ping) WithOpaqueID(s string) func(*PingRequest) { + return func(r *PingRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.put_script.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.put_script.go new file mode 100644 index 00000000..21bbc162 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.put_script.go @@ -0,0 +1,241 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" + "time" +) + +func newPutScriptFunc(t Transport) PutScript { + return func(id string, body io.Reader, o ...func(*PutScriptRequest)) (*Response, error) { + var r = PutScriptRequest{ScriptID: id, Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// PutScript creates or updates a script. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html. +type PutScript func(id string, body io.Reader, o ...func(*PutScriptRequest)) (*Response, error) + +// PutScriptRequest configures the Put Script API request. +type PutScriptRequest struct { + ScriptID string + + Body io.Reader + + ScriptContext string + + MasterTimeout time.Duration + Timeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r PutScriptRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(1 + len("_scripts") + 1 + len(r.ScriptID) + 1 + len(r.ScriptContext)) + path.WriteString("/") + path.WriteString("_scripts") + path.WriteString("/") + path.WriteString(r.ScriptID) + if r.ScriptContext != "" { + path.WriteString("/") + path.WriteString(r.ScriptContext) + } + + params = make(map[string]string) + + if r.ScriptContext != "" { + params["context"] = r.ScriptContext + } + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f PutScript) WithContext(v context.Context) func(*PutScriptRequest) { + return func(r *PutScriptRequest) { + r.ctx = v + } +} + +// WithScriptContext - script context. +func (f PutScript) WithScriptContext(v string) func(*PutScriptRequest) { + return func(r *PutScriptRequest) { + r.ScriptContext = v + } +} + +// WithMasterTimeout - specify timeout for connection to master. +func (f PutScript) WithMasterTimeout(v time.Duration) func(*PutScriptRequest) { + return func(r *PutScriptRequest) { + r.MasterTimeout = v + } +} + +// WithTimeout - explicit operation timeout. +func (f PutScript) WithTimeout(v time.Duration) func(*PutScriptRequest) { + return func(r *PutScriptRequest) { + r.Timeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f PutScript) WithPretty() func(*PutScriptRequest) { + return func(r *PutScriptRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f PutScript) WithHuman() func(*PutScriptRequest) { + return func(r *PutScriptRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f PutScript) WithErrorTrace() func(*PutScriptRequest) { + return func(r *PutScriptRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f PutScript) WithFilterPath(v ...string) func(*PutScriptRequest) { + return func(r *PutScriptRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f PutScript) WithHeader(h map[string]string) func(*PutScriptRequest) { + return func(r *PutScriptRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f PutScript) WithOpaqueID(s string) func(*PutScriptRequest) { + return func(r *PutScriptRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.rank_eval.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.rank_eval.go new file mode 100644 index 00000000..baee8701 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.rank_eval.go @@ -0,0 +1,257 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" +) + +func newRankEvalFunc(t Transport) RankEval { + return func(body io.Reader, o ...func(*RankEvalRequest)) (*Response, error) { + var r = RankEvalRequest{Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// RankEval allows to evaluate the quality of ranked search results over a set of typical search queries +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/search-rank-eval.html. +type RankEval func(body io.Reader, o ...func(*RankEvalRequest)) (*Response, error) + +// RankEvalRequest configures the Rank Eval API request. +type RankEvalRequest struct { + Index []string + + Body io.Reader + + AllowNoIndices *bool + ExpandWildcards string + IgnoreUnavailable *bool + SearchType string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r RankEvalRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len(strings.Join(r.Index, ",")) + 1 + len("_rank_eval")) + if len(r.Index) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + } + path.WriteString("/") + path.WriteString("_rank_eval") + + params = make(map[string]string) + + if r.AllowNoIndices != nil { + params["allow_no_indices"] = strconv.FormatBool(*r.AllowNoIndices) + } + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if r.IgnoreUnavailable != nil { + params["ignore_unavailable"] = strconv.FormatBool(*r.IgnoreUnavailable) + } + + if r.SearchType != "" { + params["search_type"] = r.SearchType + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f RankEval) WithContext(v context.Context) func(*RankEvalRequest) { + return func(r *RankEvalRequest) { + r.ctx = v + } +} + +// WithIndex - a list of index names to search; use _all to perform the operation on all indices. +func (f RankEval) WithIndex(v ...string) func(*RankEvalRequest) { + return func(r *RankEvalRequest) { + r.Index = v + } +} + +// WithAllowNoIndices - whether to ignore if a wildcard indices expression resolves into no concrete indices. (this includes `_all` string or when no indices have been specified). +func (f RankEval) WithAllowNoIndices(v bool) func(*RankEvalRequest) { + return func(r *RankEvalRequest) { + r.AllowNoIndices = &v + } +} + +// WithExpandWildcards - whether to expand wildcard expression to concrete indices that are open, closed or both.. +func (f RankEval) WithExpandWildcards(v string) func(*RankEvalRequest) { + return func(r *RankEvalRequest) { + r.ExpandWildcards = v + } +} + +// WithIgnoreUnavailable - whether specified concrete indices should be ignored when unavailable (missing or closed). +func (f RankEval) WithIgnoreUnavailable(v bool) func(*RankEvalRequest) { + return func(r *RankEvalRequest) { + r.IgnoreUnavailable = &v + } +} + +// WithSearchType - search operation type. +func (f RankEval) WithSearchType(v string) func(*RankEvalRequest) { + return func(r *RankEvalRequest) { + r.SearchType = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f RankEval) WithPretty() func(*RankEvalRequest) { + return func(r *RankEvalRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f RankEval) WithHuman() func(*RankEvalRequest) { + return func(r *RankEvalRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f RankEval) WithErrorTrace() func(*RankEvalRequest) { + return func(r *RankEvalRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f RankEval) WithFilterPath(v ...string) func(*RankEvalRequest) { + return func(r *RankEvalRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f RankEval) WithHeader(h map[string]string) func(*RankEvalRequest) { + return func(r *RankEvalRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f RankEval) WithOpaqueID(s string) func(*RankEvalRequest) { + return func(r *RankEvalRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.reindex.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.reindex.go new file mode 100644 index 00000000..92c917c1 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.reindex.go @@ -0,0 +1,295 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "fmt" + "io" + "net/http" + "strconv" + "strings" + "time" +) + +func newReindexFunc(t Transport) Reindex { + return func(body io.Reader, o ...func(*ReindexRequest)) (*Response, error) { + var r = ReindexRequest{Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// Reindex allows to copy documents from one index to another, optionally filtering the source +// documents by a query, changing the destination index settings, or fetching the +// documents from a remote cluster. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-reindex.html. +type Reindex func(body io.Reader, o ...func(*ReindexRequest)) (*Response, error) + +// ReindexRequest configures the Reindex API request. +type ReindexRequest struct { + Body io.Reader + + MaxDocs *int + Refresh *bool + RequestsPerSecond *int + Scroll time.Duration + Slices interface{} + Timeout time.Duration + WaitForActiveShards string + WaitForCompletion *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r ReindexRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(len("/_reindex")) + path.WriteString("/_reindex") + + params = make(map[string]string) + + if r.MaxDocs != nil { + params["max_docs"] = strconv.FormatInt(int64(*r.MaxDocs), 10) + } + + if r.Refresh != nil { + params["refresh"] = strconv.FormatBool(*r.Refresh) + } + + if r.RequestsPerSecond != nil { + params["requests_per_second"] = strconv.FormatInt(int64(*r.RequestsPerSecond), 10) + } + + if r.Scroll != 0 { + params["scroll"] = formatDuration(r.Scroll) + } + + if r.Slices != nil { + params["slices"] = fmt.Sprintf("%v", r.Slices) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.WaitForActiveShards != "" { + params["wait_for_active_shards"] = r.WaitForActiveShards + } + + if r.WaitForCompletion != nil { + params["wait_for_completion"] = strconv.FormatBool(*r.WaitForCompletion) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f Reindex) WithContext(v context.Context) func(*ReindexRequest) { + return func(r *ReindexRequest) { + r.ctx = v + } +} + +// WithMaxDocs - maximum number of documents to process (default: all documents). +func (f Reindex) WithMaxDocs(v int) func(*ReindexRequest) { + return func(r *ReindexRequest) { + r.MaxDocs = &v + } +} + +// WithRefresh - should the affected indexes be refreshed?. +func (f Reindex) WithRefresh(v bool) func(*ReindexRequest) { + return func(r *ReindexRequest) { + r.Refresh = &v + } +} + +// WithRequestsPerSecond - the throttle to set on this request in sub-requests per second. -1 means no throttle.. +func (f Reindex) WithRequestsPerSecond(v int) func(*ReindexRequest) { + return func(r *ReindexRequest) { + r.RequestsPerSecond = &v + } +} + +// WithScroll - control how long to keep the search context alive. +func (f Reindex) WithScroll(v time.Duration) func(*ReindexRequest) { + return func(r *ReindexRequest) { + r.Scroll = v + } +} + +// WithSlices - the number of slices this task should be divided into. defaults to 1, meaning the task isn't sliced into subtasks. can be set to `auto`.. +func (f Reindex) WithSlices(v interface{}) func(*ReindexRequest) { + return func(r *ReindexRequest) { + r.Slices = v + } +} + +// WithTimeout - time each individual bulk request should wait for shards that are unavailable.. +func (f Reindex) WithTimeout(v time.Duration) func(*ReindexRequest) { + return func(r *ReindexRequest) { + r.Timeout = v + } +} + +// WithWaitForActiveShards - sets the number of shard copies that must be active before proceeding with the reindex operation. defaults to 1, meaning the primary shard only. set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1). +func (f Reindex) WithWaitForActiveShards(v string) func(*ReindexRequest) { + return func(r *ReindexRequest) { + r.WaitForActiveShards = v + } +} + +// WithWaitForCompletion - should the request should block until the reindex is complete.. +func (f Reindex) WithWaitForCompletion(v bool) func(*ReindexRequest) { + return func(r *ReindexRequest) { + r.WaitForCompletion = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f Reindex) WithPretty() func(*ReindexRequest) { + return func(r *ReindexRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f Reindex) WithHuman() func(*ReindexRequest) { + return func(r *ReindexRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f Reindex) WithErrorTrace() func(*ReindexRequest) { + return func(r *ReindexRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f Reindex) WithFilterPath(v ...string) func(*ReindexRequest) { + return func(r *ReindexRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f Reindex) WithHeader(h map[string]string) func(*ReindexRequest) { + return func(r *ReindexRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f Reindex) WithOpaqueID(s string) func(*ReindexRequest) { + return func(r *ReindexRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.reindex_rethrottle.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.reindex_rethrottle.go new file mode 100644 index 00000000..2d5af07a --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.reindex_rethrottle.go @@ -0,0 +1,207 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newReindexRethrottleFunc(t Transport) ReindexRethrottle { + return func(task_id string, requests_per_second *int, o ...func(*ReindexRethrottleRequest)) (*Response, error) { + var r = ReindexRethrottleRequest{TaskID: task_id, RequestsPerSecond: requests_per_second} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// ReindexRethrottle changes the number of requests per second for a particular Reindex operation. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-reindex.html. +type ReindexRethrottle func(task_id string, requests_per_second *int, o ...func(*ReindexRethrottleRequest)) (*Response, error) + +// ReindexRethrottleRequest configures the Reindex Rethrottle API request. +type ReindexRethrottleRequest struct { + TaskID string + + RequestsPerSecond *int + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r ReindexRethrottleRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_reindex") + 1 + len(r.TaskID) + 1 + len("_rethrottle")) + path.WriteString("/") + path.WriteString("_reindex") + path.WriteString("/") + path.WriteString(r.TaskID) + path.WriteString("/") + path.WriteString("_rethrottle") + + params = make(map[string]string) + + if r.RequestsPerSecond != nil { + params["requests_per_second"] = strconv.FormatInt(int64(*r.RequestsPerSecond), 10) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f ReindexRethrottle) WithContext(v context.Context) func(*ReindexRethrottleRequest) { + return func(r *ReindexRethrottleRequest) { + r.ctx = v + } +} + +// WithRequestsPerSecond - the throttle to set on this request in floating sub-requests per second. -1 means set no throttle.. +func (f ReindexRethrottle) WithRequestsPerSecond(v int) func(*ReindexRethrottleRequest) { + return func(r *ReindexRethrottleRequest) { + r.RequestsPerSecond = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f ReindexRethrottle) WithPretty() func(*ReindexRethrottleRequest) { + return func(r *ReindexRethrottleRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f ReindexRethrottle) WithHuman() func(*ReindexRethrottleRequest) { + return func(r *ReindexRethrottleRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f ReindexRethrottle) WithErrorTrace() func(*ReindexRethrottleRequest) { + return func(r *ReindexRethrottleRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f ReindexRethrottle) WithFilterPath(v ...string) func(*ReindexRethrottleRequest) { + return func(r *ReindexRethrottleRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f ReindexRethrottle) WithHeader(h map[string]string) func(*ReindexRethrottleRequest) { + return func(r *ReindexRethrottleRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f ReindexRethrottle) WithOpaqueID(s string) func(*ReindexRethrottleRequest) { + return func(r *ReindexRethrottleRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.render_search_template.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.render_search_template.go new file mode 100644 index 00000000..5be6d987 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.render_search_template.go @@ -0,0 +1,216 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newRenderSearchTemplateFunc(t Transport) RenderSearchTemplate { + return func(o ...func(*RenderSearchTemplateRequest)) (*Response, error) { + var r = RenderSearchTemplateRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// RenderSearchTemplate allows to use the Mustache language to pre-render a search definition. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/render-search-template-api.html. +type RenderSearchTemplate func(o ...func(*RenderSearchTemplateRequest)) (*Response, error) + +// RenderSearchTemplateRequest configures the Render Search Template API request. +type RenderSearchTemplateRequest struct { + TemplateID string + + Body io.Reader + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r RenderSearchTemplateRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_render") + 1 + len("template") + 1 + len(r.TemplateID)) + path.WriteString("/") + path.WriteString("_render") + path.WriteString("/") + path.WriteString("template") + if r.TemplateID != "" { + path.WriteString("/") + path.WriteString(r.TemplateID) + } + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f RenderSearchTemplate) WithContext(v context.Context) func(*RenderSearchTemplateRequest) { + return func(r *RenderSearchTemplateRequest) { + r.ctx = v + } +} + +// WithBody - The search definition template and its params. +func (f RenderSearchTemplate) WithBody(v io.Reader) func(*RenderSearchTemplateRequest) { + return func(r *RenderSearchTemplateRequest) { + r.Body = v + } +} + +// WithTemplateID - the ID of the stored search template. +func (f RenderSearchTemplate) WithTemplateID(v string) func(*RenderSearchTemplateRequest) { + return func(r *RenderSearchTemplateRequest) { + r.TemplateID = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f RenderSearchTemplate) WithPretty() func(*RenderSearchTemplateRequest) { + return func(r *RenderSearchTemplateRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f RenderSearchTemplate) WithHuman() func(*RenderSearchTemplateRequest) { + return func(r *RenderSearchTemplateRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f RenderSearchTemplate) WithErrorTrace() func(*RenderSearchTemplateRequest) { + return func(r *RenderSearchTemplateRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f RenderSearchTemplate) WithFilterPath(v ...string) func(*RenderSearchTemplateRequest) { + return func(r *RenderSearchTemplateRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f RenderSearchTemplate) WithHeader(h map[string]string) func(*RenderSearchTemplateRequest) { + return func(r *RenderSearchTemplateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f RenderSearchTemplate) WithOpaqueID(s string) func(*RenderSearchTemplateRequest) { + return func(r *RenderSearchTemplateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.scripts_painless_execute.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.scripts_painless_execute.go new file mode 100644 index 00000000..43ec1004 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.scripts_painless_execute.go @@ -0,0 +1,202 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newScriptsPainlessExecuteFunc(t Transport) ScriptsPainlessExecute { + return func(o ...func(*ScriptsPainlessExecuteRequest)) (*Response, error) { + var r = ScriptsPainlessExecuteRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// ScriptsPainlessExecute allows an arbitrary script to be executed and a result to be returned +// +// This API is experimental. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/painless/master/painless-execute-api.html. +type ScriptsPainlessExecute func(o ...func(*ScriptsPainlessExecuteRequest)) (*Response, error) + +// ScriptsPainlessExecuteRequest configures the Scripts Painless Execute API request. +type ScriptsPainlessExecuteRequest struct { + Body io.Reader + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r ScriptsPainlessExecuteRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(len("/_scripts/painless/_execute")) + path.WriteString("/_scripts/painless/_execute") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f ScriptsPainlessExecute) WithContext(v context.Context) func(*ScriptsPainlessExecuteRequest) { + return func(r *ScriptsPainlessExecuteRequest) { + r.ctx = v + } +} + +// WithBody - The script to execute. +func (f ScriptsPainlessExecute) WithBody(v io.Reader) func(*ScriptsPainlessExecuteRequest) { + return func(r *ScriptsPainlessExecuteRequest) { + r.Body = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f ScriptsPainlessExecute) WithPretty() func(*ScriptsPainlessExecuteRequest) { + return func(r *ScriptsPainlessExecuteRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f ScriptsPainlessExecute) WithHuman() func(*ScriptsPainlessExecuteRequest) { + return func(r *ScriptsPainlessExecuteRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f ScriptsPainlessExecute) WithErrorTrace() func(*ScriptsPainlessExecuteRequest) { + return func(r *ScriptsPainlessExecuteRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f ScriptsPainlessExecute) WithFilterPath(v ...string) func(*ScriptsPainlessExecuteRequest) { + return func(r *ScriptsPainlessExecuteRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f ScriptsPainlessExecute) WithHeader(h map[string]string) func(*ScriptsPainlessExecuteRequest) { + return func(r *ScriptsPainlessExecuteRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f ScriptsPainlessExecute) WithOpaqueID(s string) func(*ScriptsPainlessExecuteRequest) { + return func(r *ScriptsPainlessExecuteRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.scroll.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.scroll.go new file mode 100644 index 00000000..fa87564f --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.scroll.go @@ -0,0 +1,240 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" + "time" +) + +func newScrollFunc(t Transport) Scroll { + return func(o ...func(*ScrollRequest)) (*Response, error) { + var r = ScrollRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// Scroll allows to retrieve a large numbers of results from a single search request. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/search-request-body.html#request-body-search-scroll. +type Scroll func(o ...func(*ScrollRequest)) (*Response, error) + +// ScrollRequest configures the Scroll API request. +type ScrollRequest struct { + Body io.Reader + + ScrollID string + + RestTotalHitsAsInt *bool + Scroll time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r ScrollRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(len("/_search/scroll")) + path.WriteString("/_search/scroll") + + params = make(map[string]string) + + if r.RestTotalHitsAsInt != nil { + params["rest_total_hits_as_int"] = strconv.FormatBool(*r.RestTotalHitsAsInt) + } + + if r.Scroll != 0 { + params["scroll"] = formatDuration(r.Scroll) + } + + if r.ScrollID != "" { + params["scroll_id"] = r.ScrollID + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f Scroll) WithContext(v context.Context) func(*ScrollRequest) { + return func(r *ScrollRequest) { + r.ctx = v + } +} + +// WithBody - The scroll ID if not passed by URL or query parameter.. +func (f Scroll) WithBody(v io.Reader) func(*ScrollRequest) { + return func(r *ScrollRequest) { + r.Body = v + } +} + +// WithScrollID - the scroll ID. +func (f Scroll) WithScrollID(v string) func(*ScrollRequest) { + return func(r *ScrollRequest) { + r.ScrollID = v + } +} + +// WithRestTotalHitsAsInt - indicates whether hits.total should be rendered as an integer or an object in the rest search response. +func (f Scroll) WithRestTotalHitsAsInt(v bool) func(*ScrollRequest) { + return func(r *ScrollRequest) { + r.RestTotalHitsAsInt = &v + } +} + +// WithScroll - specify how long a consistent view of the index should be maintained for scrolled search. +func (f Scroll) WithScroll(v time.Duration) func(*ScrollRequest) { + return func(r *ScrollRequest) { + r.Scroll = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f Scroll) WithPretty() func(*ScrollRequest) { + return func(r *ScrollRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f Scroll) WithHuman() func(*ScrollRequest) { + return func(r *ScrollRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f Scroll) WithErrorTrace() func(*ScrollRequest) { + return func(r *ScrollRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f Scroll) WithFilterPath(v ...string) func(*ScrollRequest) { + return func(r *ScrollRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f Scroll) WithHeader(h map[string]string) func(*ScrollRequest) { + return func(r *ScrollRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f Scroll) WithOpaqueID(s string) func(*ScrollRequest) { + return func(r *ScrollRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.search.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.search.go new file mode 100644 index 00000000..3b0981f8 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.search.go @@ -0,0 +1,746 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "fmt" + "io" + "net/http" + "strconv" + "strings" + "time" +) + +func newSearchFunc(t Transport) Search { + return func(o ...func(*SearchRequest)) (*Response, error) { + var r = SearchRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// Search returns results matching a query. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/search-search.html. +type Search func(o ...func(*SearchRequest)) (*Response, error) + +// SearchRequest configures the Search API request. +type SearchRequest struct { + Index []string + DocumentType []string + + Body io.Reader + + AllowNoIndices *bool + AllowPartialSearchResults *bool + Analyzer string + AnalyzeWildcard *bool + BatchedReduceSize *int + CcsMinimizeRoundtrips *bool + DefaultOperator string + Df string + DocvalueFields []string + ExpandWildcards string + Explain *bool + From *int + IgnoreThrottled *bool + IgnoreUnavailable *bool + Lenient *bool + MaxConcurrentShardRequests *int + MinCompatibleShardNode string + Preference string + PreFilterShardSize *int + Query string + RequestCache *bool + RestTotalHitsAsInt *bool + Routing []string + Scroll time.Duration + SearchType string + SeqNoPrimaryTerm *bool + Size *int + Sort []string + Source []string + SourceExcludes []string + SourceIncludes []string + Stats []string + StoredFields []string + SuggestField string + SuggestMode string + SuggestSize *int + SuggestText string + TerminateAfter *int + Timeout time.Duration + TrackScores *bool + TrackTotalHits interface{} + TypedKeys *bool + Version *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SearchRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len(strings.Join(r.Index, ",")) + 1 + len(strings.Join(r.DocumentType, ",")) + 1 + len("_search")) + if len(r.Index) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + } + if len(r.DocumentType) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.DocumentType, ",")) + } + path.WriteString("/") + path.WriteString("_search") + + params = make(map[string]string) + + if r.AllowNoIndices != nil { + params["allow_no_indices"] = strconv.FormatBool(*r.AllowNoIndices) + } + + if r.AllowPartialSearchResults != nil { + params["allow_partial_search_results"] = strconv.FormatBool(*r.AllowPartialSearchResults) + } + + if r.Analyzer != "" { + params["analyzer"] = r.Analyzer + } + + if r.AnalyzeWildcard != nil { + params["analyze_wildcard"] = strconv.FormatBool(*r.AnalyzeWildcard) + } + + if r.BatchedReduceSize != nil { + params["batched_reduce_size"] = strconv.FormatInt(int64(*r.BatchedReduceSize), 10) + } + + if r.CcsMinimizeRoundtrips != nil { + params["ccs_minimize_roundtrips"] = strconv.FormatBool(*r.CcsMinimizeRoundtrips) + } + + if r.DefaultOperator != "" { + params["default_operator"] = r.DefaultOperator + } + + if r.Df != "" { + params["df"] = r.Df + } + + if len(r.DocvalueFields) > 0 { + params["docvalue_fields"] = strings.Join(r.DocvalueFields, ",") + } + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if r.Explain != nil { + params["explain"] = strconv.FormatBool(*r.Explain) + } + + if r.From != nil { + params["from"] = strconv.FormatInt(int64(*r.From), 10) + } + + if r.IgnoreThrottled != nil { + params["ignore_throttled"] = strconv.FormatBool(*r.IgnoreThrottled) + } + + if r.IgnoreUnavailable != nil { + params["ignore_unavailable"] = strconv.FormatBool(*r.IgnoreUnavailable) + } + + if r.Lenient != nil { + params["lenient"] = strconv.FormatBool(*r.Lenient) + } + + if r.MaxConcurrentShardRequests != nil { + params["max_concurrent_shard_requests"] = strconv.FormatInt(int64(*r.MaxConcurrentShardRequests), 10) + } + + if r.MinCompatibleShardNode != "" { + params["min_compatible_shard_node"] = r.MinCompatibleShardNode + } + + if r.Preference != "" { + params["preference"] = r.Preference + } + + if r.PreFilterShardSize != nil { + params["pre_filter_shard_size"] = strconv.FormatInt(int64(*r.PreFilterShardSize), 10) + } + + if r.Query != "" { + params["q"] = r.Query + } + + if r.RequestCache != nil { + params["request_cache"] = strconv.FormatBool(*r.RequestCache) + } + + if r.RestTotalHitsAsInt != nil { + params["rest_total_hits_as_int"] = strconv.FormatBool(*r.RestTotalHitsAsInt) + } + + if len(r.Routing) > 0 { + params["routing"] = strings.Join(r.Routing, ",") + } + + if r.Scroll != 0 { + params["scroll"] = formatDuration(r.Scroll) + } + + if r.SearchType != "" { + params["search_type"] = r.SearchType + } + + if r.SeqNoPrimaryTerm != nil { + params["seq_no_primary_term"] = strconv.FormatBool(*r.SeqNoPrimaryTerm) + } + + if r.Size != nil { + params["size"] = strconv.FormatInt(int64(*r.Size), 10) + } + + if len(r.Sort) > 0 { + params["sort"] = strings.Join(r.Sort, ",") + } + + if len(r.Source) > 0 { + params["_source"] = strings.Join(r.Source, ",") + } + + if len(r.SourceExcludes) > 0 { + params["_source_excludes"] = strings.Join(r.SourceExcludes, ",") + } + + if len(r.SourceIncludes) > 0 { + params["_source_includes"] = strings.Join(r.SourceIncludes, ",") + } + + if len(r.Stats) > 0 { + params["stats"] = strings.Join(r.Stats, ",") + } + + if len(r.StoredFields) > 0 { + params["stored_fields"] = strings.Join(r.StoredFields, ",") + } + + if r.SuggestField != "" { + params["suggest_field"] = r.SuggestField + } + + if r.SuggestMode != "" { + params["suggest_mode"] = r.SuggestMode + } + + if r.SuggestSize != nil { + params["suggest_size"] = strconv.FormatInt(int64(*r.SuggestSize), 10) + } + + if r.SuggestText != "" { + params["suggest_text"] = r.SuggestText + } + + if r.TerminateAfter != nil { + params["terminate_after"] = strconv.FormatInt(int64(*r.TerminateAfter), 10) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.TrackScores != nil { + params["track_scores"] = strconv.FormatBool(*r.TrackScores) + } + + if r.TrackTotalHits != nil { + params["track_total_hits"] = fmt.Sprintf("%v", r.TrackTotalHits) + } + + if r.TypedKeys != nil { + params["typed_keys"] = strconv.FormatBool(*r.TypedKeys) + } + + if r.Version != nil { + params["version"] = strconv.FormatBool(*r.Version) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f Search) WithContext(v context.Context) func(*SearchRequest) { + return func(r *SearchRequest) { + r.ctx = v + } +} + +// WithBody - The search definition using the Query DSL. +func (f Search) WithBody(v io.Reader) func(*SearchRequest) { + return func(r *SearchRequest) { + r.Body = v + } +} + +// WithIndex - a list of index names to search; use _all to perform the operation on all indices. +func (f Search) WithIndex(v ...string) func(*SearchRequest) { + return func(r *SearchRequest) { + r.Index = v + } +} + +// WithDocumentType - a list of document types to search; leave empty to perform the operation on all types. +func (f Search) WithDocumentType(v ...string) func(*SearchRequest) { + return func(r *SearchRequest) { + r.DocumentType = v + } +} + +// WithAllowNoIndices - whether to ignore if a wildcard indices expression resolves into no concrete indices. (this includes `_all` string or when no indices have been specified). +func (f Search) WithAllowNoIndices(v bool) func(*SearchRequest) { + return func(r *SearchRequest) { + r.AllowNoIndices = &v + } +} + +// WithAllowPartialSearchResults - indicate if an error should be returned if there is a partial search failure or timeout. +func (f Search) WithAllowPartialSearchResults(v bool) func(*SearchRequest) { + return func(r *SearchRequest) { + r.AllowPartialSearchResults = &v + } +} + +// WithAnalyzer - the analyzer to use for the query string. +func (f Search) WithAnalyzer(v string) func(*SearchRequest) { + return func(r *SearchRequest) { + r.Analyzer = v + } +} + +// WithAnalyzeWildcard - specify whether wildcard and prefix queries should be analyzed (default: false). +func (f Search) WithAnalyzeWildcard(v bool) func(*SearchRequest) { + return func(r *SearchRequest) { + r.AnalyzeWildcard = &v + } +} + +// WithBatchedReduceSize - the number of shard results that should be reduced at once on the coordinating node. this value should be used as a protection mechanism to reduce the memory overhead per search request if the potential number of shards in the request can be large.. +func (f Search) WithBatchedReduceSize(v int) func(*SearchRequest) { + return func(r *SearchRequest) { + r.BatchedReduceSize = &v + } +} + +// WithCcsMinimizeRoundtrips - indicates whether network round-trips should be minimized as part of cross-cluster search requests execution. +func (f Search) WithCcsMinimizeRoundtrips(v bool) func(*SearchRequest) { + return func(r *SearchRequest) { + r.CcsMinimizeRoundtrips = &v + } +} + +// WithDefaultOperator - the default operator for query string query (and or or). +func (f Search) WithDefaultOperator(v string) func(*SearchRequest) { + return func(r *SearchRequest) { + r.DefaultOperator = v + } +} + +// WithDf - the field to use as default where no field prefix is given in the query string. +func (f Search) WithDf(v string) func(*SearchRequest) { + return func(r *SearchRequest) { + r.Df = v + } +} + +// WithDocvalueFields - a list of fields to return as the docvalue representation of a field for each hit. +func (f Search) WithDocvalueFields(v ...string) func(*SearchRequest) { + return func(r *SearchRequest) { + r.DocvalueFields = v + } +} + +// WithExpandWildcards - whether to expand wildcard expression to concrete indices that are open, closed or both.. +func (f Search) WithExpandWildcards(v string) func(*SearchRequest) { + return func(r *SearchRequest) { + r.ExpandWildcards = v + } +} + +// WithExplain - specify whether to return detailed information about score computation as part of a hit. +func (f Search) WithExplain(v bool) func(*SearchRequest) { + return func(r *SearchRequest) { + r.Explain = &v + } +} + +// WithFrom - starting offset (default: 0). +func (f Search) WithFrom(v int) func(*SearchRequest) { + return func(r *SearchRequest) { + r.From = &v + } +} + +// WithIgnoreThrottled - whether specified concrete, expanded or aliased indices should be ignored when throttled. +func (f Search) WithIgnoreThrottled(v bool) func(*SearchRequest) { + return func(r *SearchRequest) { + r.IgnoreThrottled = &v + } +} + +// WithIgnoreUnavailable - whether specified concrete indices should be ignored when unavailable (missing or closed). +func (f Search) WithIgnoreUnavailable(v bool) func(*SearchRequest) { + return func(r *SearchRequest) { + r.IgnoreUnavailable = &v + } +} + +// WithLenient - specify whether format-based query failures (such as providing text to a numeric field) should be ignored. +func (f Search) WithLenient(v bool) func(*SearchRequest) { + return func(r *SearchRequest) { + r.Lenient = &v + } +} + +// WithMaxConcurrentShardRequests - the number of concurrent shard requests per node this search executes concurrently. this value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests. +func (f Search) WithMaxConcurrentShardRequests(v int) func(*SearchRequest) { + return func(r *SearchRequest) { + r.MaxConcurrentShardRequests = &v + } +} + +// WithMinCompatibleShardNode - the minimum compatible version that all shards involved in search should have for this request to be successful. +func (f Search) WithMinCompatibleShardNode(v string) func(*SearchRequest) { + return func(r *SearchRequest) { + r.MinCompatibleShardNode = v + } +} + +// WithPreference - specify the node or shard the operation should be performed on (default: random). +func (f Search) WithPreference(v string) func(*SearchRequest) { + return func(r *SearchRequest) { + r.Preference = v + } +} + +// WithPreFilterShardSize - a threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. this filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on its rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint.. +func (f Search) WithPreFilterShardSize(v int) func(*SearchRequest) { + return func(r *SearchRequest) { + r.PreFilterShardSize = &v + } +} + +// WithQuery - query in the lucene query string syntax. +func (f Search) WithQuery(v string) func(*SearchRequest) { + return func(r *SearchRequest) { + r.Query = v + } +} + +// WithRequestCache - specify if request cache should be used for this request or not, defaults to index level setting. +func (f Search) WithRequestCache(v bool) func(*SearchRequest) { + return func(r *SearchRequest) { + r.RequestCache = &v + } +} + +// WithRestTotalHitsAsInt - indicates whether hits.total should be rendered as an integer or an object in the rest search response. +func (f Search) WithRestTotalHitsAsInt(v bool) func(*SearchRequest) { + return func(r *SearchRequest) { + r.RestTotalHitsAsInt = &v + } +} + +// WithRouting - a list of specific routing values. +func (f Search) WithRouting(v ...string) func(*SearchRequest) { + return func(r *SearchRequest) { + r.Routing = v + } +} + +// WithScroll - specify how long a consistent view of the index should be maintained for scrolled search. +func (f Search) WithScroll(v time.Duration) func(*SearchRequest) { + return func(r *SearchRequest) { + r.Scroll = v + } +} + +// WithSearchType - search operation type. +func (f Search) WithSearchType(v string) func(*SearchRequest) { + return func(r *SearchRequest) { + r.SearchType = v + } +} + +// WithSeqNoPrimaryTerm - specify whether to return sequence number and primary term of the last modification of each hit. +func (f Search) WithSeqNoPrimaryTerm(v bool) func(*SearchRequest) { + return func(r *SearchRequest) { + r.SeqNoPrimaryTerm = &v + } +} + +// WithSize - number of hits to return (default: 10). +func (f Search) WithSize(v int) func(*SearchRequest) { + return func(r *SearchRequest) { + r.Size = &v + } +} + +// WithSort - a list of : pairs. +func (f Search) WithSort(v ...string) func(*SearchRequest) { + return func(r *SearchRequest) { + r.Sort = v + } +} + +// WithSource - true or false to return the _source field or not, or a list of fields to return. +func (f Search) WithSource(v ...string) func(*SearchRequest) { + return func(r *SearchRequest) { + r.Source = v + } +} + +// WithSourceExcludes - a list of fields to exclude from the returned _source field. +func (f Search) WithSourceExcludes(v ...string) func(*SearchRequest) { + return func(r *SearchRequest) { + r.SourceExcludes = v + } +} + +// WithSourceIncludes - a list of fields to extract and return from the _source field. +func (f Search) WithSourceIncludes(v ...string) func(*SearchRequest) { + return func(r *SearchRequest) { + r.SourceIncludes = v + } +} + +// WithStats - specific 'tag' of the request for logging and statistical purposes. +func (f Search) WithStats(v ...string) func(*SearchRequest) { + return func(r *SearchRequest) { + r.Stats = v + } +} + +// WithStoredFields - a list of stored fields to return as part of a hit. +func (f Search) WithStoredFields(v ...string) func(*SearchRequest) { + return func(r *SearchRequest) { + r.StoredFields = v + } +} + +// WithSuggestField - specify which field to use for suggestions. +func (f Search) WithSuggestField(v string) func(*SearchRequest) { + return func(r *SearchRequest) { + r.SuggestField = v + } +} + +// WithSuggestMode - specify suggest mode. +func (f Search) WithSuggestMode(v string) func(*SearchRequest) { + return func(r *SearchRequest) { + r.SuggestMode = v + } +} + +// WithSuggestSize - how many suggestions to return in response. +func (f Search) WithSuggestSize(v int) func(*SearchRequest) { + return func(r *SearchRequest) { + r.SuggestSize = &v + } +} + +// WithSuggestText - the source text for which the suggestions should be returned. +func (f Search) WithSuggestText(v string) func(*SearchRequest) { + return func(r *SearchRequest) { + r.SuggestText = v + } +} + +// WithTerminateAfter - the maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.. +func (f Search) WithTerminateAfter(v int) func(*SearchRequest) { + return func(r *SearchRequest) { + r.TerminateAfter = &v + } +} + +// WithTimeout - explicit operation timeout. +func (f Search) WithTimeout(v time.Duration) func(*SearchRequest) { + return func(r *SearchRequest) { + r.Timeout = v + } +} + +// WithTrackScores - whether to calculate and return scores even if they are not used for sorting. +func (f Search) WithTrackScores(v bool) func(*SearchRequest) { + return func(r *SearchRequest) { + r.TrackScores = &v + } +} + +// WithTrackTotalHits - indicate if the number of documents that match the query should be tracked. +func (f Search) WithTrackTotalHits(v interface{}) func(*SearchRequest) { + return func(r *SearchRequest) { + r.TrackTotalHits = v + } +} + +// WithTypedKeys - specify whether aggregation and suggester names should be prefixed by their respective types in the response. +func (f Search) WithTypedKeys(v bool) func(*SearchRequest) { + return func(r *SearchRequest) { + r.TypedKeys = &v + } +} + +// WithVersion - specify whether to return document version as part of a hit. +func (f Search) WithVersion(v bool) func(*SearchRequest) { + return func(r *SearchRequest) { + r.Version = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f Search) WithPretty() func(*SearchRequest) { + return func(r *SearchRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f Search) WithHuman() func(*SearchRequest) { + return func(r *SearchRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f Search) WithErrorTrace() func(*SearchRequest) { + return func(r *SearchRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f Search) WithFilterPath(v ...string) func(*SearchRequest) { + return func(r *SearchRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f Search) WithHeader(h map[string]string) func(*SearchRequest) { + return func(r *SearchRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f Search) WithOpaqueID(s string) func(*SearchRequest) { + return func(r *SearchRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.search_mvt.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.search_mvt.go new file mode 100644 index 00000000..25096667 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.search_mvt.go @@ -0,0 +1,309 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "errors" + "fmt" + "io" + "net/http" + "strconv" + "strings" +) + +func newSearchMvtFunc(t Transport) SearchMvt { + return func(index []string, field string, zoom *int, x *int, y *int, o ...func(*SearchMvtRequest)) (*Response, error) { + var r = SearchMvtRequest{Index: index, Y: y, Field: field, Zoom: zoom, X: x} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SearchMvt searches a vector tile for geospatial values. Returns results as a binary Mapbox vector tile. +// +// This API is experimental. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/search-vector-tile-api.html. +type SearchMvt func(index []string, field string, zoom *int, x *int, y *int, o ...func(*SearchMvtRequest)) (*Response, error) + +// SearchMvtRequest configures the Search Mvt API request. +type SearchMvtRequest struct { + Index []string + + Body io.Reader + + Field string + X *int + Y *int + Zoom *int + + ExactBounds *bool + Extent *int + GridPrecision *int + GridType string + Size *int + TrackTotalHits interface{} + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SearchMvtRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + if len(r.Index) == 0 { + return nil, errors.New("index is required and cannot be nil or empty") + } + if r.Zoom == nil { + return nil, errors.New("zoom is required and cannot be nil") + } + if r.X == nil { + return nil, errors.New("x is required and cannot be nil") + } + if r.Y == nil { + return nil, errors.New("y is required and cannot be nil") + } + + path.Grow(1 + len(strings.Join(r.Index, ",")) + 1 + len("_mvt") + 1 + len(r.Field) + 1 + len(strconv.Itoa(*r.Zoom)) + 1 + len(strconv.Itoa(*r.X)) + 1 + len(strconv.Itoa(*r.Y))) + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + path.WriteString("/") + path.WriteString("_mvt") + path.WriteString("/") + path.WriteString(r.Field) + path.WriteString("/") + path.WriteString(strconv.Itoa(*r.Zoom)) + path.WriteString("/") + path.WriteString(strconv.Itoa(*r.X)) + path.WriteString("/") + path.WriteString(strconv.Itoa(*r.Y)) + + params = make(map[string]string) + + if r.ExactBounds != nil { + params["exact_bounds"] = strconv.FormatBool(*r.ExactBounds) + } + + if r.Extent != nil { + params["extent"] = strconv.FormatInt(int64(*r.Extent), 10) + } + + if r.GridPrecision != nil { + params["grid_precision"] = strconv.FormatInt(int64(*r.GridPrecision), 10) + } + + if r.GridType != "" { + params["grid_type"] = r.GridType + } + + if r.Size != nil { + params["size"] = strconv.FormatInt(int64(*r.Size), 10) + } + + if r.TrackTotalHits != nil { + params["track_total_hits"] = fmt.Sprintf("%v", r.TrackTotalHits) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SearchMvt) WithContext(v context.Context) func(*SearchMvtRequest) { + return func(r *SearchMvtRequest) { + r.ctx = v + } +} + +// WithBody - Search request body.. +func (f SearchMvt) WithBody(v io.Reader) func(*SearchMvtRequest) { + return func(r *SearchMvtRequest) { + r.Body = v + } +} + +// WithExactBounds - if false, the meta layer's feature is the bounding box of the tile. if true, the meta layer's feature is a bounding box resulting from a `geo_bounds` aggregation.. +func (f SearchMvt) WithExactBounds(v bool) func(*SearchMvtRequest) { + return func(r *SearchMvtRequest) { + r.ExactBounds = &v + } +} + +// WithExtent - size, in pixels, of a side of the vector tile.. +func (f SearchMvt) WithExtent(v int) func(*SearchMvtRequest) { + return func(r *SearchMvtRequest) { + r.Extent = &v + } +} + +// WithGridPrecision - additional zoom levels available through the aggs layer. accepts 0-8.. +func (f SearchMvt) WithGridPrecision(v int) func(*SearchMvtRequest) { + return func(r *SearchMvtRequest) { + r.GridPrecision = &v + } +} + +// WithGridType - determines the geometry type for features in the aggs layer.. +func (f SearchMvt) WithGridType(v string) func(*SearchMvtRequest) { + return func(r *SearchMvtRequest) { + r.GridType = v + } +} + +// WithSize - maximum number of features to return in the hits layer. accepts 0-10000.. +func (f SearchMvt) WithSize(v int) func(*SearchMvtRequest) { + return func(r *SearchMvtRequest) { + r.Size = &v + } +} + +// WithTrackTotalHits - indicate if the number of documents that match the query should be tracked. a number can also be specified, to accurately track the total hit count up to the number.. +func (f SearchMvt) WithTrackTotalHits(v interface{}) func(*SearchMvtRequest) { + return func(r *SearchMvtRequest) { + r.TrackTotalHits = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SearchMvt) WithPretty() func(*SearchMvtRequest) { + return func(r *SearchMvtRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SearchMvt) WithHuman() func(*SearchMvtRequest) { + return func(r *SearchMvtRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SearchMvt) WithErrorTrace() func(*SearchMvtRequest) { + return func(r *SearchMvtRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SearchMvt) WithFilterPath(v ...string) func(*SearchMvtRequest) { + return func(r *SearchMvtRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SearchMvt) WithHeader(h map[string]string) func(*SearchMvtRequest) { + return func(r *SearchMvtRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SearchMvt) WithOpaqueID(s string) func(*SearchMvtRequest) { + return func(r *SearchMvtRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.search_shards.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.search_shards.go new file mode 100644 index 00000000..85dc88d2 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.search_shards.go @@ -0,0 +1,274 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newSearchShardsFunc(t Transport) SearchShards { + return func(o ...func(*SearchShardsRequest)) (*Response, error) { + var r = SearchShardsRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SearchShards returns information about the indices and shards that a search request would be executed against. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/search-shards.html. +type SearchShards func(o ...func(*SearchShardsRequest)) (*Response, error) + +// SearchShardsRequest configures the Search Shards API request. +type SearchShardsRequest struct { + Index []string + + AllowNoIndices *bool + ExpandWildcards string + IgnoreUnavailable *bool + Local *bool + Preference string + Routing string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SearchShardsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len(strings.Join(r.Index, ",")) + 1 + len("_search_shards")) + if len(r.Index) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + } + path.WriteString("/") + path.WriteString("_search_shards") + + params = make(map[string]string) + + if r.AllowNoIndices != nil { + params["allow_no_indices"] = strconv.FormatBool(*r.AllowNoIndices) + } + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if r.IgnoreUnavailable != nil { + params["ignore_unavailable"] = strconv.FormatBool(*r.IgnoreUnavailable) + } + + if r.Local != nil { + params["local"] = strconv.FormatBool(*r.Local) + } + + if r.Preference != "" { + params["preference"] = r.Preference + } + + if r.Routing != "" { + params["routing"] = r.Routing + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SearchShards) WithContext(v context.Context) func(*SearchShardsRequest) { + return func(r *SearchShardsRequest) { + r.ctx = v + } +} + +// WithIndex - a list of index names to search; use _all to perform the operation on all indices. +func (f SearchShards) WithIndex(v ...string) func(*SearchShardsRequest) { + return func(r *SearchShardsRequest) { + r.Index = v + } +} + +// WithAllowNoIndices - whether to ignore if a wildcard indices expression resolves into no concrete indices. (this includes `_all` string or when no indices have been specified). +func (f SearchShards) WithAllowNoIndices(v bool) func(*SearchShardsRequest) { + return func(r *SearchShardsRequest) { + r.AllowNoIndices = &v + } +} + +// WithExpandWildcards - whether to expand wildcard expression to concrete indices that are open, closed or both.. +func (f SearchShards) WithExpandWildcards(v string) func(*SearchShardsRequest) { + return func(r *SearchShardsRequest) { + r.ExpandWildcards = v + } +} + +// WithIgnoreUnavailable - whether specified concrete indices should be ignored when unavailable (missing or closed). +func (f SearchShards) WithIgnoreUnavailable(v bool) func(*SearchShardsRequest) { + return func(r *SearchShardsRequest) { + r.IgnoreUnavailable = &v + } +} + +// WithLocal - return local information, do not retrieve the state from master node (default: false). +func (f SearchShards) WithLocal(v bool) func(*SearchShardsRequest) { + return func(r *SearchShardsRequest) { + r.Local = &v + } +} + +// WithPreference - specify the node or shard the operation should be performed on (default: random). +func (f SearchShards) WithPreference(v string) func(*SearchShardsRequest) { + return func(r *SearchShardsRequest) { + r.Preference = v + } +} + +// WithRouting - specific routing value. +func (f SearchShards) WithRouting(v string) func(*SearchShardsRequest) { + return func(r *SearchShardsRequest) { + r.Routing = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SearchShards) WithPretty() func(*SearchShardsRequest) { + return func(r *SearchShardsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SearchShards) WithHuman() func(*SearchShardsRequest) { + return func(r *SearchShardsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SearchShards) WithErrorTrace() func(*SearchShardsRequest) { + return func(r *SearchShardsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SearchShards) WithFilterPath(v ...string) func(*SearchShardsRequest) { + return func(r *SearchShardsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SearchShards) WithHeader(h map[string]string) func(*SearchShardsRequest) { + return func(r *SearchShardsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SearchShards) WithOpaqueID(s string) func(*SearchShardsRequest) { + return func(r *SearchShardsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.search_template.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.search_template.go new file mode 100644 index 00000000..75d5cf36 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.search_template.go @@ -0,0 +1,380 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" + "time" +) + +func newSearchTemplateFunc(t Transport) SearchTemplate { + return func(body io.Reader, o ...func(*SearchTemplateRequest)) (*Response, error) { + var r = SearchTemplateRequest{Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SearchTemplate allows to use the Mustache language to pre-render a search definition. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html. +type SearchTemplate func(body io.Reader, o ...func(*SearchTemplateRequest)) (*Response, error) + +// SearchTemplateRequest configures the Search Template API request. +type SearchTemplateRequest struct { + Index []string + DocumentType []string + + Body io.Reader + + AllowNoIndices *bool + CcsMinimizeRoundtrips *bool + ExpandWildcards string + Explain *bool + IgnoreThrottled *bool + IgnoreUnavailable *bool + Preference string + Profile *bool + RestTotalHitsAsInt *bool + Routing []string + Scroll time.Duration + SearchType string + TypedKeys *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SearchTemplateRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len(strings.Join(r.Index, ",")) + 1 + len(strings.Join(r.DocumentType, ",")) + 1 + len("_search") + 1 + len("template")) + if len(r.Index) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + } + if len(r.DocumentType) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.DocumentType, ",")) + } + path.WriteString("/") + path.WriteString("_search") + path.WriteString("/") + path.WriteString("template") + + params = make(map[string]string) + + if r.AllowNoIndices != nil { + params["allow_no_indices"] = strconv.FormatBool(*r.AllowNoIndices) + } + + if r.CcsMinimizeRoundtrips != nil { + params["ccs_minimize_roundtrips"] = strconv.FormatBool(*r.CcsMinimizeRoundtrips) + } + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if r.Explain != nil { + params["explain"] = strconv.FormatBool(*r.Explain) + } + + if r.IgnoreThrottled != nil { + params["ignore_throttled"] = strconv.FormatBool(*r.IgnoreThrottled) + } + + if r.IgnoreUnavailable != nil { + params["ignore_unavailable"] = strconv.FormatBool(*r.IgnoreUnavailable) + } + + if r.Preference != "" { + params["preference"] = r.Preference + } + + if r.Profile != nil { + params["profile"] = strconv.FormatBool(*r.Profile) + } + + if r.RestTotalHitsAsInt != nil { + params["rest_total_hits_as_int"] = strconv.FormatBool(*r.RestTotalHitsAsInt) + } + + if len(r.Routing) > 0 { + params["routing"] = strings.Join(r.Routing, ",") + } + + if r.Scroll != 0 { + params["scroll"] = formatDuration(r.Scroll) + } + + if r.SearchType != "" { + params["search_type"] = r.SearchType + } + + if r.TypedKeys != nil { + params["typed_keys"] = strconv.FormatBool(*r.TypedKeys) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SearchTemplate) WithContext(v context.Context) func(*SearchTemplateRequest) { + return func(r *SearchTemplateRequest) { + r.ctx = v + } +} + +// WithIndex - a list of index names to search; use _all to perform the operation on all indices. +func (f SearchTemplate) WithIndex(v ...string) func(*SearchTemplateRequest) { + return func(r *SearchTemplateRequest) { + r.Index = v + } +} + +// WithDocumentType - a list of document types to search; leave empty to perform the operation on all types. +func (f SearchTemplate) WithDocumentType(v ...string) func(*SearchTemplateRequest) { + return func(r *SearchTemplateRequest) { + r.DocumentType = v + } +} + +// WithAllowNoIndices - whether to ignore if a wildcard indices expression resolves into no concrete indices. (this includes `_all` string or when no indices have been specified). +func (f SearchTemplate) WithAllowNoIndices(v bool) func(*SearchTemplateRequest) { + return func(r *SearchTemplateRequest) { + r.AllowNoIndices = &v + } +} + +// WithCcsMinimizeRoundtrips - indicates whether network round-trips should be minimized as part of cross-cluster search requests execution. +func (f SearchTemplate) WithCcsMinimizeRoundtrips(v bool) func(*SearchTemplateRequest) { + return func(r *SearchTemplateRequest) { + r.CcsMinimizeRoundtrips = &v + } +} + +// WithExpandWildcards - whether to expand wildcard expression to concrete indices that are open, closed or both.. +func (f SearchTemplate) WithExpandWildcards(v string) func(*SearchTemplateRequest) { + return func(r *SearchTemplateRequest) { + r.ExpandWildcards = v + } +} + +// WithExplain - specify whether to return detailed information about score computation as part of a hit. +func (f SearchTemplate) WithExplain(v bool) func(*SearchTemplateRequest) { + return func(r *SearchTemplateRequest) { + r.Explain = &v + } +} + +// WithIgnoreThrottled - whether specified concrete, expanded or aliased indices should be ignored when throttled. +func (f SearchTemplate) WithIgnoreThrottled(v bool) func(*SearchTemplateRequest) { + return func(r *SearchTemplateRequest) { + r.IgnoreThrottled = &v + } +} + +// WithIgnoreUnavailable - whether specified concrete indices should be ignored when unavailable (missing or closed). +func (f SearchTemplate) WithIgnoreUnavailable(v bool) func(*SearchTemplateRequest) { + return func(r *SearchTemplateRequest) { + r.IgnoreUnavailable = &v + } +} + +// WithPreference - specify the node or shard the operation should be performed on (default: random). +func (f SearchTemplate) WithPreference(v string) func(*SearchTemplateRequest) { + return func(r *SearchTemplateRequest) { + r.Preference = v + } +} + +// WithProfile - specify whether to profile the query execution. +func (f SearchTemplate) WithProfile(v bool) func(*SearchTemplateRequest) { + return func(r *SearchTemplateRequest) { + r.Profile = &v + } +} + +// WithRestTotalHitsAsInt - indicates whether hits.total should be rendered as an integer or an object in the rest search response. +func (f SearchTemplate) WithRestTotalHitsAsInt(v bool) func(*SearchTemplateRequest) { + return func(r *SearchTemplateRequest) { + r.RestTotalHitsAsInt = &v + } +} + +// WithRouting - a list of specific routing values. +func (f SearchTemplate) WithRouting(v ...string) func(*SearchTemplateRequest) { + return func(r *SearchTemplateRequest) { + r.Routing = v + } +} + +// WithScroll - specify how long a consistent view of the index should be maintained for scrolled search. +func (f SearchTemplate) WithScroll(v time.Duration) func(*SearchTemplateRequest) { + return func(r *SearchTemplateRequest) { + r.Scroll = v + } +} + +// WithSearchType - search operation type. +func (f SearchTemplate) WithSearchType(v string) func(*SearchTemplateRequest) { + return func(r *SearchTemplateRequest) { + r.SearchType = v + } +} + +// WithTypedKeys - specify whether aggregation and suggester names should be prefixed by their respective types in the response. +func (f SearchTemplate) WithTypedKeys(v bool) func(*SearchTemplateRequest) { + return func(r *SearchTemplateRequest) { + r.TypedKeys = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SearchTemplate) WithPretty() func(*SearchTemplateRequest) { + return func(r *SearchTemplateRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SearchTemplate) WithHuman() func(*SearchTemplateRequest) { + return func(r *SearchTemplateRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SearchTemplate) WithErrorTrace() func(*SearchTemplateRequest) { + return func(r *SearchTemplateRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SearchTemplate) WithFilterPath(v ...string) func(*SearchTemplateRequest) { + return func(r *SearchTemplateRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SearchTemplate) WithHeader(h map[string]string) func(*SearchTemplateRequest) { + return func(r *SearchTemplateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SearchTemplate) WithOpaqueID(s string) func(*SearchTemplateRequest) { + return func(r *SearchTemplateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.shutdown.delete_node.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.shutdown.delete_node.go new file mode 100644 index 00000000..cc26c60e --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.shutdown.delete_node.go @@ -0,0 +1,193 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newShutdownDeleteNodeFunc(t Transport) ShutdownDeleteNode { + return func(node_id string, o ...func(*ShutdownDeleteNodeRequest)) (*Response, error) { + var r = ShutdownDeleteNodeRequest{NodeID: node_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// ShutdownDeleteNode removes a node from the shutdown list. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current. +type ShutdownDeleteNode func(node_id string, o ...func(*ShutdownDeleteNodeRequest)) (*Response, error) + +// ShutdownDeleteNodeRequest configures the Shutdown Delete Node API request. +type ShutdownDeleteNodeRequest struct { + NodeID string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r ShutdownDeleteNodeRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + path.Grow(1 + len("_nodes") + 1 + len(r.NodeID) + 1 + len("shutdown")) + path.WriteString("/") + path.WriteString("_nodes") + path.WriteString("/") + path.WriteString(r.NodeID) + path.WriteString("/") + path.WriteString("shutdown") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f ShutdownDeleteNode) WithContext(v context.Context) func(*ShutdownDeleteNodeRequest) { + return func(r *ShutdownDeleteNodeRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f ShutdownDeleteNode) WithPretty() func(*ShutdownDeleteNodeRequest) { + return func(r *ShutdownDeleteNodeRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f ShutdownDeleteNode) WithHuman() func(*ShutdownDeleteNodeRequest) { + return func(r *ShutdownDeleteNodeRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f ShutdownDeleteNode) WithErrorTrace() func(*ShutdownDeleteNodeRequest) { + return func(r *ShutdownDeleteNodeRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f ShutdownDeleteNode) WithFilterPath(v ...string) func(*ShutdownDeleteNodeRequest) { + return func(r *ShutdownDeleteNodeRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f ShutdownDeleteNode) WithHeader(h map[string]string) func(*ShutdownDeleteNodeRequest) { + return func(r *ShutdownDeleteNodeRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f ShutdownDeleteNode) WithOpaqueID(s string) func(*ShutdownDeleteNodeRequest) { + return func(r *ShutdownDeleteNodeRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.shutdown.get_node.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.shutdown.get_node.go new file mode 100644 index 00000000..0903f7b2 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.shutdown.get_node.go @@ -0,0 +1,202 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newShutdownGetNodeFunc(t Transport) ShutdownGetNode { + return func(o ...func(*ShutdownGetNodeRequest)) (*Response, error) { + var r = ShutdownGetNodeRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// ShutdownGetNode retrieve status of a node or nodes that are currently marked as shutting down. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current. +type ShutdownGetNode func(o ...func(*ShutdownGetNodeRequest)) (*Response, error) + +// ShutdownGetNodeRequest configures the Shutdown Get Node API request. +type ShutdownGetNodeRequest struct { + NodeID string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r ShutdownGetNodeRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_nodes") + 1 + len(r.NodeID) + 1 + len("shutdown")) + path.WriteString("/") + path.WriteString("_nodes") + if r.NodeID != "" { + path.WriteString("/") + path.WriteString(r.NodeID) + } + path.WriteString("/") + path.WriteString("shutdown") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f ShutdownGetNode) WithContext(v context.Context) func(*ShutdownGetNodeRequest) { + return func(r *ShutdownGetNodeRequest) { + r.ctx = v + } +} + +// WithNodeID - which node for which to retrieve the shutdown status. +func (f ShutdownGetNode) WithNodeID(v string) func(*ShutdownGetNodeRequest) { + return func(r *ShutdownGetNodeRequest) { + r.NodeID = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f ShutdownGetNode) WithPretty() func(*ShutdownGetNodeRequest) { + return func(r *ShutdownGetNodeRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f ShutdownGetNode) WithHuman() func(*ShutdownGetNodeRequest) { + return func(r *ShutdownGetNodeRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f ShutdownGetNode) WithErrorTrace() func(*ShutdownGetNodeRequest) { + return func(r *ShutdownGetNodeRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f ShutdownGetNode) WithFilterPath(v ...string) func(*ShutdownGetNodeRequest) { + return func(r *ShutdownGetNodeRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f ShutdownGetNode) WithHeader(h map[string]string) func(*ShutdownGetNodeRequest) { + return func(r *ShutdownGetNodeRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f ShutdownGetNode) WithOpaqueID(s string) func(*ShutdownGetNodeRequest) { + return func(r *ShutdownGetNodeRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.shutdown.put_node.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.shutdown.put_node.go new file mode 100644 index 00000000..6e98b5a5 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.shutdown.put_node.go @@ -0,0 +1,200 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newShutdownPutNodeFunc(t Transport) ShutdownPutNode { + return func(body io.Reader, node_id string, o ...func(*ShutdownPutNodeRequest)) (*Response, error) { + var r = ShutdownPutNodeRequest{Body: body, NodeID: node_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// ShutdownPutNode adds a node to be shut down. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current. +type ShutdownPutNode func(body io.Reader, node_id string, o ...func(*ShutdownPutNodeRequest)) (*Response, error) + +// ShutdownPutNodeRequest configures the Shutdown Put Node API request. +type ShutdownPutNodeRequest struct { + Body io.Reader + + NodeID string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r ShutdownPutNodeRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(1 + len("_nodes") + 1 + len(r.NodeID) + 1 + len("shutdown")) + path.WriteString("/") + path.WriteString("_nodes") + path.WriteString("/") + path.WriteString(r.NodeID) + path.WriteString("/") + path.WriteString("shutdown") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f ShutdownPutNode) WithContext(v context.Context) func(*ShutdownPutNodeRequest) { + return func(r *ShutdownPutNodeRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f ShutdownPutNode) WithPretty() func(*ShutdownPutNodeRequest) { + return func(r *ShutdownPutNodeRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f ShutdownPutNode) WithHuman() func(*ShutdownPutNodeRequest) { + return func(r *ShutdownPutNodeRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f ShutdownPutNode) WithErrorTrace() func(*ShutdownPutNodeRequest) { + return func(r *ShutdownPutNodeRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f ShutdownPutNode) WithFilterPath(v ...string) func(*ShutdownPutNodeRequest) { + return func(r *ShutdownPutNodeRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f ShutdownPutNode) WithHeader(h map[string]string) func(*ShutdownPutNodeRequest) { + return func(r *ShutdownPutNodeRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f ShutdownPutNode) WithOpaqueID(s string) func(*ShutdownPutNodeRequest) { + return func(r *ShutdownPutNodeRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.snapshot.cleanup_repository.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.snapshot.cleanup_repository.go new file mode 100644 index 00000000..978d3360 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.snapshot.cleanup_repository.go @@ -0,0 +1,219 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" + "time" +) + +func newSnapshotCleanupRepositoryFunc(t Transport) SnapshotCleanupRepository { + return func(repository string, o ...func(*SnapshotCleanupRepositoryRequest)) (*Response, error) { + var r = SnapshotCleanupRepositoryRequest{Repository: repository} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SnapshotCleanupRepository removes stale data from repository. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/clean-up-snapshot-repo-api.html. +type SnapshotCleanupRepository func(repository string, o ...func(*SnapshotCleanupRepositoryRequest)) (*Response, error) + +// SnapshotCleanupRepositoryRequest configures the Snapshot Cleanup Repository API request. +type SnapshotCleanupRepositoryRequest struct { + Repository string + + MasterTimeout time.Duration + Timeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SnapshotCleanupRepositoryRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_snapshot") + 1 + len(r.Repository) + 1 + len("_cleanup")) + path.WriteString("/") + path.WriteString("_snapshot") + path.WriteString("/") + path.WriteString(r.Repository) + path.WriteString("/") + path.WriteString("_cleanup") + + params = make(map[string]string) + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SnapshotCleanupRepository) WithContext(v context.Context) func(*SnapshotCleanupRepositoryRequest) { + return func(r *SnapshotCleanupRepositoryRequest) { + r.ctx = v + } +} + +// WithMasterTimeout - explicit operation timeout for connection to master node. +func (f SnapshotCleanupRepository) WithMasterTimeout(v time.Duration) func(*SnapshotCleanupRepositoryRequest) { + return func(r *SnapshotCleanupRepositoryRequest) { + r.MasterTimeout = v + } +} + +// WithTimeout - explicit operation timeout. +func (f SnapshotCleanupRepository) WithTimeout(v time.Duration) func(*SnapshotCleanupRepositoryRequest) { + return func(r *SnapshotCleanupRepositoryRequest) { + r.Timeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SnapshotCleanupRepository) WithPretty() func(*SnapshotCleanupRepositoryRequest) { + return func(r *SnapshotCleanupRepositoryRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SnapshotCleanupRepository) WithHuman() func(*SnapshotCleanupRepositoryRequest) { + return func(r *SnapshotCleanupRepositoryRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SnapshotCleanupRepository) WithErrorTrace() func(*SnapshotCleanupRepositoryRequest) { + return func(r *SnapshotCleanupRepositoryRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SnapshotCleanupRepository) WithFilterPath(v ...string) func(*SnapshotCleanupRepositoryRequest) { + return func(r *SnapshotCleanupRepositoryRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SnapshotCleanupRepository) WithHeader(h map[string]string) func(*SnapshotCleanupRepositoryRequest) { + return func(r *SnapshotCleanupRepositoryRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SnapshotCleanupRepository) WithOpaqueID(s string) func(*SnapshotCleanupRepositoryRequest) { + return func(r *SnapshotCleanupRepositoryRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.snapshot.clone.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.snapshot.clone.go new file mode 100644 index 00000000..69c18414 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.snapshot.clone.go @@ -0,0 +1,220 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" + "time" +) + +func newSnapshotCloneFunc(t Transport) SnapshotClone { + return func(repository string, snapshot string, body io.Reader, target_snapshot string, o ...func(*SnapshotCloneRequest)) (*Response, error) { + var r = SnapshotCloneRequest{Repository: repository, Snapshot: snapshot, Body: body, TargetSnapshot: target_snapshot} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SnapshotClone clones indices from one snapshot into another snapshot in the same repository. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html. +type SnapshotClone func(repository string, snapshot string, body io.Reader, target_snapshot string, o ...func(*SnapshotCloneRequest)) (*Response, error) + +// SnapshotCloneRequest configures the Snapshot Clone API request. +type SnapshotCloneRequest struct { + Body io.Reader + + Repository string + Snapshot string + TargetSnapshot string + + MasterTimeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SnapshotCloneRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(1 + len("_snapshot") + 1 + len(r.Repository) + 1 + len(r.Snapshot) + 1 + len("_clone") + 1 + len(r.TargetSnapshot)) + path.WriteString("/") + path.WriteString("_snapshot") + path.WriteString("/") + path.WriteString(r.Repository) + path.WriteString("/") + path.WriteString(r.Snapshot) + path.WriteString("/") + path.WriteString("_clone") + path.WriteString("/") + path.WriteString(r.TargetSnapshot) + + params = make(map[string]string) + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SnapshotClone) WithContext(v context.Context) func(*SnapshotCloneRequest) { + return func(r *SnapshotCloneRequest) { + r.ctx = v + } +} + +// WithMasterTimeout - explicit operation timeout for connection to master node. +func (f SnapshotClone) WithMasterTimeout(v time.Duration) func(*SnapshotCloneRequest) { + return func(r *SnapshotCloneRequest) { + r.MasterTimeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SnapshotClone) WithPretty() func(*SnapshotCloneRequest) { + return func(r *SnapshotCloneRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SnapshotClone) WithHuman() func(*SnapshotCloneRequest) { + return func(r *SnapshotCloneRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SnapshotClone) WithErrorTrace() func(*SnapshotCloneRequest) { + return func(r *SnapshotCloneRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SnapshotClone) WithFilterPath(v ...string) func(*SnapshotCloneRequest) { + return func(r *SnapshotCloneRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SnapshotClone) WithHeader(h map[string]string) func(*SnapshotCloneRequest) { + return func(r *SnapshotCloneRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SnapshotClone) WithOpaqueID(s string) func(*SnapshotCloneRequest) { + return func(r *SnapshotCloneRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.snapshot.create.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.snapshot.create.go new file mode 100644 index 00000000..cbc0b2fa --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.snapshot.create.go @@ -0,0 +1,235 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" + "time" +) + +func newSnapshotCreateFunc(t Transport) SnapshotCreate { + return func(repository string, snapshot string, o ...func(*SnapshotCreateRequest)) (*Response, error) { + var r = SnapshotCreateRequest{Repository: repository, Snapshot: snapshot} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SnapshotCreate creates a snapshot in a repository. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html. +type SnapshotCreate func(repository string, snapshot string, o ...func(*SnapshotCreateRequest)) (*Response, error) + +// SnapshotCreateRequest configures the Snapshot Create API request. +type SnapshotCreateRequest struct { + Body io.Reader + + Repository string + Snapshot string + + MasterTimeout time.Duration + WaitForCompletion *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SnapshotCreateRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(1 + len("_snapshot") + 1 + len(r.Repository) + 1 + len(r.Snapshot)) + path.WriteString("/") + path.WriteString("_snapshot") + path.WriteString("/") + path.WriteString(r.Repository) + path.WriteString("/") + path.WriteString(r.Snapshot) + + params = make(map[string]string) + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.WaitForCompletion != nil { + params["wait_for_completion"] = strconv.FormatBool(*r.WaitForCompletion) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SnapshotCreate) WithContext(v context.Context) func(*SnapshotCreateRequest) { + return func(r *SnapshotCreateRequest) { + r.ctx = v + } +} + +// WithBody - The snapshot definition. +func (f SnapshotCreate) WithBody(v io.Reader) func(*SnapshotCreateRequest) { + return func(r *SnapshotCreateRequest) { + r.Body = v + } +} + +// WithMasterTimeout - explicit operation timeout for connection to master node. +func (f SnapshotCreate) WithMasterTimeout(v time.Duration) func(*SnapshotCreateRequest) { + return func(r *SnapshotCreateRequest) { + r.MasterTimeout = v + } +} + +// WithWaitForCompletion - should this request wait until the operation has completed before returning. +func (f SnapshotCreate) WithWaitForCompletion(v bool) func(*SnapshotCreateRequest) { + return func(r *SnapshotCreateRequest) { + r.WaitForCompletion = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SnapshotCreate) WithPretty() func(*SnapshotCreateRequest) { + return func(r *SnapshotCreateRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SnapshotCreate) WithHuman() func(*SnapshotCreateRequest) { + return func(r *SnapshotCreateRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SnapshotCreate) WithErrorTrace() func(*SnapshotCreateRequest) { + return func(r *SnapshotCreateRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SnapshotCreate) WithFilterPath(v ...string) func(*SnapshotCreateRequest) { + return func(r *SnapshotCreateRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SnapshotCreate) WithHeader(h map[string]string) func(*SnapshotCreateRequest) { + return func(r *SnapshotCreateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SnapshotCreate) WithOpaqueID(s string) func(*SnapshotCreateRequest) { + return func(r *SnapshotCreateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.snapshot.create_repository.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.snapshot.create_repository.go new file mode 100644 index 00000000..8692cfd5 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.snapshot.create_repository.go @@ -0,0 +1,237 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" + "time" +) + +func newSnapshotCreateRepositoryFunc(t Transport) SnapshotCreateRepository { + return func(repository string, body io.Reader, o ...func(*SnapshotCreateRepositoryRequest)) (*Response, error) { + var r = SnapshotCreateRepositoryRequest{Repository: repository, Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SnapshotCreateRepository creates a repository. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html. +type SnapshotCreateRepository func(repository string, body io.Reader, o ...func(*SnapshotCreateRepositoryRequest)) (*Response, error) + +// SnapshotCreateRepositoryRequest configures the Snapshot Create Repository API request. +type SnapshotCreateRepositoryRequest struct { + Body io.Reader + + Repository string + + MasterTimeout time.Duration + Timeout time.Duration + Verify *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SnapshotCreateRepositoryRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(1 + len("_snapshot") + 1 + len(r.Repository)) + path.WriteString("/") + path.WriteString("_snapshot") + path.WriteString("/") + path.WriteString(r.Repository) + + params = make(map[string]string) + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Verify != nil { + params["verify"] = strconv.FormatBool(*r.Verify) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SnapshotCreateRepository) WithContext(v context.Context) func(*SnapshotCreateRepositoryRequest) { + return func(r *SnapshotCreateRepositoryRequest) { + r.ctx = v + } +} + +// WithMasterTimeout - explicit operation timeout for connection to master node. +func (f SnapshotCreateRepository) WithMasterTimeout(v time.Duration) func(*SnapshotCreateRepositoryRequest) { + return func(r *SnapshotCreateRepositoryRequest) { + r.MasterTimeout = v + } +} + +// WithTimeout - explicit operation timeout. +func (f SnapshotCreateRepository) WithTimeout(v time.Duration) func(*SnapshotCreateRepositoryRequest) { + return func(r *SnapshotCreateRepositoryRequest) { + r.Timeout = v + } +} + +// WithVerify - whether to verify the repository after creation. +func (f SnapshotCreateRepository) WithVerify(v bool) func(*SnapshotCreateRepositoryRequest) { + return func(r *SnapshotCreateRepositoryRequest) { + r.Verify = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SnapshotCreateRepository) WithPretty() func(*SnapshotCreateRepositoryRequest) { + return func(r *SnapshotCreateRepositoryRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SnapshotCreateRepository) WithHuman() func(*SnapshotCreateRepositoryRequest) { + return func(r *SnapshotCreateRepositoryRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SnapshotCreateRepository) WithErrorTrace() func(*SnapshotCreateRepositoryRequest) { + return func(r *SnapshotCreateRepositoryRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SnapshotCreateRepository) WithFilterPath(v ...string) func(*SnapshotCreateRepositoryRequest) { + return func(r *SnapshotCreateRepositoryRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SnapshotCreateRepository) WithHeader(h map[string]string) func(*SnapshotCreateRepositoryRequest) { + return func(r *SnapshotCreateRepositoryRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SnapshotCreateRepository) WithOpaqueID(s string) func(*SnapshotCreateRepositoryRequest) { + return func(r *SnapshotCreateRepositoryRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.snapshot.delete.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.snapshot.delete.go new file mode 100644 index 00000000..c69da2d6 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.snapshot.delete.go @@ -0,0 +1,208 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" + "time" +) + +func newSnapshotDeleteFunc(t Transport) SnapshotDelete { + return func(repository string, snapshot string, o ...func(*SnapshotDeleteRequest)) (*Response, error) { + var r = SnapshotDeleteRequest{Repository: repository, Snapshot: snapshot} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SnapshotDelete deletes a snapshot. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html. +type SnapshotDelete func(repository string, snapshot string, o ...func(*SnapshotDeleteRequest)) (*Response, error) + +// SnapshotDeleteRequest configures the Snapshot Delete API request. +type SnapshotDeleteRequest struct { + Repository string + Snapshot string + + MasterTimeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SnapshotDeleteRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + path.Grow(1 + len("_snapshot") + 1 + len(r.Repository) + 1 + len(r.Snapshot)) + path.WriteString("/") + path.WriteString("_snapshot") + path.WriteString("/") + path.WriteString(r.Repository) + path.WriteString("/") + path.WriteString(r.Snapshot) + + params = make(map[string]string) + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SnapshotDelete) WithContext(v context.Context) func(*SnapshotDeleteRequest) { + return func(r *SnapshotDeleteRequest) { + r.ctx = v + } +} + +// WithMasterTimeout - explicit operation timeout for connection to master node. +func (f SnapshotDelete) WithMasterTimeout(v time.Duration) func(*SnapshotDeleteRequest) { + return func(r *SnapshotDeleteRequest) { + r.MasterTimeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SnapshotDelete) WithPretty() func(*SnapshotDeleteRequest) { + return func(r *SnapshotDeleteRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SnapshotDelete) WithHuman() func(*SnapshotDeleteRequest) { + return func(r *SnapshotDeleteRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SnapshotDelete) WithErrorTrace() func(*SnapshotDeleteRequest) { + return func(r *SnapshotDeleteRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SnapshotDelete) WithFilterPath(v ...string) func(*SnapshotDeleteRequest) { + return func(r *SnapshotDeleteRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SnapshotDelete) WithHeader(h map[string]string) func(*SnapshotDeleteRequest) { + return func(r *SnapshotDeleteRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SnapshotDelete) WithOpaqueID(s string) func(*SnapshotDeleteRequest) { + return func(r *SnapshotDeleteRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.snapshot.delete_repository.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.snapshot.delete_repository.go new file mode 100644 index 00000000..2efa3d23 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.snapshot.delete_repository.go @@ -0,0 +1,222 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "errors" + "net/http" + "strings" + "time" +) + +func newSnapshotDeleteRepositoryFunc(t Transport) SnapshotDeleteRepository { + return func(repository []string, o ...func(*SnapshotDeleteRepositoryRequest)) (*Response, error) { + var r = SnapshotDeleteRepositoryRequest{Repository: repository} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SnapshotDeleteRepository deletes a repository. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html. +type SnapshotDeleteRepository func(repository []string, o ...func(*SnapshotDeleteRepositoryRequest)) (*Response, error) + +// SnapshotDeleteRepositoryRequest configures the Snapshot Delete Repository API request. +type SnapshotDeleteRepositoryRequest struct { + Repository []string + + MasterTimeout time.Duration + Timeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SnapshotDeleteRepositoryRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + if len(r.Repository) == 0 { + return nil, errors.New("repository is required and cannot be nil or empty") + } + + path.Grow(1 + len("_snapshot") + 1 + len(strings.Join(r.Repository, ","))) + path.WriteString("/") + path.WriteString("_snapshot") + path.WriteString("/") + path.WriteString(strings.Join(r.Repository, ",")) + + params = make(map[string]string) + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SnapshotDeleteRepository) WithContext(v context.Context) func(*SnapshotDeleteRepositoryRequest) { + return func(r *SnapshotDeleteRepositoryRequest) { + r.ctx = v + } +} + +// WithMasterTimeout - explicit operation timeout for connection to master node. +func (f SnapshotDeleteRepository) WithMasterTimeout(v time.Duration) func(*SnapshotDeleteRepositoryRequest) { + return func(r *SnapshotDeleteRepositoryRequest) { + r.MasterTimeout = v + } +} + +// WithTimeout - explicit operation timeout. +func (f SnapshotDeleteRepository) WithTimeout(v time.Duration) func(*SnapshotDeleteRepositoryRequest) { + return func(r *SnapshotDeleteRepositoryRequest) { + r.Timeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SnapshotDeleteRepository) WithPretty() func(*SnapshotDeleteRepositoryRequest) { + return func(r *SnapshotDeleteRepositoryRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SnapshotDeleteRepository) WithHuman() func(*SnapshotDeleteRepositoryRequest) { + return func(r *SnapshotDeleteRepositoryRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SnapshotDeleteRepository) WithErrorTrace() func(*SnapshotDeleteRepositoryRequest) { + return func(r *SnapshotDeleteRepositoryRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SnapshotDeleteRepository) WithFilterPath(v ...string) func(*SnapshotDeleteRepositoryRequest) { + return func(r *SnapshotDeleteRepositoryRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SnapshotDeleteRepository) WithHeader(h map[string]string) func(*SnapshotDeleteRepositoryRequest) { + return func(r *SnapshotDeleteRepositoryRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SnapshotDeleteRepository) WithOpaqueID(s string) func(*SnapshotDeleteRepositoryRequest) { + return func(r *SnapshotDeleteRepositoryRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.snapshot.get.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.snapshot.get.go new file mode 100644 index 00000000..9aaefa5d --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.snapshot.get.go @@ -0,0 +1,347 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "errors" + "fmt" + "net/http" + "strconv" + "strings" + "time" +) + +func newSnapshotGetFunc(t Transport) SnapshotGet { + return func(repository string, snapshot []string, o ...func(*SnapshotGetRequest)) (*Response, error) { + var r = SnapshotGetRequest{Repository: repository, Snapshot: snapshot} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SnapshotGet returns information about a snapshot. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html. +type SnapshotGet func(repository string, snapshot []string, o ...func(*SnapshotGetRequest)) (*Response, error) + +// SnapshotGetRequest configures the Snapshot Get API request. +type SnapshotGetRequest struct { + Repository string + Snapshot []string + + After string + FromSortValue string + IgnoreUnavailable *bool + IncludeRepository *bool + IndexDetails *bool + MasterTimeout time.Duration + Offset interface{} + Order string + Size interface{} + SlmPolicyFilter string + Sort string + Verbose *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SnapshotGetRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + if len(r.Snapshot) == 0 { + return nil, errors.New("snapshot is required and cannot be nil or empty") + } + + path.Grow(1 + len("_snapshot") + 1 + len(r.Repository) + 1 + len(strings.Join(r.Snapshot, ","))) + path.WriteString("/") + path.WriteString("_snapshot") + path.WriteString("/") + path.WriteString(r.Repository) + path.WriteString("/") + path.WriteString(strings.Join(r.Snapshot, ",")) + + params = make(map[string]string) + + if r.After != "" { + params["after"] = r.After + } + + if r.FromSortValue != "" { + params["from_sort_value"] = r.FromSortValue + } + + if r.IgnoreUnavailable != nil { + params["ignore_unavailable"] = strconv.FormatBool(*r.IgnoreUnavailable) + } + + if r.IncludeRepository != nil { + params["include_repository"] = strconv.FormatBool(*r.IncludeRepository) + } + + if r.IndexDetails != nil { + params["index_details"] = strconv.FormatBool(*r.IndexDetails) + } + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Offset != nil { + params["offset"] = fmt.Sprintf("%v", r.Offset) + } + + if r.Order != "" { + params["order"] = r.Order + } + + if r.Size != nil { + params["size"] = fmt.Sprintf("%v", r.Size) + } + + if r.SlmPolicyFilter != "" { + params["slm_policy_filter"] = r.SlmPolicyFilter + } + + if r.Sort != "" { + params["sort"] = r.Sort + } + + if r.Verbose != nil { + params["verbose"] = strconv.FormatBool(*r.Verbose) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SnapshotGet) WithContext(v context.Context) func(*SnapshotGetRequest) { + return func(r *SnapshotGetRequest) { + r.ctx = v + } +} + +// WithAfter - offset identifier to start pagination from as returned by the 'next' field in the response body.. +func (f SnapshotGet) WithAfter(v string) func(*SnapshotGetRequest) { + return func(r *SnapshotGetRequest) { + r.After = v + } +} + +// WithFromSortValue - value of the current sort column at which to start retrieval.. +func (f SnapshotGet) WithFromSortValue(v string) func(*SnapshotGetRequest) { + return func(r *SnapshotGetRequest) { + r.FromSortValue = v + } +} + +// WithIgnoreUnavailable - whether to ignore unavailable snapshots, defaults to false which means a snapshotmissingexception is thrown. +func (f SnapshotGet) WithIgnoreUnavailable(v bool) func(*SnapshotGetRequest) { + return func(r *SnapshotGetRequest) { + r.IgnoreUnavailable = &v + } +} + +// WithIncludeRepository - whether to include the repository name in the snapshot info. defaults to true.. +func (f SnapshotGet) WithIncludeRepository(v bool) func(*SnapshotGetRequest) { + return func(r *SnapshotGetRequest) { + r.IncludeRepository = &v + } +} + +// WithIndexDetails - whether to include details of each index in the snapshot, if those details are available. defaults to false.. +func (f SnapshotGet) WithIndexDetails(v bool) func(*SnapshotGetRequest) { + return func(r *SnapshotGetRequest) { + r.IndexDetails = &v + } +} + +// WithMasterTimeout - explicit operation timeout for connection to master node. +func (f SnapshotGet) WithMasterTimeout(v time.Duration) func(*SnapshotGetRequest) { + return func(r *SnapshotGetRequest) { + r.MasterTimeout = v + } +} + +// WithOffset - numeric offset to start pagination based on the snapshots matching the request. defaults to 0. +func (f SnapshotGet) WithOffset(v interface{}) func(*SnapshotGetRequest) { + return func(r *SnapshotGetRequest) { + r.Offset = v + } +} + +// WithOrder - sort order. +func (f SnapshotGet) WithOrder(v string) func(*SnapshotGetRequest) { + return func(r *SnapshotGetRequest) { + r.Order = v + } +} + +// WithSize - maximum number of snapshots to return. defaults to 0 which means return all that match without limit.. +func (f SnapshotGet) WithSize(v interface{}) func(*SnapshotGetRequest) { + return func(r *SnapshotGetRequest) { + r.Size = v + } +} + +// WithSlmPolicyFilter - filter snapshots by a list of slm policy names that snapshots belong to. accepts wildcards. use the special pattern '_none' to match snapshots without an slm policy. +func (f SnapshotGet) WithSlmPolicyFilter(v string) func(*SnapshotGetRequest) { + return func(r *SnapshotGetRequest) { + r.SlmPolicyFilter = v + } +} + +// WithSort - allows setting a sort order for the result. defaults to start_time. +func (f SnapshotGet) WithSort(v string) func(*SnapshotGetRequest) { + return func(r *SnapshotGetRequest) { + r.Sort = v + } +} + +// WithVerbose - whether to show verbose snapshot info or only show the basic info found in the repository index blob. +func (f SnapshotGet) WithVerbose(v bool) func(*SnapshotGetRequest) { + return func(r *SnapshotGetRequest) { + r.Verbose = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SnapshotGet) WithPretty() func(*SnapshotGetRequest) { + return func(r *SnapshotGetRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SnapshotGet) WithHuman() func(*SnapshotGetRequest) { + return func(r *SnapshotGetRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SnapshotGet) WithErrorTrace() func(*SnapshotGetRequest) { + return func(r *SnapshotGetRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SnapshotGet) WithFilterPath(v ...string) func(*SnapshotGetRequest) { + return func(r *SnapshotGetRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SnapshotGet) WithHeader(h map[string]string) func(*SnapshotGetRequest) { + return func(r *SnapshotGetRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SnapshotGet) WithOpaqueID(s string) func(*SnapshotGetRequest) { + return func(r *SnapshotGetRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.snapshot.get_repository.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.snapshot.get_repository.go new file mode 100644 index 00000000..516d468e --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.snapshot.get_repository.go @@ -0,0 +1,227 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" + "time" +) + +func newSnapshotGetRepositoryFunc(t Transport) SnapshotGetRepository { + return func(o ...func(*SnapshotGetRepositoryRequest)) (*Response, error) { + var r = SnapshotGetRepositoryRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SnapshotGetRepository returns information about a repository. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html. +type SnapshotGetRepository func(o ...func(*SnapshotGetRepositoryRequest)) (*Response, error) + +// SnapshotGetRepositoryRequest configures the Snapshot Get Repository API request. +type SnapshotGetRepositoryRequest struct { + Repository []string + + Local *bool + MasterTimeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SnapshotGetRepositoryRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_snapshot") + 1 + len(strings.Join(r.Repository, ","))) + path.WriteString("/") + path.WriteString("_snapshot") + if len(r.Repository) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Repository, ",")) + } + + params = make(map[string]string) + + if r.Local != nil { + params["local"] = strconv.FormatBool(*r.Local) + } + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SnapshotGetRepository) WithContext(v context.Context) func(*SnapshotGetRepositoryRequest) { + return func(r *SnapshotGetRepositoryRequest) { + r.ctx = v + } +} + +// WithRepository - a list of repository names. +func (f SnapshotGetRepository) WithRepository(v ...string) func(*SnapshotGetRepositoryRequest) { + return func(r *SnapshotGetRepositoryRequest) { + r.Repository = v + } +} + +// WithLocal - return local information, do not retrieve the state from master node (default: false). +func (f SnapshotGetRepository) WithLocal(v bool) func(*SnapshotGetRepositoryRequest) { + return func(r *SnapshotGetRepositoryRequest) { + r.Local = &v + } +} + +// WithMasterTimeout - explicit operation timeout for connection to master node. +func (f SnapshotGetRepository) WithMasterTimeout(v time.Duration) func(*SnapshotGetRepositoryRequest) { + return func(r *SnapshotGetRepositoryRequest) { + r.MasterTimeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SnapshotGetRepository) WithPretty() func(*SnapshotGetRepositoryRequest) { + return func(r *SnapshotGetRepositoryRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SnapshotGetRepository) WithHuman() func(*SnapshotGetRepositoryRequest) { + return func(r *SnapshotGetRepositoryRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SnapshotGetRepository) WithErrorTrace() func(*SnapshotGetRepositoryRequest) { + return func(r *SnapshotGetRepositoryRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SnapshotGetRepository) WithFilterPath(v ...string) func(*SnapshotGetRepositoryRequest) { + return func(r *SnapshotGetRepositoryRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SnapshotGetRepository) WithHeader(h map[string]string) func(*SnapshotGetRepositoryRequest) { + return func(r *SnapshotGetRepositoryRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SnapshotGetRepository) WithOpaqueID(s string) func(*SnapshotGetRepositoryRequest) { + return func(r *SnapshotGetRepositoryRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.snapshot.repository_analyze.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.snapshot.repository_analyze.go new file mode 100644 index 00000000..8cfec358 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.snapshot.repository_analyze.go @@ -0,0 +1,328 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" + "time" +) + +func newSnapshotRepositoryAnalyzeFunc(t Transport) SnapshotRepositoryAnalyze { + return func(repository string, o ...func(*SnapshotRepositoryAnalyzeRequest)) (*Response, error) { + var r = SnapshotRepositoryAnalyzeRequest{Repository: repository} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SnapshotRepositoryAnalyze analyzes a repository for correctness and performance +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html. +type SnapshotRepositoryAnalyze func(repository string, o ...func(*SnapshotRepositoryAnalyzeRequest)) (*Response, error) + +// SnapshotRepositoryAnalyzeRequest configures the Snapshot Repository Analyze API request. +type SnapshotRepositoryAnalyzeRequest struct { + Repository string + + BlobCount *int + Concurrency *int + Detailed *bool + EarlyReadNodeCount *int + MaxBlobSize string + MaxTotalDataSize string + RareActionProbability *int + RarelyAbortWrites *bool + ReadNodeCount *int + Seed *int + Timeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SnapshotRepositoryAnalyzeRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_snapshot") + 1 + len(r.Repository) + 1 + len("_analyze")) + path.WriteString("/") + path.WriteString("_snapshot") + path.WriteString("/") + path.WriteString(r.Repository) + path.WriteString("/") + path.WriteString("_analyze") + + params = make(map[string]string) + + if r.BlobCount != nil { + params["blob_count"] = strconv.FormatInt(int64(*r.BlobCount), 10) + } + + if r.Concurrency != nil { + params["concurrency"] = strconv.FormatInt(int64(*r.Concurrency), 10) + } + + if r.Detailed != nil { + params["detailed"] = strconv.FormatBool(*r.Detailed) + } + + if r.EarlyReadNodeCount != nil { + params["early_read_node_count"] = strconv.FormatInt(int64(*r.EarlyReadNodeCount), 10) + } + + if r.MaxBlobSize != "" { + params["max_blob_size"] = r.MaxBlobSize + } + + if r.MaxTotalDataSize != "" { + params["max_total_data_size"] = r.MaxTotalDataSize + } + + if r.RareActionProbability != nil { + params["rare_action_probability"] = strconv.FormatInt(int64(*r.RareActionProbability), 10) + } + + if r.RarelyAbortWrites != nil { + params["rarely_abort_writes"] = strconv.FormatBool(*r.RarelyAbortWrites) + } + + if r.ReadNodeCount != nil { + params["read_node_count"] = strconv.FormatInt(int64(*r.ReadNodeCount), 10) + } + + if r.Seed != nil { + params["seed"] = strconv.FormatInt(int64(*r.Seed), 10) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SnapshotRepositoryAnalyze) WithContext(v context.Context) func(*SnapshotRepositoryAnalyzeRequest) { + return func(r *SnapshotRepositoryAnalyzeRequest) { + r.ctx = v + } +} + +// WithBlobCount - number of blobs to create during the test. defaults to 100.. +func (f SnapshotRepositoryAnalyze) WithBlobCount(v int) func(*SnapshotRepositoryAnalyzeRequest) { + return func(r *SnapshotRepositoryAnalyzeRequest) { + r.BlobCount = &v + } +} + +// WithConcurrency - number of operations to run concurrently during the test. defaults to 10.. +func (f SnapshotRepositoryAnalyze) WithConcurrency(v int) func(*SnapshotRepositoryAnalyzeRequest) { + return func(r *SnapshotRepositoryAnalyzeRequest) { + r.Concurrency = &v + } +} + +// WithDetailed - whether to return detailed results or a summary. defaults to 'false' so that only the summary is returned.. +func (f SnapshotRepositoryAnalyze) WithDetailed(v bool) func(*SnapshotRepositoryAnalyzeRequest) { + return func(r *SnapshotRepositoryAnalyzeRequest) { + r.Detailed = &v + } +} + +// WithEarlyReadNodeCount - number of nodes on which to perform an early read on a blob, i.e. before writing has completed. early reads are rare actions so the 'rare_action_probability' parameter is also relevant. defaults to 2.. +func (f SnapshotRepositoryAnalyze) WithEarlyReadNodeCount(v int) func(*SnapshotRepositoryAnalyzeRequest) { + return func(r *SnapshotRepositoryAnalyzeRequest) { + r.EarlyReadNodeCount = &v + } +} + +// WithMaxBlobSize - maximum size of a blob to create during the test, e.g '1gb' or '100mb'. defaults to '10mb'.. +func (f SnapshotRepositoryAnalyze) WithMaxBlobSize(v string) func(*SnapshotRepositoryAnalyzeRequest) { + return func(r *SnapshotRepositoryAnalyzeRequest) { + r.MaxBlobSize = v + } +} + +// WithMaxTotalDataSize - maximum total size of all blobs to create during the test, e.g '1tb' or '100gb'. defaults to '1gb'.. +func (f SnapshotRepositoryAnalyze) WithMaxTotalDataSize(v string) func(*SnapshotRepositoryAnalyzeRequest) { + return func(r *SnapshotRepositoryAnalyzeRequest) { + r.MaxTotalDataSize = v + } +} + +// WithRareActionProbability - probability of taking a rare action such as an early read or an overwrite. defaults to 0.02.. +func (f SnapshotRepositoryAnalyze) WithRareActionProbability(v int) func(*SnapshotRepositoryAnalyzeRequest) { + return func(r *SnapshotRepositoryAnalyzeRequest) { + r.RareActionProbability = &v + } +} + +// WithRarelyAbortWrites - whether to rarely abort writes before they complete. defaults to 'true'.. +func (f SnapshotRepositoryAnalyze) WithRarelyAbortWrites(v bool) func(*SnapshotRepositoryAnalyzeRequest) { + return func(r *SnapshotRepositoryAnalyzeRequest) { + r.RarelyAbortWrites = &v + } +} + +// WithReadNodeCount - number of nodes on which to read a blob after writing. defaults to 10.. +func (f SnapshotRepositoryAnalyze) WithReadNodeCount(v int) func(*SnapshotRepositoryAnalyzeRequest) { + return func(r *SnapshotRepositoryAnalyzeRequest) { + r.ReadNodeCount = &v + } +} + +// WithSeed - seed for the random number generator used to create the test workload. defaults to a random value.. +func (f SnapshotRepositoryAnalyze) WithSeed(v int) func(*SnapshotRepositoryAnalyzeRequest) { + return func(r *SnapshotRepositoryAnalyzeRequest) { + r.Seed = &v + } +} + +// WithTimeout - explicit operation timeout. defaults to '30s'.. +func (f SnapshotRepositoryAnalyze) WithTimeout(v time.Duration) func(*SnapshotRepositoryAnalyzeRequest) { + return func(r *SnapshotRepositoryAnalyzeRequest) { + r.Timeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SnapshotRepositoryAnalyze) WithPretty() func(*SnapshotRepositoryAnalyzeRequest) { + return func(r *SnapshotRepositoryAnalyzeRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SnapshotRepositoryAnalyze) WithHuman() func(*SnapshotRepositoryAnalyzeRequest) { + return func(r *SnapshotRepositoryAnalyzeRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SnapshotRepositoryAnalyze) WithErrorTrace() func(*SnapshotRepositoryAnalyzeRequest) { + return func(r *SnapshotRepositoryAnalyzeRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SnapshotRepositoryAnalyze) WithFilterPath(v ...string) func(*SnapshotRepositoryAnalyzeRequest) { + return func(r *SnapshotRepositoryAnalyzeRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SnapshotRepositoryAnalyze) WithHeader(h map[string]string) func(*SnapshotRepositoryAnalyzeRequest) { + return func(r *SnapshotRepositoryAnalyzeRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SnapshotRepositoryAnalyze) WithOpaqueID(s string) func(*SnapshotRepositoryAnalyzeRequest) { + return func(r *SnapshotRepositoryAnalyzeRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.snapshot.restore.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.snapshot.restore.go new file mode 100644 index 00000000..dfd2df8b --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.snapshot.restore.go @@ -0,0 +1,237 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" + "time" +) + +func newSnapshotRestoreFunc(t Transport) SnapshotRestore { + return func(repository string, snapshot string, o ...func(*SnapshotRestoreRequest)) (*Response, error) { + var r = SnapshotRestoreRequest{Repository: repository, Snapshot: snapshot} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SnapshotRestore restores a snapshot. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html. +type SnapshotRestore func(repository string, snapshot string, o ...func(*SnapshotRestoreRequest)) (*Response, error) + +// SnapshotRestoreRequest configures the Snapshot Restore API request. +type SnapshotRestoreRequest struct { + Body io.Reader + + Repository string + Snapshot string + + MasterTimeout time.Duration + WaitForCompletion *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SnapshotRestoreRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_snapshot") + 1 + len(r.Repository) + 1 + len(r.Snapshot) + 1 + len("_restore")) + path.WriteString("/") + path.WriteString("_snapshot") + path.WriteString("/") + path.WriteString(r.Repository) + path.WriteString("/") + path.WriteString(r.Snapshot) + path.WriteString("/") + path.WriteString("_restore") + + params = make(map[string]string) + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.WaitForCompletion != nil { + params["wait_for_completion"] = strconv.FormatBool(*r.WaitForCompletion) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SnapshotRestore) WithContext(v context.Context) func(*SnapshotRestoreRequest) { + return func(r *SnapshotRestoreRequest) { + r.ctx = v + } +} + +// WithBody - Details of what to restore. +func (f SnapshotRestore) WithBody(v io.Reader) func(*SnapshotRestoreRequest) { + return func(r *SnapshotRestoreRequest) { + r.Body = v + } +} + +// WithMasterTimeout - explicit operation timeout for connection to master node. +func (f SnapshotRestore) WithMasterTimeout(v time.Duration) func(*SnapshotRestoreRequest) { + return func(r *SnapshotRestoreRequest) { + r.MasterTimeout = v + } +} + +// WithWaitForCompletion - should this request wait until the operation has completed before returning. +func (f SnapshotRestore) WithWaitForCompletion(v bool) func(*SnapshotRestoreRequest) { + return func(r *SnapshotRestoreRequest) { + r.WaitForCompletion = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SnapshotRestore) WithPretty() func(*SnapshotRestoreRequest) { + return func(r *SnapshotRestoreRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SnapshotRestore) WithHuman() func(*SnapshotRestoreRequest) { + return func(r *SnapshotRestoreRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SnapshotRestore) WithErrorTrace() func(*SnapshotRestoreRequest) { + return func(r *SnapshotRestoreRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SnapshotRestore) WithFilterPath(v ...string) func(*SnapshotRestoreRequest) { + return func(r *SnapshotRestoreRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SnapshotRestore) WithHeader(h map[string]string) func(*SnapshotRestoreRequest) { + return func(r *SnapshotRestoreRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SnapshotRestore) WithOpaqueID(s string) func(*SnapshotRestoreRequest) { + return func(r *SnapshotRestoreRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.snapshot.status.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.snapshot.status.go new file mode 100644 index 00000000..7e33b661 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.snapshot.status.go @@ -0,0 +1,241 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" + "time" +) + +func newSnapshotStatusFunc(t Transport) SnapshotStatus { + return func(o ...func(*SnapshotStatusRequest)) (*Response, error) { + var r = SnapshotStatusRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SnapshotStatus returns information about the status of a snapshot. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html. +type SnapshotStatus func(o ...func(*SnapshotStatusRequest)) (*Response, error) + +// SnapshotStatusRequest configures the Snapshot Status API request. +type SnapshotStatusRequest struct { + Repository string + Snapshot []string + + IgnoreUnavailable *bool + MasterTimeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SnapshotStatusRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_snapshot") + 1 + len(r.Repository) + 1 + len(strings.Join(r.Snapshot, ",")) + 1 + len("_status")) + path.WriteString("/") + path.WriteString("_snapshot") + if r.Repository != "" { + path.WriteString("/") + path.WriteString(r.Repository) + } + if len(r.Snapshot) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Snapshot, ",")) + } + path.WriteString("/") + path.WriteString("_status") + + params = make(map[string]string) + + if r.IgnoreUnavailable != nil { + params["ignore_unavailable"] = strconv.FormatBool(*r.IgnoreUnavailable) + } + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SnapshotStatus) WithContext(v context.Context) func(*SnapshotStatusRequest) { + return func(r *SnapshotStatusRequest) { + r.ctx = v + } +} + +// WithRepository - a repository name. +func (f SnapshotStatus) WithRepository(v string) func(*SnapshotStatusRequest) { + return func(r *SnapshotStatusRequest) { + r.Repository = v + } +} + +// WithSnapshot - a list of snapshot names. +func (f SnapshotStatus) WithSnapshot(v ...string) func(*SnapshotStatusRequest) { + return func(r *SnapshotStatusRequest) { + r.Snapshot = v + } +} + +// WithIgnoreUnavailable - whether to ignore unavailable snapshots, defaults to false which means a snapshotmissingexception is thrown. +func (f SnapshotStatus) WithIgnoreUnavailable(v bool) func(*SnapshotStatusRequest) { + return func(r *SnapshotStatusRequest) { + r.IgnoreUnavailable = &v + } +} + +// WithMasterTimeout - explicit operation timeout for connection to master node. +func (f SnapshotStatus) WithMasterTimeout(v time.Duration) func(*SnapshotStatusRequest) { + return func(r *SnapshotStatusRequest) { + r.MasterTimeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SnapshotStatus) WithPretty() func(*SnapshotStatusRequest) { + return func(r *SnapshotStatusRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SnapshotStatus) WithHuman() func(*SnapshotStatusRequest) { + return func(r *SnapshotStatusRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SnapshotStatus) WithErrorTrace() func(*SnapshotStatusRequest) { + return func(r *SnapshotStatusRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SnapshotStatus) WithFilterPath(v ...string) func(*SnapshotStatusRequest) { + return func(r *SnapshotStatusRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SnapshotStatus) WithHeader(h map[string]string) func(*SnapshotStatusRequest) { + return func(r *SnapshotStatusRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SnapshotStatus) WithOpaqueID(s string) func(*SnapshotStatusRequest) { + return func(r *SnapshotStatusRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.snapshot.verify_repository.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.snapshot.verify_repository.go new file mode 100644 index 00000000..559b7e35 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.snapshot.verify_repository.go @@ -0,0 +1,219 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" + "time" +) + +func newSnapshotVerifyRepositoryFunc(t Transport) SnapshotVerifyRepository { + return func(repository string, o ...func(*SnapshotVerifyRepositoryRequest)) (*Response, error) { + var r = SnapshotVerifyRepositoryRequest{Repository: repository} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SnapshotVerifyRepository verifies a repository. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html. +type SnapshotVerifyRepository func(repository string, o ...func(*SnapshotVerifyRepositoryRequest)) (*Response, error) + +// SnapshotVerifyRepositoryRequest configures the Snapshot Verify Repository API request. +type SnapshotVerifyRepositoryRequest struct { + Repository string + + MasterTimeout time.Duration + Timeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SnapshotVerifyRepositoryRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_snapshot") + 1 + len(r.Repository) + 1 + len("_verify")) + path.WriteString("/") + path.WriteString("_snapshot") + path.WriteString("/") + path.WriteString(r.Repository) + path.WriteString("/") + path.WriteString("_verify") + + params = make(map[string]string) + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SnapshotVerifyRepository) WithContext(v context.Context) func(*SnapshotVerifyRepositoryRequest) { + return func(r *SnapshotVerifyRepositoryRequest) { + r.ctx = v + } +} + +// WithMasterTimeout - explicit operation timeout for connection to master node. +func (f SnapshotVerifyRepository) WithMasterTimeout(v time.Duration) func(*SnapshotVerifyRepositoryRequest) { + return func(r *SnapshotVerifyRepositoryRequest) { + r.MasterTimeout = v + } +} + +// WithTimeout - explicit operation timeout. +func (f SnapshotVerifyRepository) WithTimeout(v time.Duration) func(*SnapshotVerifyRepositoryRequest) { + return func(r *SnapshotVerifyRepositoryRequest) { + r.Timeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SnapshotVerifyRepository) WithPretty() func(*SnapshotVerifyRepositoryRequest) { + return func(r *SnapshotVerifyRepositoryRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SnapshotVerifyRepository) WithHuman() func(*SnapshotVerifyRepositoryRequest) { + return func(r *SnapshotVerifyRepositoryRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SnapshotVerifyRepository) WithErrorTrace() func(*SnapshotVerifyRepositoryRequest) { + return func(r *SnapshotVerifyRepositoryRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SnapshotVerifyRepository) WithFilterPath(v ...string) func(*SnapshotVerifyRepositoryRequest) { + return func(r *SnapshotVerifyRepositoryRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SnapshotVerifyRepository) WithHeader(h map[string]string) func(*SnapshotVerifyRepositoryRequest) { + return func(r *SnapshotVerifyRepositoryRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SnapshotVerifyRepository) WithOpaqueID(s string) func(*SnapshotVerifyRepositoryRequest) { + return func(r *SnapshotVerifyRepositoryRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.tasks.cancel.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.tasks.cancel.go new file mode 100644 index 00000000..b6f867d1 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.tasks.cancel.go @@ -0,0 +1,254 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newTasksCancelFunc(t Transport) TasksCancel { + return func(o ...func(*TasksCancelRequest)) (*Response, error) { + var r = TasksCancelRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// TasksCancel cancels a task, if it can be cancelled through an API. +// +// This API is experimental. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html. +type TasksCancel func(o ...func(*TasksCancelRequest)) (*Response, error) + +// TasksCancelRequest configures the Tasks Cancel API request. +type TasksCancelRequest struct { + TaskID string + + Actions []string + Nodes []string + ParentTaskID string + WaitForCompletion *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r TasksCancelRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_tasks") + 1 + len(r.TaskID) + 1 + len("_cancel")) + path.WriteString("/") + path.WriteString("_tasks") + if r.TaskID != "" { + path.WriteString("/") + path.WriteString(r.TaskID) + } + path.WriteString("/") + path.WriteString("_cancel") + + params = make(map[string]string) + + if len(r.Actions) > 0 { + params["actions"] = strings.Join(r.Actions, ",") + } + + if len(r.Nodes) > 0 { + params["nodes"] = strings.Join(r.Nodes, ",") + } + + if r.ParentTaskID != "" { + params["parent_task_id"] = r.ParentTaskID + } + + if r.WaitForCompletion != nil { + params["wait_for_completion"] = strconv.FormatBool(*r.WaitForCompletion) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f TasksCancel) WithContext(v context.Context) func(*TasksCancelRequest) { + return func(r *TasksCancelRequest) { + r.ctx = v + } +} + +// WithTaskID - cancel the task with specified task ID (node_id:task_number). +func (f TasksCancel) WithTaskID(v string) func(*TasksCancelRequest) { + return func(r *TasksCancelRequest) { + r.TaskID = v + } +} + +// WithActions - a list of actions that should be cancelled. leave empty to cancel all.. +func (f TasksCancel) WithActions(v ...string) func(*TasksCancelRequest) { + return func(r *TasksCancelRequest) { + r.Actions = v + } +} + +// WithNodes - a list of node ids or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes. +func (f TasksCancel) WithNodes(v ...string) func(*TasksCancelRequest) { + return func(r *TasksCancelRequest) { + r.Nodes = v + } +} + +// WithParentTaskID - cancel tasks with specified parent task ID (node_id:task_number). set to -1 to cancel all.. +func (f TasksCancel) WithParentTaskID(v string) func(*TasksCancelRequest) { + return func(r *TasksCancelRequest) { + r.ParentTaskID = v + } +} + +// WithWaitForCompletion - should the request block until the cancellation of the task and its descendant tasks is completed. defaults to false. +func (f TasksCancel) WithWaitForCompletion(v bool) func(*TasksCancelRequest) { + return func(r *TasksCancelRequest) { + r.WaitForCompletion = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f TasksCancel) WithPretty() func(*TasksCancelRequest) { + return func(r *TasksCancelRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f TasksCancel) WithHuman() func(*TasksCancelRequest) { + return func(r *TasksCancelRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f TasksCancel) WithErrorTrace() func(*TasksCancelRequest) { + return func(r *TasksCancelRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f TasksCancel) WithFilterPath(v ...string) func(*TasksCancelRequest) { + return func(r *TasksCancelRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f TasksCancel) WithHeader(h map[string]string) func(*TasksCancelRequest) { + return func(r *TasksCancelRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f TasksCancel) WithOpaqueID(s string) func(*TasksCancelRequest) { + return func(r *TasksCancelRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.tasks.get.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.tasks.get.go new file mode 100644 index 00000000..fb6396fb --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.tasks.get.go @@ -0,0 +1,220 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" + "time" +) + +func newTasksGetFunc(t Transport) TasksGet { + return func(task_id string, o ...func(*TasksGetRequest)) (*Response, error) { + var r = TasksGetRequest{TaskID: task_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// TasksGet returns information about a task. +// +// This API is experimental. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html. +type TasksGet func(task_id string, o ...func(*TasksGetRequest)) (*Response, error) + +// TasksGetRequest configures the Tasks Get API request. +type TasksGetRequest struct { + TaskID string + + Timeout time.Duration + WaitForCompletion *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r TasksGetRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_tasks") + 1 + len(r.TaskID)) + path.WriteString("/") + path.WriteString("_tasks") + path.WriteString("/") + path.WriteString(r.TaskID) + + params = make(map[string]string) + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.WaitForCompletion != nil { + params["wait_for_completion"] = strconv.FormatBool(*r.WaitForCompletion) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f TasksGet) WithContext(v context.Context) func(*TasksGetRequest) { + return func(r *TasksGetRequest) { + r.ctx = v + } +} + +// WithTimeout - explicit operation timeout. +func (f TasksGet) WithTimeout(v time.Duration) func(*TasksGetRequest) { + return func(r *TasksGetRequest) { + r.Timeout = v + } +} + +// WithWaitForCompletion - wait for the matching tasks to complete (default: false). +func (f TasksGet) WithWaitForCompletion(v bool) func(*TasksGetRequest) { + return func(r *TasksGetRequest) { + r.WaitForCompletion = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f TasksGet) WithPretty() func(*TasksGetRequest) { + return func(r *TasksGetRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f TasksGet) WithHuman() func(*TasksGetRequest) { + return func(r *TasksGetRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f TasksGet) WithErrorTrace() func(*TasksGetRequest) { + return func(r *TasksGetRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f TasksGet) WithFilterPath(v ...string) func(*TasksGetRequest) { + return func(r *TasksGetRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f TasksGet) WithHeader(h map[string]string) func(*TasksGetRequest) { + return func(r *TasksGetRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f TasksGet) WithOpaqueID(s string) func(*TasksGetRequest) { + return func(r *TasksGetRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.tasks.list.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.tasks.list.go new file mode 100644 index 00000000..e055017f --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.tasks.list.go @@ -0,0 +1,275 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" + "time" +) + +func newTasksListFunc(t Transport) TasksList { + return func(o ...func(*TasksListRequest)) (*Response, error) { + var r = TasksListRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// TasksList returns a list of tasks. +// +// This API is experimental. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html. +type TasksList func(o ...func(*TasksListRequest)) (*Response, error) + +// TasksListRequest configures the Tasks List API request. +type TasksListRequest struct { + Actions []string + Detailed *bool + GroupBy string + Nodes []string + ParentTaskID string + Timeout time.Duration + WaitForCompletion *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r TasksListRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(len("/_tasks")) + path.WriteString("/_tasks") + + params = make(map[string]string) + + if len(r.Actions) > 0 { + params["actions"] = strings.Join(r.Actions, ",") + } + + if r.Detailed != nil { + params["detailed"] = strconv.FormatBool(*r.Detailed) + } + + if r.GroupBy != "" { + params["group_by"] = r.GroupBy + } + + if len(r.Nodes) > 0 { + params["nodes"] = strings.Join(r.Nodes, ",") + } + + if r.ParentTaskID != "" { + params["parent_task_id"] = r.ParentTaskID + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.WaitForCompletion != nil { + params["wait_for_completion"] = strconv.FormatBool(*r.WaitForCompletion) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f TasksList) WithContext(v context.Context) func(*TasksListRequest) { + return func(r *TasksListRequest) { + r.ctx = v + } +} + +// WithActions - a list of actions that should be returned. leave empty to return all.. +func (f TasksList) WithActions(v ...string) func(*TasksListRequest) { + return func(r *TasksListRequest) { + r.Actions = v + } +} + +// WithDetailed - return detailed task information (default: false). +func (f TasksList) WithDetailed(v bool) func(*TasksListRequest) { + return func(r *TasksListRequest) { + r.Detailed = &v + } +} + +// WithGroupBy - group tasks by nodes or parent/child relationships. +func (f TasksList) WithGroupBy(v string) func(*TasksListRequest) { + return func(r *TasksListRequest) { + r.GroupBy = v + } +} + +// WithNodes - a list of node ids or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes. +func (f TasksList) WithNodes(v ...string) func(*TasksListRequest) { + return func(r *TasksListRequest) { + r.Nodes = v + } +} + +// WithParentTaskID - return tasks with specified parent task ID (node_id:task_number). set to -1 to return all.. +func (f TasksList) WithParentTaskID(v string) func(*TasksListRequest) { + return func(r *TasksListRequest) { + r.ParentTaskID = v + } +} + +// WithTimeout - explicit operation timeout. +func (f TasksList) WithTimeout(v time.Duration) func(*TasksListRequest) { + return func(r *TasksListRequest) { + r.Timeout = v + } +} + +// WithWaitForCompletion - wait for the matching tasks to complete (default: false). +func (f TasksList) WithWaitForCompletion(v bool) func(*TasksListRequest) { + return func(r *TasksListRequest) { + r.WaitForCompletion = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f TasksList) WithPretty() func(*TasksListRequest) { + return func(r *TasksListRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f TasksList) WithHuman() func(*TasksListRequest) { + return func(r *TasksListRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f TasksList) WithErrorTrace() func(*TasksListRequest) { + return func(r *TasksListRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f TasksList) WithFilterPath(v ...string) func(*TasksListRequest) { + return func(r *TasksListRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f TasksList) WithHeader(h map[string]string) func(*TasksListRequest) { + return func(r *TasksListRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f TasksList) WithOpaqueID(s string) func(*TasksListRequest) { + return func(r *TasksListRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.terms_enum.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.terms_enum.go new file mode 100644 index 00000000..e78d1604 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.terms_enum.go @@ -0,0 +1,210 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "errors" + "io" + "net/http" + "strings" +) + +func newTermsEnumFunc(t Transport) TermsEnum { + return func(index []string, o ...func(*TermsEnumRequest)) (*Response, error) { + var r = TermsEnumRequest{Index: index} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// TermsEnum the terms enum API can be used to discover terms in the index that begin with the provided string. It is designed for low-latency look-ups used in auto-complete scenarios. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/search-terms-enum.html. +type TermsEnum func(index []string, o ...func(*TermsEnumRequest)) (*Response, error) + +// TermsEnumRequest configures the Terms Enum API request. +type TermsEnumRequest struct { + Index []string + + Body io.Reader + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r TermsEnumRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + if len(r.Index) == 0 { + return nil, errors.New("index is required and cannot be nil or empty") + } + + path.Grow(1 + len(strings.Join(r.Index, ",")) + 1 + len("_terms_enum")) + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + path.WriteString("/") + path.WriteString("_terms_enum") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f TermsEnum) WithContext(v context.Context) func(*TermsEnumRequest) { + return func(r *TermsEnumRequest) { + r.ctx = v + } +} + +// WithBody - field name, string which is the prefix expected in matching terms, timeout and size for max number of results. +func (f TermsEnum) WithBody(v io.Reader) func(*TermsEnumRequest) { + return func(r *TermsEnumRequest) { + r.Body = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f TermsEnum) WithPretty() func(*TermsEnumRequest) { + return func(r *TermsEnumRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f TermsEnum) WithHuman() func(*TermsEnumRequest) { + return func(r *TermsEnumRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f TermsEnum) WithErrorTrace() func(*TermsEnumRequest) { + return func(r *TermsEnumRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f TermsEnum) WithFilterPath(v ...string) func(*TermsEnumRequest) { + return func(r *TermsEnumRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f TermsEnum) WithHeader(h map[string]string) func(*TermsEnumRequest) { + return func(r *TermsEnumRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f TermsEnum) WithOpaqueID(s string) func(*TermsEnumRequest) { + return func(r *TermsEnumRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.termvectors.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.termvectors.go new file mode 100644 index 00000000..b031c1d3 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.termvectors.go @@ -0,0 +1,367 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" +) + +func newTermvectorsFunc(t Transport) Termvectors { + return func(index string, o ...func(*TermvectorsRequest)) (*Response, error) { + var r = TermvectorsRequest{Index: index} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// Termvectors returns information and statistics about terms in the fields of a particular document. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-termvectors.html. +type Termvectors func(index string, o ...func(*TermvectorsRequest)) (*Response, error) + +// TermvectorsRequest configures the Termvectors API request. +type TermvectorsRequest struct { + Index string + DocumentType string + DocumentID string + + Body io.Reader + + Fields []string + FieldStatistics *bool + Offsets *bool + Payloads *bool + Positions *bool + Preference string + Realtime *bool + Routing string + TermStatistics *bool + Version *int + VersionType string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r TermvectorsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + if r.DocumentType == "" { + r.DocumentType = "_doc" + } + + path.Grow(1 + len(r.Index) + 1 + len(r.DocumentType) + 1 + len(r.DocumentID) + 1 + len("_termvectors")) + path.WriteString("/") + path.WriteString(r.Index) + if r.DocumentType != "" { + path.WriteString("/") + path.WriteString(r.DocumentType) + } + if r.DocumentID != "" { + path.WriteString("/") + path.WriteString(r.DocumentID) + } + path.WriteString("/") + path.WriteString("_termvectors") + + params = make(map[string]string) + + if len(r.Fields) > 0 { + params["fields"] = strings.Join(r.Fields, ",") + } + + if r.FieldStatistics != nil { + params["field_statistics"] = strconv.FormatBool(*r.FieldStatistics) + } + + if r.Offsets != nil { + params["offsets"] = strconv.FormatBool(*r.Offsets) + } + + if r.Payloads != nil { + params["payloads"] = strconv.FormatBool(*r.Payloads) + } + + if r.Positions != nil { + params["positions"] = strconv.FormatBool(*r.Positions) + } + + if r.Preference != "" { + params["preference"] = r.Preference + } + + if r.Realtime != nil { + params["realtime"] = strconv.FormatBool(*r.Realtime) + } + + if r.Routing != "" { + params["routing"] = r.Routing + } + + if r.TermStatistics != nil { + params["term_statistics"] = strconv.FormatBool(*r.TermStatistics) + } + + if r.Version != nil { + params["version"] = strconv.FormatInt(int64(*r.Version), 10) + } + + if r.VersionType != "" { + params["version_type"] = r.VersionType + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f Termvectors) WithContext(v context.Context) func(*TermvectorsRequest) { + return func(r *TermvectorsRequest) { + r.ctx = v + } +} + +// WithBody - Define parameters and or supply a document to get termvectors for. See documentation.. +func (f Termvectors) WithBody(v io.Reader) func(*TermvectorsRequest) { + return func(r *TermvectorsRequest) { + r.Body = v + } +} + +// WithDocumentID - the ID of the document, when not specified a doc param should be supplied.. +func (f Termvectors) WithDocumentID(v string) func(*TermvectorsRequest) { + return func(r *TermvectorsRequest) { + r.DocumentID = v + } +} + +// WithDocumentType - the type of the document.. +func (f Termvectors) WithDocumentType(v string) func(*TermvectorsRequest) { + return func(r *TermvectorsRequest) { + r.DocumentType = v + } +} + +// WithFields - a list of fields to return.. +func (f Termvectors) WithFields(v ...string) func(*TermvectorsRequest) { + return func(r *TermvectorsRequest) { + r.Fields = v + } +} + +// WithFieldStatistics - specifies if document count, sum of document frequencies and sum of total term frequencies should be returned.. +func (f Termvectors) WithFieldStatistics(v bool) func(*TermvectorsRequest) { + return func(r *TermvectorsRequest) { + r.FieldStatistics = &v + } +} + +// WithOffsets - specifies if term offsets should be returned.. +func (f Termvectors) WithOffsets(v bool) func(*TermvectorsRequest) { + return func(r *TermvectorsRequest) { + r.Offsets = &v + } +} + +// WithPayloads - specifies if term payloads should be returned.. +func (f Termvectors) WithPayloads(v bool) func(*TermvectorsRequest) { + return func(r *TermvectorsRequest) { + r.Payloads = &v + } +} + +// WithPositions - specifies if term positions should be returned.. +func (f Termvectors) WithPositions(v bool) func(*TermvectorsRequest) { + return func(r *TermvectorsRequest) { + r.Positions = &v + } +} + +// WithPreference - specify the node or shard the operation should be performed on (default: random).. +func (f Termvectors) WithPreference(v string) func(*TermvectorsRequest) { + return func(r *TermvectorsRequest) { + r.Preference = v + } +} + +// WithRealtime - specifies if request is real-time as opposed to near-real-time (default: true).. +func (f Termvectors) WithRealtime(v bool) func(*TermvectorsRequest) { + return func(r *TermvectorsRequest) { + r.Realtime = &v + } +} + +// WithRouting - specific routing value.. +func (f Termvectors) WithRouting(v string) func(*TermvectorsRequest) { + return func(r *TermvectorsRequest) { + r.Routing = v + } +} + +// WithTermStatistics - specifies if total term frequency and document frequency should be returned.. +func (f Termvectors) WithTermStatistics(v bool) func(*TermvectorsRequest) { + return func(r *TermvectorsRequest) { + r.TermStatistics = &v + } +} + +// WithVersion - explicit version number for concurrency control. +func (f Termvectors) WithVersion(v int) func(*TermvectorsRequest) { + return func(r *TermvectorsRequest) { + r.Version = &v + } +} + +// WithVersionType - specific version type. +func (f Termvectors) WithVersionType(v string) func(*TermvectorsRequest) { + return func(r *TermvectorsRequest) { + r.VersionType = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f Termvectors) WithPretty() func(*TermvectorsRequest) { + return func(r *TermvectorsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f Termvectors) WithHuman() func(*TermvectorsRequest) { + return func(r *TermvectorsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f Termvectors) WithErrorTrace() func(*TermvectorsRequest) { + return func(r *TermvectorsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f Termvectors) WithFilterPath(v ...string) func(*TermvectorsRequest) { + return func(r *TermvectorsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f Termvectors) WithHeader(h map[string]string) func(*TermvectorsRequest) { + return func(r *TermvectorsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f Termvectors) WithOpaqueID(s string) func(*TermvectorsRequest) { + return func(r *TermvectorsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.update.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.update.go new file mode 100644 index 00000000..733c02d4 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.update.go @@ -0,0 +1,364 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" + "time" +) + +func newUpdateFunc(t Transport) Update { + return func(index string, id string, body io.Reader, o ...func(*UpdateRequest)) (*Response, error) { + var r = UpdateRequest{Index: index, DocumentID: id, Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// Update updates a document with a script or partial document. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-update.html. +type Update func(index string, id string, body io.Reader, o ...func(*UpdateRequest)) (*Response, error) + +// UpdateRequest configures the Update API request. +type UpdateRequest struct { + Index string + DocumentType string + DocumentID string + + Body io.Reader + + IfPrimaryTerm *int + IfSeqNo *int + Lang string + Refresh string + RequireAlias *bool + RetryOnConflict *int + Routing string + Source []string + SourceExcludes []string + SourceIncludes []string + Timeout time.Duration + WaitForActiveShards string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r UpdateRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + if r.DocumentType == "" { + r.DocumentType = "_doc" + } + + path.Grow(1 + len(r.Index) + 1 + len(r.DocumentType) + 1 + len(r.DocumentID) + 1 + len("_update")) + path.WriteString("/") + path.WriteString(r.Index) + if r.DocumentType != "" { + path.WriteString("/") + path.WriteString(r.DocumentType) + } + path.WriteString("/") + path.WriteString(r.DocumentID) + path.WriteString("/") + path.WriteString("_update") + + params = make(map[string]string) + + if r.IfPrimaryTerm != nil { + params["if_primary_term"] = strconv.FormatInt(int64(*r.IfPrimaryTerm), 10) + } + + if r.IfSeqNo != nil { + params["if_seq_no"] = strconv.FormatInt(int64(*r.IfSeqNo), 10) + } + + if r.Lang != "" { + params["lang"] = r.Lang + } + + if r.Refresh != "" { + params["refresh"] = r.Refresh + } + + if r.RequireAlias != nil { + params["require_alias"] = strconv.FormatBool(*r.RequireAlias) + } + + if r.RetryOnConflict != nil { + params["retry_on_conflict"] = strconv.FormatInt(int64(*r.RetryOnConflict), 10) + } + + if r.Routing != "" { + params["routing"] = r.Routing + } + + if len(r.Source) > 0 { + params["_source"] = strings.Join(r.Source, ",") + } + + if len(r.SourceExcludes) > 0 { + params["_source_excludes"] = strings.Join(r.SourceExcludes, ",") + } + + if len(r.SourceIncludes) > 0 { + params["_source_includes"] = strings.Join(r.SourceIncludes, ",") + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.WaitForActiveShards != "" { + params["wait_for_active_shards"] = r.WaitForActiveShards + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f Update) WithContext(v context.Context) func(*UpdateRequest) { + return func(r *UpdateRequest) { + r.ctx = v + } +} + +// WithDocumentType - the type of the document. +func (f Update) WithDocumentType(v string) func(*UpdateRequest) { + return func(r *UpdateRequest) { + r.DocumentType = v + } +} + +// WithIfPrimaryTerm - only perform the update operation if the last operation that has changed the document has the specified primary term. +func (f Update) WithIfPrimaryTerm(v int) func(*UpdateRequest) { + return func(r *UpdateRequest) { + r.IfPrimaryTerm = &v + } +} + +// WithIfSeqNo - only perform the update operation if the last operation that has changed the document has the specified sequence number. +func (f Update) WithIfSeqNo(v int) func(*UpdateRequest) { + return func(r *UpdateRequest) { + r.IfSeqNo = &v + } +} + +// WithLang - the script language (default: painless). +func (f Update) WithLang(v string) func(*UpdateRequest) { + return func(r *UpdateRequest) { + r.Lang = v + } +} + +// WithRefresh - if `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes.. +func (f Update) WithRefresh(v string) func(*UpdateRequest) { + return func(r *UpdateRequest) { + r.Refresh = v + } +} + +// WithRequireAlias - when true, requires destination is an alias. default is false. +func (f Update) WithRequireAlias(v bool) func(*UpdateRequest) { + return func(r *UpdateRequest) { + r.RequireAlias = &v + } +} + +// WithRetryOnConflict - specify how many times should the operation be retried when a conflict occurs (default: 0). +func (f Update) WithRetryOnConflict(v int) func(*UpdateRequest) { + return func(r *UpdateRequest) { + r.RetryOnConflict = &v + } +} + +// WithRouting - specific routing value. +func (f Update) WithRouting(v string) func(*UpdateRequest) { + return func(r *UpdateRequest) { + r.Routing = v + } +} + +// WithSource - true or false to return the _source field or not, or a list of fields to return. +func (f Update) WithSource(v ...string) func(*UpdateRequest) { + return func(r *UpdateRequest) { + r.Source = v + } +} + +// WithSourceExcludes - a list of fields to exclude from the returned _source field. +func (f Update) WithSourceExcludes(v ...string) func(*UpdateRequest) { + return func(r *UpdateRequest) { + r.SourceExcludes = v + } +} + +// WithSourceIncludes - a list of fields to extract and return from the _source field. +func (f Update) WithSourceIncludes(v ...string) func(*UpdateRequest) { + return func(r *UpdateRequest) { + r.SourceIncludes = v + } +} + +// WithTimeout - explicit operation timeout. +func (f Update) WithTimeout(v time.Duration) func(*UpdateRequest) { + return func(r *UpdateRequest) { + r.Timeout = v + } +} + +// WithWaitForActiveShards - sets the number of shard copies that must be active before proceeding with the update operation. defaults to 1, meaning the primary shard only. set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1). +func (f Update) WithWaitForActiveShards(v string) func(*UpdateRequest) { + return func(r *UpdateRequest) { + r.WaitForActiveShards = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f Update) WithPretty() func(*UpdateRequest) { + return func(r *UpdateRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f Update) WithHuman() func(*UpdateRequest) { + return func(r *UpdateRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f Update) WithErrorTrace() func(*UpdateRequest) { + return func(r *UpdateRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f Update) WithFilterPath(v ...string) func(*UpdateRequest) { + return func(r *UpdateRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f Update) WithHeader(h map[string]string) func(*UpdateRequest) { + return func(r *UpdateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f Update) WithOpaqueID(s string) func(*UpdateRequest) { + return func(r *UpdateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.update_by_query.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.update_by_query.go new file mode 100644 index 00000000..a75bae0e --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.update_by_query.go @@ -0,0 +1,611 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "errors" + "fmt" + "io" + "net/http" + "strconv" + "strings" + "time" +) + +func newUpdateByQueryFunc(t Transport) UpdateByQuery { + return func(index []string, o ...func(*UpdateByQueryRequest)) (*Response, error) { + var r = UpdateByQueryRequest{Index: index} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// UpdateByQuery performs an update on every document in the index without changing the source, +// for example to pick up a mapping change. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-update-by-query.html. +type UpdateByQuery func(index []string, o ...func(*UpdateByQueryRequest)) (*Response, error) + +// UpdateByQueryRequest configures the Update By Query API request. +type UpdateByQueryRequest struct { + Index []string + DocumentType []string + + Body io.Reader + + AllowNoIndices *bool + Analyzer string + AnalyzeWildcard *bool + Conflicts string + DefaultOperator string + Df string + ExpandWildcards string + From *int + IgnoreUnavailable *bool + Lenient *bool + MaxDocs *int + Pipeline string + Preference string + Query string + Refresh *bool + RequestCache *bool + RequestsPerSecond *int + Routing []string + Scroll time.Duration + ScrollSize *int + SearchTimeout time.Duration + SearchType string + Size *int + Slices interface{} + Sort []string + Stats []string + TerminateAfter *int + Timeout time.Duration + Version *bool + VersionType *bool + WaitForActiveShards string + WaitForCompletion *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r UpdateByQueryRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + if len(r.Index) == 0 { + return nil, errors.New("index is required and cannot be nil or empty") + } + + path.Grow(1 + len(strings.Join(r.Index, ",")) + 1 + len(strings.Join(r.DocumentType, ",")) + 1 + len("_update_by_query")) + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + if len(r.DocumentType) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.DocumentType, ",")) + } + path.WriteString("/") + path.WriteString("_update_by_query") + + params = make(map[string]string) + + if r.AllowNoIndices != nil { + params["allow_no_indices"] = strconv.FormatBool(*r.AllowNoIndices) + } + + if r.Analyzer != "" { + params["analyzer"] = r.Analyzer + } + + if r.AnalyzeWildcard != nil { + params["analyze_wildcard"] = strconv.FormatBool(*r.AnalyzeWildcard) + } + + if r.Conflicts != "" { + params["conflicts"] = r.Conflicts + } + + if r.DefaultOperator != "" { + params["default_operator"] = r.DefaultOperator + } + + if r.Df != "" { + params["df"] = r.Df + } + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if r.From != nil { + params["from"] = strconv.FormatInt(int64(*r.From), 10) + } + + if r.IgnoreUnavailable != nil { + params["ignore_unavailable"] = strconv.FormatBool(*r.IgnoreUnavailable) + } + + if r.Lenient != nil { + params["lenient"] = strconv.FormatBool(*r.Lenient) + } + + if r.MaxDocs != nil { + params["max_docs"] = strconv.FormatInt(int64(*r.MaxDocs), 10) + } + + if r.Pipeline != "" { + params["pipeline"] = r.Pipeline + } + + if r.Preference != "" { + params["preference"] = r.Preference + } + + if r.Query != "" { + params["q"] = r.Query + } + + if r.Refresh != nil { + params["refresh"] = strconv.FormatBool(*r.Refresh) + } + + if r.RequestCache != nil { + params["request_cache"] = strconv.FormatBool(*r.RequestCache) + } + + if r.RequestsPerSecond != nil { + params["requests_per_second"] = strconv.FormatInt(int64(*r.RequestsPerSecond), 10) + } + + if len(r.Routing) > 0 { + params["routing"] = strings.Join(r.Routing, ",") + } + + if r.Scroll != 0 { + params["scroll"] = formatDuration(r.Scroll) + } + + if r.ScrollSize != nil { + params["scroll_size"] = strconv.FormatInt(int64(*r.ScrollSize), 10) + } + + if r.SearchTimeout != 0 { + params["search_timeout"] = formatDuration(r.SearchTimeout) + } + + if r.SearchType != "" { + params["search_type"] = r.SearchType + } + + if r.Size != nil { + params["size"] = strconv.FormatInt(int64(*r.Size), 10) + } + + if r.Slices != nil { + params["slices"] = fmt.Sprintf("%v", r.Slices) + } + + if len(r.Sort) > 0 { + params["sort"] = strings.Join(r.Sort, ",") + } + + if len(r.Stats) > 0 { + params["stats"] = strings.Join(r.Stats, ",") + } + + if r.TerminateAfter != nil { + params["terminate_after"] = strconv.FormatInt(int64(*r.TerminateAfter), 10) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Version != nil { + params["version"] = strconv.FormatBool(*r.Version) + } + + if r.VersionType != nil { + params["version_type"] = strconv.FormatBool(*r.VersionType) + } + + if r.WaitForActiveShards != "" { + params["wait_for_active_shards"] = r.WaitForActiveShards + } + + if r.WaitForCompletion != nil { + params["wait_for_completion"] = strconv.FormatBool(*r.WaitForCompletion) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f UpdateByQuery) WithContext(v context.Context) func(*UpdateByQueryRequest) { + return func(r *UpdateByQueryRequest) { + r.ctx = v + } +} + +// WithBody - The search definition using the Query DSL. +func (f UpdateByQuery) WithBody(v io.Reader) func(*UpdateByQueryRequest) { + return func(r *UpdateByQueryRequest) { + r.Body = v + } +} + +// WithDocumentType - a list of document types to search; leave empty to perform the operation on all types. +func (f UpdateByQuery) WithDocumentType(v ...string) func(*UpdateByQueryRequest) { + return func(r *UpdateByQueryRequest) { + r.DocumentType = v + } +} + +// WithAllowNoIndices - whether to ignore if a wildcard indices expression resolves into no concrete indices. (this includes `_all` string or when no indices have been specified). +func (f UpdateByQuery) WithAllowNoIndices(v bool) func(*UpdateByQueryRequest) { + return func(r *UpdateByQueryRequest) { + r.AllowNoIndices = &v + } +} + +// WithAnalyzer - the analyzer to use for the query string. +func (f UpdateByQuery) WithAnalyzer(v string) func(*UpdateByQueryRequest) { + return func(r *UpdateByQueryRequest) { + r.Analyzer = v + } +} + +// WithAnalyzeWildcard - specify whether wildcard and prefix queries should be analyzed (default: false). +func (f UpdateByQuery) WithAnalyzeWildcard(v bool) func(*UpdateByQueryRequest) { + return func(r *UpdateByQueryRequest) { + r.AnalyzeWildcard = &v + } +} + +// WithConflicts - what to do when the update by query hits version conflicts?. +func (f UpdateByQuery) WithConflicts(v string) func(*UpdateByQueryRequest) { + return func(r *UpdateByQueryRequest) { + r.Conflicts = v + } +} + +// WithDefaultOperator - the default operator for query string query (and or or). +func (f UpdateByQuery) WithDefaultOperator(v string) func(*UpdateByQueryRequest) { + return func(r *UpdateByQueryRequest) { + r.DefaultOperator = v + } +} + +// WithDf - the field to use as default where no field prefix is given in the query string. +func (f UpdateByQuery) WithDf(v string) func(*UpdateByQueryRequest) { + return func(r *UpdateByQueryRequest) { + r.Df = v + } +} + +// WithExpandWildcards - whether to expand wildcard expression to concrete indices that are open, closed or both.. +func (f UpdateByQuery) WithExpandWildcards(v string) func(*UpdateByQueryRequest) { + return func(r *UpdateByQueryRequest) { + r.ExpandWildcards = v + } +} + +// WithFrom - starting offset (default: 0). +func (f UpdateByQuery) WithFrom(v int) func(*UpdateByQueryRequest) { + return func(r *UpdateByQueryRequest) { + r.From = &v + } +} + +// WithIgnoreUnavailable - whether specified concrete indices should be ignored when unavailable (missing or closed). +func (f UpdateByQuery) WithIgnoreUnavailable(v bool) func(*UpdateByQueryRequest) { + return func(r *UpdateByQueryRequest) { + r.IgnoreUnavailable = &v + } +} + +// WithLenient - specify whether format-based query failures (such as providing text to a numeric field) should be ignored. +func (f UpdateByQuery) WithLenient(v bool) func(*UpdateByQueryRequest) { + return func(r *UpdateByQueryRequest) { + r.Lenient = &v + } +} + +// WithMaxDocs - maximum number of documents to process (default: all documents). +func (f UpdateByQuery) WithMaxDocs(v int) func(*UpdateByQueryRequest) { + return func(r *UpdateByQueryRequest) { + r.MaxDocs = &v + } +} + +// WithPipeline - ingest pipeline to set on index requests made by this action. (default: none). +func (f UpdateByQuery) WithPipeline(v string) func(*UpdateByQueryRequest) { + return func(r *UpdateByQueryRequest) { + r.Pipeline = v + } +} + +// WithPreference - specify the node or shard the operation should be performed on (default: random). +func (f UpdateByQuery) WithPreference(v string) func(*UpdateByQueryRequest) { + return func(r *UpdateByQueryRequest) { + r.Preference = v + } +} + +// WithQuery - query in the lucene query string syntax. +func (f UpdateByQuery) WithQuery(v string) func(*UpdateByQueryRequest) { + return func(r *UpdateByQueryRequest) { + r.Query = v + } +} + +// WithRefresh - should the affected indexes be refreshed?. +func (f UpdateByQuery) WithRefresh(v bool) func(*UpdateByQueryRequest) { + return func(r *UpdateByQueryRequest) { + r.Refresh = &v + } +} + +// WithRequestCache - specify if request cache should be used for this request or not, defaults to index level setting. +func (f UpdateByQuery) WithRequestCache(v bool) func(*UpdateByQueryRequest) { + return func(r *UpdateByQueryRequest) { + r.RequestCache = &v + } +} + +// WithRequestsPerSecond - the throttle to set on this request in sub-requests per second. -1 means no throttle.. +func (f UpdateByQuery) WithRequestsPerSecond(v int) func(*UpdateByQueryRequest) { + return func(r *UpdateByQueryRequest) { + r.RequestsPerSecond = &v + } +} + +// WithRouting - a list of specific routing values. +func (f UpdateByQuery) WithRouting(v ...string) func(*UpdateByQueryRequest) { + return func(r *UpdateByQueryRequest) { + r.Routing = v + } +} + +// WithScroll - specify how long a consistent view of the index should be maintained for scrolled search. +func (f UpdateByQuery) WithScroll(v time.Duration) func(*UpdateByQueryRequest) { + return func(r *UpdateByQueryRequest) { + r.Scroll = v + } +} + +// WithScrollSize - size on the scroll request powering the update by query. +func (f UpdateByQuery) WithScrollSize(v int) func(*UpdateByQueryRequest) { + return func(r *UpdateByQueryRequest) { + r.ScrollSize = &v + } +} + +// WithSearchTimeout - explicit timeout for each search request. defaults to no timeout.. +func (f UpdateByQuery) WithSearchTimeout(v time.Duration) func(*UpdateByQueryRequest) { + return func(r *UpdateByQueryRequest) { + r.SearchTimeout = v + } +} + +// WithSearchType - search operation type. +func (f UpdateByQuery) WithSearchType(v string) func(*UpdateByQueryRequest) { + return func(r *UpdateByQueryRequest) { + r.SearchType = v + } +} + +// WithSize - deprecated, please use `max_docs` instead. +func (f UpdateByQuery) WithSize(v int) func(*UpdateByQueryRequest) { + return func(r *UpdateByQueryRequest) { + r.Size = &v + } +} + +// WithSlices - the number of slices this task should be divided into. defaults to 1, meaning the task isn't sliced into subtasks. can be set to `auto`.. +func (f UpdateByQuery) WithSlices(v interface{}) func(*UpdateByQueryRequest) { + return func(r *UpdateByQueryRequest) { + r.Slices = v + } +} + +// WithSort - a list of : pairs. +func (f UpdateByQuery) WithSort(v ...string) func(*UpdateByQueryRequest) { + return func(r *UpdateByQueryRequest) { + r.Sort = v + } +} + +// WithStats - specific 'tag' of the request for logging and statistical purposes. +func (f UpdateByQuery) WithStats(v ...string) func(*UpdateByQueryRequest) { + return func(r *UpdateByQueryRequest) { + r.Stats = v + } +} + +// WithTerminateAfter - the maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.. +func (f UpdateByQuery) WithTerminateAfter(v int) func(*UpdateByQueryRequest) { + return func(r *UpdateByQueryRequest) { + r.TerminateAfter = &v + } +} + +// WithTimeout - time each individual bulk request should wait for shards that are unavailable.. +func (f UpdateByQuery) WithTimeout(v time.Duration) func(*UpdateByQueryRequest) { + return func(r *UpdateByQueryRequest) { + r.Timeout = v + } +} + +// WithVersion - specify whether to return document version as part of a hit. +func (f UpdateByQuery) WithVersion(v bool) func(*UpdateByQueryRequest) { + return func(r *UpdateByQueryRequest) { + r.Version = &v + } +} + +// WithVersionType - should the document increment the version number (internal) on hit or not (reindex). +func (f UpdateByQuery) WithVersionType(v bool) func(*UpdateByQueryRequest) { + return func(r *UpdateByQueryRequest) { + r.VersionType = &v + } +} + +// WithWaitForActiveShards - sets the number of shard copies that must be active before proceeding with the update by query operation. defaults to 1, meaning the primary shard only. set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1). +func (f UpdateByQuery) WithWaitForActiveShards(v string) func(*UpdateByQueryRequest) { + return func(r *UpdateByQueryRequest) { + r.WaitForActiveShards = v + } +} + +// WithWaitForCompletion - should the request should block until the update by query operation is complete.. +func (f UpdateByQuery) WithWaitForCompletion(v bool) func(*UpdateByQueryRequest) { + return func(r *UpdateByQueryRequest) { + r.WaitForCompletion = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f UpdateByQuery) WithPretty() func(*UpdateByQueryRequest) { + return func(r *UpdateByQueryRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f UpdateByQuery) WithHuman() func(*UpdateByQueryRequest) { + return func(r *UpdateByQueryRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f UpdateByQuery) WithErrorTrace() func(*UpdateByQueryRequest) { + return func(r *UpdateByQueryRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f UpdateByQuery) WithFilterPath(v ...string) func(*UpdateByQueryRequest) { + return func(r *UpdateByQueryRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f UpdateByQuery) WithHeader(h map[string]string) func(*UpdateByQueryRequest) { + return func(r *UpdateByQueryRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f UpdateByQuery) WithOpaqueID(s string) func(*UpdateByQueryRequest) { + return func(r *UpdateByQueryRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.update_by_query_rethrottle.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.update_by_query_rethrottle.go new file mode 100644 index 00000000..4187276b --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.update_by_query_rethrottle.go @@ -0,0 +1,207 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newUpdateByQueryRethrottleFunc(t Transport) UpdateByQueryRethrottle { + return func(task_id string, requests_per_second *int, o ...func(*UpdateByQueryRethrottleRequest)) (*Response, error) { + var r = UpdateByQueryRethrottleRequest{TaskID: task_id, RequestsPerSecond: requests_per_second} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// UpdateByQueryRethrottle changes the number of requests per second for a particular Update By Query operation. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update-by-query.html. +type UpdateByQueryRethrottle func(task_id string, requests_per_second *int, o ...func(*UpdateByQueryRethrottleRequest)) (*Response, error) + +// UpdateByQueryRethrottleRequest configures the Update By Query Rethrottle API request. +type UpdateByQueryRethrottleRequest struct { + TaskID string + + RequestsPerSecond *int + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r UpdateByQueryRethrottleRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_update_by_query") + 1 + len(r.TaskID) + 1 + len("_rethrottle")) + path.WriteString("/") + path.WriteString("_update_by_query") + path.WriteString("/") + path.WriteString(r.TaskID) + path.WriteString("/") + path.WriteString("_rethrottle") + + params = make(map[string]string) + + if r.RequestsPerSecond != nil { + params["requests_per_second"] = strconv.FormatInt(int64(*r.RequestsPerSecond), 10) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f UpdateByQueryRethrottle) WithContext(v context.Context) func(*UpdateByQueryRethrottleRequest) { + return func(r *UpdateByQueryRethrottleRequest) { + r.ctx = v + } +} + +// WithRequestsPerSecond - the throttle to set on this request in floating sub-requests per second. -1 means set no throttle.. +func (f UpdateByQueryRethrottle) WithRequestsPerSecond(v int) func(*UpdateByQueryRethrottleRequest) { + return func(r *UpdateByQueryRethrottleRequest) { + r.RequestsPerSecond = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f UpdateByQueryRethrottle) WithPretty() func(*UpdateByQueryRethrottleRequest) { + return func(r *UpdateByQueryRethrottleRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f UpdateByQueryRethrottle) WithHuman() func(*UpdateByQueryRethrottleRequest) { + return func(r *UpdateByQueryRethrottleRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f UpdateByQueryRethrottle) WithErrorTrace() func(*UpdateByQueryRethrottleRequest) { + return func(r *UpdateByQueryRethrottleRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f UpdateByQueryRethrottle) WithFilterPath(v ...string) func(*UpdateByQueryRethrottleRequest) { + return func(r *UpdateByQueryRethrottleRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f UpdateByQueryRethrottle) WithHeader(h map[string]string) func(*UpdateByQueryRethrottleRequest) { + return func(r *UpdateByQueryRethrottleRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f UpdateByQueryRethrottle) WithOpaqueID(s string) func(*UpdateByQueryRethrottleRequest) { + return func(r *UpdateByQueryRethrottleRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.async_search.delete.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.async_search.delete.go new file mode 100644 index 00000000..7711d018 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.async_search.delete.go @@ -0,0 +1,191 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newAsyncSearchDeleteFunc(t Transport) AsyncSearchDelete { + return func(id string, o ...func(*AsyncSearchDeleteRequest)) (*Response, error) { + var r = AsyncSearchDeleteRequest{DocumentID: id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// AsyncSearchDelete - Deletes an async search by ID. If the search is still running, the search request will be cancelled. Otherwise, the saved search results are deleted. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html. +type AsyncSearchDelete func(id string, o ...func(*AsyncSearchDeleteRequest)) (*Response, error) + +// AsyncSearchDeleteRequest configures the Async Search Delete API request. +type AsyncSearchDeleteRequest struct { + DocumentID string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r AsyncSearchDeleteRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + path.Grow(1 + len("_async_search") + 1 + len(r.DocumentID)) + path.WriteString("/") + path.WriteString("_async_search") + path.WriteString("/") + path.WriteString(r.DocumentID) + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f AsyncSearchDelete) WithContext(v context.Context) func(*AsyncSearchDeleteRequest) { + return func(r *AsyncSearchDeleteRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f AsyncSearchDelete) WithPretty() func(*AsyncSearchDeleteRequest) { + return func(r *AsyncSearchDeleteRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f AsyncSearchDelete) WithHuman() func(*AsyncSearchDeleteRequest) { + return func(r *AsyncSearchDeleteRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f AsyncSearchDelete) WithErrorTrace() func(*AsyncSearchDeleteRequest) { + return func(r *AsyncSearchDeleteRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f AsyncSearchDelete) WithFilterPath(v ...string) func(*AsyncSearchDeleteRequest) { + return func(r *AsyncSearchDeleteRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f AsyncSearchDelete) WithHeader(h map[string]string) func(*AsyncSearchDeleteRequest) { + return func(r *AsyncSearchDeleteRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f AsyncSearchDelete) WithOpaqueID(s string) func(*AsyncSearchDeleteRequest) { + return func(r *AsyncSearchDeleteRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.async_search.get.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.async_search.get.go new file mode 100644 index 00000000..30fc98b2 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.async_search.get.go @@ -0,0 +1,230 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" + "time" +) + +func newAsyncSearchGetFunc(t Transport) AsyncSearchGet { + return func(id string, o ...func(*AsyncSearchGetRequest)) (*Response, error) { + var r = AsyncSearchGetRequest{DocumentID: id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// AsyncSearchGet - Retrieves the results of a previously submitted async search request given its ID. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html. +type AsyncSearchGet func(id string, o ...func(*AsyncSearchGetRequest)) (*Response, error) + +// AsyncSearchGetRequest configures the Async Search Get API request. +type AsyncSearchGetRequest struct { + DocumentID string + + KeepAlive time.Duration + TypedKeys *bool + WaitForCompletionTimeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r AsyncSearchGetRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_async_search") + 1 + len(r.DocumentID)) + path.WriteString("/") + path.WriteString("_async_search") + path.WriteString("/") + path.WriteString(r.DocumentID) + + params = make(map[string]string) + + if r.KeepAlive != 0 { + params["keep_alive"] = formatDuration(r.KeepAlive) + } + + if r.TypedKeys != nil { + params["typed_keys"] = strconv.FormatBool(*r.TypedKeys) + } + + if r.WaitForCompletionTimeout != 0 { + params["wait_for_completion_timeout"] = formatDuration(r.WaitForCompletionTimeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f AsyncSearchGet) WithContext(v context.Context) func(*AsyncSearchGetRequest) { + return func(r *AsyncSearchGetRequest) { + r.ctx = v + } +} + +// WithKeepAlive - specify the time interval in which the results (partial or final) for this search will be available. +func (f AsyncSearchGet) WithKeepAlive(v time.Duration) func(*AsyncSearchGetRequest) { + return func(r *AsyncSearchGetRequest) { + r.KeepAlive = v + } +} + +// WithTypedKeys - specify whether aggregation and suggester names should be prefixed by their respective types in the response. +func (f AsyncSearchGet) WithTypedKeys(v bool) func(*AsyncSearchGetRequest) { + return func(r *AsyncSearchGetRequest) { + r.TypedKeys = &v + } +} + +// WithWaitForCompletionTimeout - specify the time that the request should block waiting for the final response. +func (f AsyncSearchGet) WithWaitForCompletionTimeout(v time.Duration) func(*AsyncSearchGetRequest) { + return func(r *AsyncSearchGetRequest) { + r.WaitForCompletionTimeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f AsyncSearchGet) WithPretty() func(*AsyncSearchGetRequest) { + return func(r *AsyncSearchGetRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f AsyncSearchGet) WithHuman() func(*AsyncSearchGetRequest) { + return func(r *AsyncSearchGetRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f AsyncSearchGet) WithErrorTrace() func(*AsyncSearchGetRequest) { + return func(r *AsyncSearchGetRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f AsyncSearchGet) WithFilterPath(v ...string) func(*AsyncSearchGetRequest) { + return func(r *AsyncSearchGetRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f AsyncSearchGet) WithHeader(h map[string]string) func(*AsyncSearchGetRequest) { + return func(r *AsyncSearchGetRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f AsyncSearchGet) WithOpaqueID(s string) func(*AsyncSearchGetRequest) { + return func(r *AsyncSearchGetRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.async_search.status.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.async_search.status.go new file mode 100644 index 00000000..b5a70684 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.async_search.status.go @@ -0,0 +1,193 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newAsyncSearchStatusFunc(t Transport) AsyncSearchStatus { + return func(id string, o ...func(*AsyncSearchStatusRequest)) (*Response, error) { + var r = AsyncSearchStatusRequest{DocumentID: id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// AsyncSearchStatus - Retrieves the status of a previously submitted async search request given its ID. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html. +type AsyncSearchStatus func(id string, o ...func(*AsyncSearchStatusRequest)) (*Response, error) + +// AsyncSearchStatusRequest configures the Async Search Status API request. +type AsyncSearchStatusRequest struct { + DocumentID string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r AsyncSearchStatusRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_async_search") + 1 + len("status") + 1 + len(r.DocumentID)) + path.WriteString("/") + path.WriteString("_async_search") + path.WriteString("/") + path.WriteString("status") + path.WriteString("/") + path.WriteString(r.DocumentID) + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f AsyncSearchStatus) WithContext(v context.Context) func(*AsyncSearchStatusRequest) { + return func(r *AsyncSearchStatusRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f AsyncSearchStatus) WithPretty() func(*AsyncSearchStatusRequest) { + return func(r *AsyncSearchStatusRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f AsyncSearchStatus) WithHuman() func(*AsyncSearchStatusRequest) { + return func(r *AsyncSearchStatusRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f AsyncSearchStatus) WithErrorTrace() func(*AsyncSearchStatusRequest) { + return func(r *AsyncSearchStatusRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f AsyncSearchStatus) WithFilterPath(v ...string) func(*AsyncSearchStatusRequest) { + return func(r *AsyncSearchStatusRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f AsyncSearchStatus) WithHeader(h map[string]string) func(*AsyncSearchStatusRequest) { + return func(r *AsyncSearchStatusRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f AsyncSearchStatus) WithOpaqueID(s string) func(*AsyncSearchStatusRequest) { + return func(r *AsyncSearchStatusRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.async_search.submit.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.async_search.submit.go new file mode 100644 index 00000000..ab4e88b3 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.async_search.submit.go @@ -0,0 +1,709 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" + "time" +) + +func newAsyncSearchSubmitFunc(t Transport) AsyncSearchSubmit { + return func(o ...func(*AsyncSearchSubmitRequest)) (*Response, error) { + var r = AsyncSearchSubmitRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// AsyncSearchSubmit - Executes a search request asynchronously. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html. +type AsyncSearchSubmit func(o ...func(*AsyncSearchSubmitRequest)) (*Response, error) + +// AsyncSearchSubmitRequest configures the Async Search Submit API request. +type AsyncSearchSubmitRequest struct { + Index []string + + Body io.Reader + + AllowNoIndices *bool + AllowPartialSearchResults *bool + Analyzer string + AnalyzeWildcard *bool + BatchedReduceSize *int + DefaultOperator string + Df string + DocvalueFields []string + ExpandWildcards string + Explain *bool + From *int + IgnoreThrottled *bool + IgnoreUnavailable *bool + KeepAlive time.Duration + KeepOnCompletion *bool + Lenient *bool + MaxConcurrentShardRequests *int + Preference string + Query string + RequestCache *bool + Routing []string + SearchType string + SeqNoPrimaryTerm *bool + Size *int + Sort []string + Source []string + SourceExcludes []string + SourceIncludes []string + Stats []string + StoredFields []string + SuggestField string + SuggestMode string + SuggestSize *int + SuggestText string + TerminateAfter *int + Timeout time.Duration + TrackScores *bool + TrackTotalHits *bool + TypedKeys *bool + Version *bool + WaitForCompletionTimeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r AsyncSearchSubmitRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len(strings.Join(r.Index, ",")) + 1 + len("_async_search")) + if len(r.Index) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + } + path.WriteString("/") + path.WriteString("_async_search") + + params = make(map[string]string) + + if r.AllowNoIndices != nil { + params["allow_no_indices"] = strconv.FormatBool(*r.AllowNoIndices) + } + + if r.AllowPartialSearchResults != nil { + params["allow_partial_search_results"] = strconv.FormatBool(*r.AllowPartialSearchResults) + } + + if r.Analyzer != "" { + params["analyzer"] = r.Analyzer + } + + if r.AnalyzeWildcard != nil { + params["analyze_wildcard"] = strconv.FormatBool(*r.AnalyzeWildcard) + } + + if r.BatchedReduceSize != nil { + params["batched_reduce_size"] = strconv.FormatInt(int64(*r.BatchedReduceSize), 10) + } + + if r.DefaultOperator != "" { + params["default_operator"] = r.DefaultOperator + } + + if r.Df != "" { + params["df"] = r.Df + } + + if len(r.DocvalueFields) > 0 { + params["docvalue_fields"] = strings.Join(r.DocvalueFields, ",") + } + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if r.Explain != nil { + params["explain"] = strconv.FormatBool(*r.Explain) + } + + if r.From != nil { + params["from"] = strconv.FormatInt(int64(*r.From), 10) + } + + if r.IgnoreThrottled != nil { + params["ignore_throttled"] = strconv.FormatBool(*r.IgnoreThrottled) + } + + if r.IgnoreUnavailable != nil { + params["ignore_unavailable"] = strconv.FormatBool(*r.IgnoreUnavailable) + } + + if r.KeepAlive != 0 { + params["keep_alive"] = formatDuration(r.KeepAlive) + } + + if r.KeepOnCompletion != nil { + params["keep_on_completion"] = strconv.FormatBool(*r.KeepOnCompletion) + } + + if r.Lenient != nil { + params["lenient"] = strconv.FormatBool(*r.Lenient) + } + + if r.MaxConcurrentShardRequests != nil { + params["max_concurrent_shard_requests"] = strconv.FormatInt(int64(*r.MaxConcurrentShardRequests), 10) + } + + if r.Preference != "" { + params["preference"] = r.Preference + } + + if r.Query != "" { + params["q"] = r.Query + } + + if r.RequestCache != nil { + params["request_cache"] = strconv.FormatBool(*r.RequestCache) + } + + if len(r.Routing) > 0 { + params["routing"] = strings.Join(r.Routing, ",") + } + + if r.SearchType != "" { + params["search_type"] = r.SearchType + } + + if r.SeqNoPrimaryTerm != nil { + params["seq_no_primary_term"] = strconv.FormatBool(*r.SeqNoPrimaryTerm) + } + + if r.Size != nil { + params["size"] = strconv.FormatInt(int64(*r.Size), 10) + } + + if len(r.Sort) > 0 { + params["sort"] = strings.Join(r.Sort, ",") + } + + if len(r.Source) > 0 { + params["_source"] = strings.Join(r.Source, ",") + } + + if len(r.SourceExcludes) > 0 { + params["_source_excludes"] = strings.Join(r.SourceExcludes, ",") + } + + if len(r.SourceIncludes) > 0 { + params["_source_includes"] = strings.Join(r.SourceIncludes, ",") + } + + if len(r.Stats) > 0 { + params["stats"] = strings.Join(r.Stats, ",") + } + + if len(r.StoredFields) > 0 { + params["stored_fields"] = strings.Join(r.StoredFields, ",") + } + + if r.SuggestField != "" { + params["suggest_field"] = r.SuggestField + } + + if r.SuggestMode != "" { + params["suggest_mode"] = r.SuggestMode + } + + if r.SuggestSize != nil { + params["suggest_size"] = strconv.FormatInt(int64(*r.SuggestSize), 10) + } + + if r.SuggestText != "" { + params["suggest_text"] = r.SuggestText + } + + if r.TerminateAfter != nil { + params["terminate_after"] = strconv.FormatInt(int64(*r.TerminateAfter), 10) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.TrackScores != nil { + params["track_scores"] = strconv.FormatBool(*r.TrackScores) + } + + if r.TrackTotalHits != nil { + params["track_total_hits"] = strconv.FormatBool(*r.TrackTotalHits) + } + + if r.TypedKeys != nil { + params["typed_keys"] = strconv.FormatBool(*r.TypedKeys) + } + + if r.Version != nil { + params["version"] = strconv.FormatBool(*r.Version) + } + + if r.WaitForCompletionTimeout != 0 { + params["wait_for_completion_timeout"] = formatDuration(r.WaitForCompletionTimeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f AsyncSearchSubmit) WithContext(v context.Context) func(*AsyncSearchSubmitRequest) { + return func(r *AsyncSearchSubmitRequest) { + r.ctx = v + } +} + +// WithBody - The search definition using the Query DSL. +func (f AsyncSearchSubmit) WithBody(v io.Reader) func(*AsyncSearchSubmitRequest) { + return func(r *AsyncSearchSubmitRequest) { + r.Body = v + } +} + +// WithIndex - a list of index names to search; use _all to perform the operation on all indices. +func (f AsyncSearchSubmit) WithIndex(v ...string) func(*AsyncSearchSubmitRequest) { + return func(r *AsyncSearchSubmitRequest) { + r.Index = v + } +} + +// WithAllowNoIndices - whether to ignore if a wildcard indices expression resolves into no concrete indices. (this includes `_all` string or when no indices have been specified). +func (f AsyncSearchSubmit) WithAllowNoIndices(v bool) func(*AsyncSearchSubmitRequest) { + return func(r *AsyncSearchSubmitRequest) { + r.AllowNoIndices = &v + } +} + +// WithAllowPartialSearchResults - indicate if an error should be returned if there is a partial search failure or timeout. +func (f AsyncSearchSubmit) WithAllowPartialSearchResults(v bool) func(*AsyncSearchSubmitRequest) { + return func(r *AsyncSearchSubmitRequest) { + r.AllowPartialSearchResults = &v + } +} + +// WithAnalyzer - the analyzer to use for the query string. +func (f AsyncSearchSubmit) WithAnalyzer(v string) func(*AsyncSearchSubmitRequest) { + return func(r *AsyncSearchSubmitRequest) { + r.Analyzer = v + } +} + +// WithAnalyzeWildcard - specify whether wildcard and prefix queries should be analyzed (default: false). +func (f AsyncSearchSubmit) WithAnalyzeWildcard(v bool) func(*AsyncSearchSubmitRequest) { + return func(r *AsyncSearchSubmitRequest) { + r.AnalyzeWildcard = &v + } +} + +// WithBatchedReduceSize - the number of shard results that should be reduced at once on the coordinating node. this value should be used as the granularity at which progress results will be made available.. +func (f AsyncSearchSubmit) WithBatchedReduceSize(v int) func(*AsyncSearchSubmitRequest) { + return func(r *AsyncSearchSubmitRequest) { + r.BatchedReduceSize = &v + } +} + +// WithDefaultOperator - the default operator for query string query (and or or). +func (f AsyncSearchSubmit) WithDefaultOperator(v string) func(*AsyncSearchSubmitRequest) { + return func(r *AsyncSearchSubmitRequest) { + r.DefaultOperator = v + } +} + +// WithDf - the field to use as default where no field prefix is given in the query string. +func (f AsyncSearchSubmit) WithDf(v string) func(*AsyncSearchSubmitRequest) { + return func(r *AsyncSearchSubmitRequest) { + r.Df = v + } +} + +// WithDocvalueFields - a list of fields to return as the docvalue representation of a field for each hit. +func (f AsyncSearchSubmit) WithDocvalueFields(v ...string) func(*AsyncSearchSubmitRequest) { + return func(r *AsyncSearchSubmitRequest) { + r.DocvalueFields = v + } +} + +// WithExpandWildcards - whether to expand wildcard expression to concrete indices that are open, closed or both.. +func (f AsyncSearchSubmit) WithExpandWildcards(v string) func(*AsyncSearchSubmitRequest) { + return func(r *AsyncSearchSubmitRequest) { + r.ExpandWildcards = v + } +} + +// WithExplain - specify whether to return detailed information about score computation as part of a hit. +func (f AsyncSearchSubmit) WithExplain(v bool) func(*AsyncSearchSubmitRequest) { + return func(r *AsyncSearchSubmitRequest) { + r.Explain = &v + } +} + +// WithFrom - starting offset (default: 0). +func (f AsyncSearchSubmit) WithFrom(v int) func(*AsyncSearchSubmitRequest) { + return func(r *AsyncSearchSubmitRequest) { + r.From = &v + } +} + +// WithIgnoreThrottled - whether specified concrete, expanded or aliased indices should be ignored when throttled. +func (f AsyncSearchSubmit) WithIgnoreThrottled(v bool) func(*AsyncSearchSubmitRequest) { + return func(r *AsyncSearchSubmitRequest) { + r.IgnoreThrottled = &v + } +} + +// WithIgnoreUnavailable - whether specified concrete indices should be ignored when unavailable (missing or closed). +func (f AsyncSearchSubmit) WithIgnoreUnavailable(v bool) func(*AsyncSearchSubmitRequest) { + return func(r *AsyncSearchSubmitRequest) { + r.IgnoreUnavailable = &v + } +} + +// WithKeepAlive - update the time interval in which the results (partial or final) for this search will be available. +func (f AsyncSearchSubmit) WithKeepAlive(v time.Duration) func(*AsyncSearchSubmitRequest) { + return func(r *AsyncSearchSubmitRequest) { + r.KeepAlive = v + } +} + +// WithKeepOnCompletion - control whether the response should be stored in the cluster if it completed within the provided [wait_for_completion] time (default: false). +func (f AsyncSearchSubmit) WithKeepOnCompletion(v bool) func(*AsyncSearchSubmitRequest) { + return func(r *AsyncSearchSubmitRequest) { + r.KeepOnCompletion = &v + } +} + +// WithLenient - specify whether format-based query failures (such as providing text to a numeric field) should be ignored. +func (f AsyncSearchSubmit) WithLenient(v bool) func(*AsyncSearchSubmitRequest) { + return func(r *AsyncSearchSubmitRequest) { + r.Lenient = &v + } +} + +// WithMaxConcurrentShardRequests - the number of concurrent shard requests per node this search executes concurrently. this value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests. +func (f AsyncSearchSubmit) WithMaxConcurrentShardRequests(v int) func(*AsyncSearchSubmitRequest) { + return func(r *AsyncSearchSubmitRequest) { + r.MaxConcurrentShardRequests = &v + } +} + +// WithPreference - specify the node or shard the operation should be performed on (default: random). +func (f AsyncSearchSubmit) WithPreference(v string) func(*AsyncSearchSubmitRequest) { + return func(r *AsyncSearchSubmitRequest) { + r.Preference = v + } +} + +// WithQuery - query in the lucene query string syntax. +func (f AsyncSearchSubmit) WithQuery(v string) func(*AsyncSearchSubmitRequest) { + return func(r *AsyncSearchSubmitRequest) { + r.Query = v + } +} + +// WithRequestCache - specify if request cache should be used for this request or not, defaults to true. +func (f AsyncSearchSubmit) WithRequestCache(v bool) func(*AsyncSearchSubmitRequest) { + return func(r *AsyncSearchSubmitRequest) { + r.RequestCache = &v + } +} + +// WithRouting - a list of specific routing values. +func (f AsyncSearchSubmit) WithRouting(v ...string) func(*AsyncSearchSubmitRequest) { + return func(r *AsyncSearchSubmitRequest) { + r.Routing = v + } +} + +// WithSearchType - search operation type. +func (f AsyncSearchSubmit) WithSearchType(v string) func(*AsyncSearchSubmitRequest) { + return func(r *AsyncSearchSubmitRequest) { + r.SearchType = v + } +} + +// WithSeqNoPrimaryTerm - specify whether to return sequence number and primary term of the last modification of each hit. +func (f AsyncSearchSubmit) WithSeqNoPrimaryTerm(v bool) func(*AsyncSearchSubmitRequest) { + return func(r *AsyncSearchSubmitRequest) { + r.SeqNoPrimaryTerm = &v + } +} + +// WithSize - number of hits to return (default: 10). +func (f AsyncSearchSubmit) WithSize(v int) func(*AsyncSearchSubmitRequest) { + return func(r *AsyncSearchSubmitRequest) { + r.Size = &v + } +} + +// WithSort - a list of : pairs. +func (f AsyncSearchSubmit) WithSort(v ...string) func(*AsyncSearchSubmitRequest) { + return func(r *AsyncSearchSubmitRequest) { + r.Sort = v + } +} + +// WithSource - true or false to return the _source field or not, or a list of fields to return. +func (f AsyncSearchSubmit) WithSource(v ...string) func(*AsyncSearchSubmitRequest) { + return func(r *AsyncSearchSubmitRequest) { + r.Source = v + } +} + +// WithSourceExcludes - a list of fields to exclude from the returned _source field. +func (f AsyncSearchSubmit) WithSourceExcludes(v ...string) func(*AsyncSearchSubmitRequest) { + return func(r *AsyncSearchSubmitRequest) { + r.SourceExcludes = v + } +} + +// WithSourceIncludes - a list of fields to extract and return from the _source field. +func (f AsyncSearchSubmit) WithSourceIncludes(v ...string) func(*AsyncSearchSubmitRequest) { + return func(r *AsyncSearchSubmitRequest) { + r.SourceIncludes = v + } +} + +// WithStats - specific 'tag' of the request for logging and statistical purposes. +func (f AsyncSearchSubmit) WithStats(v ...string) func(*AsyncSearchSubmitRequest) { + return func(r *AsyncSearchSubmitRequest) { + r.Stats = v + } +} + +// WithStoredFields - a list of stored fields to return as part of a hit. +func (f AsyncSearchSubmit) WithStoredFields(v ...string) func(*AsyncSearchSubmitRequest) { + return func(r *AsyncSearchSubmitRequest) { + r.StoredFields = v + } +} + +// WithSuggestField - specify which field to use for suggestions. +func (f AsyncSearchSubmit) WithSuggestField(v string) func(*AsyncSearchSubmitRequest) { + return func(r *AsyncSearchSubmitRequest) { + r.SuggestField = v + } +} + +// WithSuggestMode - specify suggest mode. +func (f AsyncSearchSubmit) WithSuggestMode(v string) func(*AsyncSearchSubmitRequest) { + return func(r *AsyncSearchSubmitRequest) { + r.SuggestMode = v + } +} + +// WithSuggestSize - how many suggestions to return in response. +func (f AsyncSearchSubmit) WithSuggestSize(v int) func(*AsyncSearchSubmitRequest) { + return func(r *AsyncSearchSubmitRequest) { + r.SuggestSize = &v + } +} + +// WithSuggestText - the source text for which the suggestions should be returned. +func (f AsyncSearchSubmit) WithSuggestText(v string) func(*AsyncSearchSubmitRequest) { + return func(r *AsyncSearchSubmitRequest) { + r.SuggestText = v + } +} + +// WithTerminateAfter - the maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.. +func (f AsyncSearchSubmit) WithTerminateAfter(v int) func(*AsyncSearchSubmitRequest) { + return func(r *AsyncSearchSubmitRequest) { + r.TerminateAfter = &v + } +} + +// WithTimeout - explicit operation timeout. +func (f AsyncSearchSubmit) WithTimeout(v time.Duration) func(*AsyncSearchSubmitRequest) { + return func(r *AsyncSearchSubmitRequest) { + r.Timeout = v + } +} + +// WithTrackScores - whether to calculate and return scores even if they are not used for sorting. +func (f AsyncSearchSubmit) WithTrackScores(v bool) func(*AsyncSearchSubmitRequest) { + return func(r *AsyncSearchSubmitRequest) { + r.TrackScores = &v + } +} + +// WithTrackTotalHits - indicate if the number of documents that match the query should be tracked. +func (f AsyncSearchSubmit) WithTrackTotalHits(v bool) func(*AsyncSearchSubmitRequest) { + return func(r *AsyncSearchSubmitRequest) { + r.TrackTotalHits = &v + } +} + +// WithTypedKeys - specify whether aggregation and suggester names should be prefixed by their respective types in the response. +func (f AsyncSearchSubmit) WithTypedKeys(v bool) func(*AsyncSearchSubmitRequest) { + return func(r *AsyncSearchSubmitRequest) { + r.TypedKeys = &v + } +} + +// WithVersion - specify whether to return document version as part of a hit. +func (f AsyncSearchSubmit) WithVersion(v bool) func(*AsyncSearchSubmitRequest) { + return func(r *AsyncSearchSubmitRequest) { + r.Version = &v + } +} + +// WithWaitForCompletionTimeout - specify the time that the request should block waiting for the final response. +func (f AsyncSearchSubmit) WithWaitForCompletionTimeout(v time.Duration) func(*AsyncSearchSubmitRequest) { + return func(r *AsyncSearchSubmitRequest) { + r.WaitForCompletionTimeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f AsyncSearchSubmit) WithPretty() func(*AsyncSearchSubmitRequest) { + return func(r *AsyncSearchSubmitRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f AsyncSearchSubmit) WithHuman() func(*AsyncSearchSubmitRequest) { + return func(r *AsyncSearchSubmitRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f AsyncSearchSubmit) WithErrorTrace() func(*AsyncSearchSubmitRequest) { + return func(r *AsyncSearchSubmitRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f AsyncSearchSubmit) WithFilterPath(v ...string) func(*AsyncSearchSubmitRequest) { + return func(r *AsyncSearchSubmitRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f AsyncSearchSubmit) WithHeader(h map[string]string) func(*AsyncSearchSubmitRequest) { + return func(r *AsyncSearchSubmitRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f AsyncSearchSubmit) WithOpaqueID(s string) func(*AsyncSearchSubmitRequest) { + return func(r *AsyncSearchSubmitRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.autoscaling.delete_autoscaling_policy.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.autoscaling.delete_autoscaling_policy.go new file mode 100644 index 00000000..7e494f4c --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.autoscaling.delete_autoscaling_policy.go @@ -0,0 +1,193 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newAutoscalingDeleteAutoscalingPolicyFunc(t Transport) AutoscalingDeleteAutoscalingPolicy { + return func(name string, o ...func(*AutoscalingDeleteAutoscalingPolicyRequest)) (*Response, error) { + var r = AutoscalingDeleteAutoscalingPolicyRequest{Name: name} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// AutoscalingDeleteAutoscalingPolicy - Deletes an autoscaling policy. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/autoscaling-delete-autoscaling-policy.html. +type AutoscalingDeleteAutoscalingPolicy func(name string, o ...func(*AutoscalingDeleteAutoscalingPolicyRequest)) (*Response, error) + +// AutoscalingDeleteAutoscalingPolicyRequest configures the Autoscaling Delete Autoscaling Policy API request. +type AutoscalingDeleteAutoscalingPolicyRequest struct { + Name string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r AutoscalingDeleteAutoscalingPolicyRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + path.Grow(1 + len("_autoscaling") + 1 + len("policy") + 1 + len(r.Name)) + path.WriteString("/") + path.WriteString("_autoscaling") + path.WriteString("/") + path.WriteString("policy") + path.WriteString("/") + path.WriteString(r.Name) + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f AutoscalingDeleteAutoscalingPolicy) WithContext(v context.Context) func(*AutoscalingDeleteAutoscalingPolicyRequest) { + return func(r *AutoscalingDeleteAutoscalingPolicyRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f AutoscalingDeleteAutoscalingPolicy) WithPretty() func(*AutoscalingDeleteAutoscalingPolicyRequest) { + return func(r *AutoscalingDeleteAutoscalingPolicyRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f AutoscalingDeleteAutoscalingPolicy) WithHuman() func(*AutoscalingDeleteAutoscalingPolicyRequest) { + return func(r *AutoscalingDeleteAutoscalingPolicyRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f AutoscalingDeleteAutoscalingPolicy) WithErrorTrace() func(*AutoscalingDeleteAutoscalingPolicyRequest) { + return func(r *AutoscalingDeleteAutoscalingPolicyRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f AutoscalingDeleteAutoscalingPolicy) WithFilterPath(v ...string) func(*AutoscalingDeleteAutoscalingPolicyRequest) { + return func(r *AutoscalingDeleteAutoscalingPolicyRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f AutoscalingDeleteAutoscalingPolicy) WithHeader(h map[string]string) func(*AutoscalingDeleteAutoscalingPolicyRequest) { + return func(r *AutoscalingDeleteAutoscalingPolicyRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f AutoscalingDeleteAutoscalingPolicy) WithOpaqueID(s string) func(*AutoscalingDeleteAutoscalingPolicyRequest) { + return func(r *AutoscalingDeleteAutoscalingPolicyRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.autoscaling.get_autoscaling_capacity.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.autoscaling.get_autoscaling_capacity.go new file mode 100644 index 00000000..febdadc9 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.autoscaling.get_autoscaling_capacity.go @@ -0,0 +1,186 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newAutoscalingGetAutoscalingCapacityFunc(t Transport) AutoscalingGetAutoscalingCapacity { + return func(o ...func(*AutoscalingGetAutoscalingCapacityRequest)) (*Response, error) { + var r = AutoscalingGetAutoscalingCapacityRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// AutoscalingGetAutoscalingCapacity - Gets the current autoscaling capacity based on the configured autoscaling policy. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/autoscaling-get-autoscaling-capacity.html. +type AutoscalingGetAutoscalingCapacity func(o ...func(*AutoscalingGetAutoscalingCapacityRequest)) (*Response, error) + +// AutoscalingGetAutoscalingCapacityRequest configures the Autoscaling Get Autoscaling Capacity API request. +type AutoscalingGetAutoscalingCapacityRequest struct { + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r AutoscalingGetAutoscalingCapacityRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(len("/_autoscaling/capacity")) + path.WriteString("/_autoscaling/capacity") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f AutoscalingGetAutoscalingCapacity) WithContext(v context.Context) func(*AutoscalingGetAutoscalingCapacityRequest) { + return func(r *AutoscalingGetAutoscalingCapacityRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f AutoscalingGetAutoscalingCapacity) WithPretty() func(*AutoscalingGetAutoscalingCapacityRequest) { + return func(r *AutoscalingGetAutoscalingCapacityRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f AutoscalingGetAutoscalingCapacity) WithHuman() func(*AutoscalingGetAutoscalingCapacityRequest) { + return func(r *AutoscalingGetAutoscalingCapacityRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f AutoscalingGetAutoscalingCapacity) WithErrorTrace() func(*AutoscalingGetAutoscalingCapacityRequest) { + return func(r *AutoscalingGetAutoscalingCapacityRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f AutoscalingGetAutoscalingCapacity) WithFilterPath(v ...string) func(*AutoscalingGetAutoscalingCapacityRequest) { + return func(r *AutoscalingGetAutoscalingCapacityRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f AutoscalingGetAutoscalingCapacity) WithHeader(h map[string]string) func(*AutoscalingGetAutoscalingCapacityRequest) { + return func(r *AutoscalingGetAutoscalingCapacityRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f AutoscalingGetAutoscalingCapacity) WithOpaqueID(s string) func(*AutoscalingGetAutoscalingCapacityRequest) { + return func(r *AutoscalingGetAutoscalingCapacityRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.autoscaling.get_autoscaling_decision.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.autoscaling.get_autoscaling_decision.go new file mode 100644 index 00000000..b5e957ea --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.autoscaling.get_autoscaling_decision.go @@ -0,0 +1,198 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.10.0: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newAutoscalingGetAutoscalingDecisionFunc(t Transport) AutoscalingGetAutoscalingDecision { + return func(o ...func(*AutoscalingGetAutoscalingDecisionRequest)) (*Response, error) { + var r = AutoscalingGetAutoscalingDecisionRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// AutoscalingGetAutoscalingDecision - Gets the current autoscaling decision based on the configured autoscaling policy, indicating whether or not autoscaling is needed. +// +// This API is experimental. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/autoscaling-get-autoscaling-decision.html. +// +type AutoscalingGetAutoscalingDecision func(o ...func(*AutoscalingGetAutoscalingDecisionRequest)) (*Response, error) + +// AutoscalingGetAutoscalingDecisionRequest configures the Autoscaling Get Autoscaling Decision API request. +// +type AutoscalingGetAutoscalingDecisionRequest struct { + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +// +func (r AutoscalingGetAutoscalingDecisionRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(len("/_autoscaling/decision")) + path.WriteString("/_autoscaling/decision") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +// +func (f AutoscalingGetAutoscalingDecision) WithContext(v context.Context) func(*AutoscalingGetAutoscalingDecisionRequest) { + return func(r *AutoscalingGetAutoscalingDecisionRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +// +func (f AutoscalingGetAutoscalingDecision) WithPretty() func(*AutoscalingGetAutoscalingDecisionRequest) { + return func(r *AutoscalingGetAutoscalingDecisionRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +// +func (f AutoscalingGetAutoscalingDecision) WithHuman() func(*AutoscalingGetAutoscalingDecisionRequest) { + return func(r *AutoscalingGetAutoscalingDecisionRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +// +func (f AutoscalingGetAutoscalingDecision) WithErrorTrace() func(*AutoscalingGetAutoscalingDecisionRequest) { + return func(r *AutoscalingGetAutoscalingDecisionRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +// +func (f AutoscalingGetAutoscalingDecision) WithFilterPath(v ...string) func(*AutoscalingGetAutoscalingDecisionRequest) { + return func(r *AutoscalingGetAutoscalingDecisionRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +// +func (f AutoscalingGetAutoscalingDecision) WithHeader(h map[string]string) func(*AutoscalingGetAutoscalingDecisionRequest) { + return func(r *AutoscalingGetAutoscalingDecisionRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +// +func (f AutoscalingGetAutoscalingDecision) WithOpaqueID(s string) func(*AutoscalingGetAutoscalingDecisionRequest) { + return func(r *AutoscalingGetAutoscalingDecisionRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.autoscaling.get_autoscaling_policy.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.autoscaling.get_autoscaling_policy.go new file mode 100644 index 00000000..63caeee5 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.autoscaling.get_autoscaling_policy.go @@ -0,0 +1,193 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newAutoscalingGetAutoscalingPolicyFunc(t Transport) AutoscalingGetAutoscalingPolicy { + return func(name string, o ...func(*AutoscalingGetAutoscalingPolicyRequest)) (*Response, error) { + var r = AutoscalingGetAutoscalingPolicyRequest{Name: name} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// AutoscalingGetAutoscalingPolicy - Retrieves an autoscaling policy. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/autoscaling-get-autoscaling-policy.html. +type AutoscalingGetAutoscalingPolicy func(name string, o ...func(*AutoscalingGetAutoscalingPolicyRequest)) (*Response, error) + +// AutoscalingGetAutoscalingPolicyRequest configures the Autoscaling Get Autoscaling Policy API request. +type AutoscalingGetAutoscalingPolicyRequest struct { + Name string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r AutoscalingGetAutoscalingPolicyRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_autoscaling") + 1 + len("policy") + 1 + len(r.Name)) + path.WriteString("/") + path.WriteString("_autoscaling") + path.WriteString("/") + path.WriteString("policy") + path.WriteString("/") + path.WriteString(r.Name) + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f AutoscalingGetAutoscalingPolicy) WithContext(v context.Context) func(*AutoscalingGetAutoscalingPolicyRequest) { + return func(r *AutoscalingGetAutoscalingPolicyRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f AutoscalingGetAutoscalingPolicy) WithPretty() func(*AutoscalingGetAutoscalingPolicyRequest) { + return func(r *AutoscalingGetAutoscalingPolicyRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f AutoscalingGetAutoscalingPolicy) WithHuman() func(*AutoscalingGetAutoscalingPolicyRequest) { + return func(r *AutoscalingGetAutoscalingPolicyRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f AutoscalingGetAutoscalingPolicy) WithErrorTrace() func(*AutoscalingGetAutoscalingPolicyRequest) { + return func(r *AutoscalingGetAutoscalingPolicyRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f AutoscalingGetAutoscalingPolicy) WithFilterPath(v ...string) func(*AutoscalingGetAutoscalingPolicyRequest) { + return func(r *AutoscalingGetAutoscalingPolicyRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f AutoscalingGetAutoscalingPolicy) WithHeader(h map[string]string) func(*AutoscalingGetAutoscalingPolicyRequest) { + return func(r *AutoscalingGetAutoscalingPolicyRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f AutoscalingGetAutoscalingPolicy) WithOpaqueID(s string) func(*AutoscalingGetAutoscalingPolicyRequest) { + return func(r *AutoscalingGetAutoscalingPolicyRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.autoscaling.put_autoscaling_policy.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.autoscaling.put_autoscaling_policy.go new file mode 100644 index 00000000..0e209b73 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.autoscaling.put_autoscaling_policy.go @@ -0,0 +1,200 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newAutoscalingPutAutoscalingPolicyFunc(t Transport) AutoscalingPutAutoscalingPolicy { + return func(name string, body io.Reader, o ...func(*AutoscalingPutAutoscalingPolicyRequest)) (*Response, error) { + var r = AutoscalingPutAutoscalingPolicyRequest{Name: name, Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// AutoscalingPutAutoscalingPolicy - Creates a new autoscaling policy. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/autoscaling-put-autoscaling-policy.html. +type AutoscalingPutAutoscalingPolicy func(name string, body io.Reader, o ...func(*AutoscalingPutAutoscalingPolicyRequest)) (*Response, error) + +// AutoscalingPutAutoscalingPolicyRequest configures the Autoscaling Put Autoscaling Policy API request. +type AutoscalingPutAutoscalingPolicyRequest struct { + Body io.Reader + + Name string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r AutoscalingPutAutoscalingPolicyRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(1 + len("_autoscaling") + 1 + len("policy") + 1 + len(r.Name)) + path.WriteString("/") + path.WriteString("_autoscaling") + path.WriteString("/") + path.WriteString("policy") + path.WriteString("/") + path.WriteString(r.Name) + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f AutoscalingPutAutoscalingPolicy) WithContext(v context.Context) func(*AutoscalingPutAutoscalingPolicyRequest) { + return func(r *AutoscalingPutAutoscalingPolicyRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f AutoscalingPutAutoscalingPolicy) WithPretty() func(*AutoscalingPutAutoscalingPolicyRequest) { + return func(r *AutoscalingPutAutoscalingPolicyRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f AutoscalingPutAutoscalingPolicy) WithHuman() func(*AutoscalingPutAutoscalingPolicyRequest) { + return func(r *AutoscalingPutAutoscalingPolicyRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f AutoscalingPutAutoscalingPolicy) WithErrorTrace() func(*AutoscalingPutAutoscalingPolicyRequest) { + return func(r *AutoscalingPutAutoscalingPolicyRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f AutoscalingPutAutoscalingPolicy) WithFilterPath(v ...string) func(*AutoscalingPutAutoscalingPolicyRequest) { + return func(r *AutoscalingPutAutoscalingPolicyRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f AutoscalingPutAutoscalingPolicy) WithHeader(h map[string]string) func(*AutoscalingPutAutoscalingPolicyRequest) { + return func(r *AutoscalingPutAutoscalingPolicyRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f AutoscalingPutAutoscalingPolicy) WithOpaqueID(s string) func(*AutoscalingPutAutoscalingPolicyRequest) { + return func(r *AutoscalingPutAutoscalingPolicyRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.cat.ml_data_frame_analytics.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.cat.ml_data_frame_analytics.go new file mode 100644 index 00000000..abb1e421 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.cat.ml_data_frame_analytics.go @@ -0,0 +1,304 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newCatMLDataFrameAnalyticsFunc(t Transport) CatMLDataFrameAnalytics { + return func(o ...func(*CatMLDataFrameAnalyticsRequest)) (*Response, error) { + var r = CatMLDataFrameAnalyticsRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// CatMLDataFrameAnalytics - Gets configuration and usage information about data frame analytics jobs. +// +// See full documentation at http://www.elastic.co/guide/en/elasticsearch/reference/current/cat-dfanalytics.html. +type CatMLDataFrameAnalytics func(o ...func(*CatMLDataFrameAnalyticsRequest)) (*Response, error) + +// CatMLDataFrameAnalyticsRequest configures the CatML Data Frame Analytics API request. +type CatMLDataFrameAnalyticsRequest struct { + DocumentID string + + AllowNoMatch *bool + Bytes string + Format string + H []string + Help *bool + S []string + Time string + V *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r CatMLDataFrameAnalyticsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_cat") + 1 + len("ml") + 1 + len("data_frame") + 1 + len("analytics") + 1 + len(r.DocumentID)) + path.WriteString("/") + path.WriteString("_cat") + path.WriteString("/") + path.WriteString("ml") + path.WriteString("/") + path.WriteString("data_frame") + path.WriteString("/") + path.WriteString("analytics") + if r.DocumentID != "" { + path.WriteString("/") + path.WriteString(r.DocumentID) + } + + params = make(map[string]string) + + if r.AllowNoMatch != nil { + params["allow_no_match"] = strconv.FormatBool(*r.AllowNoMatch) + } + + if r.Bytes != "" { + params["bytes"] = r.Bytes + } + + if r.Format != "" { + params["format"] = r.Format + } + + if len(r.H) > 0 { + params["h"] = strings.Join(r.H, ",") + } + + if r.Help != nil { + params["help"] = strconv.FormatBool(*r.Help) + } + + if len(r.S) > 0 { + params["s"] = strings.Join(r.S, ",") + } + + if r.Time != "" { + params["time"] = r.Time + } + + if r.V != nil { + params["v"] = strconv.FormatBool(*r.V) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f CatMLDataFrameAnalytics) WithContext(v context.Context) func(*CatMLDataFrameAnalyticsRequest) { + return func(r *CatMLDataFrameAnalyticsRequest) { + r.ctx = v + } +} + +// WithDocumentID - the ID of the data frame analytics to fetch. +func (f CatMLDataFrameAnalytics) WithDocumentID(v string) func(*CatMLDataFrameAnalyticsRequest) { + return func(r *CatMLDataFrameAnalyticsRequest) { + r.DocumentID = v + } +} + +// WithAllowNoMatch - whether to ignore if a wildcard expression matches no configs. (this includes `_all` string or when no configs have been specified). +func (f CatMLDataFrameAnalytics) WithAllowNoMatch(v bool) func(*CatMLDataFrameAnalyticsRequest) { + return func(r *CatMLDataFrameAnalyticsRequest) { + r.AllowNoMatch = &v + } +} + +// WithBytes - the unit in which to display byte values. +func (f CatMLDataFrameAnalytics) WithBytes(v string) func(*CatMLDataFrameAnalyticsRequest) { + return func(r *CatMLDataFrameAnalyticsRequest) { + r.Bytes = v + } +} + +// WithFormat - a short version of the accept header, e.g. json, yaml. +func (f CatMLDataFrameAnalytics) WithFormat(v string) func(*CatMLDataFrameAnalyticsRequest) { + return func(r *CatMLDataFrameAnalyticsRequest) { + r.Format = v + } +} + +// WithH - comma-separated list of column names to display. +func (f CatMLDataFrameAnalytics) WithH(v ...string) func(*CatMLDataFrameAnalyticsRequest) { + return func(r *CatMLDataFrameAnalyticsRequest) { + r.H = v + } +} + +// WithHelp - return help information. +func (f CatMLDataFrameAnalytics) WithHelp(v bool) func(*CatMLDataFrameAnalyticsRequest) { + return func(r *CatMLDataFrameAnalyticsRequest) { + r.Help = &v + } +} + +// WithS - comma-separated list of column names or column aliases to sort by. +func (f CatMLDataFrameAnalytics) WithS(v ...string) func(*CatMLDataFrameAnalyticsRequest) { + return func(r *CatMLDataFrameAnalyticsRequest) { + r.S = v + } +} + +// WithTime - the unit in which to display time values. +func (f CatMLDataFrameAnalytics) WithTime(v string) func(*CatMLDataFrameAnalyticsRequest) { + return func(r *CatMLDataFrameAnalyticsRequest) { + r.Time = v + } +} + +// WithV - verbose mode. display column headers. +func (f CatMLDataFrameAnalytics) WithV(v bool) func(*CatMLDataFrameAnalyticsRequest) { + return func(r *CatMLDataFrameAnalyticsRequest) { + r.V = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f CatMLDataFrameAnalytics) WithPretty() func(*CatMLDataFrameAnalyticsRequest) { + return func(r *CatMLDataFrameAnalyticsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f CatMLDataFrameAnalytics) WithHuman() func(*CatMLDataFrameAnalyticsRequest) { + return func(r *CatMLDataFrameAnalyticsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f CatMLDataFrameAnalytics) WithErrorTrace() func(*CatMLDataFrameAnalyticsRequest) { + return func(r *CatMLDataFrameAnalyticsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f CatMLDataFrameAnalytics) WithFilterPath(v ...string) func(*CatMLDataFrameAnalyticsRequest) { + return func(r *CatMLDataFrameAnalyticsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f CatMLDataFrameAnalytics) WithHeader(h map[string]string) func(*CatMLDataFrameAnalyticsRequest) { + return func(r *CatMLDataFrameAnalyticsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f CatMLDataFrameAnalytics) WithOpaqueID(s string) func(*CatMLDataFrameAnalyticsRequest) { + return func(r *CatMLDataFrameAnalyticsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.cat.ml_datafeeds.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.cat.ml_datafeeds.go new file mode 100644 index 00000000..31edcb10 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.cat.ml_datafeeds.go @@ -0,0 +1,302 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newCatMLDatafeedsFunc(t Transport) CatMLDatafeeds { + return func(o ...func(*CatMLDatafeedsRequest)) (*Response, error) { + var r = CatMLDatafeedsRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// CatMLDatafeeds - Gets configuration and usage information about datafeeds. +// +// See full documentation at http://www.elastic.co/guide/en/elasticsearch/reference/current/cat-datafeeds.html. +type CatMLDatafeeds func(o ...func(*CatMLDatafeedsRequest)) (*Response, error) + +// CatMLDatafeedsRequest configures the CatML Datafeeds API request. +type CatMLDatafeedsRequest struct { + DatafeedID string + + AllowNoDatafeeds *bool + AllowNoMatch *bool + Format string + H []string + Help *bool + S []string + Time string + V *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r CatMLDatafeedsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_cat") + 1 + len("ml") + 1 + len("datafeeds") + 1 + len(r.DatafeedID)) + path.WriteString("/") + path.WriteString("_cat") + path.WriteString("/") + path.WriteString("ml") + path.WriteString("/") + path.WriteString("datafeeds") + if r.DatafeedID != "" { + path.WriteString("/") + path.WriteString(r.DatafeedID) + } + + params = make(map[string]string) + + if r.AllowNoDatafeeds != nil { + params["allow_no_datafeeds"] = strconv.FormatBool(*r.AllowNoDatafeeds) + } + + if r.AllowNoMatch != nil { + params["allow_no_match"] = strconv.FormatBool(*r.AllowNoMatch) + } + + if r.Format != "" { + params["format"] = r.Format + } + + if len(r.H) > 0 { + params["h"] = strings.Join(r.H, ",") + } + + if r.Help != nil { + params["help"] = strconv.FormatBool(*r.Help) + } + + if len(r.S) > 0 { + params["s"] = strings.Join(r.S, ",") + } + + if r.Time != "" { + params["time"] = r.Time + } + + if r.V != nil { + params["v"] = strconv.FormatBool(*r.V) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f CatMLDatafeeds) WithContext(v context.Context) func(*CatMLDatafeedsRequest) { + return func(r *CatMLDatafeedsRequest) { + r.ctx = v + } +} + +// WithDatafeedID - the ID of the datafeeds stats to fetch. +func (f CatMLDatafeeds) WithDatafeedID(v string) func(*CatMLDatafeedsRequest) { + return func(r *CatMLDatafeedsRequest) { + r.DatafeedID = v + } +} + +// WithAllowNoDatafeeds - whether to ignore if a wildcard expression matches no datafeeds. (this includes `_all` string or when no datafeeds have been specified). +func (f CatMLDatafeeds) WithAllowNoDatafeeds(v bool) func(*CatMLDatafeedsRequest) { + return func(r *CatMLDatafeedsRequest) { + r.AllowNoDatafeeds = &v + } +} + +// WithAllowNoMatch - whether to ignore if a wildcard expression matches no datafeeds. (this includes `_all` string or when no datafeeds have been specified). +func (f CatMLDatafeeds) WithAllowNoMatch(v bool) func(*CatMLDatafeedsRequest) { + return func(r *CatMLDatafeedsRequest) { + r.AllowNoMatch = &v + } +} + +// WithFormat - a short version of the accept header, e.g. json, yaml. +func (f CatMLDatafeeds) WithFormat(v string) func(*CatMLDatafeedsRequest) { + return func(r *CatMLDatafeedsRequest) { + r.Format = v + } +} + +// WithH - comma-separated list of column names to display. +func (f CatMLDatafeeds) WithH(v ...string) func(*CatMLDatafeedsRequest) { + return func(r *CatMLDatafeedsRequest) { + r.H = v + } +} + +// WithHelp - return help information. +func (f CatMLDatafeeds) WithHelp(v bool) func(*CatMLDatafeedsRequest) { + return func(r *CatMLDatafeedsRequest) { + r.Help = &v + } +} + +// WithS - comma-separated list of column names or column aliases to sort by. +func (f CatMLDatafeeds) WithS(v ...string) func(*CatMLDatafeedsRequest) { + return func(r *CatMLDatafeedsRequest) { + r.S = v + } +} + +// WithTime - the unit in which to display time values. +func (f CatMLDatafeeds) WithTime(v string) func(*CatMLDatafeedsRequest) { + return func(r *CatMLDatafeedsRequest) { + r.Time = v + } +} + +// WithV - verbose mode. display column headers. +func (f CatMLDatafeeds) WithV(v bool) func(*CatMLDatafeedsRequest) { + return func(r *CatMLDatafeedsRequest) { + r.V = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f CatMLDatafeeds) WithPretty() func(*CatMLDatafeedsRequest) { + return func(r *CatMLDatafeedsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f CatMLDatafeeds) WithHuman() func(*CatMLDatafeedsRequest) { + return func(r *CatMLDatafeedsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f CatMLDatafeeds) WithErrorTrace() func(*CatMLDatafeedsRequest) { + return func(r *CatMLDatafeedsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f CatMLDatafeeds) WithFilterPath(v ...string) func(*CatMLDatafeedsRequest) { + return func(r *CatMLDatafeedsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f CatMLDatafeeds) WithHeader(h map[string]string) func(*CatMLDatafeedsRequest) { + return func(r *CatMLDatafeedsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f CatMLDatafeeds) WithOpaqueID(s string) func(*CatMLDatafeedsRequest) { + return func(r *CatMLDatafeedsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.cat.ml_jobs.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.cat.ml_jobs.go new file mode 100644 index 00000000..db594193 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.cat.ml_jobs.go @@ -0,0 +1,314 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newCatMLJobsFunc(t Transport) CatMLJobs { + return func(o ...func(*CatMLJobsRequest)) (*Response, error) { + var r = CatMLJobsRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// CatMLJobs - Gets configuration and usage information about anomaly detection jobs. +// +// See full documentation at http://www.elastic.co/guide/en/elasticsearch/reference/current/cat-anomaly-detectors.html. +type CatMLJobs func(o ...func(*CatMLJobsRequest)) (*Response, error) + +// CatMLJobsRequest configures the CatML Jobs API request. +type CatMLJobsRequest struct { + JobID string + + AllowNoJobs *bool + AllowNoMatch *bool + Bytes string + Format string + H []string + Help *bool + S []string + Time string + V *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r CatMLJobsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_cat") + 1 + len("ml") + 1 + len("anomaly_detectors") + 1 + len(r.JobID)) + path.WriteString("/") + path.WriteString("_cat") + path.WriteString("/") + path.WriteString("ml") + path.WriteString("/") + path.WriteString("anomaly_detectors") + if r.JobID != "" { + path.WriteString("/") + path.WriteString(r.JobID) + } + + params = make(map[string]string) + + if r.AllowNoJobs != nil { + params["allow_no_jobs"] = strconv.FormatBool(*r.AllowNoJobs) + } + + if r.AllowNoMatch != nil { + params["allow_no_match"] = strconv.FormatBool(*r.AllowNoMatch) + } + + if r.Bytes != "" { + params["bytes"] = r.Bytes + } + + if r.Format != "" { + params["format"] = r.Format + } + + if len(r.H) > 0 { + params["h"] = strings.Join(r.H, ",") + } + + if r.Help != nil { + params["help"] = strconv.FormatBool(*r.Help) + } + + if len(r.S) > 0 { + params["s"] = strings.Join(r.S, ",") + } + + if r.Time != "" { + params["time"] = r.Time + } + + if r.V != nil { + params["v"] = strconv.FormatBool(*r.V) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f CatMLJobs) WithContext(v context.Context) func(*CatMLJobsRequest) { + return func(r *CatMLJobsRequest) { + r.ctx = v + } +} + +// WithJobID - the ID of the jobs stats to fetch. +func (f CatMLJobs) WithJobID(v string) func(*CatMLJobsRequest) { + return func(r *CatMLJobsRequest) { + r.JobID = v + } +} + +// WithAllowNoJobs - whether to ignore if a wildcard expression matches no jobs. (this includes `_all` string or when no jobs have been specified). +func (f CatMLJobs) WithAllowNoJobs(v bool) func(*CatMLJobsRequest) { + return func(r *CatMLJobsRequest) { + r.AllowNoJobs = &v + } +} + +// WithAllowNoMatch - whether to ignore if a wildcard expression matches no jobs. (this includes `_all` string or when no jobs have been specified). +func (f CatMLJobs) WithAllowNoMatch(v bool) func(*CatMLJobsRequest) { + return func(r *CatMLJobsRequest) { + r.AllowNoMatch = &v + } +} + +// WithBytes - the unit in which to display byte values. +func (f CatMLJobs) WithBytes(v string) func(*CatMLJobsRequest) { + return func(r *CatMLJobsRequest) { + r.Bytes = v + } +} + +// WithFormat - a short version of the accept header, e.g. json, yaml. +func (f CatMLJobs) WithFormat(v string) func(*CatMLJobsRequest) { + return func(r *CatMLJobsRequest) { + r.Format = v + } +} + +// WithH - comma-separated list of column names to display. +func (f CatMLJobs) WithH(v ...string) func(*CatMLJobsRequest) { + return func(r *CatMLJobsRequest) { + r.H = v + } +} + +// WithHelp - return help information. +func (f CatMLJobs) WithHelp(v bool) func(*CatMLJobsRequest) { + return func(r *CatMLJobsRequest) { + r.Help = &v + } +} + +// WithS - comma-separated list of column names or column aliases to sort by. +func (f CatMLJobs) WithS(v ...string) func(*CatMLJobsRequest) { + return func(r *CatMLJobsRequest) { + r.S = v + } +} + +// WithTime - the unit in which to display time values. +func (f CatMLJobs) WithTime(v string) func(*CatMLJobsRequest) { + return func(r *CatMLJobsRequest) { + r.Time = v + } +} + +// WithV - verbose mode. display column headers. +func (f CatMLJobs) WithV(v bool) func(*CatMLJobsRequest) { + return func(r *CatMLJobsRequest) { + r.V = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f CatMLJobs) WithPretty() func(*CatMLJobsRequest) { + return func(r *CatMLJobsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f CatMLJobs) WithHuman() func(*CatMLJobsRequest) { + return func(r *CatMLJobsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f CatMLJobs) WithErrorTrace() func(*CatMLJobsRequest) { + return func(r *CatMLJobsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f CatMLJobs) WithFilterPath(v ...string) func(*CatMLJobsRequest) { + return func(r *CatMLJobsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f CatMLJobs) WithHeader(h map[string]string) func(*CatMLJobsRequest) { + return func(r *CatMLJobsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f CatMLJobs) WithOpaqueID(s string) func(*CatMLJobsRequest) { + return func(r *CatMLJobsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.cat.ml_trained_models.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.cat.ml_trained_models.go new file mode 100644 index 00000000..de26c268 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.cat.ml_trained_models.go @@ -0,0 +1,326 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newCatMLTrainedModelsFunc(t Transport) CatMLTrainedModels { + return func(o ...func(*CatMLTrainedModelsRequest)) (*Response, error) { + var r = CatMLTrainedModelsRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// CatMLTrainedModels - Gets configuration and usage information about inference trained models. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-trained-model.html. +type CatMLTrainedModels func(o ...func(*CatMLTrainedModelsRequest)) (*Response, error) + +// CatMLTrainedModelsRequest configures the CatML Trained Models API request. +type CatMLTrainedModelsRequest struct { + ModelID string + + AllowNoMatch *bool + Bytes string + Format string + From *int + H []string + Help *bool + S []string + Size *int + Time string + V *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r CatMLTrainedModelsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_cat") + 1 + len("ml") + 1 + len("trained_models") + 1 + len(r.ModelID)) + path.WriteString("/") + path.WriteString("_cat") + path.WriteString("/") + path.WriteString("ml") + path.WriteString("/") + path.WriteString("trained_models") + if r.ModelID != "" { + path.WriteString("/") + path.WriteString(r.ModelID) + } + + params = make(map[string]string) + + if r.AllowNoMatch != nil { + params["allow_no_match"] = strconv.FormatBool(*r.AllowNoMatch) + } + + if r.Bytes != "" { + params["bytes"] = r.Bytes + } + + if r.Format != "" { + params["format"] = r.Format + } + + if r.From != nil { + params["from"] = strconv.FormatInt(int64(*r.From), 10) + } + + if len(r.H) > 0 { + params["h"] = strings.Join(r.H, ",") + } + + if r.Help != nil { + params["help"] = strconv.FormatBool(*r.Help) + } + + if len(r.S) > 0 { + params["s"] = strings.Join(r.S, ",") + } + + if r.Size != nil { + params["size"] = strconv.FormatInt(int64(*r.Size), 10) + } + + if r.Time != "" { + params["time"] = r.Time + } + + if r.V != nil { + params["v"] = strconv.FormatBool(*r.V) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f CatMLTrainedModels) WithContext(v context.Context) func(*CatMLTrainedModelsRequest) { + return func(r *CatMLTrainedModelsRequest) { + r.ctx = v + } +} + +// WithModelID - the ID of the trained models stats to fetch. +func (f CatMLTrainedModels) WithModelID(v string) func(*CatMLTrainedModelsRequest) { + return func(r *CatMLTrainedModelsRequest) { + r.ModelID = v + } +} + +// WithAllowNoMatch - whether to ignore if a wildcard expression matches no trained models. (this includes `_all` string or when no trained models have been specified). +func (f CatMLTrainedModels) WithAllowNoMatch(v bool) func(*CatMLTrainedModelsRequest) { + return func(r *CatMLTrainedModelsRequest) { + r.AllowNoMatch = &v + } +} + +// WithBytes - the unit in which to display byte values. +func (f CatMLTrainedModels) WithBytes(v string) func(*CatMLTrainedModelsRequest) { + return func(r *CatMLTrainedModelsRequest) { + r.Bytes = v + } +} + +// WithFormat - a short version of the accept header, e.g. json, yaml. +func (f CatMLTrainedModels) WithFormat(v string) func(*CatMLTrainedModelsRequest) { + return func(r *CatMLTrainedModelsRequest) { + r.Format = v + } +} + +// WithFrom - skips a number of trained models. +func (f CatMLTrainedModels) WithFrom(v int) func(*CatMLTrainedModelsRequest) { + return func(r *CatMLTrainedModelsRequest) { + r.From = &v + } +} + +// WithH - comma-separated list of column names to display. +func (f CatMLTrainedModels) WithH(v ...string) func(*CatMLTrainedModelsRequest) { + return func(r *CatMLTrainedModelsRequest) { + r.H = v + } +} + +// WithHelp - return help information. +func (f CatMLTrainedModels) WithHelp(v bool) func(*CatMLTrainedModelsRequest) { + return func(r *CatMLTrainedModelsRequest) { + r.Help = &v + } +} + +// WithS - comma-separated list of column names or column aliases to sort by. +func (f CatMLTrainedModels) WithS(v ...string) func(*CatMLTrainedModelsRequest) { + return func(r *CatMLTrainedModelsRequest) { + r.S = v + } +} + +// WithSize - specifies a max number of trained models to get. +func (f CatMLTrainedModels) WithSize(v int) func(*CatMLTrainedModelsRequest) { + return func(r *CatMLTrainedModelsRequest) { + r.Size = &v + } +} + +// WithTime - the unit in which to display time values. +func (f CatMLTrainedModels) WithTime(v string) func(*CatMLTrainedModelsRequest) { + return func(r *CatMLTrainedModelsRequest) { + r.Time = v + } +} + +// WithV - verbose mode. display column headers. +func (f CatMLTrainedModels) WithV(v bool) func(*CatMLTrainedModelsRequest) { + return func(r *CatMLTrainedModelsRequest) { + r.V = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f CatMLTrainedModels) WithPretty() func(*CatMLTrainedModelsRequest) { + return func(r *CatMLTrainedModelsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f CatMLTrainedModels) WithHuman() func(*CatMLTrainedModelsRequest) { + return func(r *CatMLTrainedModelsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f CatMLTrainedModels) WithErrorTrace() func(*CatMLTrainedModelsRequest) { + return func(r *CatMLTrainedModelsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f CatMLTrainedModels) WithFilterPath(v ...string) func(*CatMLTrainedModelsRequest) { + return func(r *CatMLTrainedModelsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f CatMLTrainedModels) WithHeader(h map[string]string) func(*CatMLTrainedModelsRequest) { + return func(r *CatMLTrainedModelsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f CatMLTrainedModels) WithOpaqueID(s string) func(*CatMLTrainedModelsRequest) { + return func(r *CatMLTrainedModelsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.cat.transforms.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.cat.transforms.go new file mode 100644 index 00000000..983b1700 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.cat.transforms.go @@ -0,0 +1,312 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newCatTransformsFunc(t Transport) CatTransforms { + return func(o ...func(*CatTransformsRequest)) (*Response, error) { + var r = CatTransformsRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// CatTransforms - Gets configuration and usage information about transforms. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-transforms.html. +type CatTransforms func(o ...func(*CatTransformsRequest)) (*Response, error) + +// CatTransformsRequest configures the Cat Transforms API request. +type CatTransformsRequest struct { + TransformID string + + AllowNoMatch *bool + Format string + From *int + H []string + Help *bool + S []string + Size *int + Time string + V *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r CatTransformsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_cat") + 1 + len("transforms") + 1 + len(r.TransformID)) + path.WriteString("/") + path.WriteString("_cat") + path.WriteString("/") + path.WriteString("transforms") + if r.TransformID != "" { + path.WriteString("/") + path.WriteString(r.TransformID) + } + + params = make(map[string]string) + + if r.AllowNoMatch != nil { + params["allow_no_match"] = strconv.FormatBool(*r.AllowNoMatch) + } + + if r.Format != "" { + params["format"] = r.Format + } + + if r.From != nil { + params["from"] = strconv.FormatInt(int64(*r.From), 10) + } + + if len(r.H) > 0 { + params["h"] = strings.Join(r.H, ",") + } + + if r.Help != nil { + params["help"] = strconv.FormatBool(*r.Help) + } + + if len(r.S) > 0 { + params["s"] = strings.Join(r.S, ",") + } + + if r.Size != nil { + params["size"] = strconv.FormatInt(int64(*r.Size), 10) + } + + if r.Time != "" { + params["time"] = r.Time + } + + if r.V != nil { + params["v"] = strconv.FormatBool(*r.V) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f CatTransforms) WithContext(v context.Context) func(*CatTransformsRequest) { + return func(r *CatTransformsRequest) { + r.ctx = v + } +} + +// WithTransformID - the ID of the transform for which to get stats. '_all' or '*' implies all transforms. +func (f CatTransforms) WithTransformID(v string) func(*CatTransformsRequest) { + return func(r *CatTransformsRequest) { + r.TransformID = v + } +} + +// WithAllowNoMatch - whether to ignore if a wildcard expression matches no transforms. (this includes `_all` string or when no transforms have been specified). +func (f CatTransforms) WithAllowNoMatch(v bool) func(*CatTransformsRequest) { + return func(r *CatTransformsRequest) { + r.AllowNoMatch = &v + } +} + +// WithFormat - a short version of the accept header, e.g. json, yaml. +func (f CatTransforms) WithFormat(v string) func(*CatTransformsRequest) { + return func(r *CatTransformsRequest) { + r.Format = v + } +} + +// WithFrom - skips a number of transform configs, defaults to 0. +func (f CatTransforms) WithFrom(v int) func(*CatTransformsRequest) { + return func(r *CatTransformsRequest) { + r.From = &v + } +} + +// WithH - comma-separated list of column names to display. +func (f CatTransforms) WithH(v ...string) func(*CatTransformsRequest) { + return func(r *CatTransformsRequest) { + r.H = v + } +} + +// WithHelp - return help information. +func (f CatTransforms) WithHelp(v bool) func(*CatTransformsRequest) { + return func(r *CatTransformsRequest) { + r.Help = &v + } +} + +// WithS - comma-separated list of column names or column aliases to sort by. +func (f CatTransforms) WithS(v ...string) func(*CatTransformsRequest) { + return func(r *CatTransformsRequest) { + r.S = v + } +} + +// WithSize - specifies a max number of transforms to get, defaults to 100. +func (f CatTransforms) WithSize(v int) func(*CatTransformsRequest) { + return func(r *CatTransformsRequest) { + r.Size = &v + } +} + +// WithTime - the unit in which to display time values. +func (f CatTransforms) WithTime(v string) func(*CatTransformsRequest) { + return func(r *CatTransformsRequest) { + r.Time = v + } +} + +// WithV - verbose mode. display column headers. +func (f CatTransforms) WithV(v bool) func(*CatTransformsRequest) { + return func(r *CatTransformsRequest) { + r.V = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f CatTransforms) WithPretty() func(*CatTransformsRequest) { + return func(r *CatTransformsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f CatTransforms) WithHuman() func(*CatTransformsRequest) { + return func(r *CatTransformsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f CatTransforms) WithErrorTrace() func(*CatTransformsRequest) { + return func(r *CatTransformsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f CatTransforms) WithFilterPath(v ...string) func(*CatTransformsRequest) { + return func(r *CatTransformsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f CatTransforms) WithHeader(h map[string]string) func(*CatTransformsRequest) { + return func(r *CatTransformsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f CatTransforms) WithOpaqueID(s string) func(*CatTransformsRequest) { + return func(r *CatTransformsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.delete_auto_follow_pattern.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.delete_auto_follow_pattern.go new file mode 100644 index 00000000..16703c6f --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.delete_auto_follow_pattern.go @@ -0,0 +1,193 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newCCRDeleteAutoFollowPatternFunc(t Transport) CCRDeleteAutoFollowPattern { + return func(name string, o ...func(*CCRDeleteAutoFollowPatternRequest)) (*Response, error) { + var r = CCRDeleteAutoFollowPatternRequest{Name: name} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// CCRDeleteAutoFollowPattern - Deletes auto-follow patterns. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-delete-auto-follow-pattern.html. +type CCRDeleteAutoFollowPattern func(name string, o ...func(*CCRDeleteAutoFollowPatternRequest)) (*Response, error) + +// CCRDeleteAutoFollowPatternRequest configures the CCR Delete Auto Follow Pattern API request. +type CCRDeleteAutoFollowPatternRequest struct { + Name string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r CCRDeleteAutoFollowPatternRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + path.Grow(1 + len("_ccr") + 1 + len("auto_follow") + 1 + len(r.Name)) + path.WriteString("/") + path.WriteString("_ccr") + path.WriteString("/") + path.WriteString("auto_follow") + path.WriteString("/") + path.WriteString(r.Name) + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f CCRDeleteAutoFollowPattern) WithContext(v context.Context) func(*CCRDeleteAutoFollowPatternRequest) { + return func(r *CCRDeleteAutoFollowPatternRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f CCRDeleteAutoFollowPattern) WithPretty() func(*CCRDeleteAutoFollowPatternRequest) { + return func(r *CCRDeleteAutoFollowPatternRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f CCRDeleteAutoFollowPattern) WithHuman() func(*CCRDeleteAutoFollowPatternRequest) { + return func(r *CCRDeleteAutoFollowPatternRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f CCRDeleteAutoFollowPattern) WithErrorTrace() func(*CCRDeleteAutoFollowPatternRequest) { + return func(r *CCRDeleteAutoFollowPatternRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f CCRDeleteAutoFollowPattern) WithFilterPath(v ...string) func(*CCRDeleteAutoFollowPatternRequest) { + return func(r *CCRDeleteAutoFollowPatternRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f CCRDeleteAutoFollowPattern) WithHeader(h map[string]string) func(*CCRDeleteAutoFollowPatternRequest) { + return func(r *CCRDeleteAutoFollowPatternRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f CCRDeleteAutoFollowPattern) WithOpaqueID(s string) func(*CCRDeleteAutoFollowPatternRequest) { + return func(r *CCRDeleteAutoFollowPatternRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.follow.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.follow.go new file mode 100644 index 00000000..6f58bce7 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.follow.go @@ -0,0 +1,213 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newCCRFollowFunc(t Transport) CCRFollow { + return func(index string, body io.Reader, o ...func(*CCRFollowRequest)) (*Response, error) { + var r = CCRFollowRequest{Index: index, Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// CCRFollow - Creates a new follower index configured to follow the referenced leader index. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-follow.html. +type CCRFollow func(index string, body io.Reader, o ...func(*CCRFollowRequest)) (*Response, error) + +// CCRFollowRequest configures the CCR Follow API request. +type CCRFollowRequest struct { + Index string + + Body io.Reader + + WaitForActiveShards string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r CCRFollowRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(1 + len(r.Index) + 1 + len("_ccr") + 1 + len("follow")) + path.WriteString("/") + path.WriteString(r.Index) + path.WriteString("/") + path.WriteString("_ccr") + path.WriteString("/") + path.WriteString("follow") + + params = make(map[string]string) + + if r.WaitForActiveShards != "" { + params["wait_for_active_shards"] = r.WaitForActiveShards + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f CCRFollow) WithContext(v context.Context) func(*CCRFollowRequest) { + return func(r *CCRFollowRequest) { + r.ctx = v + } +} + +// WithWaitForActiveShards - sets the number of shard copies that must be active before returning. defaults to 0. set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1). +func (f CCRFollow) WithWaitForActiveShards(v string) func(*CCRFollowRequest) { + return func(r *CCRFollowRequest) { + r.WaitForActiveShards = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f CCRFollow) WithPretty() func(*CCRFollowRequest) { + return func(r *CCRFollowRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f CCRFollow) WithHuman() func(*CCRFollowRequest) { + return func(r *CCRFollowRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f CCRFollow) WithErrorTrace() func(*CCRFollowRequest) { + return func(r *CCRFollowRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f CCRFollow) WithFilterPath(v ...string) func(*CCRFollowRequest) { + return func(r *CCRFollowRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f CCRFollow) WithHeader(h map[string]string) func(*CCRFollowRequest) { + return func(r *CCRFollowRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f CCRFollow) WithOpaqueID(s string) func(*CCRFollowRequest) { + return func(r *CCRFollowRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.follow_info.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.follow_info.go new file mode 100644 index 00000000..9820b08f --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.follow_info.go @@ -0,0 +1,198 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "errors" + "net/http" + "strings" +) + +func newCCRFollowInfoFunc(t Transport) CCRFollowInfo { + return func(index []string, o ...func(*CCRFollowInfoRequest)) (*Response, error) { + var r = CCRFollowInfoRequest{Index: index} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// CCRFollowInfo - Retrieves information about all follower indices, including parameters and status for each follower index +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-follow-info.html. +type CCRFollowInfo func(index []string, o ...func(*CCRFollowInfoRequest)) (*Response, error) + +// CCRFollowInfoRequest configures the CCR Follow Info API request. +type CCRFollowInfoRequest struct { + Index []string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r CCRFollowInfoRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + if len(r.Index) == 0 { + return nil, errors.New("index is required and cannot be nil or empty") + } + + path.Grow(1 + len(strings.Join(r.Index, ",")) + 1 + len("_ccr") + 1 + len("info")) + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + path.WriteString("/") + path.WriteString("_ccr") + path.WriteString("/") + path.WriteString("info") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f CCRFollowInfo) WithContext(v context.Context) func(*CCRFollowInfoRequest) { + return func(r *CCRFollowInfoRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f CCRFollowInfo) WithPretty() func(*CCRFollowInfoRequest) { + return func(r *CCRFollowInfoRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f CCRFollowInfo) WithHuman() func(*CCRFollowInfoRequest) { + return func(r *CCRFollowInfoRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f CCRFollowInfo) WithErrorTrace() func(*CCRFollowInfoRequest) { + return func(r *CCRFollowInfoRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f CCRFollowInfo) WithFilterPath(v ...string) func(*CCRFollowInfoRequest) { + return func(r *CCRFollowInfoRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f CCRFollowInfo) WithHeader(h map[string]string) func(*CCRFollowInfoRequest) { + return func(r *CCRFollowInfoRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f CCRFollowInfo) WithOpaqueID(s string) func(*CCRFollowInfoRequest) { + return func(r *CCRFollowInfoRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.follow_stats.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.follow_stats.go new file mode 100644 index 00000000..c4bd986b --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.follow_stats.go @@ -0,0 +1,198 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "errors" + "net/http" + "strings" +) + +func newCCRFollowStatsFunc(t Transport) CCRFollowStats { + return func(index []string, o ...func(*CCRFollowStatsRequest)) (*Response, error) { + var r = CCRFollowStatsRequest{Index: index} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// CCRFollowStats - Retrieves follower stats. return shard-level stats about the following tasks associated with each shard for the specified indices. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-follow-stats.html. +type CCRFollowStats func(index []string, o ...func(*CCRFollowStatsRequest)) (*Response, error) + +// CCRFollowStatsRequest configures the CCR Follow Stats API request. +type CCRFollowStatsRequest struct { + Index []string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r CCRFollowStatsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + if len(r.Index) == 0 { + return nil, errors.New("index is required and cannot be nil or empty") + } + + path.Grow(1 + len(strings.Join(r.Index, ",")) + 1 + len("_ccr") + 1 + len("stats")) + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + path.WriteString("/") + path.WriteString("_ccr") + path.WriteString("/") + path.WriteString("stats") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f CCRFollowStats) WithContext(v context.Context) func(*CCRFollowStatsRequest) { + return func(r *CCRFollowStatsRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f CCRFollowStats) WithPretty() func(*CCRFollowStatsRequest) { + return func(r *CCRFollowStatsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f CCRFollowStats) WithHuman() func(*CCRFollowStatsRequest) { + return func(r *CCRFollowStatsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f CCRFollowStats) WithErrorTrace() func(*CCRFollowStatsRequest) { + return func(r *CCRFollowStatsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f CCRFollowStats) WithFilterPath(v ...string) func(*CCRFollowStatsRequest) { + return func(r *CCRFollowStatsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f CCRFollowStats) WithHeader(h map[string]string) func(*CCRFollowStatsRequest) { + return func(r *CCRFollowStatsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f CCRFollowStats) WithOpaqueID(s string) func(*CCRFollowStatsRequest) { + return func(r *CCRFollowStatsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.forget_follower.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.forget_follower.go new file mode 100644 index 00000000..e6dce8ef --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.forget_follower.go @@ -0,0 +1,200 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newCCRForgetFollowerFunc(t Transport) CCRForgetFollower { + return func(index string, body io.Reader, o ...func(*CCRForgetFollowerRequest)) (*Response, error) { + var r = CCRForgetFollowerRequest{Index: index, Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// CCRForgetFollower - Removes the follower retention leases from the leader. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-forget-follower.html. +type CCRForgetFollower func(index string, body io.Reader, o ...func(*CCRForgetFollowerRequest)) (*Response, error) + +// CCRForgetFollowerRequest configures the CCR Forget Follower API request. +type CCRForgetFollowerRequest struct { + Index string + + Body io.Reader + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r CCRForgetFollowerRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len(r.Index) + 1 + len("_ccr") + 1 + len("forget_follower")) + path.WriteString("/") + path.WriteString(r.Index) + path.WriteString("/") + path.WriteString("_ccr") + path.WriteString("/") + path.WriteString("forget_follower") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f CCRForgetFollower) WithContext(v context.Context) func(*CCRForgetFollowerRequest) { + return func(r *CCRForgetFollowerRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f CCRForgetFollower) WithPretty() func(*CCRForgetFollowerRequest) { + return func(r *CCRForgetFollowerRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f CCRForgetFollower) WithHuman() func(*CCRForgetFollowerRequest) { + return func(r *CCRForgetFollowerRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f CCRForgetFollower) WithErrorTrace() func(*CCRForgetFollowerRequest) { + return func(r *CCRForgetFollowerRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f CCRForgetFollower) WithFilterPath(v ...string) func(*CCRForgetFollowerRequest) { + return func(r *CCRForgetFollowerRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f CCRForgetFollower) WithHeader(h map[string]string) func(*CCRForgetFollowerRequest) { + return func(r *CCRForgetFollowerRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f CCRForgetFollower) WithOpaqueID(s string) func(*CCRForgetFollowerRequest) { + return func(r *CCRForgetFollowerRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.get_auto_follow_pattern.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.get_auto_follow_pattern.go new file mode 100644 index 00000000..5108036d --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.get_auto_follow_pattern.go @@ -0,0 +1,202 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newCCRGetAutoFollowPatternFunc(t Transport) CCRGetAutoFollowPattern { + return func(o ...func(*CCRGetAutoFollowPatternRequest)) (*Response, error) { + var r = CCRGetAutoFollowPatternRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// CCRGetAutoFollowPattern - Gets configured auto-follow patterns. Returns the specified auto-follow pattern collection. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-auto-follow-pattern.html. +type CCRGetAutoFollowPattern func(o ...func(*CCRGetAutoFollowPatternRequest)) (*Response, error) + +// CCRGetAutoFollowPatternRequest configures the CCR Get Auto Follow Pattern API request. +type CCRGetAutoFollowPatternRequest struct { + Name string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r CCRGetAutoFollowPatternRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_ccr") + 1 + len("auto_follow") + 1 + len(r.Name)) + path.WriteString("/") + path.WriteString("_ccr") + path.WriteString("/") + path.WriteString("auto_follow") + if r.Name != "" { + path.WriteString("/") + path.WriteString(r.Name) + } + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f CCRGetAutoFollowPattern) WithContext(v context.Context) func(*CCRGetAutoFollowPatternRequest) { + return func(r *CCRGetAutoFollowPatternRequest) { + r.ctx = v + } +} + +// WithName - the name of the auto follow pattern.. +func (f CCRGetAutoFollowPattern) WithName(v string) func(*CCRGetAutoFollowPatternRequest) { + return func(r *CCRGetAutoFollowPatternRequest) { + r.Name = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f CCRGetAutoFollowPattern) WithPretty() func(*CCRGetAutoFollowPatternRequest) { + return func(r *CCRGetAutoFollowPatternRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f CCRGetAutoFollowPattern) WithHuman() func(*CCRGetAutoFollowPatternRequest) { + return func(r *CCRGetAutoFollowPatternRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f CCRGetAutoFollowPattern) WithErrorTrace() func(*CCRGetAutoFollowPatternRequest) { + return func(r *CCRGetAutoFollowPatternRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f CCRGetAutoFollowPattern) WithFilterPath(v ...string) func(*CCRGetAutoFollowPatternRequest) { + return func(r *CCRGetAutoFollowPatternRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f CCRGetAutoFollowPattern) WithHeader(h map[string]string) func(*CCRGetAutoFollowPatternRequest) { + return func(r *CCRGetAutoFollowPatternRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f CCRGetAutoFollowPattern) WithOpaqueID(s string) func(*CCRGetAutoFollowPatternRequest) { + return func(r *CCRGetAutoFollowPatternRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.pause_auto_follow_pattern.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.pause_auto_follow_pattern.go new file mode 100644 index 00000000..d55fd0ac --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.pause_auto_follow_pattern.go @@ -0,0 +1,195 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newCCRPauseAutoFollowPatternFunc(t Transport) CCRPauseAutoFollowPattern { + return func(name string, o ...func(*CCRPauseAutoFollowPatternRequest)) (*Response, error) { + var r = CCRPauseAutoFollowPatternRequest{Name: name} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// CCRPauseAutoFollowPattern - Pauses an auto-follow pattern +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-pause-auto-follow-pattern.html. +type CCRPauseAutoFollowPattern func(name string, o ...func(*CCRPauseAutoFollowPatternRequest)) (*Response, error) + +// CCRPauseAutoFollowPatternRequest configures the CCR Pause Auto Follow Pattern API request. +type CCRPauseAutoFollowPatternRequest struct { + Name string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r CCRPauseAutoFollowPatternRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_ccr") + 1 + len("auto_follow") + 1 + len(r.Name) + 1 + len("pause")) + path.WriteString("/") + path.WriteString("_ccr") + path.WriteString("/") + path.WriteString("auto_follow") + path.WriteString("/") + path.WriteString(r.Name) + path.WriteString("/") + path.WriteString("pause") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f CCRPauseAutoFollowPattern) WithContext(v context.Context) func(*CCRPauseAutoFollowPatternRequest) { + return func(r *CCRPauseAutoFollowPatternRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f CCRPauseAutoFollowPattern) WithPretty() func(*CCRPauseAutoFollowPatternRequest) { + return func(r *CCRPauseAutoFollowPatternRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f CCRPauseAutoFollowPattern) WithHuman() func(*CCRPauseAutoFollowPatternRequest) { + return func(r *CCRPauseAutoFollowPatternRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f CCRPauseAutoFollowPattern) WithErrorTrace() func(*CCRPauseAutoFollowPatternRequest) { + return func(r *CCRPauseAutoFollowPatternRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f CCRPauseAutoFollowPattern) WithFilterPath(v ...string) func(*CCRPauseAutoFollowPatternRequest) { + return func(r *CCRPauseAutoFollowPatternRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f CCRPauseAutoFollowPattern) WithHeader(h map[string]string) func(*CCRPauseAutoFollowPatternRequest) { + return func(r *CCRPauseAutoFollowPatternRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f CCRPauseAutoFollowPattern) WithOpaqueID(s string) func(*CCRPauseAutoFollowPatternRequest) { + return func(r *CCRPauseAutoFollowPatternRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.pause_follow.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.pause_follow.go new file mode 100644 index 00000000..5ebbca25 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.pause_follow.go @@ -0,0 +1,193 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newCCRPauseFollowFunc(t Transport) CCRPauseFollow { + return func(index string, o ...func(*CCRPauseFollowRequest)) (*Response, error) { + var r = CCRPauseFollowRequest{Index: index} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// CCRPauseFollow - Pauses a follower index. The follower index will not fetch any additional operations from the leader index. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-pause-follow.html. +type CCRPauseFollow func(index string, o ...func(*CCRPauseFollowRequest)) (*Response, error) + +// CCRPauseFollowRequest configures the CCR Pause Follow API request. +type CCRPauseFollowRequest struct { + Index string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r CCRPauseFollowRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len(r.Index) + 1 + len("_ccr") + 1 + len("pause_follow")) + path.WriteString("/") + path.WriteString(r.Index) + path.WriteString("/") + path.WriteString("_ccr") + path.WriteString("/") + path.WriteString("pause_follow") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f CCRPauseFollow) WithContext(v context.Context) func(*CCRPauseFollowRequest) { + return func(r *CCRPauseFollowRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f CCRPauseFollow) WithPretty() func(*CCRPauseFollowRequest) { + return func(r *CCRPauseFollowRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f CCRPauseFollow) WithHuman() func(*CCRPauseFollowRequest) { + return func(r *CCRPauseFollowRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f CCRPauseFollow) WithErrorTrace() func(*CCRPauseFollowRequest) { + return func(r *CCRPauseFollowRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f CCRPauseFollow) WithFilterPath(v ...string) func(*CCRPauseFollowRequest) { + return func(r *CCRPauseFollowRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f CCRPauseFollow) WithHeader(h map[string]string) func(*CCRPauseFollowRequest) { + return func(r *CCRPauseFollowRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f CCRPauseFollow) WithOpaqueID(s string) func(*CCRPauseFollowRequest) { + return func(r *CCRPauseFollowRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.put_auto_follow_pattern.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.put_auto_follow_pattern.go new file mode 100644 index 00000000..5e1ae334 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.put_auto_follow_pattern.go @@ -0,0 +1,200 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newCCRPutAutoFollowPatternFunc(t Transport) CCRPutAutoFollowPattern { + return func(name string, body io.Reader, o ...func(*CCRPutAutoFollowPatternRequest)) (*Response, error) { + var r = CCRPutAutoFollowPatternRequest{Name: name, Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// CCRPutAutoFollowPattern - Creates a new named collection of auto-follow patterns against a specified remote cluster. Newly created indices on the remote cluster matching any of the specified patterns will be automatically configured as follower indices. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-auto-follow-pattern.html. +type CCRPutAutoFollowPattern func(name string, body io.Reader, o ...func(*CCRPutAutoFollowPatternRequest)) (*Response, error) + +// CCRPutAutoFollowPatternRequest configures the CCR Put Auto Follow Pattern API request. +type CCRPutAutoFollowPatternRequest struct { + Body io.Reader + + Name string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r CCRPutAutoFollowPatternRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(1 + len("_ccr") + 1 + len("auto_follow") + 1 + len(r.Name)) + path.WriteString("/") + path.WriteString("_ccr") + path.WriteString("/") + path.WriteString("auto_follow") + path.WriteString("/") + path.WriteString(r.Name) + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f CCRPutAutoFollowPattern) WithContext(v context.Context) func(*CCRPutAutoFollowPatternRequest) { + return func(r *CCRPutAutoFollowPatternRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f CCRPutAutoFollowPattern) WithPretty() func(*CCRPutAutoFollowPatternRequest) { + return func(r *CCRPutAutoFollowPatternRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f CCRPutAutoFollowPattern) WithHuman() func(*CCRPutAutoFollowPatternRequest) { + return func(r *CCRPutAutoFollowPatternRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f CCRPutAutoFollowPattern) WithErrorTrace() func(*CCRPutAutoFollowPatternRequest) { + return func(r *CCRPutAutoFollowPatternRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f CCRPutAutoFollowPattern) WithFilterPath(v ...string) func(*CCRPutAutoFollowPatternRequest) { + return func(r *CCRPutAutoFollowPatternRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f CCRPutAutoFollowPattern) WithHeader(h map[string]string) func(*CCRPutAutoFollowPatternRequest) { + return func(r *CCRPutAutoFollowPatternRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f CCRPutAutoFollowPattern) WithOpaqueID(s string) func(*CCRPutAutoFollowPatternRequest) { + return func(r *CCRPutAutoFollowPatternRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.resume_auto_follow_pattern.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.resume_auto_follow_pattern.go new file mode 100644 index 00000000..5acb3db2 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.resume_auto_follow_pattern.go @@ -0,0 +1,195 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newCCRResumeAutoFollowPatternFunc(t Transport) CCRResumeAutoFollowPattern { + return func(name string, o ...func(*CCRResumeAutoFollowPatternRequest)) (*Response, error) { + var r = CCRResumeAutoFollowPatternRequest{Name: name} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// CCRResumeAutoFollowPattern - Resumes an auto-follow pattern that has been paused +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-resume-auto-follow-pattern.html. +type CCRResumeAutoFollowPattern func(name string, o ...func(*CCRResumeAutoFollowPatternRequest)) (*Response, error) + +// CCRResumeAutoFollowPatternRequest configures the CCR Resume Auto Follow Pattern API request. +type CCRResumeAutoFollowPatternRequest struct { + Name string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r CCRResumeAutoFollowPatternRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_ccr") + 1 + len("auto_follow") + 1 + len(r.Name) + 1 + len("resume")) + path.WriteString("/") + path.WriteString("_ccr") + path.WriteString("/") + path.WriteString("auto_follow") + path.WriteString("/") + path.WriteString(r.Name) + path.WriteString("/") + path.WriteString("resume") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f CCRResumeAutoFollowPattern) WithContext(v context.Context) func(*CCRResumeAutoFollowPatternRequest) { + return func(r *CCRResumeAutoFollowPatternRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f CCRResumeAutoFollowPattern) WithPretty() func(*CCRResumeAutoFollowPatternRequest) { + return func(r *CCRResumeAutoFollowPatternRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f CCRResumeAutoFollowPattern) WithHuman() func(*CCRResumeAutoFollowPatternRequest) { + return func(r *CCRResumeAutoFollowPatternRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f CCRResumeAutoFollowPattern) WithErrorTrace() func(*CCRResumeAutoFollowPatternRequest) { + return func(r *CCRResumeAutoFollowPatternRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f CCRResumeAutoFollowPattern) WithFilterPath(v ...string) func(*CCRResumeAutoFollowPatternRequest) { + return func(r *CCRResumeAutoFollowPatternRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f CCRResumeAutoFollowPattern) WithHeader(h map[string]string) func(*CCRResumeAutoFollowPatternRequest) { + return func(r *CCRResumeAutoFollowPatternRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f CCRResumeAutoFollowPattern) WithOpaqueID(s string) func(*CCRResumeAutoFollowPatternRequest) { + return func(r *CCRResumeAutoFollowPatternRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.resume_follow.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.resume_follow.go new file mode 100644 index 00000000..684a6e5b --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.resume_follow.go @@ -0,0 +1,207 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newCCRResumeFollowFunc(t Transport) CCRResumeFollow { + return func(index string, o ...func(*CCRResumeFollowRequest)) (*Response, error) { + var r = CCRResumeFollowRequest{Index: index} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// CCRResumeFollow - Resumes a follower index that has been paused +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-resume-follow.html. +type CCRResumeFollow func(index string, o ...func(*CCRResumeFollowRequest)) (*Response, error) + +// CCRResumeFollowRequest configures the CCR Resume Follow API request. +type CCRResumeFollowRequest struct { + Index string + + Body io.Reader + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r CCRResumeFollowRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len(r.Index) + 1 + len("_ccr") + 1 + len("resume_follow")) + path.WriteString("/") + path.WriteString(r.Index) + path.WriteString("/") + path.WriteString("_ccr") + path.WriteString("/") + path.WriteString("resume_follow") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f CCRResumeFollow) WithContext(v context.Context) func(*CCRResumeFollowRequest) { + return func(r *CCRResumeFollowRequest) { + r.ctx = v + } +} + +// WithBody - The name of the leader index and other optional ccr related parameters. +func (f CCRResumeFollow) WithBody(v io.Reader) func(*CCRResumeFollowRequest) { + return func(r *CCRResumeFollowRequest) { + r.Body = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f CCRResumeFollow) WithPretty() func(*CCRResumeFollowRequest) { + return func(r *CCRResumeFollowRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f CCRResumeFollow) WithHuman() func(*CCRResumeFollowRequest) { + return func(r *CCRResumeFollowRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f CCRResumeFollow) WithErrorTrace() func(*CCRResumeFollowRequest) { + return func(r *CCRResumeFollowRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f CCRResumeFollow) WithFilterPath(v ...string) func(*CCRResumeFollowRequest) { + return func(r *CCRResumeFollowRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f CCRResumeFollow) WithHeader(h map[string]string) func(*CCRResumeFollowRequest) { + return func(r *CCRResumeFollowRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f CCRResumeFollow) WithOpaqueID(s string) func(*CCRResumeFollowRequest) { + return func(r *CCRResumeFollowRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.stats.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.stats.go new file mode 100644 index 00000000..4d5560ae --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.stats.go @@ -0,0 +1,186 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newCCRStatsFunc(t Transport) CCRStats { + return func(o ...func(*CCRStatsRequest)) (*Response, error) { + var r = CCRStatsRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// CCRStats - Gets all stats related to cross-cluster replication. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-stats.html. +type CCRStats func(o ...func(*CCRStatsRequest)) (*Response, error) + +// CCRStatsRequest configures the CCR Stats API request. +type CCRStatsRequest struct { + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r CCRStatsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(len("/_ccr/stats")) + path.WriteString("/_ccr/stats") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f CCRStats) WithContext(v context.Context) func(*CCRStatsRequest) { + return func(r *CCRStatsRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f CCRStats) WithPretty() func(*CCRStatsRequest) { + return func(r *CCRStatsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f CCRStats) WithHuman() func(*CCRStatsRequest) { + return func(r *CCRStatsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f CCRStats) WithErrorTrace() func(*CCRStatsRequest) { + return func(r *CCRStatsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f CCRStats) WithFilterPath(v ...string) func(*CCRStatsRequest) { + return func(r *CCRStatsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f CCRStats) WithHeader(h map[string]string) func(*CCRStatsRequest) { + return func(r *CCRStatsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f CCRStats) WithOpaqueID(s string) func(*CCRStatsRequest) { + return func(r *CCRStatsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.unfollow.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.unfollow.go new file mode 100644 index 00000000..dbe6b468 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ccr.unfollow.go @@ -0,0 +1,193 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newCCRUnfollowFunc(t Transport) CCRUnfollow { + return func(index string, o ...func(*CCRUnfollowRequest)) (*Response, error) { + var r = CCRUnfollowRequest{Index: index} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// CCRUnfollow - Stops the following task associated with a follower index and removes index metadata and settings associated with cross-cluster replication. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-unfollow.html. +type CCRUnfollow func(index string, o ...func(*CCRUnfollowRequest)) (*Response, error) + +// CCRUnfollowRequest configures the CCR Unfollow API request. +type CCRUnfollowRequest struct { + Index string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r CCRUnfollowRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len(r.Index) + 1 + len("_ccr") + 1 + len("unfollow")) + path.WriteString("/") + path.WriteString(r.Index) + path.WriteString("/") + path.WriteString("_ccr") + path.WriteString("/") + path.WriteString("unfollow") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f CCRUnfollow) WithContext(v context.Context) func(*CCRUnfollowRequest) { + return func(r *CCRUnfollowRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f CCRUnfollow) WithPretty() func(*CCRUnfollowRequest) { + return func(r *CCRUnfollowRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f CCRUnfollow) WithHuman() func(*CCRUnfollowRequest) { + return func(r *CCRUnfollowRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f CCRUnfollow) WithErrorTrace() func(*CCRUnfollowRequest) { + return func(r *CCRUnfollowRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f CCRUnfollow) WithFilterPath(v ...string) func(*CCRUnfollowRequest) { + return func(r *CCRUnfollowRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f CCRUnfollow) WithHeader(h map[string]string) func(*CCRUnfollowRequest) { + return func(r *CCRUnfollowRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f CCRUnfollow) WithOpaqueID(s string) func(*CCRUnfollowRequest) { + return func(r *CCRUnfollowRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.close_point_in_time.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.close_point_in_time.go new file mode 100644 index 00000000..408698ed --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.close_point_in_time.go @@ -0,0 +1,200 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newClosePointInTimeFunc(t Transport) ClosePointInTime { + return func(o ...func(*ClosePointInTimeRequest)) (*Response, error) { + var r = ClosePointInTimeRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// ClosePointInTime - Close a point in time +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/point-in-time-api.html. +type ClosePointInTime func(o ...func(*ClosePointInTimeRequest)) (*Response, error) + +// ClosePointInTimeRequest configures the Close Point In Time API request. +type ClosePointInTimeRequest struct { + Body io.Reader + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r ClosePointInTimeRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + path.Grow(len("/_pit")) + path.WriteString("/_pit") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f ClosePointInTime) WithContext(v context.Context) func(*ClosePointInTimeRequest) { + return func(r *ClosePointInTimeRequest) { + r.ctx = v + } +} + +// WithBody - a point-in-time id to close. +func (f ClosePointInTime) WithBody(v io.Reader) func(*ClosePointInTimeRequest) { + return func(r *ClosePointInTimeRequest) { + r.Body = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f ClosePointInTime) WithPretty() func(*ClosePointInTimeRequest) { + return func(r *ClosePointInTimeRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f ClosePointInTime) WithHuman() func(*ClosePointInTimeRequest) { + return func(r *ClosePointInTimeRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f ClosePointInTime) WithErrorTrace() func(*ClosePointInTimeRequest) { + return func(r *ClosePointInTimeRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f ClosePointInTime) WithFilterPath(v ...string) func(*ClosePointInTimeRequest) { + return func(r *ClosePointInTimeRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f ClosePointInTime) WithHeader(h map[string]string) func(*ClosePointInTimeRequest) { + return func(r *ClosePointInTimeRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f ClosePointInTime) WithOpaqueID(s string) func(*ClosePointInTimeRequest) { + return func(r *ClosePointInTimeRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.data_frame_transform_deprecated.delete_transform.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.data_frame_transform_deprecated.delete_transform.go new file mode 100644 index 00000000..d1ee8d9e --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.data_frame_transform_deprecated.delete_transform.go @@ -0,0 +1,209 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newDataFrameTransformDeprecatedDeleteTransformFunc(t Transport) DataFrameTransformDeprecatedDeleteTransform { + return func(transform_id string, o ...func(*DataFrameTransformDeprecatedDeleteTransformRequest)) (*Response, error) { + var r = DataFrameTransformDeprecatedDeleteTransformRequest{TransformID: transform_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// DataFrameTransformDeprecatedDeleteTransform - Deletes an existing transform. +// +// This API is beta. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-transform.html. +type DataFrameTransformDeprecatedDeleteTransform func(transform_id string, o ...func(*DataFrameTransformDeprecatedDeleteTransformRequest)) (*Response, error) + +// DataFrameTransformDeprecatedDeleteTransformRequest configures the Data Frame Transform Deprecated Delete Transform API request. +type DataFrameTransformDeprecatedDeleteTransformRequest struct { + TransformID string + + Force *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r DataFrameTransformDeprecatedDeleteTransformRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + path.Grow(1 + len("_data_frame") + 1 + len("transforms") + 1 + len(r.TransformID)) + path.WriteString("/") + path.WriteString("_data_frame") + path.WriteString("/") + path.WriteString("transforms") + path.WriteString("/") + path.WriteString(r.TransformID) + + params = make(map[string]string) + + if r.Force != nil { + params["force"] = strconv.FormatBool(*r.Force) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f DataFrameTransformDeprecatedDeleteTransform) WithContext(v context.Context) func(*DataFrameTransformDeprecatedDeleteTransformRequest) { + return func(r *DataFrameTransformDeprecatedDeleteTransformRequest) { + r.ctx = v + } +} + +// WithForce - when `true`, the transform is deleted regardless of its current state. the default value is `false`, meaning that the transform must be `stopped` before it can be deleted.. +func (f DataFrameTransformDeprecatedDeleteTransform) WithForce(v bool) func(*DataFrameTransformDeprecatedDeleteTransformRequest) { + return func(r *DataFrameTransformDeprecatedDeleteTransformRequest) { + r.Force = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f DataFrameTransformDeprecatedDeleteTransform) WithPretty() func(*DataFrameTransformDeprecatedDeleteTransformRequest) { + return func(r *DataFrameTransformDeprecatedDeleteTransformRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f DataFrameTransformDeprecatedDeleteTransform) WithHuman() func(*DataFrameTransformDeprecatedDeleteTransformRequest) { + return func(r *DataFrameTransformDeprecatedDeleteTransformRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f DataFrameTransformDeprecatedDeleteTransform) WithErrorTrace() func(*DataFrameTransformDeprecatedDeleteTransformRequest) { + return func(r *DataFrameTransformDeprecatedDeleteTransformRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f DataFrameTransformDeprecatedDeleteTransform) WithFilterPath(v ...string) func(*DataFrameTransformDeprecatedDeleteTransformRequest) { + return func(r *DataFrameTransformDeprecatedDeleteTransformRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f DataFrameTransformDeprecatedDeleteTransform) WithHeader(h map[string]string) func(*DataFrameTransformDeprecatedDeleteTransformRequest) { + return func(r *DataFrameTransformDeprecatedDeleteTransformRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f DataFrameTransformDeprecatedDeleteTransform) WithOpaqueID(s string) func(*DataFrameTransformDeprecatedDeleteTransformRequest) { + return func(r *DataFrameTransformDeprecatedDeleteTransformRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.data_frame_transform_deprecated.get_transform.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.data_frame_transform_deprecated.get_transform.go new file mode 100644 index 00000000..7b93484b --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.data_frame_transform_deprecated.get_transform.go @@ -0,0 +1,254 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newDataFrameTransformDeprecatedGetTransformFunc(t Transport) DataFrameTransformDeprecatedGetTransform { + return func(o ...func(*DataFrameTransformDeprecatedGetTransformRequest)) (*Response, error) { + var r = DataFrameTransformDeprecatedGetTransformRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// DataFrameTransformDeprecatedGetTransform - Retrieves configuration information for transforms. +// +// This API is beta. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/get-transform.html. +type DataFrameTransformDeprecatedGetTransform func(o ...func(*DataFrameTransformDeprecatedGetTransformRequest)) (*Response, error) + +// DataFrameTransformDeprecatedGetTransformRequest configures the Data Frame Transform Deprecated Get Transform API request. +type DataFrameTransformDeprecatedGetTransformRequest struct { + TransformID string + + AllowNoMatch *bool + ExcludeGenerated *bool + From *int + Size *int + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r DataFrameTransformDeprecatedGetTransformRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_data_frame") + 1 + len("transforms") + 1 + len(r.TransformID)) + path.WriteString("/") + path.WriteString("_data_frame") + path.WriteString("/") + path.WriteString("transforms") + if r.TransformID != "" { + path.WriteString("/") + path.WriteString(r.TransformID) + } + + params = make(map[string]string) + + if r.AllowNoMatch != nil { + params["allow_no_match"] = strconv.FormatBool(*r.AllowNoMatch) + } + + if r.ExcludeGenerated != nil { + params["exclude_generated"] = strconv.FormatBool(*r.ExcludeGenerated) + } + + if r.From != nil { + params["from"] = strconv.FormatInt(int64(*r.From), 10) + } + + if r.Size != nil { + params["size"] = strconv.FormatInt(int64(*r.Size), 10) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f DataFrameTransformDeprecatedGetTransform) WithContext(v context.Context) func(*DataFrameTransformDeprecatedGetTransformRequest) { + return func(r *DataFrameTransformDeprecatedGetTransformRequest) { + r.ctx = v + } +} + +// WithTransformID - the ID or comma delimited list of ID expressions of the transforms to get, '_all' or '*' implies get all transforms. +func (f DataFrameTransformDeprecatedGetTransform) WithTransformID(v string) func(*DataFrameTransformDeprecatedGetTransformRequest) { + return func(r *DataFrameTransformDeprecatedGetTransformRequest) { + r.TransformID = v + } +} + +// WithAllowNoMatch - whether to ignore if a wildcard expression matches no transforms. (this includes `_all` string or when no transforms have been specified). +func (f DataFrameTransformDeprecatedGetTransform) WithAllowNoMatch(v bool) func(*DataFrameTransformDeprecatedGetTransformRequest) { + return func(r *DataFrameTransformDeprecatedGetTransformRequest) { + r.AllowNoMatch = &v + } +} + +// WithExcludeGenerated - omits generated fields. allows transform configurations to be easily copied between clusters and within the same cluster. +func (f DataFrameTransformDeprecatedGetTransform) WithExcludeGenerated(v bool) func(*DataFrameTransformDeprecatedGetTransformRequest) { + return func(r *DataFrameTransformDeprecatedGetTransformRequest) { + r.ExcludeGenerated = &v + } +} + +// WithFrom - skips a number of transform configs, defaults to 0. +func (f DataFrameTransformDeprecatedGetTransform) WithFrom(v int) func(*DataFrameTransformDeprecatedGetTransformRequest) { + return func(r *DataFrameTransformDeprecatedGetTransformRequest) { + r.From = &v + } +} + +// WithSize - specifies a max number of transforms to get, defaults to 100. +func (f DataFrameTransformDeprecatedGetTransform) WithSize(v int) func(*DataFrameTransformDeprecatedGetTransformRequest) { + return func(r *DataFrameTransformDeprecatedGetTransformRequest) { + r.Size = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f DataFrameTransformDeprecatedGetTransform) WithPretty() func(*DataFrameTransformDeprecatedGetTransformRequest) { + return func(r *DataFrameTransformDeprecatedGetTransformRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f DataFrameTransformDeprecatedGetTransform) WithHuman() func(*DataFrameTransformDeprecatedGetTransformRequest) { + return func(r *DataFrameTransformDeprecatedGetTransformRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f DataFrameTransformDeprecatedGetTransform) WithErrorTrace() func(*DataFrameTransformDeprecatedGetTransformRequest) { + return func(r *DataFrameTransformDeprecatedGetTransformRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f DataFrameTransformDeprecatedGetTransform) WithFilterPath(v ...string) func(*DataFrameTransformDeprecatedGetTransformRequest) { + return func(r *DataFrameTransformDeprecatedGetTransformRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f DataFrameTransformDeprecatedGetTransform) WithHeader(h map[string]string) func(*DataFrameTransformDeprecatedGetTransformRequest) { + return func(r *DataFrameTransformDeprecatedGetTransformRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f DataFrameTransformDeprecatedGetTransform) WithOpaqueID(s string) func(*DataFrameTransformDeprecatedGetTransformRequest) { + return func(r *DataFrameTransformDeprecatedGetTransformRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.data_frame_transform_deprecated.get_transform_stats.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.data_frame_transform_deprecated.get_transform_stats.go new file mode 100644 index 00000000..92a73394 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.data_frame_transform_deprecated.get_transform_stats.go @@ -0,0 +1,235 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newDataFrameTransformDeprecatedGetTransformStatsFunc(t Transport) DataFrameTransformDeprecatedGetTransformStats { + return func(transform_id string, o ...func(*DataFrameTransformDeprecatedGetTransformStatsRequest)) (*Response, error) { + var r = DataFrameTransformDeprecatedGetTransformStatsRequest{TransformID: transform_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// DataFrameTransformDeprecatedGetTransformStats - Retrieves usage information for transforms. +// +// This API is beta. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/get-transform-stats.html. +type DataFrameTransformDeprecatedGetTransformStats func(transform_id string, o ...func(*DataFrameTransformDeprecatedGetTransformStatsRequest)) (*Response, error) + +// DataFrameTransformDeprecatedGetTransformStatsRequest configures the Data Frame Transform Deprecated Get Transform Stats API request. +type DataFrameTransformDeprecatedGetTransformStatsRequest struct { + TransformID string + + AllowNoMatch *bool + From *int + Size *int + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r DataFrameTransformDeprecatedGetTransformStatsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_data_frame") + 1 + len("transforms") + 1 + len(r.TransformID) + 1 + len("_stats")) + path.WriteString("/") + path.WriteString("_data_frame") + path.WriteString("/") + path.WriteString("transforms") + path.WriteString("/") + path.WriteString(r.TransformID) + path.WriteString("/") + path.WriteString("_stats") + + params = make(map[string]string) + + if r.AllowNoMatch != nil { + params["allow_no_match"] = strconv.FormatBool(*r.AllowNoMatch) + } + + if r.From != nil { + params["from"] = strconv.FormatInt(int64(*r.From), 10) + } + + if r.Size != nil { + params["size"] = strconv.FormatInt(int64(*r.Size), 10) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f DataFrameTransformDeprecatedGetTransformStats) WithContext(v context.Context) func(*DataFrameTransformDeprecatedGetTransformStatsRequest) { + return func(r *DataFrameTransformDeprecatedGetTransformStatsRequest) { + r.ctx = v + } +} + +// WithAllowNoMatch - whether to ignore if a wildcard expression matches no transforms. (this includes `_all` string or when no transforms have been specified). +func (f DataFrameTransformDeprecatedGetTransformStats) WithAllowNoMatch(v bool) func(*DataFrameTransformDeprecatedGetTransformStatsRequest) { + return func(r *DataFrameTransformDeprecatedGetTransformStatsRequest) { + r.AllowNoMatch = &v + } +} + +// WithFrom - skips a number of transform stats, defaults to 0. +func (f DataFrameTransformDeprecatedGetTransformStats) WithFrom(v int) func(*DataFrameTransformDeprecatedGetTransformStatsRequest) { + return func(r *DataFrameTransformDeprecatedGetTransformStatsRequest) { + r.From = &v + } +} + +// WithSize - specifies a max number of transform stats to get, defaults to 100. +func (f DataFrameTransformDeprecatedGetTransformStats) WithSize(v int) func(*DataFrameTransformDeprecatedGetTransformStatsRequest) { + return func(r *DataFrameTransformDeprecatedGetTransformStatsRequest) { + r.Size = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f DataFrameTransformDeprecatedGetTransformStats) WithPretty() func(*DataFrameTransformDeprecatedGetTransformStatsRequest) { + return func(r *DataFrameTransformDeprecatedGetTransformStatsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f DataFrameTransformDeprecatedGetTransformStats) WithHuman() func(*DataFrameTransformDeprecatedGetTransformStatsRequest) { + return func(r *DataFrameTransformDeprecatedGetTransformStatsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f DataFrameTransformDeprecatedGetTransformStats) WithErrorTrace() func(*DataFrameTransformDeprecatedGetTransformStatsRequest) { + return func(r *DataFrameTransformDeprecatedGetTransformStatsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f DataFrameTransformDeprecatedGetTransformStats) WithFilterPath(v ...string) func(*DataFrameTransformDeprecatedGetTransformStatsRequest) { + return func(r *DataFrameTransformDeprecatedGetTransformStatsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f DataFrameTransformDeprecatedGetTransformStats) WithHeader(h map[string]string) func(*DataFrameTransformDeprecatedGetTransformStatsRequest) { + return func(r *DataFrameTransformDeprecatedGetTransformStatsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f DataFrameTransformDeprecatedGetTransformStats) WithOpaqueID(s string) func(*DataFrameTransformDeprecatedGetTransformStatsRequest) { + return func(r *DataFrameTransformDeprecatedGetTransformStatsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.data_frame_transform_deprecated.preview_transform.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.data_frame_transform_deprecated.preview_transform.go new file mode 100644 index 00000000..ecaa4b46 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.data_frame_transform_deprecated.preview_transform.go @@ -0,0 +1,195 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newDataFrameTransformDeprecatedPreviewTransformFunc(t Transport) DataFrameTransformDeprecatedPreviewTransform { + return func(body io.Reader, o ...func(*DataFrameTransformDeprecatedPreviewTransformRequest)) (*Response, error) { + var r = DataFrameTransformDeprecatedPreviewTransformRequest{Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// DataFrameTransformDeprecatedPreviewTransform - Previews a transform. +// +// This API is beta. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/preview-transform.html. +type DataFrameTransformDeprecatedPreviewTransform func(body io.Reader, o ...func(*DataFrameTransformDeprecatedPreviewTransformRequest)) (*Response, error) + +// DataFrameTransformDeprecatedPreviewTransformRequest configures the Data Frame Transform Deprecated Preview Transform API request. +type DataFrameTransformDeprecatedPreviewTransformRequest struct { + Body io.Reader + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r DataFrameTransformDeprecatedPreviewTransformRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(len("/_data_frame/transforms/_preview")) + path.WriteString("/_data_frame/transforms/_preview") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f DataFrameTransformDeprecatedPreviewTransform) WithContext(v context.Context) func(*DataFrameTransformDeprecatedPreviewTransformRequest) { + return func(r *DataFrameTransformDeprecatedPreviewTransformRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f DataFrameTransformDeprecatedPreviewTransform) WithPretty() func(*DataFrameTransformDeprecatedPreviewTransformRequest) { + return func(r *DataFrameTransformDeprecatedPreviewTransformRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f DataFrameTransformDeprecatedPreviewTransform) WithHuman() func(*DataFrameTransformDeprecatedPreviewTransformRequest) { + return func(r *DataFrameTransformDeprecatedPreviewTransformRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f DataFrameTransformDeprecatedPreviewTransform) WithErrorTrace() func(*DataFrameTransformDeprecatedPreviewTransformRequest) { + return func(r *DataFrameTransformDeprecatedPreviewTransformRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f DataFrameTransformDeprecatedPreviewTransform) WithFilterPath(v ...string) func(*DataFrameTransformDeprecatedPreviewTransformRequest) { + return func(r *DataFrameTransformDeprecatedPreviewTransformRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f DataFrameTransformDeprecatedPreviewTransform) WithHeader(h map[string]string) func(*DataFrameTransformDeprecatedPreviewTransformRequest) { + return func(r *DataFrameTransformDeprecatedPreviewTransformRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f DataFrameTransformDeprecatedPreviewTransform) WithOpaqueID(s string) func(*DataFrameTransformDeprecatedPreviewTransformRequest) { + return func(r *DataFrameTransformDeprecatedPreviewTransformRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.data_frame_transform_deprecated.put_transform.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.data_frame_transform_deprecated.put_transform.go new file mode 100644 index 00000000..d0a50d38 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.data_frame_transform_deprecated.put_transform.go @@ -0,0 +1,216 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" +) + +func newDataFrameTransformDeprecatedPutTransformFunc(t Transport) DataFrameTransformDeprecatedPutTransform { + return func(body io.Reader, transform_id string, o ...func(*DataFrameTransformDeprecatedPutTransformRequest)) (*Response, error) { + var r = DataFrameTransformDeprecatedPutTransformRequest{Body: body, TransformID: transform_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// DataFrameTransformDeprecatedPutTransform - Instantiates a transform. +// +// This API is beta. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/put-transform.html. +type DataFrameTransformDeprecatedPutTransform func(body io.Reader, transform_id string, o ...func(*DataFrameTransformDeprecatedPutTransformRequest)) (*Response, error) + +// DataFrameTransformDeprecatedPutTransformRequest configures the Data Frame Transform Deprecated Put Transform API request. +type DataFrameTransformDeprecatedPutTransformRequest struct { + Body io.Reader + + TransformID string + + DeferValidation *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r DataFrameTransformDeprecatedPutTransformRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(1 + len("_data_frame") + 1 + len("transforms") + 1 + len(r.TransformID)) + path.WriteString("/") + path.WriteString("_data_frame") + path.WriteString("/") + path.WriteString("transforms") + path.WriteString("/") + path.WriteString(r.TransformID) + + params = make(map[string]string) + + if r.DeferValidation != nil { + params["defer_validation"] = strconv.FormatBool(*r.DeferValidation) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f DataFrameTransformDeprecatedPutTransform) WithContext(v context.Context) func(*DataFrameTransformDeprecatedPutTransformRequest) { + return func(r *DataFrameTransformDeprecatedPutTransformRequest) { + r.ctx = v + } +} + +// WithDeferValidation - if validations should be deferred until transform starts, defaults to false.. +func (f DataFrameTransformDeprecatedPutTransform) WithDeferValidation(v bool) func(*DataFrameTransformDeprecatedPutTransformRequest) { + return func(r *DataFrameTransformDeprecatedPutTransformRequest) { + r.DeferValidation = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f DataFrameTransformDeprecatedPutTransform) WithPretty() func(*DataFrameTransformDeprecatedPutTransformRequest) { + return func(r *DataFrameTransformDeprecatedPutTransformRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f DataFrameTransformDeprecatedPutTransform) WithHuman() func(*DataFrameTransformDeprecatedPutTransformRequest) { + return func(r *DataFrameTransformDeprecatedPutTransformRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f DataFrameTransformDeprecatedPutTransform) WithErrorTrace() func(*DataFrameTransformDeprecatedPutTransformRequest) { + return func(r *DataFrameTransformDeprecatedPutTransformRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f DataFrameTransformDeprecatedPutTransform) WithFilterPath(v ...string) func(*DataFrameTransformDeprecatedPutTransformRequest) { + return func(r *DataFrameTransformDeprecatedPutTransformRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f DataFrameTransformDeprecatedPutTransform) WithHeader(h map[string]string) func(*DataFrameTransformDeprecatedPutTransformRequest) { + return func(r *DataFrameTransformDeprecatedPutTransformRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f DataFrameTransformDeprecatedPutTransform) WithOpaqueID(s string) func(*DataFrameTransformDeprecatedPutTransformRequest) { + return func(r *DataFrameTransformDeprecatedPutTransformRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.data_frame_transform_deprecated.start_transform.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.data_frame_transform_deprecated.start_transform.go new file mode 100644 index 00000000..65eb1ec4 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.data_frame_transform_deprecated.start_transform.go @@ -0,0 +1,211 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" + "time" +) + +func newDataFrameTransformDeprecatedStartTransformFunc(t Transport) DataFrameTransformDeprecatedStartTransform { + return func(transform_id string, o ...func(*DataFrameTransformDeprecatedStartTransformRequest)) (*Response, error) { + var r = DataFrameTransformDeprecatedStartTransformRequest{TransformID: transform_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// DataFrameTransformDeprecatedStartTransform - Starts one or more transforms. +// +// This API is beta. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/start-transform.html. +type DataFrameTransformDeprecatedStartTransform func(transform_id string, o ...func(*DataFrameTransformDeprecatedStartTransformRequest)) (*Response, error) + +// DataFrameTransformDeprecatedStartTransformRequest configures the Data Frame Transform Deprecated Start Transform API request. +type DataFrameTransformDeprecatedStartTransformRequest struct { + TransformID string + + Timeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r DataFrameTransformDeprecatedStartTransformRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_data_frame") + 1 + len("transforms") + 1 + len(r.TransformID) + 1 + len("_start")) + path.WriteString("/") + path.WriteString("_data_frame") + path.WriteString("/") + path.WriteString("transforms") + path.WriteString("/") + path.WriteString(r.TransformID) + path.WriteString("/") + path.WriteString("_start") + + params = make(map[string]string) + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f DataFrameTransformDeprecatedStartTransform) WithContext(v context.Context) func(*DataFrameTransformDeprecatedStartTransformRequest) { + return func(r *DataFrameTransformDeprecatedStartTransformRequest) { + r.ctx = v + } +} + +// WithTimeout - controls the time to wait for the transform to start. +func (f DataFrameTransformDeprecatedStartTransform) WithTimeout(v time.Duration) func(*DataFrameTransformDeprecatedStartTransformRequest) { + return func(r *DataFrameTransformDeprecatedStartTransformRequest) { + r.Timeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f DataFrameTransformDeprecatedStartTransform) WithPretty() func(*DataFrameTransformDeprecatedStartTransformRequest) { + return func(r *DataFrameTransformDeprecatedStartTransformRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f DataFrameTransformDeprecatedStartTransform) WithHuman() func(*DataFrameTransformDeprecatedStartTransformRequest) { + return func(r *DataFrameTransformDeprecatedStartTransformRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f DataFrameTransformDeprecatedStartTransform) WithErrorTrace() func(*DataFrameTransformDeprecatedStartTransformRequest) { + return func(r *DataFrameTransformDeprecatedStartTransformRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f DataFrameTransformDeprecatedStartTransform) WithFilterPath(v ...string) func(*DataFrameTransformDeprecatedStartTransformRequest) { + return func(r *DataFrameTransformDeprecatedStartTransformRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f DataFrameTransformDeprecatedStartTransform) WithHeader(h map[string]string) func(*DataFrameTransformDeprecatedStartTransformRequest) { + return func(r *DataFrameTransformDeprecatedStartTransformRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f DataFrameTransformDeprecatedStartTransform) WithOpaqueID(s string) func(*DataFrameTransformDeprecatedStartTransformRequest) { + return func(r *DataFrameTransformDeprecatedStartTransformRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.data_frame_transform_deprecated.stop_transform.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.data_frame_transform_deprecated.stop_transform.go new file mode 100644 index 00000000..ad9f897e --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.data_frame_transform_deprecated.stop_transform.go @@ -0,0 +1,236 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" + "time" +) + +func newDataFrameTransformDeprecatedStopTransformFunc(t Transport) DataFrameTransformDeprecatedStopTransform { + return func(transform_id string, o ...func(*DataFrameTransformDeprecatedStopTransformRequest)) (*Response, error) { + var r = DataFrameTransformDeprecatedStopTransformRequest{TransformID: transform_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// DataFrameTransformDeprecatedStopTransform - Stops one or more transforms. +// +// This API is beta. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/stop-transform.html. +type DataFrameTransformDeprecatedStopTransform func(transform_id string, o ...func(*DataFrameTransformDeprecatedStopTransformRequest)) (*Response, error) + +// DataFrameTransformDeprecatedStopTransformRequest configures the Data Frame Transform Deprecated Stop Transform API request. +type DataFrameTransformDeprecatedStopTransformRequest struct { + TransformID string + + AllowNoMatch *bool + Timeout time.Duration + WaitForCompletion *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r DataFrameTransformDeprecatedStopTransformRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_data_frame") + 1 + len("transforms") + 1 + len(r.TransformID) + 1 + len("_stop")) + path.WriteString("/") + path.WriteString("_data_frame") + path.WriteString("/") + path.WriteString("transforms") + path.WriteString("/") + path.WriteString(r.TransformID) + path.WriteString("/") + path.WriteString("_stop") + + params = make(map[string]string) + + if r.AllowNoMatch != nil { + params["allow_no_match"] = strconv.FormatBool(*r.AllowNoMatch) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.WaitForCompletion != nil { + params["wait_for_completion"] = strconv.FormatBool(*r.WaitForCompletion) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f DataFrameTransformDeprecatedStopTransform) WithContext(v context.Context) func(*DataFrameTransformDeprecatedStopTransformRequest) { + return func(r *DataFrameTransformDeprecatedStopTransformRequest) { + r.ctx = v + } +} + +// WithAllowNoMatch - whether to ignore if a wildcard expression matches no transforms. (this includes `_all` string or when no transforms have been specified). +func (f DataFrameTransformDeprecatedStopTransform) WithAllowNoMatch(v bool) func(*DataFrameTransformDeprecatedStopTransformRequest) { + return func(r *DataFrameTransformDeprecatedStopTransformRequest) { + r.AllowNoMatch = &v + } +} + +// WithTimeout - controls the time to wait until the transform has stopped. default to 30 seconds. +func (f DataFrameTransformDeprecatedStopTransform) WithTimeout(v time.Duration) func(*DataFrameTransformDeprecatedStopTransformRequest) { + return func(r *DataFrameTransformDeprecatedStopTransformRequest) { + r.Timeout = v + } +} + +// WithWaitForCompletion - whether to wait for the transform to fully stop before returning or not. default to false. +func (f DataFrameTransformDeprecatedStopTransform) WithWaitForCompletion(v bool) func(*DataFrameTransformDeprecatedStopTransformRequest) { + return func(r *DataFrameTransformDeprecatedStopTransformRequest) { + r.WaitForCompletion = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f DataFrameTransformDeprecatedStopTransform) WithPretty() func(*DataFrameTransformDeprecatedStopTransformRequest) { + return func(r *DataFrameTransformDeprecatedStopTransformRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f DataFrameTransformDeprecatedStopTransform) WithHuman() func(*DataFrameTransformDeprecatedStopTransformRequest) { + return func(r *DataFrameTransformDeprecatedStopTransformRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f DataFrameTransformDeprecatedStopTransform) WithErrorTrace() func(*DataFrameTransformDeprecatedStopTransformRequest) { + return func(r *DataFrameTransformDeprecatedStopTransformRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f DataFrameTransformDeprecatedStopTransform) WithFilterPath(v ...string) func(*DataFrameTransformDeprecatedStopTransformRequest) { + return func(r *DataFrameTransformDeprecatedStopTransformRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f DataFrameTransformDeprecatedStopTransform) WithHeader(h map[string]string) func(*DataFrameTransformDeprecatedStopTransformRequest) { + return func(r *DataFrameTransformDeprecatedStopTransformRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f DataFrameTransformDeprecatedStopTransform) WithOpaqueID(s string) func(*DataFrameTransformDeprecatedStopTransformRequest) { + return func(r *DataFrameTransformDeprecatedStopTransformRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.data_frame_transform_deprecated.update_transform.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.data_frame_transform_deprecated.update_transform.go new file mode 100644 index 00000000..2f7156fe --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.data_frame_transform_deprecated.update_transform.go @@ -0,0 +1,218 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" +) + +func newDataFrameTransformDeprecatedUpdateTransformFunc(t Transport) DataFrameTransformDeprecatedUpdateTransform { + return func(body io.Reader, transform_id string, o ...func(*DataFrameTransformDeprecatedUpdateTransformRequest)) (*Response, error) { + var r = DataFrameTransformDeprecatedUpdateTransformRequest{Body: body, TransformID: transform_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// DataFrameTransformDeprecatedUpdateTransform - Updates certain properties of a transform. +// +// This API is beta. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/update-transform.html. +type DataFrameTransformDeprecatedUpdateTransform func(body io.Reader, transform_id string, o ...func(*DataFrameTransformDeprecatedUpdateTransformRequest)) (*Response, error) + +// DataFrameTransformDeprecatedUpdateTransformRequest configures the Data Frame Transform Deprecated Update Transform API request. +type DataFrameTransformDeprecatedUpdateTransformRequest struct { + Body io.Reader + + TransformID string + + DeferValidation *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r DataFrameTransformDeprecatedUpdateTransformRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_data_frame") + 1 + len("transforms") + 1 + len(r.TransformID) + 1 + len("_update")) + path.WriteString("/") + path.WriteString("_data_frame") + path.WriteString("/") + path.WriteString("transforms") + path.WriteString("/") + path.WriteString(r.TransformID) + path.WriteString("/") + path.WriteString("_update") + + params = make(map[string]string) + + if r.DeferValidation != nil { + params["defer_validation"] = strconv.FormatBool(*r.DeferValidation) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f DataFrameTransformDeprecatedUpdateTransform) WithContext(v context.Context) func(*DataFrameTransformDeprecatedUpdateTransformRequest) { + return func(r *DataFrameTransformDeprecatedUpdateTransformRequest) { + r.ctx = v + } +} + +// WithDeferValidation - if validations should be deferred until transform starts, defaults to false.. +func (f DataFrameTransformDeprecatedUpdateTransform) WithDeferValidation(v bool) func(*DataFrameTransformDeprecatedUpdateTransformRequest) { + return func(r *DataFrameTransformDeprecatedUpdateTransformRequest) { + r.DeferValidation = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f DataFrameTransformDeprecatedUpdateTransform) WithPretty() func(*DataFrameTransformDeprecatedUpdateTransformRequest) { + return func(r *DataFrameTransformDeprecatedUpdateTransformRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f DataFrameTransformDeprecatedUpdateTransform) WithHuman() func(*DataFrameTransformDeprecatedUpdateTransformRequest) { + return func(r *DataFrameTransformDeprecatedUpdateTransformRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f DataFrameTransformDeprecatedUpdateTransform) WithErrorTrace() func(*DataFrameTransformDeprecatedUpdateTransformRequest) { + return func(r *DataFrameTransformDeprecatedUpdateTransformRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f DataFrameTransformDeprecatedUpdateTransform) WithFilterPath(v ...string) func(*DataFrameTransformDeprecatedUpdateTransformRequest) { + return func(r *DataFrameTransformDeprecatedUpdateTransformRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f DataFrameTransformDeprecatedUpdateTransform) WithHeader(h map[string]string) func(*DataFrameTransformDeprecatedUpdateTransformRequest) { + return func(r *DataFrameTransformDeprecatedUpdateTransformRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f DataFrameTransformDeprecatedUpdateTransform) WithOpaqueID(s string) func(*DataFrameTransformDeprecatedUpdateTransformRequest) { + return func(r *DataFrameTransformDeprecatedUpdateTransformRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.enrich.delete_policy.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.enrich.delete_policy.go new file mode 100644 index 00000000..f78c302c --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.enrich.delete_policy.go @@ -0,0 +1,193 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newEnrichDeletePolicyFunc(t Transport) EnrichDeletePolicy { + return func(name string, o ...func(*EnrichDeletePolicyRequest)) (*Response, error) { + var r = EnrichDeletePolicyRequest{Name: name} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// EnrichDeletePolicy - Deletes an existing enrich policy and its enrich index. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-enrich-policy-api.html. +type EnrichDeletePolicy func(name string, o ...func(*EnrichDeletePolicyRequest)) (*Response, error) + +// EnrichDeletePolicyRequest configures the Enrich Delete Policy API request. +type EnrichDeletePolicyRequest struct { + Name string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r EnrichDeletePolicyRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + path.Grow(1 + len("_enrich") + 1 + len("policy") + 1 + len(r.Name)) + path.WriteString("/") + path.WriteString("_enrich") + path.WriteString("/") + path.WriteString("policy") + path.WriteString("/") + path.WriteString(r.Name) + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f EnrichDeletePolicy) WithContext(v context.Context) func(*EnrichDeletePolicyRequest) { + return func(r *EnrichDeletePolicyRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f EnrichDeletePolicy) WithPretty() func(*EnrichDeletePolicyRequest) { + return func(r *EnrichDeletePolicyRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f EnrichDeletePolicy) WithHuman() func(*EnrichDeletePolicyRequest) { + return func(r *EnrichDeletePolicyRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f EnrichDeletePolicy) WithErrorTrace() func(*EnrichDeletePolicyRequest) { + return func(r *EnrichDeletePolicyRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f EnrichDeletePolicy) WithFilterPath(v ...string) func(*EnrichDeletePolicyRequest) { + return func(r *EnrichDeletePolicyRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f EnrichDeletePolicy) WithHeader(h map[string]string) func(*EnrichDeletePolicyRequest) { + return func(r *EnrichDeletePolicyRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f EnrichDeletePolicy) WithOpaqueID(s string) func(*EnrichDeletePolicyRequest) { + return func(r *EnrichDeletePolicyRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.enrich.execute_policy.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.enrich.execute_policy.go new file mode 100644 index 00000000..30cd6959 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.enrich.execute_policy.go @@ -0,0 +1,209 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newEnrichExecutePolicyFunc(t Transport) EnrichExecutePolicy { + return func(name string, o ...func(*EnrichExecutePolicyRequest)) (*Response, error) { + var r = EnrichExecutePolicyRequest{Name: name} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// EnrichExecutePolicy - Creates the enrich index for an existing enrich policy. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/execute-enrich-policy-api.html. +type EnrichExecutePolicy func(name string, o ...func(*EnrichExecutePolicyRequest)) (*Response, error) + +// EnrichExecutePolicyRequest configures the Enrich Execute Policy API request. +type EnrichExecutePolicyRequest struct { + Name string + + WaitForCompletion *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r EnrichExecutePolicyRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(1 + len("_enrich") + 1 + len("policy") + 1 + len(r.Name) + 1 + len("_execute")) + path.WriteString("/") + path.WriteString("_enrich") + path.WriteString("/") + path.WriteString("policy") + path.WriteString("/") + path.WriteString(r.Name) + path.WriteString("/") + path.WriteString("_execute") + + params = make(map[string]string) + + if r.WaitForCompletion != nil { + params["wait_for_completion"] = strconv.FormatBool(*r.WaitForCompletion) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f EnrichExecutePolicy) WithContext(v context.Context) func(*EnrichExecutePolicyRequest) { + return func(r *EnrichExecutePolicyRequest) { + r.ctx = v + } +} + +// WithWaitForCompletion - should the request should block until the execution is complete.. +func (f EnrichExecutePolicy) WithWaitForCompletion(v bool) func(*EnrichExecutePolicyRequest) { + return func(r *EnrichExecutePolicyRequest) { + r.WaitForCompletion = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f EnrichExecutePolicy) WithPretty() func(*EnrichExecutePolicyRequest) { + return func(r *EnrichExecutePolicyRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f EnrichExecutePolicy) WithHuman() func(*EnrichExecutePolicyRequest) { + return func(r *EnrichExecutePolicyRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f EnrichExecutePolicy) WithErrorTrace() func(*EnrichExecutePolicyRequest) { + return func(r *EnrichExecutePolicyRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f EnrichExecutePolicy) WithFilterPath(v ...string) func(*EnrichExecutePolicyRequest) { + return func(r *EnrichExecutePolicyRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f EnrichExecutePolicy) WithHeader(h map[string]string) func(*EnrichExecutePolicyRequest) { + return func(r *EnrichExecutePolicyRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f EnrichExecutePolicy) WithOpaqueID(s string) func(*EnrichExecutePolicyRequest) { + return func(r *EnrichExecutePolicyRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.enrich.get_policy.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.enrich.get_policy.go new file mode 100644 index 00000000..25242718 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.enrich.get_policy.go @@ -0,0 +1,202 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newEnrichGetPolicyFunc(t Transport) EnrichGetPolicy { + return func(o ...func(*EnrichGetPolicyRequest)) (*Response, error) { + var r = EnrichGetPolicyRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// EnrichGetPolicy - Gets information about an enrich policy. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/get-enrich-policy-api.html. +type EnrichGetPolicy func(o ...func(*EnrichGetPolicyRequest)) (*Response, error) + +// EnrichGetPolicyRequest configures the Enrich Get Policy API request. +type EnrichGetPolicyRequest struct { + Name []string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r EnrichGetPolicyRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_enrich") + 1 + len("policy") + 1 + len(strings.Join(r.Name, ","))) + path.WriteString("/") + path.WriteString("_enrich") + path.WriteString("/") + path.WriteString("policy") + if len(r.Name) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Name, ",")) + } + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f EnrichGetPolicy) WithContext(v context.Context) func(*EnrichGetPolicyRequest) { + return func(r *EnrichGetPolicyRequest) { + r.ctx = v + } +} + +// WithName - a list of enrich policy names. +func (f EnrichGetPolicy) WithName(v ...string) func(*EnrichGetPolicyRequest) { + return func(r *EnrichGetPolicyRequest) { + r.Name = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f EnrichGetPolicy) WithPretty() func(*EnrichGetPolicyRequest) { + return func(r *EnrichGetPolicyRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f EnrichGetPolicy) WithHuman() func(*EnrichGetPolicyRequest) { + return func(r *EnrichGetPolicyRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f EnrichGetPolicy) WithErrorTrace() func(*EnrichGetPolicyRequest) { + return func(r *EnrichGetPolicyRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f EnrichGetPolicy) WithFilterPath(v ...string) func(*EnrichGetPolicyRequest) { + return func(r *EnrichGetPolicyRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f EnrichGetPolicy) WithHeader(h map[string]string) func(*EnrichGetPolicyRequest) { + return func(r *EnrichGetPolicyRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f EnrichGetPolicy) WithOpaqueID(s string) func(*EnrichGetPolicyRequest) { + return func(r *EnrichGetPolicyRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.enrich.put_policy.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.enrich.put_policy.go new file mode 100644 index 00000000..96bbede9 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.enrich.put_policy.go @@ -0,0 +1,200 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newEnrichPutPolicyFunc(t Transport) EnrichPutPolicy { + return func(name string, body io.Reader, o ...func(*EnrichPutPolicyRequest)) (*Response, error) { + var r = EnrichPutPolicyRequest{Name: name, Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// EnrichPutPolicy - Creates a new enrich policy. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/put-enrich-policy-api.html. +type EnrichPutPolicy func(name string, body io.Reader, o ...func(*EnrichPutPolicyRequest)) (*Response, error) + +// EnrichPutPolicyRequest configures the Enrich Put Policy API request. +type EnrichPutPolicyRequest struct { + Body io.Reader + + Name string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r EnrichPutPolicyRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(1 + len("_enrich") + 1 + len("policy") + 1 + len(r.Name)) + path.WriteString("/") + path.WriteString("_enrich") + path.WriteString("/") + path.WriteString("policy") + path.WriteString("/") + path.WriteString(r.Name) + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f EnrichPutPolicy) WithContext(v context.Context) func(*EnrichPutPolicyRequest) { + return func(r *EnrichPutPolicyRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f EnrichPutPolicy) WithPretty() func(*EnrichPutPolicyRequest) { + return func(r *EnrichPutPolicyRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f EnrichPutPolicy) WithHuman() func(*EnrichPutPolicyRequest) { + return func(r *EnrichPutPolicyRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f EnrichPutPolicy) WithErrorTrace() func(*EnrichPutPolicyRequest) { + return func(r *EnrichPutPolicyRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f EnrichPutPolicy) WithFilterPath(v ...string) func(*EnrichPutPolicyRequest) { + return func(r *EnrichPutPolicyRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f EnrichPutPolicy) WithHeader(h map[string]string) func(*EnrichPutPolicyRequest) { + return func(r *EnrichPutPolicyRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f EnrichPutPolicy) WithOpaqueID(s string) func(*EnrichPutPolicyRequest) { + return func(r *EnrichPutPolicyRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.enrich.stats.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.enrich.stats.go new file mode 100644 index 00000000..863e5b46 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.enrich.stats.go @@ -0,0 +1,186 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newEnrichStatsFunc(t Transport) EnrichStats { + return func(o ...func(*EnrichStatsRequest)) (*Response, error) { + var r = EnrichStatsRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// EnrichStats - Gets enrich coordinator statistics and information about enrich policies that are currently executing. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/enrich-stats-api.html. +type EnrichStats func(o ...func(*EnrichStatsRequest)) (*Response, error) + +// EnrichStatsRequest configures the Enrich Stats API request. +type EnrichStatsRequest struct { + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r EnrichStatsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(len("/_enrich/_stats")) + path.WriteString("/_enrich/_stats") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f EnrichStats) WithContext(v context.Context) func(*EnrichStatsRequest) { + return func(r *EnrichStatsRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f EnrichStats) WithPretty() func(*EnrichStatsRequest) { + return func(r *EnrichStatsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f EnrichStats) WithHuman() func(*EnrichStatsRequest) { + return func(r *EnrichStatsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f EnrichStats) WithErrorTrace() func(*EnrichStatsRequest) { + return func(r *EnrichStatsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f EnrichStats) WithFilterPath(v ...string) func(*EnrichStatsRequest) { + return func(r *EnrichStatsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f EnrichStats) WithHeader(h map[string]string) func(*EnrichStatsRequest) { + return func(r *EnrichStatsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f EnrichStats) WithOpaqueID(s string) func(*EnrichStatsRequest) { + return func(r *EnrichStatsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.eql.delete.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.eql.delete.go new file mode 100644 index 00000000..24cb8fce --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.eql.delete.go @@ -0,0 +1,193 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newEqlDeleteFunc(t Transport) EqlDelete { + return func(id string, o ...func(*EqlDeleteRequest)) (*Response, error) { + var r = EqlDeleteRequest{DocumentID: id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// EqlDelete - Deletes an async EQL search by ID. If the search is still running, the search request will be cancelled. Otherwise, the saved search results are deleted. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-search-api.html. +type EqlDelete func(id string, o ...func(*EqlDeleteRequest)) (*Response, error) + +// EqlDeleteRequest configures the Eql Delete API request. +type EqlDeleteRequest struct { + DocumentID string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r EqlDeleteRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + path.Grow(1 + len("_eql") + 1 + len("search") + 1 + len(r.DocumentID)) + path.WriteString("/") + path.WriteString("_eql") + path.WriteString("/") + path.WriteString("search") + path.WriteString("/") + path.WriteString(r.DocumentID) + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f EqlDelete) WithContext(v context.Context) func(*EqlDeleteRequest) { + return func(r *EqlDeleteRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f EqlDelete) WithPretty() func(*EqlDeleteRequest) { + return func(r *EqlDeleteRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f EqlDelete) WithHuman() func(*EqlDeleteRequest) { + return func(r *EqlDeleteRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f EqlDelete) WithErrorTrace() func(*EqlDeleteRequest) { + return func(r *EqlDeleteRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f EqlDelete) WithFilterPath(v ...string) func(*EqlDeleteRequest) { + return func(r *EqlDeleteRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f EqlDelete) WithHeader(h map[string]string) func(*EqlDeleteRequest) { + return func(r *EqlDeleteRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f EqlDelete) WithOpaqueID(s string) func(*EqlDeleteRequest) { + return func(r *EqlDeleteRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.eql.get.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.eql.get.go new file mode 100644 index 00000000..8a95177a --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.eql.get.go @@ -0,0 +1,219 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" + "time" +) + +func newEqlGetFunc(t Transport) EqlGet { + return func(id string, o ...func(*EqlGetRequest)) (*Response, error) { + var r = EqlGetRequest{DocumentID: id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// EqlGet - Returns async results from previously executed Event Query Language (EQL) search +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-search-api.html. +type EqlGet func(id string, o ...func(*EqlGetRequest)) (*Response, error) + +// EqlGetRequest configures the Eql Get API request. +type EqlGetRequest struct { + DocumentID string + + KeepAlive time.Duration + WaitForCompletionTimeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r EqlGetRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_eql") + 1 + len("search") + 1 + len(r.DocumentID)) + path.WriteString("/") + path.WriteString("_eql") + path.WriteString("/") + path.WriteString("search") + path.WriteString("/") + path.WriteString(r.DocumentID) + + params = make(map[string]string) + + if r.KeepAlive != 0 { + params["keep_alive"] = formatDuration(r.KeepAlive) + } + + if r.WaitForCompletionTimeout != 0 { + params["wait_for_completion_timeout"] = formatDuration(r.WaitForCompletionTimeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f EqlGet) WithContext(v context.Context) func(*EqlGetRequest) { + return func(r *EqlGetRequest) { + r.ctx = v + } +} + +// WithKeepAlive - update the time interval in which the results (partial or final) for this search will be available. +func (f EqlGet) WithKeepAlive(v time.Duration) func(*EqlGetRequest) { + return func(r *EqlGetRequest) { + r.KeepAlive = v + } +} + +// WithWaitForCompletionTimeout - specify the time that the request should block waiting for the final response. +func (f EqlGet) WithWaitForCompletionTimeout(v time.Duration) func(*EqlGetRequest) { + return func(r *EqlGetRequest) { + r.WaitForCompletionTimeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f EqlGet) WithPretty() func(*EqlGetRequest) { + return func(r *EqlGetRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f EqlGet) WithHuman() func(*EqlGetRequest) { + return func(r *EqlGetRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f EqlGet) WithErrorTrace() func(*EqlGetRequest) { + return func(r *EqlGetRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f EqlGet) WithFilterPath(v ...string) func(*EqlGetRequest) { + return func(r *EqlGetRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f EqlGet) WithHeader(h map[string]string) func(*EqlGetRequest) { + return func(r *EqlGetRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f EqlGet) WithOpaqueID(s string) func(*EqlGetRequest) { + return func(r *EqlGetRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.eql.get_status.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.eql.get_status.go new file mode 100644 index 00000000..84921011 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.eql.get_status.go @@ -0,0 +1,195 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newEqlGetStatusFunc(t Transport) EqlGetStatus { + return func(id string, o ...func(*EqlGetStatusRequest)) (*Response, error) { + var r = EqlGetStatusRequest{DocumentID: id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// EqlGetStatus - Returns the status of a previously submitted async or stored Event Query Language (EQL) search +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-search-api.html. +type EqlGetStatus func(id string, o ...func(*EqlGetStatusRequest)) (*Response, error) + +// EqlGetStatusRequest configures the Eql Get Status API request. +type EqlGetStatusRequest struct { + DocumentID string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r EqlGetStatusRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_eql") + 1 + len("search") + 1 + len("status") + 1 + len(r.DocumentID)) + path.WriteString("/") + path.WriteString("_eql") + path.WriteString("/") + path.WriteString("search") + path.WriteString("/") + path.WriteString("status") + path.WriteString("/") + path.WriteString(r.DocumentID) + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f EqlGetStatus) WithContext(v context.Context) func(*EqlGetStatusRequest) { + return func(r *EqlGetStatusRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f EqlGetStatus) WithPretty() func(*EqlGetStatusRequest) { + return func(r *EqlGetStatusRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f EqlGetStatus) WithHuman() func(*EqlGetStatusRequest) { + return func(r *EqlGetStatusRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f EqlGetStatus) WithErrorTrace() func(*EqlGetStatusRequest) { + return func(r *EqlGetStatusRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f EqlGetStatus) WithFilterPath(v ...string) func(*EqlGetStatusRequest) { + return func(r *EqlGetStatusRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f EqlGetStatus) WithHeader(h map[string]string) func(*EqlGetStatusRequest) { + return func(r *EqlGetStatusRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f EqlGetStatus) WithOpaqueID(s string) func(*EqlGetStatusRequest) { + return func(r *EqlGetStatusRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.eql.search.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.eql.search.go new file mode 100644 index 00000000..4f277452 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.eql.search.go @@ -0,0 +1,239 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" + "time" +) + +func newEqlSearchFunc(t Transport) EqlSearch { + return func(index string, body io.Reader, o ...func(*EqlSearchRequest)) (*Response, error) { + var r = EqlSearchRequest{Index: index, Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// EqlSearch - Returns results matching a query expressed in Event Query Language (EQL) +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-search-api.html. +type EqlSearch func(index string, body io.Reader, o ...func(*EqlSearchRequest)) (*Response, error) + +// EqlSearchRequest configures the Eql Search API request. +type EqlSearchRequest struct { + Index string + + Body io.Reader + + KeepAlive time.Duration + KeepOnCompletion *bool + WaitForCompletionTimeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r EqlSearchRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len(r.Index) + 1 + len("_eql") + 1 + len("search")) + path.WriteString("/") + path.WriteString(r.Index) + path.WriteString("/") + path.WriteString("_eql") + path.WriteString("/") + path.WriteString("search") + + params = make(map[string]string) + + if r.KeepAlive != 0 { + params["keep_alive"] = formatDuration(r.KeepAlive) + } + + if r.KeepOnCompletion != nil { + params["keep_on_completion"] = strconv.FormatBool(*r.KeepOnCompletion) + } + + if r.WaitForCompletionTimeout != 0 { + params["wait_for_completion_timeout"] = formatDuration(r.WaitForCompletionTimeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f EqlSearch) WithContext(v context.Context) func(*EqlSearchRequest) { + return func(r *EqlSearchRequest) { + r.ctx = v + } +} + +// WithKeepAlive - update the time interval in which the results (partial or final) for this search will be available. +func (f EqlSearch) WithKeepAlive(v time.Duration) func(*EqlSearchRequest) { + return func(r *EqlSearchRequest) { + r.KeepAlive = v + } +} + +// WithKeepOnCompletion - control whether the response should be stored in the cluster if it completed within the provided [wait_for_completion] time (default: false). +func (f EqlSearch) WithKeepOnCompletion(v bool) func(*EqlSearchRequest) { + return func(r *EqlSearchRequest) { + r.KeepOnCompletion = &v + } +} + +// WithWaitForCompletionTimeout - specify the time that the request should block waiting for the final response. +func (f EqlSearch) WithWaitForCompletionTimeout(v time.Duration) func(*EqlSearchRequest) { + return func(r *EqlSearchRequest) { + r.WaitForCompletionTimeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f EqlSearch) WithPretty() func(*EqlSearchRequest) { + return func(r *EqlSearchRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f EqlSearch) WithHuman() func(*EqlSearchRequest) { + return func(r *EqlSearchRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f EqlSearch) WithErrorTrace() func(*EqlSearchRequest) { + return func(r *EqlSearchRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f EqlSearch) WithFilterPath(v ...string) func(*EqlSearchRequest) { + return func(r *EqlSearchRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f EqlSearch) WithHeader(h map[string]string) func(*EqlSearchRequest) { + return func(r *EqlSearchRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f EqlSearch) WithOpaqueID(s string) func(*EqlSearchRequest) { + return func(r *EqlSearchRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.graph.explore.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.graph.explore.go new file mode 100644 index 00000000..3a59da31 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.graph.explore.go @@ -0,0 +1,250 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "errors" + "io" + "net/http" + "strings" + "time" +) + +func newGraphExploreFunc(t Transport) GraphExplore { + return func(index []string, o ...func(*GraphExploreRequest)) (*Response, error) { + var r = GraphExploreRequest{Index: index} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// GraphExplore - Explore extracted and summarized information about the documents and terms in an index. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/graph-explore-api.html. +type GraphExplore func(index []string, o ...func(*GraphExploreRequest)) (*Response, error) + +// GraphExploreRequest configures the Graph Explore API request. +type GraphExploreRequest struct { + Index []string + DocumentType []string + + Body io.Reader + + Routing string + Timeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r GraphExploreRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + if len(r.Index) == 0 { + return nil, errors.New("index is required and cannot be nil or empty") + } + + path.Grow(1 + len(strings.Join(r.Index, ",")) + 1 + len(strings.Join(r.DocumentType, ",")) + 1 + len("_graph") + 1 + len("explore")) + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + if len(r.DocumentType) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.DocumentType, ",")) + } + path.WriteString("/") + path.WriteString("_graph") + path.WriteString("/") + path.WriteString("explore") + + params = make(map[string]string) + + if r.Routing != "" { + params["routing"] = r.Routing + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f GraphExplore) WithContext(v context.Context) func(*GraphExploreRequest) { + return func(r *GraphExploreRequest) { + r.ctx = v + } +} + +// WithBody - Graph Query DSL. +func (f GraphExplore) WithBody(v io.Reader) func(*GraphExploreRequest) { + return func(r *GraphExploreRequest) { + r.Body = v + } +} + +// WithDocumentType - a list of document types to search; leave empty to perform the operation on all types. +func (f GraphExplore) WithDocumentType(v ...string) func(*GraphExploreRequest) { + return func(r *GraphExploreRequest) { + r.DocumentType = v + } +} + +// WithRouting - specific routing value. +func (f GraphExplore) WithRouting(v string) func(*GraphExploreRequest) { + return func(r *GraphExploreRequest) { + r.Routing = v + } +} + +// WithTimeout - explicit operation timeout. +func (f GraphExplore) WithTimeout(v time.Duration) func(*GraphExploreRequest) { + return func(r *GraphExploreRequest) { + r.Timeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f GraphExplore) WithPretty() func(*GraphExploreRequest) { + return func(r *GraphExploreRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f GraphExplore) WithHuman() func(*GraphExploreRequest) { + return func(r *GraphExploreRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f GraphExplore) WithErrorTrace() func(*GraphExploreRequest) { + return func(r *GraphExploreRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f GraphExplore) WithFilterPath(v ...string) func(*GraphExploreRequest) { + return func(r *GraphExploreRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f GraphExplore) WithHeader(h map[string]string) func(*GraphExploreRequest) { + return func(r *GraphExploreRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f GraphExplore) WithOpaqueID(s string) func(*GraphExploreRequest) { + return func(r *GraphExploreRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ilm.delete_lifecycle.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ilm.delete_lifecycle.go new file mode 100644 index 00000000..4942e00d --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ilm.delete_lifecycle.go @@ -0,0 +1,193 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newILMDeleteLifecycleFunc(t Transport) ILMDeleteLifecycle { + return func(policy string, o ...func(*ILMDeleteLifecycleRequest)) (*Response, error) { + var r = ILMDeleteLifecycleRequest{Policy: policy} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// ILMDeleteLifecycle - Deletes the specified lifecycle policy definition. A currently used policy cannot be deleted. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-delete-lifecycle.html. +type ILMDeleteLifecycle func(policy string, o ...func(*ILMDeleteLifecycleRequest)) (*Response, error) + +// ILMDeleteLifecycleRequest configures the ILM Delete Lifecycle API request. +type ILMDeleteLifecycleRequest struct { + Policy string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r ILMDeleteLifecycleRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + path.Grow(1 + len("_ilm") + 1 + len("policy") + 1 + len(r.Policy)) + path.WriteString("/") + path.WriteString("_ilm") + path.WriteString("/") + path.WriteString("policy") + path.WriteString("/") + path.WriteString(r.Policy) + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f ILMDeleteLifecycle) WithContext(v context.Context) func(*ILMDeleteLifecycleRequest) { + return func(r *ILMDeleteLifecycleRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f ILMDeleteLifecycle) WithPretty() func(*ILMDeleteLifecycleRequest) { + return func(r *ILMDeleteLifecycleRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f ILMDeleteLifecycle) WithHuman() func(*ILMDeleteLifecycleRequest) { + return func(r *ILMDeleteLifecycleRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f ILMDeleteLifecycle) WithErrorTrace() func(*ILMDeleteLifecycleRequest) { + return func(r *ILMDeleteLifecycleRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f ILMDeleteLifecycle) WithFilterPath(v ...string) func(*ILMDeleteLifecycleRequest) { + return func(r *ILMDeleteLifecycleRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f ILMDeleteLifecycle) WithHeader(h map[string]string) func(*ILMDeleteLifecycleRequest) { + return func(r *ILMDeleteLifecycleRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f ILMDeleteLifecycle) WithOpaqueID(s string) func(*ILMDeleteLifecycleRequest) { + return func(r *ILMDeleteLifecycleRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ilm.explain_lifecycle.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ilm.explain_lifecycle.go new file mode 100644 index 00000000..f3aba187 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ilm.explain_lifecycle.go @@ -0,0 +1,219 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newILMExplainLifecycleFunc(t Transport) ILMExplainLifecycle { + return func(index string, o ...func(*ILMExplainLifecycleRequest)) (*Response, error) { + var r = ILMExplainLifecycleRequest{Index: index} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// ILMExplainLifecycle - Retrieves information about the index's current lifecycle state, such as the currently executing phase, action, and step. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-explain-lifecycle.html. +type ILMExplainLifecycle func(index string, o ...func(*ILMExplainLifecycleRequest)) (*Response, error) + +// ILMExplainLifecycleRequest configures the ILM Explain Lifecycle API request. +type ILMExplainLifecycleRequest struct { + Index string + + OnlyErrors *bool + OnlyManaged *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r ILMExplainLifecycleRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len(r.Index) + 1 + len("_ilm") + 1 + len("explain")) + path.WriteString("/") + path.WriteString(r.Index) + path.WriteString("/") + path.WriteString("_ilm") + path.WriteString("/") + path.WriteString("explain") + + params = make(map[string]string) + + if r.OnlyErrors != nil { + params["only_errors"] = strconv.FormatBool(*r.OnlyErrors) + } + + if r.OnlyManaged != nil { + params["only_managed"] = strconv.FormatBool(*r.OnlyManaged) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f ILMExplainLifecycle) WithContext(v context.Context) func(*ILMExplainLifecycleRequest) { + return func(r *ILMExplainLifecycleRequest) { + r.ctx = v + } +} + +// WithOnlyErrors - filters the indices included in the response to ones in an ilm error state, implies only_managed. +func (f ILMExplainLifecycle) WithOnlyErrors(v bool) func(*ILMExplainLifecycleRequest) { + return func(r *ILMExplainLifecycleRequest) { + r.OnlyErrors = &v + } +} + +// WithOnlyManaged - filters the indices included in the response to ones managed by ilm. +func (f ILMExplainLifecycle) WithOnlyManaged(v bool) func(*ILMExplainLifecycleRequest) { + return func(r *ILMExplainLifecycleRequest) { + r.OnlyManaged = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f ILMExplainLifecycle) WithPretty() func(*ILMExplainLifecycleRequest) { + return func(r *ILMExplainLifecycleRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f ILMExplainLifecycle) WithHuman() func(*ILMExplainLifecycleRequest) { + return func(r *ILMExplainLifecycleRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f ILMExplainLifecycle) WithErrorTrace() func(*ILMExplainLifecycleRequest) { + return func(r *ILMExplainLifecycleRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f ILMExplainLifecycle) WithFilterPath(v ...string) func(*ILMExplainLifecycleRequest) { + return func(r *ILMExplainLifecycleRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f ILMExplainLifecycle) WithHeader(h map[string]string) func(*ILMExplainLifecycleRequest) { + return func(r *ILMExplainLifecycleRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f ILMExplainLifecycle) WithOpaqueID(s string) func(*ILMExplainLifecycleRequest) { + return func(r *ILMExplainLifecycleRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ilm.get_lifecycle.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ilm.get_lifecycle.go new file mode 100644 index 00000000..e0cc3e77 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ilm.get_lifecycle.go @@ -0,0 +1,202 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newILMGetLifecycleFunc(t Transport) ILMGetLifecycle { + return func(o ...func(*ILMGetLifecycleRequest)) (*Response, error) { + var r = ILMGetLifecycleRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// ILMGetLifecycle - Returns the specified policy definition. Includes the policy version and last modified date. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-get-lifecycle.html. +type ILMGetLifecycle func(o ...func(*ILMGetLifecycleRequest)) (*Response, error) + +// ILMGetLifecycleRequest configures the ILM Get Lifecycle API request. +type ILMGetLifecycleRequest struct { + Policy string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r ILMGetLifecycleRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_ilm") + 1 + len("policy") + 1 + len(r.Policy)) + path.WriteString("/") + path.WriteString("_ilm") + path.WriteString("/") + path.WriteString("policy") + if r.Policy != "" { + path.WriteString("/") + path.WriteString(r.Policy) + } + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f ILMGetLifecycle) WithContext(v context.Context) func(*ILMGetLifecycleRequest) { + return func(r *ILMGetLifecycleRequest) { + r.ctx = v + } +} + +// WithPolicy - the name of the index lifecycle policy. +func (f ILMGetLifecycle) WithPolicy(v string) func(*ILMGetLifecycleRequest) { + return func(r *ILMGetLifecycleRequest) { + r.Policy = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f ILMGetLifecycle) WithPretty() func(*ILMGetLifecycleRequest) { + return func(r *ILMGetLifecycleRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f ILMGetLifecycle) WithHuman() func(*ILMGetLifecycleRequest) { + return func(r *ILMGetLifecycleRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f ILMGetLifecycle) WithErrorTrace() func(*ILMGetLifecycleRequest) { + return func(r *ILMGetLifecycleRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f ILMGetLifecycle) WithFilterPath(v ...string) func(*ILMGetLifecycleRequest) { + return func(r *ILMGetLifecycleRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f ILMGetLifecycle) WithHeader(h map[string]string) func(*ILMGetLifecycleRequest) { + return func(r *ILMGetLifecycleRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f ILMGetLifecycle) WithOpaqueID(s string) func(*ILMGetLifecycleRequest) { + return func(r *ILMGetLifecycleRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ilm.get_status.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ilm.get_status.go new file mode 100644 index 00000000..2fef8bca --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ilm.get_status.go @@ -0,0 +1,186 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newILMGetStatusFunc(t Transport) ILMGetStatus { + return func(o ...func(*ILMGetStatusRequest)) (*Response, error) { + var r = ILMGetStatusRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// ILMGetStatus - Retrieves the current index lifecycle management (ILM) status. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-get-status.html. +type ILMGetStatus func(o ...func(*ILMGetStatusRequest)) (*Response, error) + +// ILMGetStatusRequest configures the ILM Get Status API request. +type ILMGetStatusRequest struct { + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r ILMGetStatusRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(len("/_ilm/status")) + path.WriteString("/_ilm/status") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f ILMGetStatus) WithContext(v context.Context) func(*ILMGetStatusRequest) { + return func(r *ILMGetStatusRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f ILMGetStatus) WithPretty() func(*ILMGetStatusRequest) { + return func(r *ILMGetStatusRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f ILMGetStatus) WithHuman() func(*ILMGetStatusRequest) { + return func(r *ILMGetStatusRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f ILMGetStatus) WithErrorTrace() func(*ILMGetStatusRequest) { + return func(r *ILMGetStatusRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f ILMGetStatus) WithFilterPath(v ...string) func(*ILMGetStatusRequest) { + return func(r *ILMGetStatusRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f ILMGetStatus) WithHeader(h map[string]string) func(*ILMGetStatusRequest) { + return func(r *ILMGetStatusRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f ILMGetStatus) WithOpaqueID(s string) func(*ILMGetStatusRequest) { + return func(r *ILMGetStatusRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ilm.migrate_to_data_tiers.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ilm.migrate_to_data_tiers.go new file mode 100644 index 00000000..d8ab01e1 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ilm.migrate_to_data_tiers.go @@ -0,0 +1,214 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" +) + +func newILMMigrateToDataTiersFunc(t Transport) ILMMigrateToDataTiers { + return func(o ...func(*ILMMigrateToDataTiersRequest)) (*Response, error) { + var r = ILMMigrateToDataTiersRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// ILMMigrateToDataTiers - Migrates the indices and ILM policies away from custom node attribute allocation routing to data tiers routing +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-migrate-to-data-tiers.html. +type ILMMigrateToDataTiers func(o ...func(*ILMMigrateToDataTiersRequest)) (*Response, error) + +// ILMMigrateToDataTiersRequest configures the ILM Migrate To Data Tiers API request. +type ILMMigrateToDataTiersRequest struct { + Body io.Reader + + DryRun *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r ILMMigrateToDataTiersRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(len("/_ilm/migrate_to_data_tiers")) + path.WriteString("/_ilm/migrate_to_data_tiers") + + params = make(map[string]string) + + if r.DryRun != nil { + params["dry_run"] = strconv.FormatBool(*r.DryRun) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f ILMMigrateToDataTiers) WithContext(v context.Context) func(*ILMMigrateToDataTiersRequest) { + return func(r *ILMMigrateToDataTiersRequest) { + r.ctx = v + } +} + +// WithBody - Optionally specify a legacy index template name to delete and optionally specify a node attribute name used for index shard routing (defaults to "data"). +func (f ILMMigrateToDataTiers) WithBody(v io.Reader) func(*ILMMigrateToDataTiersRequest) { + return func(r *ILMMigrateToDataTiersRequest) { + r.Body = v + } +} + +// WithDryRun - if set to true it will simulate the migration, providing a way to retrieve the ilm policies and indices that need to be migrated. the default is false. +func (f ILMMigrateToDataTiers) WithDryRun(v bool) func(*ILMMigrateToDataTiersRequest) { + return func(r *ILMMigrateToDataTiersRequest) { + r.DryRun = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f ILMMigrateToDataTiers) WithPretty() func(*ILMMigrateToDataTiersRequest) { + return func(r *ILMMigrateToDataTiersRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f ILMMigrateToDataTiers) WithHuman() func(*ILMMigrateToDataTiersRequest) { + return func(r *ILMMigrateToDataTiersRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f ILMMigrateToDataTiers) WithErrorTrace() func(*ILMMigrateToDataTiersRequest) { + return func(r *ILMMigrateToDataTiersRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f ILMMigrateToDataTiers) WithFilterPath(v ...string) func(*ILMMigrateToDataTiersRequest) { + return func(r *ILMMigrateToDataTiersRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f ILMMigrateToDataTiers) WithHeader(h map[string]string) func(*ILMMigrateToDataTiersRequest) { + return func(r *ILMMigrateToDataTiersRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f ILMMigrateToDataTiers) WithOpaqueID(s string) func(*ILMMigrateToDataTiersRequest) { + return func(r *ILMMigrateToDataTiersRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ilm.move_to_step.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ilm.move_to_step.go new file mode 100644 index 00000000..1762b70b --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ilm.move_to_step.go @@ -0,0 +1,207 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newILMMoveToStepFunc(t Transport) ILMMoveToStep { + return func(index string, o ...func(*ILMMoveToStepRequest)) (*Response, error) { + var r = ILMMoveToStepRequest{Index: index} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// ILMMoveToStep - Manually moves an index into the specified step and executes that step. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-move-to-step.html. +type ILMMoveToStep func(index string, o ...func(*ILMMoveToStepRequest)) (*Response, error) + +// ILMMoveToStepRequest configures the ILM Move To Step API request. +type ILMMoveToStepRequest struct { + Index string + + Body io.Reader + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r ILMMoveToStepRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_ilm") + 1 + len("move") + 1 + len(r.Index)) + path.WriteString("/") + path.WriteString("_ilm") + path.WriteString("/") + path.WriteString("move") + path.WriteString("/") + path.WriteString(r.Index) + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f ILMMoveToStep) WithContext(v context.Context) func(*ILMMoveToStepRequest) { + return func(r *ILMMoveToStepRequest) { + r.ctx = v + } +} + +// WithBody - The new lifecycle step to move to. +func (f ILMMoveToStep) WithBody(v io.Reader) func(*ILMMoveToStepRequest) { + return func(r *ILMMoveToStepRequest) { + r.Body = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f ILMMoveToStep) WithPretty() func(*ILMMoveToStepRequest) { + return func(r *ILMMoveToStepRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f ILMMoveToStep) WithHuman() func(*ILMMoveToStepRequest) { + return func(r *ILMMoveToStepRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f ILMMoveToStep) WithErrorTrace() func(*ILMMoveToStepRequest) { + return func(r *ILMMoveToStepRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f ILMMoveToStep) WithFilterPath(v ...string) func(*ILMMoveToStepRequest) { + return func(r *ILMMoveToStepRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f ILMMoveToStep) WithHeader(h map[string]string) func(*ILMMoveToStepRequest) { + return func(r *ILMMoveToStepRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f ILMMoveToStep) WithOpaqueID(s string) func(*ILMMoveToStepRequest) { + return func(r *ILMMoveToStepRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ilm.put_lifecycle.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ilm.put_lifecycle.go new file mode 100644 index 00000000..5cf805d1 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ilm.put_lifecycle.go @@ -0,0 +1,207 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newILMPutLifecycleFunc(t Transport) ILMPutLifecycle { + return func(policy string, o ...func(*ILMPutLifecycleRequest)) (*Response, error) { + var r = ILMPutLifecycleRequest{Policy: policy} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// ILMPutLifecycle - Creates a lifecycle policy +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-put-lifecycle.html. +type ILMPutLifecycle func(policy string, o ...func(*ILMPutLifecycleRequest)) (*Response, error) + +// ILMPutLifecycleRequest configures the ILM Put Lifecycle API request. +type ILMPutLifecycleRequest struct { + Body io.Reader + + Policy string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r ILMPutLifecycleRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(1 + len("_ilm") + 1 + len("policy") + 1 + len(r.Policy)) + path.WriteString("/") + path.WriteString("_ilm") + path.WriteString("/") + path.WriteString("policy") + path.WriteString("/") + path.WriteString(r.Policy) + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f ILMPutLifecycle) WithContext(v context.Context) func(*ILMPutLifecycleRequest) { + return func(r *ILMPutLifecycleRequest) { + r.ctx = v + } +} + +// WithBody - The lifecycle policy definition to register. +func (f ILMPutLifecycle) WithBody(v io.Reader) func(*ILMPutLifecycleRequest) { + return func(r *ILMPutLifecycleRequest) { + r.Body = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f ILMPutLifecycle) WithPretty() func(*ILMPutLifecycleRequest) { + return func(r *ILMPutLifecycleRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f ILMPutLifecycle) WithHuman() func(*ILMPutLifecycleRequest) { + return func(r *ILMPutLifecycleRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f ILMPutLifecycle) WithErrorTrace() func(*ILMPutLifecycleRequest) { + return func(r *ILMPutLifecycleRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f ILMPutLifecycle) WithFilterPath(v ...string) func(*ILMPutLifecycleRequest) { + return func(r *ILMPutLifecycleRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f ILMPutLifecycle) WithHeader(h map[string]string) func(*ILMPutLifecycleRequest) { + return func(r *ILMPutLifecycleRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f ILMPutLifecycle) WithOpaqueID(s string) func(*ILMPutLifecycleRequest) { + return func(r *ILMPutLifecycleRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ilm.remove_policy.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ilm.remove_policy.go new file mode 100644 index 00000000..388b45a3 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ilm.remove_policy.go @@ -0,0 +1,193 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newILMRemovePolicyFunc(t Transport) ILMRemovePolicy { + return func(index string, o ...func(*ILMRemovePolicyRequest)) (*Response, error) { + var r = ILMRemovePolicyRequest{Index: index} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// ILMRemovePolicy - Removes the assigned lifecycle policy and stops managing the specified index +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-remove-policy.html. +type ILMRemovePolicy func(index string, o ...func(*ILMRemovePolicyRequest)) (*Response, error) + +// ILMRemovePolicyRequest configures the ILM Remove Policy API request. +type ILMRemovePolicyRequest struct { + Index string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r ILMRemovePolicyRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len(r.Index) + 1 + len("_ilm") + 1 + len("remove")) + path.WriteString("/") + path.WriteString(r.Index) + path.WriteString("/") + path.WriteString("_ilm") + path.WriteString("/") + path.WriteString("remove") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f ILMRemovePolicy) WithContext(v context.Context) func(*ILMRemovePolicyRequest) { + return func(r *ILMRemovePolicyRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f ILMRemovePolicy) WithPretty() func(*ILMRemovePolicyRequest) { + return func(r *ILMRemovePolicyRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f ILMRemovePolicy) WithHuman() func(*ILMRemovePolicyRequest) { + return func(r *ILMRemovePolicyRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f ILMRemovePolicy) WithErrorTrace() func(*ILMRemovePolicyRequest) { + return func(r *ILMRemovePolicyRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f ILMRemovePolicy) WithFilterPath(v ...string) func(*ILMRemovePolicyRequest) { + return func(r *ILMRemovePolicyRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f ILMRemovePolicy) WithHeader(h map[string]string) func(*ILMRemovePolicyRequest) { + return func(r *ILMRemovePolicyRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f ILMRemovePolicy) WithOpaqueID(s string) func(*ILMRemovePolicyRequest) { + return func(r *ILMRemovePolicyRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ilm.retry.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ilm.retry.go new file mode 100644 index 00000000..051cf041 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ilm.retry.go @@ -0,0 +1,193 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newILMRetryFunc(t Transport) ILMRetry { + return func(index string, o ...func(*ILMRetryRequest)) (*Response, error) { + var r = ILMRetryRequest{Index: index} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// ILMRetry - Retries executing the policy for an index that is in the ERROR step. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-retry-policy.html. +type ILMRetry func(index string, o ...func(*ILMRetryRequest)) (*Response, error) + +// ILMRetryRequest configures the ILM Retry API request. +type ILMRetryRequest struct { + Index string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r ILMRetryRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len(r.Index) + 1 + len("_ilm") + 1 + len("retry")) + path.WriteString("/") + path.WriteString(r.Index) + path.WriteString("/") + path.WriteString("_ilm") + path.WriteString("/") + path.WriteString("retry") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f ILMRetry) WithContext(v context.Context) func(*ILMRetryRequest) { + return func(r *ILMRetryRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f ILMRetry) WithPretty() func(*ILMRetryRequest) { + return func(r *ILMRetryRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f ILMRetry) WithHuman() func(*ILMRetryRequest) { + return func(r *ILMRetryRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f ILMRetry) WithErrorTrace() func(*ILMRetryRequest) { + return func(r *ILMRetryRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f ILMRetry) WithFilterPath(v ...string) func(*ILMRetryRequest) { + return func(r *ILMRetryRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f ILMRetry) WithHeader(h map[string]string) func(*ILMRetryRequest) { + return func(r *ILMRetryRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f ILMRetry) WithOpaqueID(s string) func(*ILMRetryRequest) { + return func(r *ILMRetryRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ilm.start.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ilm.start.go new file mode 100644 index 00000000..901c6dc6 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ilm.start.go @@ -0,0 +1,186 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newILMStartFunc(t Transport) ILMStart { + return func(o ...func(*ILMStartRequest)) (*Response, error) { + var r = ILMStartRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// ILMStart - Start the index lifecycle management (ILM) plugin. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-start.html. +type ILMStart func(o ...func(*ILMStartRequest)) (*Response, error) + +// ILMStartRequest configures the ILM Start API request. +type ILMStartRequest struct { + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r ILMStartRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(len("/_ilm/start")) + path.WriteString("/_ilm/start") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f ILMStart) WithContext(v context.Context) func(*ILMStartRequest) { + return func(r *ILMStartRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f ILMStart) WithPretty() func(*ILMStartRequest) { + return func(r *ILMStartRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f ILMStart) WithHuman() func(*ILMStartRequest) { + return func(r *ILMStartRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f ILMStart) WithErrorTrace() func(*ILMStartRequest) { + return func(r *ILMStartRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f ILMStart) WithFilterPath(v ...string) func(*ILMStartRequest) { + return func(r *ILMStartRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f ILMStart) WithHeader(h map[string]string) func(*ILMStartRequest) { + return func(r *ILMStartRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f ILMStart) WithOpaqueID(s string) func(*ILMStartRequest) { + return func(r *ILMStartRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ilm.stop.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ilm.stop.go new file mode 100644 index 00000000..b0163515 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ilm.stop.go @@ -0,0 +1,186 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newILMStopFunc(t Transport) ILMStop { + return func(o ...func(*ILMStopRequest)) (*Response, error) { + var r = ILMStopRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// ILMStop - Halts all lifecycle management operations and stops the index lifecycle management (ILM) plugin +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-stop.html. +type ILMStop func(o ...func(*ILMStopRequest)) (*Response, error) + +// ILMStopRequest configures the ILM Stop API request. +type ILMStopRequest struct { + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r ILMStopRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(len("/_ilm/stop")) + path.WriteString("/_ilm/stop") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f ILMStop) WithContext(v context.Context) func(*ILMStopRequest) { + return func(r *ILMStopRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f ILMStop) WithPretty() func(*ILMStopRequest) { + return func(r *ILMStopRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f ILMStop) WithHuman() func(*ILMStopRequest) { + return func(r *ILMStopRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f ILMStop) WithErrorTrace() func(*ILMStopRequest) { + return func(r *ILMStopRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f ILMStop) WithFilterPath(v ...string) func(*ILMStopRequest) { + return func(r *ILMStopRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f ILMStop) WithHeader(h map[string]string) func(*ILMStopRequest) { + return func(r *ILMStopRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f ILMStop) WithOpaqueID(s string) func(*ILMStopRequest) { + return func(r *ILMStopRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.indices.create_data_stream.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.indices.create_data_stream.go new file mode 100644 index 00000000..54937f21 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.indices.create_data_stream.go @@ -0,0 +1,191 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newIndicesCreateDataStreamFunc(t Transport) IndicesCreateDataStream { + return func(name string, o ...func(*IndicesCreateDataStreamRequest)) (*Response, error) { + var r = IndicesCreateDataStreamRequest{Name: name} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesCreateDataStream - Creates a data stream +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html. +type IndicesCreateDataStream func(name string, o ...func(*IndicesCreateDataStreamRequest)) (*Response, error) + +// IndicesCreateDataStreamRequest configures the Indices Create Data Stream API request. +type IndicesCreateDataStreamRequest struct { + Name string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesCreateDataStreamRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(1 + len("_data_stream") + 1 + len(r.Name)) + path.WriteString("/") + path.WriteString("_data_stream") + path.WriteString("/") + path.WriteString(r.Name) + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesCreateDataStream) WithContext(v context.Context) func(*IndicesCreateDataStreamRequest) { + return func(r *IndicesCreateDataStreamRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesCreateDataStream) WithPretty() func(*IndicesCreateDataStreamRequest) { + return func(r *IndicesCreateDataStreamRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesCreateDataStream) WithHuman() func(*IndicesCreateDataStreamRequest) { + return func(r *IndicesCreateDataStreamRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesCreateDataStream) WithErrorTrace() func(*IndicesCreateDataStreamRequest) { + return func(r *IndicesCreateDataStreamRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesCreateDataStream) WithFilterPath(v ...string) func(*IndicesCreateDataStreamRequest) { + return func(r *IndicesCreateDataStreamRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesCreateDataStream) WithHeader(h map[string]string) func(*IndicesCreateDataStreamRequest) { + return func(r *IndicesCreateDataStreamRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesCreateDataStream) WithOpaqueID(s string) func(*IndicesCreateDataStreamRequest) { + return func(r *IndicesCreateDataStreamRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.indices.data_streams_stats.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.indices.data_streams_stats.go new file mode 100644 index 00000000..818804c9 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.indices.data_streams_stats.go @@ -0,0 +1,202 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newIndicesDataStreamsStatsFunc(t Transport) IndicesDataStreamsStats { + return func(o ...func(*IndicesDataStreamsStatsRequest)) (*Response, error) { + var r = IndicesDataStreamsStatsRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesDataStreamsStats - Provides statistics on operations happening in a data stream. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html. +type IndicesDataStreamsStats func(o ...func(*IndicesDataStreamsStatsRequest)) (*Response, error) + +// IndicesDataStreamsStatsRequest configures the Indices Data Streams Stats API request. +type IndicesDataStreamsStatsRequest struct { + Name []string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesDataStreamsStatsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_data_stream") + 1 + len(strings.Join(r.Name, ",")) + 1 + len("_stats")) + path.WriteString("/") + path.WriteString("_data_stream") + if len(r.Name) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Name, ",")) + } + path.WriteString("/") + path.WriteString("_stats") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesDataStreamsStats) WithContext(v context.Context) func(*IndicesDataStreamsStatsRequest) { + return func(r *IndicesDataStreamsStatsRequest) { + r.ctx = v + } +} + +// WithName - a list of data stream names; use _all to perform the operation on all data streams. +func (f IndicesDataStreamsStats) WithName(v ...string) func(*IndicesDataStreamsStatsRequest) { + return func(r *IndicesDataStreamsStatsRequest) { + r.Name = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesDataStreamsStats) WithPretty() func(*IndicesDataStreamsStatsRequest) { + return func(r *IndicesDataStreamsStatsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesDataStreamsStats) WithHuman() func(*IndicesDataStreamsStatsRequest) { + return func(r *IndicesDataStreamsStatsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesDataStreamsStats) WithErrorTrace() func(*IndicesDataStreamsStatsRequest) { + return func(r *IndicesDataStreamsStatsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesDataStreamsStats) WithFilterPath(v ...string) func(*IndicesDataStreamsStatsRequest) { + return func(r *IndicesDataStreamsStatsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesDataStreamsStats) WithHeader(h map[string]string) func(*IndicesDataStreamsStatsRequest) { + return func(r *IndicesDataStreamsStatsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesDataStreamsStats) WithOpaqueID(s string) func(*IndicesDataStreamsStatsRequest) { + return func(r *IndicesDataStreamsStatsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.indices.delete_data_stream.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.indices.delete_data_stream.go new file mode 100644 index 00000000..d4dfa55d --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.indices.delete_data_stream.go @@ -0,0 +1,209 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "errors" + "net/http" + "strings" +) + +func newIndicesDeleteDataStreamFunc(t Transport) IndicesDeleteDataStream { + return func(name []string, o ...func(*IndicesDeleteDataStreamRequest)) (*Response, error) { + var r = IndicesDeleteDataStreamRequest{Name: name} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesDeleteDataStream - Deletes a data stream. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html. +type IndicesDeleteDataStream func(name []string, o ...func(*IndicesDeleteDataStreamRequest)) (*Response, error) + +// IndicesDeleteDataStreamRequest configures the Indices Delete Data Stream API request. +type IndicesDeleteDataStreamRequest struct { + Name []string + + ExpandWildcards string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesDeleteDataStreamRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + if len(r.Name) == 0 { + return nil, errors.New("name is required and cannot be nil or empty") + } + + path.Grow(1 + len("_data_stream") + 1 + len(strings.Join(r.Name, ","))) + path.WriteString("/") + path.WriteString("_data_stream") + path.WriteString("/") + path.WriteString(strings.Join(r.Name, ",")) + + params = make(map[string]string) + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesDeleteDataStream) WithContext(v context.Context) func(*IndicesDeleteDataStreamRequest) { + return func(r *IndicesDeleteDataStreamRequest) { + r.ctx = v + } +} + +// WithExpandWildcards - whether wildcard expressions should get expanded to open or closed indices (default: open). +func (f IndicesDeleteDataStream) WithExpandWildcards(v string) func(*IndicesDeleteDataStreamRequest) { + return func(r *IndicesDeleteDataStreamRequest) { + r.ExpandWildcards = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesDeleteDataStream) WithPretty() func(*IndicesDeleteDataStreamRequest) { + return func(r *IndicesDeleteDataStreamRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesDeleteDataStream) WithHuman() func(*IndicesDeleteDataStreamRequest) { + return func(r *IndicesDeleteDataStreamRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesDeleteDataStream) WithErrorTrace() func(*IndicesDeleteDataStreamRequest) { + return func(r *IndicesDeleteDataStreamRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesDeleteDataStream) WithFilterPath(v ...string) func(*IndicesDeleteDataStreamRequest) { + return func(r *IndicesDeleteDataStreamRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesDeleteDataStream) WithHeader(h map[string]string) func(*IndicesDeleteDataStreamRequest) { + return func(r *IndicesDeleteDataStreamRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesDeleteDataStream) WithOpaqueID(s string) func(*IndicesDeleteDataStreamRequest) { + return func(r *IndicesDeleteDataStreamRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.indices.freeze.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.indices.freeze.go new file mode 100644 index 00000000..28a53444 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.indices.freeze.go @@ -0,0 +1,266 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" + "time" +) + +func newIndicesFreezeFunc(t Transport) IndicesFreeze { + return func(index string, o ...func(*IndicesFreezeRequest)) (*Response, error) { + var r = IndicesFreezeRequest{Index: index} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesFreeze - Freezes an index. A frozen index has almost no overhead on the cluster (except for maintaining its metadata in memory) and is read-only. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/freeze-index-api.html. +type IndicesFreeze func(index string, o ...func(*IndicesFreezeRequest)) (*Response, error) + +// IndicesFreezeRequest configures the Indices Freeze API request. +type IndicesFreezeRequest struct { + Index string + + AllowNoIndices *bool + ExpandWildcards string + IgnoreUnavailable *bool + MasterTimeout time.Duration + Timeout time.Duration + WaitForActiveShards string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesFreezeRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len(r.Index) + 1 + len("_freeze")) + path.WriteString("/") + path.WriteString(r.Index) + path.WriteString("/") + path.WriteString("_freeze") + + params = make(map[string]string) + + if r.AllowNoIndices != nil { + params["allow_no_indices"] = strconv.FormatBool(*r.AllowNoIndices) + } + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if r.IgnoreUnavailable != nil { + params["ignore_unavailable"] = strconv.FormatBool(*r.IgnoreUnavailable) + } + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.WaitForActiveShards != "" { + params["wait_for_active_shards"] = r.WaitForActiveShards + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesFreeze) WithContext(v context.Context) func(*IndicesFreezeRequest) { + return func(r *IndicesFreezeRequest) { + r.ctx = v + } +} + +// WithAllowNoIndices - whether to ignore if a wildcard indices expression resolves into no concrete indices. (this includes `_all` string or when no indices have been specified). +func (f IndicesFreeze) WithAllowNoIndices(v bool) func(*IndicesFreezeRequest) { + return func(r *IndicesFreezeRequest) { + r.AllowNoIndices = &v + } +} + +// WithExpandWildcards - whether to expand wildcard expression to concrete indices that are open, closed or both.. +func (f IndicesFreeze) WithExpandWildcards(v string) func(*IndicesFreezeRequest) { + return func(r *IndicesFreezeRequest) { + r.ExpandWildcards = v + } +} + +// WithIgnoreUnavailable - whether specified concrete indices should be ignored when unavailable (missing or closed). +func (f IndicesFreeze) WithIgnoreUnavailable(v bool) func(*IndicesFreezeRequest) { + return func(r *IndicesFreezeRequest) { + r.IgnoreUnavailable = &v + } +} + +// WithMasterTimeout - specify timeout for connection to master. +func (f IndicesFreeze) WithMasterTimeout(v time.Duration) func(*IndicesFreezeRequest) { + return func(r *IndicesFreezeRequest) { + r.MasterTimeout = v + } +} + +// WithTimeout - explicit operation timeout. +func (f IndicesFreeze) WithTimeout(v time.Duration) func(*IndicesFreezeRequest) { + return func(r *IndicesFreezeRequest) { + r.Timeout = v + } +} + +// WithWaitForActiveShards - sets the number of active shards to wait for before the operation returns.. +func (f IndicesFreeze) WithWaitForActiveShards(v string) func(*IndicesFreezeRequest) { + return func(r *IndicesFreezeRequest) { + r.WaitForActiveShards = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesFreeze) WithPretty() func(*IndicesFreezeRequest) { + return func(r *IndicesFreezeRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesFreeze) WithHuman() func(*IndicesFreezeRequest) { + return func(r *IndicesFreezeRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesFreeze) WithErrorTrace() func(*IndicesFreezeRequest) { + return func(r *IndicesFreezeRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesFreeze) WithFilterPath(v ...string) func(*IndicesFreezeRequest) { + return func(r *IndicesFreezeRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesFreeze) WithHeader(h map[string]string) func(*IndicesFreezeRequest) { + return func(r *IndicesFreezeRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesFreeze) WithOpaqueID(s string) func(*IndicesFreezeRequest) { + return func(r *IndicesFreezeRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.indices.get_data_stream.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.indices.get_data_stream.go new file mode 100644 index 00000000..5b596355 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.indices.get_data_stream.go @@ -0,0 +1,213 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newIndicesGetDataStreamFunc(t Transport) IndicesGetDataStream { + return func(o ...func(*IndicesGetDataStreamRequest)) (*Response, error) { + var r = IndicesGetDataStreamRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesGetDataStream - Returns data streams. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html. +type IndicesGetDataStream func(o ...func(*IndicesGetDataStreamRequest)) (*Response, error) + +// IndicesGetDataStreamRequest configures the Indices Get Data Stream API request. +type IndicesGetDataStreamRequest struct { + Name []string + + ExpandWildcards string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesGetDataStreamRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_data_stream") + 1 + len(strings.Join(r.Name, ","))) + path.WriteString("/") + path.WriteString("_data_stream") + if len(r.Name) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Name, ",")) + } + + params = make(map[string]string) + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesGetDataStream) WithContext(v context.Context) func(*IndicesGetDataStreamRequest) { + return func(r *IndicesGetDataStreamRequest) { + r.ctx = v + } +} + +// WithName - a list of data streams to get; use `*` to get all data streams. +func (f IndicesGetDataStream) WithName(v ...string) func(*IndicesGetDataStreamRequest) { + return func(r *IndicesGetDataStreamRequest) { + r.Name = v + } +} + +// WithExpandWildcards - whether wildcard expressions should get expanded to open or closed indices (default: open). +func (f IndicesGetDataStream) WithExpandWildcards(v string) func(*IndicesGetDataStreamRequest) { + return func(r *IndicesGetDataStreamRequest) { + r.ExpandWildcards = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesGetDataStream) WithPretty() func(*IndicesGetDataStreamRequest) { + return func(r *IndicesGetDataStreamRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesGetDataStream) WithHuman() func(*IndicesGetDataStreamRequest) { + return func(r *IndicesGetDataStreamRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesGetDataStream) WithErrorTrace() func(*IndicesGetDataStreamRequest) { + return func(r *IndicesGetDataStreamRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesGetDataStream) WithFilterPath(v ...string) func(*IndicesGetDataStreamRequest) { + return func(r *IndicesGetDataStreamRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesGetDataStream) WithHeader(h map[string]string) func(*IndicesGetDataStreamRequest) { + return func(r *IndicesGetDataStreamRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesGetDataStream) WithOpaqueID(s string) func(*IndicesGetDataStreamRequest) { + return func(r *IndicesGetDataStreamRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.indices.migrate_to_data_stream.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.indices.migrate_to_data_stream.go new file mode 100644 index 00000000..f749db06 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.indices.migrate_to_data_stream.go @@ -0,0 +1,193 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newIndicesMigrateToDataStreamFunc(t Transport) IndicesMigrateToDataStream { + return func(name string, o ...func(*IndicesMigrateToDataStreamRequest)) (*Response, error) { + var r = IndicesMigrateToDataStreamRequest{Name: name} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesMigrateToDataStream - Migrates an alias to a data stream +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html. +type IndicesMigrateToDataStream func(name string, o ...func(*IndicesMigrateToDataStreamRequest)) (*Response, error) + +// IndicesMigrateToDataStreamRequest configures the Indices Migrate To Data Stream API request. +type IndicesMigrateToDataStreamRequest struct { + Name string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesMigrateToDataStreamRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_data_stream") + 1 + len("_migrate") + 1 + len(r.Name)) + path.WriteString("/") + path.WriteString("_data_stream") + path.WriteString("/") + path.WriteString("_migrate") + path.WriteString("/") + path.WriteString(r.Name) + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesMigrateToDataStream) WithContext(v context.Context) func(*IndicesMigrateToDataStreamRequest) { + return func(r *IndicesMigrateToDataStreamRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesMigrateToDataStream) WithPretty() func(*IndicesMigrateToDataStreamRequest) { + return func(r *IndicesMigrateToDataStreamRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesMigrateToDataStream) WithHuman() func(*IndicesMigrateToDataStreamRequest) { + return func(r *IndicesMigrateToDataStreamRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesMigrateToDataStream) WithErrorTrace() func(*IndicesMigrateToDataStreamRequest) { + return func(r *IndicesMigrateToDataStreamRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesMigrateToDataStream) WithFilterPath(v ...string) func(*IndicesMigrateToDataStreamRequest) { + return func(r *IndicesMigrateToDataStreamRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesMigrateToDataStream) WithHeader(h map[string]string) func(*IndicesMigrateToDataStreamRequest) { + return func(r *IndicesMigrateToDataStreamRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesMigrateToDataStream) WithOpaqueID(s string) func(*IndicesMigrateToDataStreamRequest) { + return func(r *IndicesMigrateToDataStreamRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.indices.promote_data_stream.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.indices.promote_data_stream.go new file mode 100644 index 00000000..ddd737c3 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.indices.promote_data_stream.go @@ -0,0 +1,193 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newIndicesPromoteDataStreamFunc(t Transport) IndicesPromoteDataStream { + return func(name string, o ...func(*IndicesPromoteDataStreamRequest)) (*Response, error) { + var r = IndicesPromoteDataStreamRequest{Name: name} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesPromoteDataStream - Promotes a data stream from a replicated data stream managed by CCR to a regular data stream +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html. +type IndicesPromoteDataStream func(name string, o ...func(*IndicesPromoteDataStreamRequest)) (*Response, error) + +// IndicesPromoteDataStreamRequest configures the Indices Promote Data Stream API request. +type IndicesPromoteDataStreamRequest struct { + Name string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesPromoteDataStreamRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_data_stream") + 1 + len("_promote") + 1 + len(r.Name)) + path.WriteString("/") + path.WriteString("_data_stream") + path.WriteString("/") + path.WriteString("_promote") + path.WriteString("/") + path.WriteString(r.Name) + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesPromoteDataStream) WithContext(v context.Context) func(*IndicesPromoteDataStreamRequest) { + return func(r *IndicesPromoteDataStreamRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesPromoteDataStream) WithPretty() func(*IndicesPromoteDataStreamRequest) { + return func(r *IndicesPromoteDataStreamRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesPromoteDataStream) WithHuman() func(*IndicesPromoteDataStreamRequest) { + return func(r *IndicesPromoteDataStreamRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesPromoteDataStream) WithErrorTrace() func(*IndicesPromoteDataStreamRequest) { + return func(r *IndicesPromoteDataStreamRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesPromoteDataStream) WithFilterPath(v ...string) func(*IndicesPromoteDataStreamRequest) { + return func(r *IndicesPromoteDataStreamRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesPromoteDataStream) WithHeader(h map[string]string) func(*IndicesPromoteDataStreamRequest) { + return func(r *IndicesPromoteDataStreamRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesPromoteDataStream) WithOpaqueID(s string) func(*IndicesPromoteDataStreamRequest) { + return func(r *IndicesPromoteDataStreamRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.indices.reload_search_analyzers.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.indices.reload_search_analyzers.go new file mode 100644 index 00000000..33ae03cd --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.indices.reload_search_analyzers.go @@ -0,0 +1,234 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "errors" + "net/http" + "strconv" + "strings" +) + +func newIndicesReloadSearchAnalyzersFunc(t Transport) IndicesReloadSearchAnalyzers { + return func(index []string, o ...func(*IndicesReloadSearchAnalyzersRequest)) (*Response, error) { + var r = IndicesReloadSearchAnalyzersRequest{Index: index} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesReloadSearchAnalyzers - Reloads an index's search analyzers and their resources. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-reload-analyzers.html. +type IndicesReloadSearchAnalyzers func(index []string, o ...func(*IndicesReloadSearchAnalyzersRequest)) (*Response, error) + +// IndicesReloadSearchAnalyzersRequest configures the Indices Reload Search Analyzers API request. +type IndicesReloadSearchAnalyzersRequest struct { + Index []string + + AllowNoIndices *bool + ExpandWildcards string + IgnoreUnavailable *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesReloadSearchAnalyzersRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + if len(r.Index) == 0 { + return nil, errors.New("index is required and cannot be nil or empty") + } + + path.Grow(1 + len(strings.Join(r.Index, ",")) + 1 + len("_reload_search_analyzers")) + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + path.WriteString("/") + path.WriteString("_reload_search_analyzers") + + params = make(map[string]string) + + if r.AllowNoIndices != nil { + params["allow_no_indices"] = strconv.FormatBool(*r.AllowNoIndices) + } + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if r.IgnoreUnavailable != nil { + params["ignore_unavailable"] = strconv.FormatBool(*r.IgnoreUnavailable) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesReloadSearchAnalyzers) WithContext(v context.Context) func(*IndicesReloadSearchAnalyzersRequest) { + return func(r *IndicesReloadSearchAnalyzersRequest) { + r.ctx = v + } +} + +// WithAllowNoIndices - whether to ignore if a wildcard indices expression resolves into no concrete indices. (this includes `_all` string or when no indices have been specified). +func (f IndicesReloadSearchAnalyzers) WithAllowNoIndices(v bool) func(*IndicesReloadSearchAnalyzersRequest) { + return func(r *IndicesReloadSearchAnalyzersRequest) { + r.AllowNoIndices = &v + } +} + +// WithExpandWildcards - whether to expand wildcard expression to concrete indices that are open, closed or both.. +func (f IndicesReloadSearchAnalyzers) WithExpandWildcards(v string) func(*IndicesReloadSearchAnalyzersRequest) { + return func(r *IndicesReloadSearchAnalyzersRequest) { + r.ExpandWildcards = v + } +} + +// WithIgnoreUnavailable - whether specified concrete indices should be ignored when unavailable (missing or closed). +func (f IndicesReloadSearchAnalyzers) WithIgnoreUnavailable(v bool) func(*IndicesReloadSearchAnalyzersRequest) { + return func(r *IndicesReloadSearchAnalyzersRequest) { + r.IgnoreUnavailable = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesReloadSearchAnalyzers) WithPretty() func(*IndicesReloadSearchAnalyzersRequest) { + return func(r *IndicesReloadSearchAnalyzersRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesReloadSearchAnalyzers) WithHuman() func(*IndicesReloadSearchAnalyzersRequest) { + return func(r *IndicesReloadSearchAnalyzersRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesReloadSearchAnalyzers) WithErrorTrace() func(*IndicesReloadSearchAnalyzersRequest) { + return func(r *IndicesReloadSearchAnalyzersRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesReloadSearchAnalyzers) WithFilterPath(v ...string) func(*IndicesReloadSearchAnalyzersRequest) { + return func(r *IndicesReloadSearchAnalyzersRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesReloadSearchAnalyzers) WithHeader(h map[string]string) func(*IndicesReloadSearchAnalyzersRequest) { + return func(r *IndicesReloadSearchAnalyzersRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesReloadSearchAnalyzers) WithOpaqueID(s string) func(*IndicesReloadSearchAnalyzersRequest) { + return func(r *IndicesReloadSearchAnalyzersRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.indices.unfreeze.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.indices.unfreeze.go new file mode 100644 index 00000000..ae51e894 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.indices.unfreeze.go @@ -0,0 +1,266 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" + "time" +) + +func newIndicesUnfreezeFunc(t Transport) IndicesUnfreeze { + return func(index string, o ...func(*IndicesUnfreezeRequest)) (*Response, error) { + var r = IndicesUnfreezeRequest{Index: index} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesUnfreeze - Unfreezes an index. When a frozen index is unfrozen, the index goes through the normal recovery process and becomes writeable again. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/unfreeze-index-api.html. +type IndicesUnfreeze func(index string, o ...func(*IndicesUnfreezeRequest)) (*Response, error) + +// IndicesUnfreezeRequest configures the Indices Unfreeze API request. +type IndicesUnfreezeRequest struct { + Index string + + AllowNoIndices *bool + ExpandWildcards string + IgnoreUnavailable *bool + MasterTimeout time.Duration + Timeout time.Duration + WaitForActiveShards string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r IndicesUnfreezeRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len(r.Index) + 1 + len("_unfreeze")) + path.WriteString("/") + path.WriteString(r.Index) + path.WriteString("/") + path.WriteString("_unfreeze") + + params = make(map[string]string) + + if r.AllowNoIndices != nil { + params["allow_no_indices"] = strconv.FormatBool(*r.AllowNoIndices) + } + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if r.IgnoreUnavailable != nil { + params["ignore_unavailable"] = strconv.FormatBool(*r.IgnoreUnavailable) + } + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.WaitForActiveShards != "" { + params["wait_for_active_shards"] = r.WaitForActiveShards + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesUnfreeze) WithContext(v context.Context) func(*IndicesUnfreezeRequest) { + return func(r *IndicesUnfreezeRequest) { + r.ctx = v + } +} + +// WithAllowNoIndices - whether to ignore if a wildcard indices expression resolves into no concrete indices. (this includes `_all` string or when no indices have been specified). +func (f IndicesUnfreeze) WithAllowNoIndices(v bool) func(*IndicesUnfreezeRequest) { + return func(r *IndicesUnfreezeRequest) { + r.AllowNoIndices = &v + } +} + +// WithExpandWildcards - whether to expand wildcard expression to concrete indices that are open, closed or both.. +func (f IndicesUnfreeze) WithExpandWildcards(v string) func(*IndicesUnfreezeRequest) { + return func(r *IndicesUnfreezeRequest) { + r.ExpandWildcards = v + } +} + +// WithIgnoreUnavailable - whether specified concrete indices should be ignored when unavailable (missing or closed). +func (f IndicesUnfreeze) WithIgnoreUnavailable(v bool) func(*IndicesUnfreezeRequest) { + return func(r *IndicesUnfreezeRequest) { + r.IgnoreUnavailable = &v + } +} + +// WithMasterTimeout - specify timeout for connection to master. +func (f IndicesUnfreeze) WithMasterTimeout(v time.Duration) func(*IndicesUnfreezeRequest) { + return func(r *IndicesUnfreezeRequest) { + r.MasterTimeout = v + } +} + +// WithTimeout - explicit operation timeout. +func (f IndicesUnfreeze) WithTimeout(v time.Duration) func(*IndicesUnfreezeRequest) { + return func(r *IndicesUnfreezeRequest) { + r.Timeout = v + } +} + +// WithWaitForActiveShards - sets the number of active shards to wait for before the operation returns.. +func (f IndicesUnfreeze) WithWaitForActiveShards(v string) func(*IndicesUnfreezeRequest) { + return func(r *IndicesUnfreezeRequest) { + r.WaitForActiveShards = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesUnfreeze) WithPretty() func(*IndicesUnfreezeRequest) { + return func(r *IndicesUnfreezeRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesUnfreeze) WithHuman() func(*IndicesUnfreezeRequest) { + return func(r *IndicesUnfreezeRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesUnfreeze) WithErrorTrace() func(*IndicesUnfreezeRequest) { + return func(r *IndicesUnfreezeRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesUnfreeze) WithFilterPath(v ...string) func(*IndicesUnfreezeRequest) { + return func(r *IndicesUnfreezeRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesUnfreeze) WithHeader(h map[string]string) func(*IndicesUnfreezeRequest) { + return func(r *IndicesUnfreezeRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesUnfreeze) WithOpaqueID(s string) func(*IndicesUnfreezeRequest) { + return func(r *IndicesUnfreezeRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.license.delete.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.license.delete.go new file mode 100644 index 00000000..b801a887 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.license.delete.go @@ -0,0 +1,186 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newLicenseDeleteFunc(t Transport) LicenseDelete { + return func(o ...func(*LicenseDeleteRequest)) (*Response, error) { + var r = LicenseDeleteRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// LicenseDelete - Deletes licensing information for the cluster +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-license.html. +type LicenseDelete func(o ...func(*LicenseDeleteRequest)) (*Response, error) + +// LicenseDeleteRequest configures the License Delete API request. +type LicenseDeleteRequest struct { + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r LicenseDeleteRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + path.Grow(len("/_license")) + path.WriteString("/_license") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f LicenseDelete) WithContext(v context.Context) func(*LicenseDeleteRequest) { + return func(r *LicenseDeleteRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f LicenseDelete) WithPretty() func(*LicenseDeleteRequest) { + return func(r *LicenseDeleteRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f LicenseDelete) WithHuman() func(*LicenseDeleteRequest) { + return func(r *LicenseDeleteRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f LicenseDelete) WithErrorTrace() func(*LicenseDeleteRequest) { + return func(r *LicenseDeleteRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f LicenseDelete) WithFilterPath(v ...string) func(*LicenseDeleteRequest) { + return func(r *LicenseDeleteRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f LicenseDelete) WithHeader(h map[string]string) func(*LicenseDeleteRequest) { + return func(r *LicenseDeleteRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f LicenseDelete) WithOpaqueID(s string) func(*LicenseDeleteRequest) { + return func(r *LicenseDeleteRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.license.get.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.license.get.go new file mode 100644 index 00000000..2aa970d6 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.license.get.go @@ -0,0 +1,212 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newLicenseGetFunc(t Transport) LicenseGet { + return func(o ...func(*LicenseGetRequest)) (*Response, error) { + var r = LicenseGetRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// LicenseGet - Retrieves licensing information for the cluster +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/get-license.html. +type LicenseGet func(o ...func(*LicenseGetRequest)) (*Response, error) + +// LicenseGetRequest configures the License Get API request. +type LicenseGetRequest struct { + AcceptEnterprise *bool + Local *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r LicenseGetRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(len("/_license")) + path.WriteString("/_license") + + params = make(map[string]string) + + if r.AcceptEnterprise != nil { + params["accept_enterprise"] = strconv.FormatBool(*r.AcceptEnterprise) + } + + if r.Local != nil { + params["local"] = strconv.FormatBool(*r.Local) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f LicenseGet) WithContext(v context.Context) func(*LicenseGetRequest) { + return func(r *LicenseGetRequest) { + r.ctx = v + } +} + +// WithAcceptEnterprise - if the active license is an enterprise license, return type as 'enterprise' (default: false). +func (f LicenseGet) WithAcceptEnterprise(v bool) func(*LicenseGetRequest) { + return func(r *LicenseGetRequest) { + r.AcceptEnterprise = &v + } +} + +// WithLocal - return local information, do not retrieve the state from master node (default: false). +func (f LicenseGet) WithLocal(v bool) func(*LicenseGetRequest) { + return func(r *LicenseGetRequest) { + r.Local = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f LicenseGet) WithPretty() func(*LicenseGetRequest) { + return func(r *LicenseGetRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f LicenseGet) WithHuman() func(*LicenseGetRequest) { + return func(r *LicenseGetRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f LicenseGet) WithErrorTrace() func(*LicenseGetRequest) { + return func(r *LicenseGetRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f LicenseGet) WithFilterPath(v ...string) func(*LicenseGetRequest) { + return func(r *LicenseGetRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f LicenseGet) WithHeader(h map[string]string) func(*LicenseGetRequest) { + return func(r *LicenseGetRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f LicenseGet) WithOpaqueID(s string) func(*LicenseGetRequest) { + return func(r *LicenseGetRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.license.get_basic_status.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.license.get_basic_status.go new file mode 100644 index 00000000..6571c69c --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.license.get_basic_status.go @@ -0,0 +1,186 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newLicenseGetBasicStatusFunc(t Transport) LicenseGetBasicStatus { + return func(o ...func(*LicenseGetBasicStatusRequest)) (*Response, error) { + var r = LicenseGetBasicStatusRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// LicenseGetBasicStatus - Retrieves information about the status of the basic license. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/get-basic-status.html. +type LicenseGetBasicStatus func(o ...func(*LicenseGetBasicStatusRequest)) (*Response, error) + +// LicenseGetBasicStatusRequest configures the License Get Basic Status API request. +type LicenseGetBasicStatusRequest struct { + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r LicenseGetBasicStatusRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(len("/_license/basic_status")) + path.WriteString("/_license/basic_status") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f LicenseGetBasicStatus) WithContext(v context.Context) func(*LicenseGetBasicStatusRequest) { + return func(r *LicenseGetBasicStatusRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f LicenseGetBasicStatus) WithPretty() func(*LicenseGetBasicStatusRequest) { + return func(r *LicenseGetBasicStatusRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f LicenseGetBasicStatus) WithHuman() func(*LicenseGetBasicStatusRequest) { + return func(r *LicenseGetBasicStatusRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f LicenseGetBasicStatus) WithErrorTrace() func(*LicenseGetBasicStatusRequest) { + return func(r *LicenseGetBasicStatusRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f LicenseGetBasicStatus) WithFilterPath(v ...string) func(*LicenseGetBasicStatusRequest) { + return func(r *LicenseGetBasicStatusRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f LicenseGetBasicStatus) WithHeader(h map[string]string) func(*LicenseGetBasicStatusRequest) { + return func(r *LicenseGetBasicStatusRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f LicenseGetBasicStatus) WithOpaqueID(s string) func(*LicenseGetBasicStatusRequest) { + return func(r *LicenseGetBasicStatusRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.license.get_trial_status.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.license.get_trial_status.go new file mode 100644 index 00000000..03493ba8 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.license.get_trial_status.go @@ -0,0 +1,186 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newLicenseGetTrialStatusFunc(t Transport) LicenseGetTrialStatus { + return func(o ...func(*LicenseGetTrialStatusRequest)) (*Response, error) { + var r = LicenseGetTrialStatusRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// LicenseGetTrialStatus - Retrieves information about the status of the trial license. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/get-trial-status.html. +type LicenseGetTrialStatus func(o ...func(*LicenseGetTrialStatusRequest)) (*Response, error) + +// LicenseGetTrialStatusRequest configures the License Get Trial Status API request. +type LicenseGetTrialStatusRequest struct { + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r LicenseGetTrialStatusRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(len("/_license/trial_status")) + path.WriteString("/_license/trial_status") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f LicenseGetTrialStatus) WithContext(v context.Context) func(*LicenseGetTrialStatusRequest) { + return func(r *LicenseGetTrialStatusRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f LicenseGetTrialStatus) WithPretty() func(*LicenseGetTrialStatusRequest) { + return func(r *LicenseGetTrialStatusRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f LicenseGetTrialStatus) WithHuman() func(*LicenseGetTrialStatusRequest) { + return func(r *LicenseGetTrialStatusRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f LicenseGetTrialStatus) WithErrorTrace() func(*LicenseGetTrialStatusRequest) { + return func(r *LicenseGetTrialStatusRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f LicenseGetTrialStatus) WithFilterPath(v ...string) func(*LicenseGetTrialStatusRequest) { + return func(r *LicenseGetTrialStatusRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f LicenseGetTrialStatus) WithHeader(h map[string]string) func(*LicenseGetTrialStatusRequest) { + return func(r *LicenseGetTrialStatusRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f LicenseGetTrialStatus) WithOpaqueID(s string) func(*LicenseGetTrialStatusRequest) { + return func(r *LicenseGetTrialStatusRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.license.post.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.license.post.go new file mode 100644 index 00000000..eb807b51 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.license.post.go @@ -0,0 +1,214 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" +) + +func newLicensePostFunc(t Transport) LicensePost { + return func(o ...func(*LicensePostRequest)) (*Response, error) { + var r = LicensePostRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// LicensePost - Updates the license for the cluster. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/update-license.html. +type LicensePost func(o ...func(*LicensePostRequest)) (*Response, error) + +// LicensePostRequest configures the License Post API request. +type LicensePostRequest struct { + Body io.Reader + + Acknowledge *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r LicensePostRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(len("/_license")) + path.WriteString("/_license") + + params = make(map[string]string) + + if r.Acknowledge != nil { + params["acknowledge"] = strconv.FormatBool(*r.Acknowledge) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f LicensePost) WithContext(v context.Context) func(*LicensePostRequest) { + return func(r *LicensePostRequest) { + r.ctx = v + } +} + +// WithBody - licenses to be installed. +func (f LicensePost) WithBody(v io.Reader) func(*LicensePostRequest) { + return func(r *LicensePostRequest) { + r.Body = v + } +} + +// WithAcknowledge - whether the user has acknowledged acknowledge messages (default: false). +func (f LicensePost) WithAcknowledge(v bool) func(*LicensePostRequest) { + return func(r *LicensePostRequest) { + r.Acknowledge = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f LicensePost) WithPretty() func(*LicensePostRequest) { + return func(r *LicensePostRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f LicensePost) WithHuman() func(*LicensePostRequest) { + return func(r *LicensePostRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f LicensePost) WithErrorTrace() func(*LicensePostRequest) { + return func(r *LicensePostRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f LicensePost) WithFilterPath(v ...string) func(*LicensePostRequest) { + return func(r *LicensePostRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f LicensePost) WithHeader(h map[string]string) func(*LicensePostRequest) { + return func(r *LicensePostRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f LicensePost) WithOpaqueID(s string) func(*LicensePostRequest) { + return func(r *LicensePostRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.license.post_start_basic.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.license.post_start_basic.go new file mode 100644 index 00000000..3b2b583a --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.license.post_start_basic.go @@ -0,0 +1,200 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newLicensePostStartBasicFunc(t Transport) LicensePostStartBasic { + return func(o ...func(*LicensePostStartBasicRequest)) (*Response, error) { + var r = LicensePostStartBasicRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// LicensePostStartBasic - Starts an indefinite basic license. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/start-basic.html. +type LicensePostStartBasic func(o ...func(*LicensePostStartBasicRequest)) (*Response, error) + +// LicensePostStartBasicRequest configures the License Post Start Basic API request. +type LicensePostStartBasicRequest struct { + Acknowledge *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r LicensePostStartBasicRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(len("/_license/start_basic")) + path.WriteString("/_license/start_basic") + + params = make(map[string]string) + + if r.Acknowledge != nil { + params["acknowledge"] = strconv.FormatBool(*r.Acknowledge) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f LicensePostStartBasic) WithContext(v context.Context) func(*LicensePostStartBasicRequest) { + return func(r *LicensePostStartBasicRequest) { + r.ctx = v + } +} + +// WithAcknowledge - whether the user has acknowledged acknowledge messages (default: false). +func (f LicensePostStartBasic) WithAcknowledge(v bool) func(*LicensePostStartBasicRequest) { + return func(r *LicensePostStartBasicRequest) { + r.Acknowledge = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f LicensePostStartBasic) WithPretty() func(*LicensePostStartBasicRequest) { + return func(r *LicensePostStartBasicRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f LicensePostStartBasic) WithHuman() func(*LicensePostStartBasicRequest) { + return func(r *LicensePostStartBasicRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f LicensePostStartBasic) WithErrorTrace() func(*LicensePostStartBasicRequest) { + return func(r *LicensePostStartBasicRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f LicensePostStartBasic) WithFilterPath(v ...string) func(*LicensePostStartBasicRequest) { + return func(r *LicensePostStartBasicRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f LicensePostStartBasic) WithHeader(h map[string]string) func(*LicensePostStartBasicRequest) { + return func(r *LicensePostStartBasicRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f LicensePostStartBasic) WithOpaqueID(s string) func(*LicensePostStartBasicRequest) { + return func(r *LicensePostStartBasicRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.license.post_start_trial.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.license.post_start_trial.go new file mode 100644 index 00000000..6aa568b1 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.license.post_start_trial.go @@ -0,0 +1,212 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newLicensePostStartTrialFunc(t Transport) LicensePostStartTrial { + return func(o ...func(*LicensePostStartTrialRequest)) (*Response, error) { + var r = LicensePostStartTrialRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// LicensePostStartTrial - starts a limited time trial license. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/start-trial.html. +type LicensePostStartTrial func(o ...func(*LicensePostStartTrialRequest)) (*Response, error) + +// LicensePostStartTrialRequest configures the License Post Start Trial API request. +type LicensePostStartTrialRequest struct { + Acknowledge *bool + DocumentType string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r LicensePostStartTrialRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(len("/_license/start_trial")) + path.WriteString("/_license/start_trial") + + params = make(map[string]string) + + if r.Acknowledge != nil { + params["acknowledge"] = strconv.FormatBool(*r.Acknowledge) + } + + if r.DocumentType != "" { + params["type"] = r.DocumentType + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f LicensePostStartTrial) WithContext(v context.Context) func(*LicensePostStartTrialRequest) { + return func(r *LicensePostStartTrialRequest) { + r.ctx = v + } +} + +// WithAcknowledge - whether the user has acknowledged acknowledge messages (default: false). +func (f LicensePostStartTrial) WithAcknowledge(v bool) func(*LicensePostStartTrialRequest) { + return func(r *LicensePostStartTrialRequest) { + r.Acknowledge = &v + } +} + +// WithDocumentType - the type of trial license to generate (default: "trial"). +func (f LicensePostStartTrial) WithDocumentType(v string) func(*LicensePostStartTrialRequest) { + return func(r *LicensePostStartTrialRequest) { + r.DocumentType = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f LicensePostStartTrial) WithPretty() func(*LicensePostStartTrialRequest) { + return func(r *LicensePostStartTrialRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f LicensePostStartTrial) WithHuman() func(*LicensePostStartTrialRequest) { + return func(r *LicensePostStartTrialRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f LicensePostStartTrial) WithErrorTrace() func(*LicensePostStartTrialRequest) { + return func(r *LicensePostStartTrialRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f LicensePostStartTrial) WithFilterPath(v ...string) func(*LicensePostStartTrialRequest) { + return func(r *LicensePostStartTrialRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f LicensePostStartTrial) WithHeader(h map[string]string) func(*LicensePostStartTrialRequest) { + return func(r *LicensePostStartTrialRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f LicensePostStartTrial) WithOpaqueID(s string) func(*LicensePostStartTrialRequest) { + return func(r *LicensePostStartTrialRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.logstash.delete_pipeline.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.logstash.delete_pipeline.go new file mode 100644 index 00000000..661b6b44 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.logstash.delete_pipeline.go @@ -0,0 +1,193 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newLogstashDeletePipelineFunc(t Transport) LogstashDeletePipeline { + return func(id string, o ...func(*LogstashDeletePipelineRequest)) (*Response, error) { + var r = LogstashDeletePipelineRequest{DocumentID: id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// LogstashDeletePipeline - Deletes Logstash Pipelines used by Central Management +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/logstash-api-delete-pipeline.html. +type LogstashDeletePipeline func(id string, o ...func(*LogstashDeletePipelineRequest)) (*Response, error) + +// LogstashDeletePipelineRequest configures the Logstash Delete Pipeline API request. +type LogstashDeletePipelineRequest struct { + DocumentID string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r LogstashDeletePipelineRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + path.Grow(1 + len("_logstash") + 1 + len("pipeline") + 1 + len(r.DocumentID)) + path.WriteString("/") + path.WriteString("_logstash") + path.WriteString("/") + path.WriteString("pipeline") + path.WriteString("/") + path.WriteString(r.DocumentID) + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f LogstashDeletePipeline) WithContext(v context.Context) func(*LogstashDeletePipelineRequest) { + return func(r *LogstashDeletePipelineRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f LogstashDeletePipeline) WithPretty() func(*LogstashDeletePipelineRequest) { + return func(r *LogstashDeletePipelineRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f LogstashDeletePipeline) WithHuman() func(*LogstashDeletePipelineRequest) { + return func(r *LogstashDeletePipelineRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f LogstashDeletePipeline) WithErrorTrace() func(*LogstashDeletePipelineRequest) { + return func(r *LogstashDeletePipelineRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f LogstashDeletePipeline) WithFilterPath(v ...string) func(*LogstashDeletePipelineRequest) { + return func(r *LogstashDeletePipelineRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f LogstashDeletePipeline) WithHeader(h map[string]string) func(*LogstashDeletePipelineRequest) { + return func(r *LogstashDeletePipelineRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f LogstashDeletePipeline) WithOpaqueID(s string) func(*LogstashDeletePipelineRequest) { + return func(r *LogstashDeletePipelineRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.logstash.get_pipeline.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.logstash.get_pipeline.go new file mode 100644 index 00000000..493b59db --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.logstash.get_pipeline.go @@ -0,0 +1,193 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newLogstashGetPipelineFunc(t Transport) LogstashGetPipeline { + return func(id string, o ...func(*LogstashGetPipelineRequest)) (*Response, error) { + var r = LogstashGetPipelineRequest{DocumentID: id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// LogstashGetPipeline - Retrieves Logstash Pipelines used by Central Management +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/logstash-api-get-pipeline.html. +type LogstashGetPipeline func(id string, o ...func(*LogstashGetPipelineRequest)) (*Response, error) + +// LogstashGetPipelineRequest configures the Logstash Get Pipeline API request. +type LogstashGetPipelineRequest struct { + DocumentID string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r LogstashGetPipelineRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_logstash") + 1 + len("pipeline") + 1 + len(r.DocumentID)) + path.WriteString("/") + path.WriteString("_logstash") + path.WriteString("/") + path.WriteString("pipeline") + path.WriteString("/") + path.WriteString(r.DocumentID) + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f LogstashGetPipeline) WithContext(v context.Context) func(*LogstashGetPipelineRequest) { + return func(r *LogstashGetPipelineRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f LogstashGetPipeline) WithPretty() func(*LogstashGetPipelineRequest) { + return func(r *LogstashGetPipelineRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f LogstashGetPipeline) WithHuman() func(*LogstashGetPipelineRequest) { + return func(r *LogstashGetPipelineRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f LogstashGetPipeline) WithErrorTrace() func(*LogstashGetPipelineRequest) { + return func(r *LogstashGetPipelineRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f LogstashGetPipeline) WithFilterPath(v ...string) func(*LogstashGetPipelineRequest) { + return func(r *LogstashGetPipelineRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f LogstashGetPipeline) WithHeader(h map[string]string) func(*LogstashGetPipelineRequest) { + return func(r *LogstashGetPipelineRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f LogstashGetPipeline) WithOpaqueID(s string) func(*LogstashGetPipelineRequest) { + return func(r *LogstashGetPipelineRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.logstash.put_pipeline.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.logstash.put_pipeline.go new file mode 100644 index 00000000..b38cdc27 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.logstash.put_pipeline.go @@ -0,0 +1,200 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newLogstashPutPipelineFunc(t Transport) LogstashPutPipeline { + return func(id string, body io.Reader, o ...func(*LogstashPutPipelineRequest)) (*Response, error) { + var r = LogstashPutPipelineRequest{DocumentID: id, Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// LogstashPutPipeline - Adds and updates Logstash Pipelines used for Central Management +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/logstash-api-put-pipeline.html. +type LogstashPutPipeline func(id string, body io.Reader, o ...func(*LogstashPutPipelineRequest)) (*Response, error) + +// LogstashPutPipelineRequest configures the Logstash Put Pipeline API request. +type LogstashPutPipelineRequest struct { + DocumentID string + + Body io.Reader + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r LogstashPutPipelineRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(1 + len("_logstash") + 1 + len("pipeline") + 1 + len(r.DocumentID)) + path.WriteString("/") + path.WriteString("_logstash") + path.WriteString("/") + path.WriteString("pipeline") + path.WriteString("/") + path.WriteString(r.DocumentID) + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f LogstashPutPipeline) WithContext(v context.Context) func(*LogstashPutPipelineRequest) { + return func(r *LogstashPutPipelineRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f LogstashPutPipeline) WithPretty() func(*LogstashPutPipelineRequest) { + return func(r *LogstashPutPipelineRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f LogstashPutPipeline) WithHuman() func(*LogstashPutPipelineRequest) { + return func(r *LogstashPutPipelineRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f LogstashPutPipeline) WithErrorTrace() func(*LogstashPutPipelineRequest) { + return func(r *LogstashPutPipelineRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f LogstashPutPipeline) WithFilterPath(v ...string) func(*LogstashPutPipelineRequest) { + return func(r *LogstashPutPipelineRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f LogstashPutPipeline) WithHeader(h map[string]string) func(*LogstashPutPipelineRequest) { + return func(r *LogstashPutPipelineRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f LogstashPutPipeline) WithOpaqueID(s string) func(*LogstashPutPipelineRequest) { + return func(r *LogstashPutPipelineRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.migration.deprecations.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.migration.deprecations.go new file mode 100644 index 00000000..25ed6c6a --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.migration.deprecations.go @@ -0,0 +1,202 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newMigrationDeprecationsFunc(t Transport) MigrationDeprecations { + return func(o ...func(*MigrationDeprecationsRequest)) (*Response, error) { + var r = MigrationDeprecationsRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MigrationDeprecations - Retrieves information about different cluster, node, and index level settings that use deprecated features that will be removed or changed in the next major version. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/migration-api-deprecation.html. +type MigrationDeprecations func(o ...func(*MigrationDeprecationsRequest)) (*Response, error) + +// MigrationDeprecationsRequest configures the Migration Deprecations API request. +type MigrationDeprecationsRequest struct { + Index string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MigrationDeprecationsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len(r.Index) + 1 + len("_migration") + 1 + len("deprecations")) + if r.Index != "" { + path.WriteString("/") + path.WriteString(r.Index) + } + path.WriteString("/") + path.WriteString("_migration") + path.WriteString("/") + path.WriteString("deprecations") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MigrationDeprecations) WithContext(v context.Context) func(*MigrationDeprecationsRequest) { + return func(r *MigrationDeprecationsRequest) { + r.ctx = v + } +} + +// WithIndex - index pattern. +func (f MigrationDeprecations) WithIndex(v string) func(*MigrationDeprecationsRequest) { + return func(r *MigrationDeprecationsRequest) { + r.Index = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MigrationDeprecations) WithPretty() func(*MigrationDeprecationsRequest) { + return func(r *MigrationDeprecationsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MigrationDeprecations) WithHuman() func(*MigrationDeprecationsRequest) { + return func(r *MigrationDeprecationsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MigrationDeprecations) WithErrorTrace() func(*MigrationDeprecationsRequest) { + return func(r *MigrationDeprecationsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MigrationDeprecations) WithFilterPath(v ...string) func(*MigrationDeprecationsRequest) { + return func(r *MigrationDeprecationsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MigrationDeprecations) WithHeader(h map[string]string) func(*MigrationDeprecationsRequest) { + return func(r *MigrationDeprecationsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MigrationDeprecations) WithOpaqueID(s string) func(*MigrationDeprecationsRequest) { + return func(r *MigrationDeprecationsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.migration.get_feature_upgrade_status.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.migration.get_feature_upgrade_status.go new file mode 100644 index 00000000..49ff3f76 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.migration.get_feature_upgrade_status.go @@ -0,0 +1,186 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newMigrationGetFeatureUpgradeStatusFunc(t Transport) MigrationGetFeatureUpgradeStatus { + return func(o ...func(*MigrationGetFeatureUpgradeStatusRequest)) (*Response, error) { + var r = MigrationGetFeatureUpgradeStatusRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MigrationGetFeatureUpgradeStatus - Find out whether system features need to be upgraded or not +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/migration-api-feature-upgrade.html. +type MigrationGetFeatureUpgradeStatus func(o ...func(*MigrationGetFeatureUpgradeStatusRequest)) (*Response, error) + +// MigrationGetFeatureUpgradeStatusRequest configures the Migration Get Feature Upgrade Status API request. +type MigrationGetFeatureUpgradeStatusRequest struct { + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MigrationGetFeatureUpgradeStatusRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(len("/_migration/system_features")) + path.WriteString("/_migration/system_features") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MigrationGetFeatureUpgradeStatus) WithContext(v context.Context) func(*MigrationGetFeatureUpgradeStatusRequest) { + return func(r *MigrationGetFeatureUpgradeStatusRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MigrationGetFeatureUpgradeStatus) WithPretty() func(*MigrationGetFeatureUpgradeStatusRequest) { + return func(r *MigrationGetFeatureUpgradeStatusRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MigrationGetFeatureUpgradeStatus) WithHuman() func(*MigrationGetFeatureUpgradeStatusRequest) { + return func(r *MigrationGetFeatureUpgradeStatusRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MigrationGetFeatureUpgradeStatus) WithErrorTrace() func(*MigrationGetFeatureUpgradeStatusRequest) { + return func(r *MigrationGetFeatureUpgradeStatusRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MigrationGetFeatureUpgradeStatus) WithFilterPath(v ...string) func(*MigrationGetFeatureUpgradeStatusRequest) { + return func(r *MigrationGetFeatureUpgradeStatusRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MigrationGetFeatureUpgradeStatus) WithHeader(h map[string]string) func(*MigrationGetFeatureUpgradeStatusRequest) { + return func(r *MigrationGetFeatureUpgradeStatusRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MigrationGetFeatureUpgradeStatus) WithOpaqueID(s string) func(*MigrationGetFeatureUpgradeStatusRequest) { + return func(r *MigrationGetFeatureUpgradeStatusRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.migration.post_feature_upgrade.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.migration.post_feature_upgrade.go new file mode 100644 index 00000000..796feedb --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.migration.post_feature_upgrade.go @@ -0,0 +1,186 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newMigrationPostFeatureUpgradeFunc(t Transport) MigrationPostFeatureUpgrade { + return func(o ...func(*MigrationPostFeatureUpgradeRequest)) (*Response, error) { + var r = MigrationPostFeatureUpgradeRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MigrationPostFeatureUpgrade - Begin upgrades for system features +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/migration-api-feature-upgrade.html. +type MigrationPostFeatureUpgrade func(o ...func(*MigrationPostFeatureUpgradeRequest)) (*Response, error) + +// MigrationPostFeatureUpgradeRequest configures the Migration Post Feature Upgrade API request. +type MigrationPostFeatureUpgradeRequest struct { + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MigrationPostFeatureUpgradeRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(len("/_migration/system_features")) + path.WriteString("/_migration/system_features") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MigrationPostFeatureUpgrade) WithContext(v context.Context) func(*MigrationPostFeatureUpgradeRequest) { + return func(r *MigrationPostFeatureUpgradeRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MigrationPostFeatureUpgrade) WithPretty() func(*MigrationPostFeatureUpgradeRequest) { + return func(r *MigrationPostFeatureUpgradeRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MigrationPostFeatureUpgrade) WithHuman() func(*MigrationPostFeatureUpgradeRequest) { + return func(r *MigrationPostFeatureUpgradeRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MigrationPostFeatureUpgrade) WithErrorTrace() func(*MigrationPostFeatureUpgradeRequest) { + return func(r *MigrationPostFeatureUpgradeRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MigrationPostFeatureUpgrade) WithFilterPath(v ...string) func(*MigrationPostFeatureUpgradeRequest) { + return func(r *MigrationPostFeatureUpgradeRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MigrationPostFeatureUpgrade) WithHeader(h map[string]string) func(*MigrationPostFeatureUpgradeRequest) { + return func(r *MigrationPostFeatureUpgradeRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MigrationPostFeatureUpgrade) WithOpaqueID(s string) func(*MigrationPostFeatureUpgradeRequest) { + return func(r *MigrationPostFeatureUpgradeRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.close_job.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.close_job.go new file mode 100644 index 00000000..2abf2f14 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.close_job.go @@ -0,0 +1,260 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" + "time" +) + +func newMLCloseJobFunc(t Transport) MLCloseJob { + return func(job_id string, o ...func(*MLCloseJobRequest)) (*Response, error) { + var r = MLCloseJobRequest{JobID: job_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLCloseJob - Closes one or more anomaly detection jobs. A job can be opened and closed multiple times throughout its lifecycle. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-close-job.html. +type MLCloseJob func(job_id string, o ...func(*MLCloseJobRequest)) (*Response, error) + +// MLCloseJobRequest configures the ML Close Job API request. +type MLCloseJobRequest struct { + Body io.Reader + + JobID string + + AllowNoJobs *bool + AllowNoMatch *bool + Force *bool + Timeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLCloseJobRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_ml") + 1 + len("anomaly_detectors") + 1 + len(r.JobID) + 1 + len("_close")) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("anomaly_detectors") + path.WriteString("/") + path.WriteString(r.JobID) + path.WriteString("/") + path.WriteString("_close") + + params = make(map[string]string) + + if r.AllowNoJobs != nil { + params["allow_no_jobs"] = strconv.FormatBool(*r.AllowNoJobs) + } + + if r.AllowNoMatch != nil { + params["allow_no_match"] = strconv.FormatBool(*r.AllowNoMatch) + } + + if r.Force != nil { + params["force"] = strconv.FormatBool(*r.Force) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLCloseJob) WithContext(v context.Context) func(*MLCloseJobRequest) { + return func(r *MLCloseJobRequest) { + r.ctx = v + } +} + +// WithBody - The URL params optionally sent in the body. +func (f MLCloseJob) WithBody(v io.Reader) func(*MLCloseJobRequest) { + return func(r *MLCloseJobRequest) { + r.Body = v + } +} + +// WithAllowNoJobs - whether to ignore if a wildcard expression matches no jobs. (this includes `_all` string or when no jobs have been specified). +func (f MLCloseJob) WithAllowNoJobs(v bool) func(*MLCloseJobRequest) { + return func(r *MLCloseJobRequest) { + r.AllowNoJobs = &v + } +} + +// WithAllowNoMatch - whether to ignore if a wildcard expression matches no jobs. (this includes `_all` string or when no jobs have been specified). +func (f MLCloseJob) WithAllowNoMatch(v bool) func(*MLCloseJobRequest) { + return func(r *MLCloseJobRequest) { + r.AllowNoMatch = &v + } +} + +// WithForce - true if the job should be forcefully closed. +func (f MLCloseJob) WithForce(v bool) func(*MLCloseJobRequest) { + return func(r *MLCloseJobRequest) { + r.Force = &v + } +} + +// WithTimeout - controls the time to wait until a job has closed. default to 30 minutes. +func (f MLCloseJob) WithTimeout(v time.Duration) func(*MLCloseJobRequest) { + return func(r *MLCloseJobRequest) { + r.Timeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLCloseJob) WithPretty() func(*MLCloseJobRequest) { + return func(r *MLCloseJobRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLCloseJob) WithHuman() func(*MLCloseJobRequest) { + return func(r *MLCloseJobRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLCloseJob) WithErrorTrace() func(*MLCloseJobRequest) { + return func(r *MLCloseJobRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLCloseJob) WithFilterPath(v ...string) func(*MLCloseJobRequest) { + return func(r *MLCloseJobRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLCloseJob) WithHeader(h map[string]string) func(*MLCloseJobRequest) { + return func(r *MLCloseJobRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLCloseJob) WithOpaqueID(s string) func(*MLCloseJobRequest) { + return func(r *MLCloseJobRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.delete_calendar.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.delete_calendar.go new file mode 100644 index 00000000..062542dc --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.delete_calendar.go @@ -0,0 +1,193 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newMLDeleteCalendarFunc(t Transport) MLDeleteCalendar { + return func(calendar_id string, o ...func(*MLDeleteCalendarRequest)) (*Response, error) { + var r = MLDeleteCalendarRequest{CalendarID: calendar_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLDeleteCalendar - Deletes a calendar. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-calendar.html. +type MLDeleteCalendar func(calendar_id string, o ...func(*MLDeleteCalendarRequest)) (*Response, error) + +// MLDeleteCalendarRequest configures the ML Delete Calendar API request. +type MLDeleteCalendarRequest struct { + CalendarID string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLDeleteCalendarRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + path.Grow(1 + len("_ml") + 1 + len("calendars") + 1 + len(r.CalendarID)) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("calendars") + path.WriteString("/") + path.WriteString(r.CalendarID) + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLDeleteCalendar) WithContext(v context.Context) func(*MLDeleteCalendarRequest) { + return func(r *MLDeleteCalendarRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLDeleteCalendar) WithPretty() func(*MLDeleteCalendarRequest) { + return func(r *MLDeleteCalendarRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLDeleteCalendar) WithHuman() func(*MLDeleteCalendarRequest) { + return func(r *MLDeleteCalendarRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLDeleteCalendar) WithErrorTrace() func(*MLDeleteCalendarRequest) { + return func(r *MLDeleteCalendarRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLDeleteCalendar) WithFilterPath(v ...string) func(*MLDeleteCalendarRequest) { + return func(r *MLDeleteCalendarRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLDeleteCalendar) WithHeader(h map[string]string) func(*MLDeleteCalendarRequest) { + return func(r *MLDeleteCalendarRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLDeleteCalendar) WithOpaqueID(s string) func(*MLDeleteCalendarRequest) { + return func(r *MLDeleteCalendarRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.delete_calendar_event.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.delete_calendar_event.go new file mode 100644 index 00000000..5e9ffe44 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.delete_calendar_event.go @@ -0,0 +1,198 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newMLDeleteCalendarEventFunc(t Transport) MLDeleteCalendarEvent { + return func(calendar_id string, event_id string, o ...func(*MLDeleteCalendarEventRequest)) (*Response, error) { + var r = MLDeleteCalendarEventRequest{CalendarID: calendar_id, EventID: event_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLDeleteCalendarEvent - Deletes scheduled events from a calendar. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-calendar-event.html. +type MLDeleteCalendarEvent func(calendar_id string, event_id string, o ...func(*MLDeleteCalendarEventRequest)) (*Response, error) + +// MLDeleteCalendarEventRequest configures the ML Delete Calendar Event API request. +type MLDeleteCalendarEventRequest struct { + CalendarID string + EventID string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLDeleteCalendarEventRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + path.Grow(1 + len("_ml") + 1 + len("calendars") + 1 + len(r.CalendarID) + 1 + len("events") + 1 + len(r.EventID)) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("calendars") + path.WriteString("/") + path.WriteString(r.CalendarID) + path.WriteString("/") + path.WriteString("events") + path.WriteString("/") + path.WriteString(r.EventID) + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLDeleteCalendarEvent) WithContext(v context.Context) func(*MLDeleteCalendarEventRequest) { + return func(r *MLDeleteCalendarEventRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLDeleteCalendarEvent) WithPretty() func(*MLDeleteCalendarEventRequest) { + return func(r *MLDeleteCalendarEventRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLDeleteCalendarEvent) WithHuman() func(*MLDeleteCalendarEventRequest) { + return func(r *MLDeleteCalendarEventRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLDeleteCalendarEvent) WithErrorTrace() func(*MLDeleteCalendarEventRequest) { + return func(r *MLDeleteCalendarEventRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLDeleteCalendarEvent) WithFilterPath(v ...string) func(*MLDeleteCalendarEventRequest) { + return func(r *MLDeleteCalendarEventRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLDeleteCalendarEvent) WithHeader(h map[string]string) func(*MLDeleteCalendarEventRequest) { + return func(r *MLDeleteCalendarEventRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLDeleteCalendarEvent) WithOpaqueID(s string) func(*MLDeleteCalendarEventRequest) { + return func(r *MLDeleteCalendarEventRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.delete_calendar_job.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.delete_calendar_job.go new file mode 100644 index 00000000..5b1f3e91 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.delete_calendar_job.go @@ -0,0 +1,198 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newMLDeleteCalendarJobFunc(t Transport) MLDeleteCalendarJob { + return func(calendar_id string, job_id string, o ...func(*MLDeleteCalendarJobRequest)) (*Response, error) { + var r = MLDeleteCalendarJobRequest{CalendarID: calendar_id, JobID: job_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLDeleteCalendarJob - Deletes anomaly detection jobs from a calendar. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-calendar-job.html. +type MLDeleteCalendarJob func(calendar_id string, job_id string, o ...func(*MLDeleteCalendarJobRequest)) (*Response, error) + +// MLDeleteCalendarJobRequest configures the ML Delete Calendar Job API request. +type MLDeleteCalendarJobRequest struct { + CalendarID string + JobID string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLDeleteCalendarJobRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + path.Grow(1 + len("_ml") + 1 + len("calendars") + 1 + len(r.CalendarID) + 1 + len("jobs") + 1 + len(r.JobID)) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("calendars") + path.WriteString("/") + path.WriteString(r.CalendarID) + path.WriteString("/") + path.WriteString("jobs") + path.WriteString("/") + path.WriteString(r.JobID) + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLDeleteCalendarJob) WithContext(v context.Context) func(*MLDeleteCalendarJobRequest) { + return func(r *MLDeleteCalendarJobRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLDeleteCalendarJob) WithPretty() func(*MLDeleteCalendarJobRequest) { + return func(r *MLDeleteCalendarJobRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLDeleteCalendarJob) WithHuman() func(*MLDeleteCalendarJobRequest) { + return func(r *MLDeleteCalendarJobRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLDeleteCalendarJob) WithErrorTrace() func(*MLDeleteCalendarJobRequest) { + return func(r *MLDeleteCalendarJobRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLDeleteCalendarJob) WithFilterPath(v ...string) func(*MLDeleteCalendarJobRequest) { + return func(r *MLDeleteCalendarJobRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLDeleteCalendarJob) WithHeader(h map[string]string) func(*MLDeleteCalendarJobRequest) { + return func(r *MLDeleteCalendarJobRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLDeleteCalendarJob) WithOpaqueID(s string) func(*MLDeleteCalendarJobRequest) { + return func(r *MLDeleteCalendarJobRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.delete_data_frame_analytics.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.delete_data_frame_analytics.go new file mode 100644 index 00000000..0c46a0aa --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.delete_data_frame_analytics.go @@ -0,0 +1,222 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" + "time" +) + +func newMLDeleteDataFrameAnalyticsFunc(t Transport) MLDeleteDataFrameAnalytics { + return func(id string, o ...func(*MLDeleteDataFrameAnalyticsRequest)) (*Response, error) { + var r = MLDeleteDataFrameAnalyticsRequest{ID: id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLDeleteDataFrameAnalytics - Deletes an existing data frame analytics job. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-dfanalytics.html. +type MLDeleteDataFrameAnalytics func(id string, o ...func(*MLDeleteDataFrameAnalyticsRequest)) (*Response, error) + +// MLDeleteDataFrameAnalyticsRequest configures the ML Delete Data Frame Analytics API request. +type MLDeleteDataFrameAnalyticsRequest struct { + ID string + + Force *bool + Timeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLDeleteDataFrameAnalyticsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + path.Grow(1 + len("_ml") + 1 + len("data_frame") + 1 + len("analytics") + 1 + len(r.ID)) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("data_frame") + path.WriteString("/") + path.WriteString("analytics") + path.WriteString("/") + path.WriteString(r.ID) + + params = make(map[string]string) + + if r.Force != nil { + params["force"] = strconv.FormatBool(*r.Force) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLDeleteDataFrameAnalytics) WithContext(v context.Context) func(*MLDeleteDataFrameAnalyticsRequest) { + return func(r *MLDeleteDataFrameAnalyticsRequest) { + r.ctx = v + } +} + +// WithForce - true if the job should be forcefully deleted. +func (f MLDeleteDataFrameAnalytics) WithForce(v bool) func(*MLDeleteDataFrameAnalyticsRequest) { + return func(r *MLDeleteDataFrameAnalyticsRequest) { + r.Force = &v + } +} + +// WithTimeout - controls the time to wait until a job is deleted. defaults to 1 minute. +func (f MLDeleteDataFrameAnalytics) WithTimeout(v time.Duration) func(*MLDeleteDataFrameAnalyticsRequest) { + return func(r *MLDeleteDataFrameAnalyticsRequest) { + r.Timeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLDeleteDataFrameAnalytics) WithPretty() func(*MLDeleteDataFrameAnalyticsRequest) { + return func(r *MLDeleteDataFrameAnalyticsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLDeleteDataFrameAnalytics) WithHuman() func(*MLDeleteDataFrameAnalyticsRequest) { + return func(r *MLDeleteDataFrameAnalyticsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLDeleteDataFrameAnalytics) WithErrorTrace() func(*MLDeleteDataFrameAnalyticsRequest) { + return func(r *MLDeleteDataFrameAnalyticsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLDeleteDataFrameAnalytics) WithFilterPath(v ...string) func(*MLDeleteDataFrameAnalyticsRequest) { + return func(r *MLDeleteDataFrameAnalyticsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLDeleteDataFrameAnalytics) WithHeader(h map[string]string) func(*MLDeleteDataFrameAnalyticsRequest) { + return func(r *MLDeleteDataFrameAnalyticsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLDeleteDataFrameAnalytics) WithOpaqueID(s string) func(*MLDeleteDataFrameAnalyticsRequest) { + return func(r *MLDeleteDataFrameAnalyticsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.delete_datafeed.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.delete_datafeed.go new file mode 100644 index 00000000..0c21a025 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.delete_datafeed.go @@ -0,0 +1,207 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newMLDeleteDatafeedFunc(t Transport) MLDeleteDatafeed { + return func(datafeed_id string, o ...func(*MLDeleteDatafeedRequest)) (*Response, error) { + var r = MLDeleteDatafeedRequest{DatafeedID: datafeed_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLDeleteDatafeed - Deletes an existing datafeed. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-datafeed.html. +type MLDeleteDatafeed func(datafeed_id string, o ...func(*MLDeleteDatafeedRequest)) (*Response, error) + +// MLDeleteDatafeedRequest configures the ML Delete Datafeed API request. +type MLDeleteDatafeedRequest struct { + DatafeedID string + + Force *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLDeleteDatafeedRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + path.Grow(1 + len("_ml") + 1 + len("datafeeds") + 1 + len(r.DatafeedID)) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("datafeeds") + path.WriteString("/") + path.WriteString(r.DatafeedID) + + params = make(map[string]string) + + if r.Force != nil { + params["force"] = strconv.FormatBool(*r.Force) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLDeleteDatafeed) WithContext(v context.Context) func(*MLDeleteDatafeedRequest) { + return func(r *MLDeleteDatafeedRequest) { + r.ctx = v + } +} + +// WithForce - true if the datafeed should be forcefully deleted. +func (f MLDeleteDatafeed) WithForce(v bool) func(*MLDeleteDatafeedRequest) { + return func(r *MLDeleteDatafeedRequest) { + r.Force = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLDeleteDatafeed) WithPretty() func(*MLDeleteDatafeedRequest) { + return func(r *MLDeleteDatafeedRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLDeleteDatafeed) WithHuman() func(*MLDeleteDatafeedRequest) { + return func(r *MLDeleteDatafeedRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLDeleteDatafeed) WithErrorTrace() func(*MLDeleteDatafeedRequest) { + return func(r *MLDeleteDatafeedRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLDeleteDatafeed) WithFilterPath(v ...string) func(*MLDeleteDatafeedRequest) { + return func(r *MLDeleteDatafeedRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLDeleteDatafeed) WithHeader(h map[string]string) func(*MLDeleteDatafeedRequest) { + return func(r *MLDeleteDatafeedRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLDeleteDatafeed) WithOpaqueID(s string) func(*MLDeleteDatafeedRequest) { + return func(r *MLDeleteDatafeedRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.delete_expired_data.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.delete_expired_data.go new file mode 100644 index 00000000..e842cd26 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.delete_expired_data.go @@ -0,0 +1,243 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" + "time" +) + +func newMLDeleteExpiredDataFunc(t Transport) MLDeleteExpiredData { + return func(o ...func(*MLDeleteExpiredDataRequest)) (*Response, error) { + var r = MLDeleteExpiredDataRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLDeleteExpiredData - Deletes expired and unused machine learning data. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-expired-data.html. +type MLDeleteExpiredData func(o ...func(*MLDeleteExpiredDataRequest)) (*Response, error) + +// MLDeleteExpiredDataRequest configures the ML Delete Expired Data API request. +type MLDeleteExpiredDataRequest struct { + Body io.Reader + + JobID string + + RequestsPerSecond *int + Timeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLDeleteExpiredDataRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + path.Grow(1 + len("_ml") + 1 + len("_delete_expired_data") + 1 + len(r.JobID)) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("_delete_expired_data") + if r.JobID != "" { + path.WriteString("/") + path.WriteString(r.JobID) + } + + params = make(map[string]string) + + if r.RequestsPerSecond != nil { + params["requests_per_second"] = strconv.FormatInt(int64(*r.RequestsPerSecond), 10) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLDeleteExpiredData) WithContext(v context.Context) func(*MLDeleteExpiredDataRequest) { + return func(r *MLDeleteExpiredDataRequest) { + r.ctx = v + } +} + +// WithBody - deleting expired data parameters. +func (f MLDeleteExpiredData) WithBody(v io.Reader) func(*MLDeleteExpiredDataRequest) { + return func(r *MLDeleteExpiredDataRequest) { + r.Body = v + } +} + +// WithJobID - the ID of the job(s) to perform expired data hygiene for. +func (f MLDeleteExpiredData) WithJobID(v string) func(*MLDeleteExpiredDataRequest) { + return func(r *MLDeleteExpiredDataRequest) { + r.JobID = v + } +} + +// WithRequestsPerSecond - the desired requests per second for the deletion processes.. +func (f MLDeleteExpiredData) WithRequestsPerSecond(v int) func(*MLDeleteExpiredDataRequest) { + return func(r *MLDeleteExpiredDataRequest) { + r.RequestsPerSecond = &v + } +} + +// WithTimeout - how long can the underlying delete processes run until they are canceled. +func (f MLDeleteExpiredData) WithTimeout(v time.Duration) func(*MLDeleteExpiredDataRequest) { + return func(r *MLDeleteExpiredDataRequest) { + r.Timeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLDeleteExpiredData) WithPretty() func(*MLDeleteExpiredDataRequest) { + return func(r *MLDeleteExpiredDataRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLDeleteExpiredData) WithHuman() func(*MLDeleteExpiredDataRequest) { + return func(r *MLDeleteExpiredDataRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLDeleteExpiredData) WithErrorTrace() func(*MLDeleteExpiredDataRequest) { + return func(r *MLDeleteExpiredDataRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLDeleteExpiredData) WithFilterPath(v ...string) func(*MLDeleteExpiredDataRequest) { + return func(r *MLDeleteExpiredDataRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLDeleteExpiredData) WithHeader(h map[string]string) func(*MLDeleteExpiredDataRequest) { + return func(r *MLDeleteExpiredDataRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLDeleteExpiredData) WithOpaqueID(s string) func(*MLDeleteExpiredDataRequest) { + return func(r *MLDeleteExpiredDataRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.delete_filter.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.delete_filter.go new file mode 100644 index 00000000..6a25611b --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.delete_filter.go @@ -0,0 +1,193 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newMLDeleteFilterFunc(t Transport) MLDeleteFilter { + return func(filter_id string, o ...func(*MLDeleteFilterRequest)) (*Response, error) { + var r = MLDeleteFilterRequest{FilterID: filter_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLDeleteFilter - Deletes a filter. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-filter.html. +type MLDeleteFilter func(filter_id string, o ...func(*MLDeleteFilterRequest)) (*Response, error) + +// MLDeleteFilterRequest configures the ML Delete Filter API request. +type MLDeleteFilterRequest struct { + FilterID string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLDeleteFilterRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + path.Grow(1 + len("_ml") + 1 + len("filters") + 1 + len(r.FilterID)) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("filters") + path.WriteString("/") + path.WriteString(r.FilterID) + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLDeleteFilter) WithContext(v context.Context) func(*MLDeleteFilterRequest) { + return func(r *MLDeleteFilterRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLDeleteFilter) WithPretty() func(*MLDeleteFilterRequest) { + return func(r *MLDeleteFilterRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLDeleteFilter) WithHuman() func(*MLDeleteFilterRequest) { + return func(r *MLDeleteFilterRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLDeleteFilter) WithErrorTrace() func(*MLDeleteFilterRequest) { + return func(r *MLDeleteFilterRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLDeleteFilter) WithFilterPath(v ...string) func(*MLDeleteFilterRequest) { + return func(r *MLDeleteFilterRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLDeleteFilter) WithHeader(h map[string]string) func(*MLDeleteFilterRequest) { + return func(r *MLDeleteFilterRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLDeleteFilter) WithOpaqueID(s string) func(*MLDeleteFilterRequest) { + return func(r *MLDeleteFilterRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.delete_forecast.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.delete_forecast.go new file mode 100644 index 00000000..3e4d68fc --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.delete_forecast.go @@ -0,0 +1,234 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" + "time" +) + +func newMLDeleteForecastFunc(t Transport) MLDeleteForecast { + return func(job_id string, o ...func(*MLDeleteForecastRequest)) (*Response, error) { + var r = MLDeleteForecastRequest{JobID: job_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLDeleteForecast - Deletes forecasts from a machine learning job. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-forecast.html. +type MLDeleteForecast func(job_id string, o ...func(*MLDeleteForecastRequest)) (*Response, error) + +// MLDeleteForecastRequest configures the ML Delete Forecast API request. +type MLDeleteForecastRequest struct { + ForecastID string + JobID string + + AllowNoForecasts *bool + Timeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLDeleteForecastRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + path.Grow(1 + len("_ml") + 1 + len("anomaly_detectors") + 1 + len(r.JobID) + 1 + len("_forecast") + 1 + len(r.ForecastID)) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("anomaly_detectors") + path.WriteString("/") + path.WriteString(r.JobID) + path.WriteString("/") + path.WriteString("_forecast") + if r.ForecastID != "" { + path.WriteString("/") + path.WriteString(r.ForecastID) + } + + params = make(map[string]string) + + if r.AllowNoForecasts != nil { + params["allow_no_forecasts"] = strconv.FormatBool(*r.AllowNoForecasts) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLDeleteForecast) WithContext(v context.Context) func(*MLDeleteForecastRequest) { + return func(r *MLDeleteForecastRequest) { + r.ctx = v + } +} + +// WithForecastID - the ID of the forecast to delete, can be comma delimited list. leaving blank implies `_all`. +func (f MLDeleteForecast) WithForecastID(v string) func(*MLDeleteForecastRequest) { + return func(r *MLDeleteForecastRequest) { + r.ForecastID = v + } +} + +// WithAllowNoForecasts - whether to ignore if `_all` matches no forecasts. +func (f MLDeleteForecast) WithAllowNoForecasts(v bool) func(*MLDeleteForecastRequest) { + return func(r *MLDeleteForecastRequest) { + r.AllowNoForecasts = &v + } +} + +// WithTimeout - controls the time to wait until the forecast(s) are deleted. default to 30 seconds. +func (f MLDeleteForecast) WithTimeout(v time.Duration) func(*MLDeleteForecastRequest) { + return func(r *MLDeleteForecastRequest) { + r.Timeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLDeleteForecast) WithPretty() func(*MLDeleteForecastRequest) { + return func(r *MLDeleteForecastRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLDeleteForecast) WithHuman() func(*MLDeleteForecastRequest) { + return func(r *MLDeleteForecastRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLDeleteForecast) WithErrorTrace() func(*MLDeleteForecastRequest) { + return func(r *MLDeleteForecastRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLDeleteForecast) WithFilterPath(v ...string) func(*MLDeleteForecastRequest) { + return func(r *MLDeleteForecastRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLDeleteForecast) WithHeader(h map[string]string) func(*MLDeleteForecastRequest) { + return func(r *MLDeleteForecastRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLDeleteForecast) WithOpaqueID(s string) func(*MLDeleteForecastRequest) { + return func(r *MLDeleteForecastRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.delete_job.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.delete_job.go new file mode 100644 index 00000000..23d3c042 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.delete_job.go @@ -0,0 +1,219 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newMLDeleteJobFunc(t Transport) MLDeleteJob { + return func(job_id string, o ...func(*MLDeleteJobRequest)) (*Response, error) { + var r = MLDeleteJobRequest{JobID: job_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLDeleteJob - Deletes an existing anomaly detection job. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-job.html. +type MLDeleteJob func(job_id string, o ...func(*MLDeleteJobRequest)) (*Response, error) + +// MLDeleteJobRequest configures the ML Delete Job API request. +type MLDeleteJobRequest struct { + JobID string + + Force *bool + WaitForCompletion *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLDeleteJobRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + path.Grow(1 + len("_ml") + 1 + len("anomaly_detectors") + 1 + len(r.JobID)) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("anomaly_detectors") + path.WriteString("/") + path.WriteString(r.JobID) + + params = make(map[string]string) + + if r.Force != nil { + params["force"] = strconv.FormatBool(*r.Force) + } + + if r.WaitForCompletion != nil { + params["wait_for_completion"] = strconv.FormatBool(*r.WaitForCompletion) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLDeleteJob) WithContext(v context.Context) func(*MLDeleteJobRequest) { + return func(r *MLDeleteJobRequest) { + r.ctx = v + } +} + +// WithForce - true if the job should be forcefully deleted. +func (f MLDeleteJob) WithForce(v bool) func(*MLDeleteJobRequest) { + return func(r *MLDeleteJobRequest) { + r.Force = &v + } +} + +// WithWaitForCompletion - should this request wait until the operation has completed before returning. +func (f MLDeleteJob) WithWaitForCompletion(v bool) func(*MLDeleteJobRequest) { + return func(r *MLDeleteJobRequest) { + r.WaitForCompletion = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLDeleteJob) WithPretty() func(*MLDeleteJobRequest) { + return func(r *MLDeleteJobRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLDeleteJob) WithHuman() func(*MLDeleteJobRequest) { + return func(r *MLDeleteJobRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLDeleteJob) WithErrorTrace() func(*MLDeleteJobRequest) { + return func(r *MLDeleteJobRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLDeleteJob) WithFilterPath(v ...string) func(*MLDeleteJobRequest) { + return func(r *MLDeleteJobRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLDeleteJob) WithHeader(h map[string]string) func(*MLDeleteJobRequest) { + return func(r *MLDeleteJobRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLDeleteJob) WithOpaqueID(s string) func(*MLDeleteJobRequest) { + return func(r *MLDeleteJobRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.delete_model_snapshot.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.delete_model_snapshot.go new file mode 100644 index 00000000..910a8c79 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.delete_model_snapshot.go @@ -0,0 +1,198 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newMLDeleteModelSnapshotFunc(t Transport) MLDeleteModelSnapshot { + return func(snapshot_id string, job_id string, o ...func(*MLDeleteModelSnapshotRequest)) (*Response, error) { + var r = MLDeleteModelSnapshotRequest{SnapshotID: snapshot_id, JobID: job_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLDeleteModelSnapshot - Deletes an existing model snapshot. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-snapshot.html. +type MLDeleteModelSnapshot func(snapshot_id string, job_id string, o ...func(*MLDeleteModelSnapshotRequest)) (*Response, error) + +// MLDeleteModelSnapshotRequest configures the ML Delete Model Snapshot API request. +type MLDeleteModelSnapshotRequest struct { + JobID string + SnapshotID string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLDeleteModelSnapshotRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + path.Grow(1 + len("_ml") + 1 + len("anomaly_detectors") + 1 + len(r.JobID) + 1 + len("model_snapshots") + 1 + len(r.SnapshotID)) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("anomaly_detectors") + path.WriteString("/") + path.WriteString(r.JobID) + path.WriteString("/") + path.WriteString("model_snapshots") + path.WriteString("/") + path.WriteString(r.SnapshotID) + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLDeleteModelSnapshot) WithContext(v context.Context) func(*MLDeleteModelSnapshotRequest) { + return func(r *MLDeleteModelSnapshotRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLDeleteModelSnapshot) WithPretty() func(*MLDeleteModelSnapshotRequest) { + return func(r *MLDeleteModelSnapshotRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLDeleteModelSnapshot) WithHuman() func(*MLDeleteModelSnapshotRequest) { + return func(r *MLDeleteModelSnapshotRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLDeleteModelSnapshot) WithErrorTrace() func(*MLDeleteModelSnapshotRequest) { + return func(r *MLDeleteModelSnapshotRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLDeleteModelSnapshot) WithFilterPath(v ...string) func(*MLDeleteModelSnapshotRequest) { + return func(r *MLDeleteModelSnapshotRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLDeleteModelSnapshot) WithHeader(h map[string]string) func(*MLDeleteModelSnapshotRequest) { + return func(r *MLDeleteModelSnapshotRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLDeleteModelSnapshot) WithOpaqueID(s string) func(*MLDeleteModelSnapshotRequest) { + return func(r *MLDeleteModelSnapshotRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.delete_trained_model.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.delete_trained_model.go new file mode 100644 index 00000000..acfb6bc3 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.delete_trained_model.go @@ -0,0 +1,193 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newMLDeleteTrainedModelFunc(t Transport) MLDeleteTrainedModel { + return func(model_id string, o ...func(*MLDeleteTrainedModelRequest)) (*Response, error) { + var r = MLDeleteTrainedModelRequest{ModelID: model_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLDeleteTrainedModel - Deletes an existing trained inference model that is currently not referenced by an ingest pipeline. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-trained-models.html. +type MLDeleteTrainedModel func(model_id string, o ...func(*MLDeleteTrainedModelRequest)) (*Response, error) + +// MLDeleteTrainedModelRequest configures the ML Delete Trained Model API request. +type MLDeleteTrainedModelRequest struct { + ModelID string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLDeleteTrainedModelRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + path.Grow(1 + len("_ml") + 1 + len("trained_models") + 1 + len(r.ModelID)) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("trained_models") + path.WriteString("/") + path.WriteString(r.ModelID) + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLDeleteTrainedModel) WithContext(v context.Context) func(*MLDeleteTrainedModelRequest) { + return func(r *MLDeleteTrainedModelRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLDeleteTrainedModel) WithPretty() func(*MLDeleteTrainedModelRequest) { + return func(r *MLDeleteTrainedModelRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLDeleteTrainedModel) WithHuman() func(*MLDeleteTrainedModelRequest) { + return func(r *MLDeleteTrainedModelRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLDeleteTrainedModel) WithErrorTrace() func(*MLDeleteTrainedModelRequest) { + return func(r *MLDeleteTrainedModelRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLDeleteTrainedModel) WithFilterPath(v ...string) func(*MLDeleteTrainedModelRequest) { + return func(r *MLDeleteTrainedModelRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLDeleteTrainedModel) WithHeader(h map[string]string) func(*MLDeleteTrainedModelRequest) { + return func(r *MLDeleteTrainedModelRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLDeleteTrainedModel) WithOpaqueID(s string) func(*MLDeleteTrainedModelRequest) { + return func(r *MLDeleteTrainedModelRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.delete_trained_model_alias.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.delete_trained_model_alias.go new file mode 100644 index 00000000..2b3fbd68 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.delete_trained_model_alias.go @@ -0,0 +1,198 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newMLDeleteTrainedModelAliasFunc(t Transport) MLDeleteTrainedModelAlias { + return func(model_alias string, model_id string, o ...func(*MLDeleteTrainedModelAliasRequest)) (*Response, error) { + var r = MLDeleteTrainedModelAliasRequest{ModelAlias: model_alias, ModelID: model_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLDeleteTrainedModelAlias - Deletes a model alias that refers to the trained model +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-trained-models-aliases.html. +type MLDeleteTrainedModelAlias func(model_alias string, model_id string, o ...func(*MLDeleteTrainedModelAliasRequest)) (*Response, error) + +// MLDeleteTrainedModelAliasRequest configures the ML Delete Trained Model Alias API request. +type MLDeleteTrainedModelAliasRequest struct { + ModelAlias string + ModelID string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLDeleteTrainedModelAliasRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + path.Grow(1 + len("_ml") + 1 + len("trained_models") + 1 + len(r.ModelID) + 1 + len("model_aliases") + 1 + len(r.ModelAlias)) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("trained_models") + path.WriteString("/") + path.WriteString(r.ModelID) + path.WriteString("/") + path.WriteString("model_aliases") + path.WriteString("/") + path.WriteString(r.ModelAlias) + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLDeleteTrainedModelAlias) WithContext(v context.Context) func(*MLDeleteTrainedModelAliasRequest) { + return func(r *MLDeleteTrainedModelAliasRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLDeleteTrainedModelAlias) WithPretty() func(*MLDeleteTrainedModelAliasRequest) { + return func(r *MLDeleteTrainedModelAliasRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLDeleteTrainedModelAlias) WithHuman() func(*MLDeleteTrainedModelAliasRequest) { + return func(r *MLDeleteTrainedModelAliasRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLDeleteTrainedModelAlias) WithErrorTrace() func(*MLDeleteTrainedModelAliasRequest) { + return func(r *MLDeleteTrainedModelAliasRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLDeleteTrainedModelAlias) WithFilterPath(v ...string) func(*MLDeleteTrainedModelAliasRequest) { + return func(r *MLDeleteTrainedModelAliasRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLDeleteTrainedModelAlias) WithHeader(h map[string]string) func(*MLDeleteTrainedModelAliasRequest) { + return func(r *MLDeleteTrainedModelAliasRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLDeleteTrainedModelAlias) WithOpaqueID(s string) func(*MLDeleteTrainedModelAliasRequest) { + return func(r *MLDeleteTrainedModelAliasRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.estimate_model_memory.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.estimate_model_memory.go new file mode 100644 index 00000000..e9976a7d --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.estimate_model_memory.go @@ -0,0 +1,193 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newMLEstimateModelMemoryFunc(t Transport) MLEstimateModelMemory { + return func(body io.Reader, o ...func(*MLEstimateModelMemoryRequest)) (*Response, error) { + var r = MLEstimateModelMemoryRequest{Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLEstimateModelMemory - Estimates the model memory +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-apis.html. +type MLEstimateModelMemory func(body io.Reader, o ...func(*MLEstimateModelMemoryRequest)) (*Response, error) + +// MLEstimateModelMemoryRequest configures the ML Estimate Model Memory API request. +type MLEstimateModelMemoryRequest struct { + Body io.Reader + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLEstimateModelMemoryRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(len("/_ml/anomaly_detectors/_estimate_model_memory")) + path.WriteString("/_ml/anomaly_detectors/_estimate_model_memory") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLEstimateModelMemory) WithContext(v context.Context) func(*MLEstimateModelMemoryRequest) { + return func(r *MLEstimateModelMemoryRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLEstimateModelMemory) WithPretty() func(*MLEstimateModelMemoryRequest) { + return func(r *MLEstimateModelMemoryRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLEstimateModelMemory) WithHuman() func(*MLEstimateModelMemoryRequest) { + return func(r *MLEstimateModelMemoryRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLEstimateModelMemory) WithErrorTrace() func(*MLEstimateModelMemoryRequest) { + return func(r *MLEstimateModelMemoryRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLEstimateModelMemory) WithFilterPath(v ...string) func(*MLEstimateModelMemoryRequest) { + return func(r *MLEstimateModelMemoryRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLEstimateModelMemory) WithHeader(h map[string]string) func(*MLEstimateModelMemoryRequest) { + return func(r *MLEstimateModelMemoryRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLEstimateModelMemory) WithOpaqueID(s string) func(*MLEstimateModelMemoryRequest) { + return func(r *MLEstimateModelMemoryRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.evaluate_data_frame.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.evaluate_data_frame.go new file mode 100644 index 00000000..301ca8a3 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.evaluate_data_frame.go @@ -0,0 +1,193 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newMLEvaluateDataFrameFunc(t Transport) MLEvaluateDataFrame { + return func(body io.Reader, o ...func(*MLEvaluateDataFrameRequest)) (*Response, error) { + var r = MLEvaluateDataFrameRequest{Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLEvaluateDataFrame - Evaluates the data frame analytics for an annotated index. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/evaluate-dfanalytics.html. +type MLEvaluateDataFrame func(body io.Reader, o ...func(*MLEvaluateDataFrameRequest)) (*Response, error) + +// MLEvaluateDataFrameRequest configures the ML Evaluate Data Frame API request. +type MLEvaluateDataFrameRequest struct { + Body io.Reader + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLEvaluateDataFrameRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(len("/_ml/data_frame/_evaluate")) + path.WriteString("/_ml/data_frame/_evaluate") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLEvaluateDataFrame) WithContext(v context.Context) func(*MLEvaluateDataFrameRequest) { + return func(r *MLEvaluateDataFrameRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLEvaluateDataFrame) WithPretty() func(*MLEvaluateDataFrameRequest) { + return func(r *MLEvaluateDataFrameRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLEvaluateDataFrame) WithHuman() func(*MLEvaluateDataFrameRequest) { + return func(r *MLEvaluateDataFrameRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLEvaluateDataFrame) WithErrorTrace() func(*MLEvaluateDataFrameRequest) { + return func(r *MLEvaluateDataFrameRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLEvaluateDataFrame) WithFilterPath(v ...string) func(*MLEvaluateDataFrameRequest) { + return func(r *MLEvaluateDataFrameRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLEvaluateDataFrame) WithHeader(h map[string]string) func(*MLEvaluateDataFrameRequest) { + return func(r *MLEvaluateDataFrameRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLEvaluateDataFrame) WithOpaqueID(s string) func(*MLEvaluateDataFrameRequest) { + return func(r *MLEvaluateDataFrameRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.explain_data_frame_analytics.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.explain_data_frame_analytics.go new file mode 100644 index 00000000..2de188b2 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.explain_data_frame_analytics.go @@ -0,0 +1,220 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newMLExplainDataFrameAnalyticsFunc(t Transport) MLExplainDataFrameAnalytics { + return func(o ...func(*MLExplainDataFrameAnalyticsRequest)) (*Response, error) { + var r = MLExplainDataFrameAnalyticsRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLExplainDataFrameAnalytics - Explains a data frame analytics config. +// +// See full documentation at http://www.elastic.co/guide/en/elasticsearch/reference/current/explain-dfanalytics.html. +type MLExplainDataFrameAnalytics func(o ...func(*MLExplainDataFrameAnalyticsRequest)) (*Response, error) + +// MLExplainDataFrameAnalyticsRequest configures the ML Explain Data Frame Analytics API request. +type MLExplainDataFrameAnalyticsRequest struct { + DocumentID string + + Body io.Reader + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLExplainDataFrameAnalyticsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_ml") + 1 + len("data_frame") + 1 + len("analytics") + 1 + len(r.DocumentID) + 1 + len("_explain")) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("data_frame") + path.WriteString("/") + path.WriteString("analytics") + if r.DocumentID != "" { + path.WriteString("/") + path.WriteString(r.DocumentID) + } + path.WriteString("/") + path.WriteString("_explain") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLExplainDataFrameAnalytics) WithContext(v context.Context) func(*MLExplainDataFrameAnalyticsRequest) { + return func(r *MLExplainDataFrameAnalyticsRequest) { + r.ctx = v + } +} + +// WithBody - The data frame analytics config to explain. +func (f MLExplainDataFrameAnalytics) WithBody(v io.Reader) func(*MLExplainDataFrameAnalyticsRequest) { + return func(r *MLExplainDataFrameAnalyticsRequest) { + r.Body = v + } +} + +// WithDocumentID - the ID of the data frame analytics to explain. +func (f MLExplainDataFrameAnalytics) WithDocumentID(v string) func(*MLExplainDataFrameAnalyticsRequest) { + return func(r *MLExplainDataFrameAnalyticsRequest) { + r.DocumentID = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLExplainDataFrameAnalytics) WithPretty() func(*MLExplainDataFrameAnalyticsRequest) { + return func(r *MLExplainDataFrameAnalyticsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLExplainDataFrameAnalytics) WithHuman() func(*MLExplainDataFrameAnalyticsRequest) { + return func(r *MLExplainDataFrameAnalyticsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLExplainDataFrameAnalytics) WithErrorTrace() func(*MLExplainDataFrameAnalyticsRequest) { + return func(r *MLExplainDataFrameAnalyticsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLExplainDataFrameAnalytics) WithFilterPath(v ...string) func(*MLExplainDataFrameAnalyticsRequest) { + return func(r *MLExplainDataFrameAnalyticsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLExplainDataFrameAnalytics) WithHeader(h map[string]string) func(*MLExplainDataFrameAnalyticsRequest) { + return func(r *MLExplainDataFrameAnalyticsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLExplainDataFrameAnalytics) WithOpaqueID(s string) func(*MLExplainDataFrameAnalyticsRequest) { + return func(r *MLExplainDataFrameAnalyticsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.find_file_structure.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.find_file_structure.go new file mode 100644 index 00000000..6560c83f --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.find_file_structure.go @@ -0,0 +1,366 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" + "time" +) + +func newMLFindFileStructureFunc(t Transport) MLFindFileStructure { + return func(body io.Reader, o ...func(*MLFindFileStructureRequest)) (*Response, error) { + var r = MLFindFileStructureRequest{Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLFindFileStructure - Finds the structure of a text file. The text file must contain data that is suitable to be ingested into Elasticsearch. +// +// This API is experimental. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/find-structure.html. +type MLFindFileStructure func(body io.Reader, o ...func(*MLFindFileStructureRequest)) (*Response, error) + +// MLFindFileStructureRequest configures the ML Find File Structure API request. +type MLFindFileStructureRequest struct { + Body io.Reader + + Charset string + ColumnNames []string + Delimiter string + Explain *bool + Format string + GrokPattern string + HasHeaderRow *bool + LineMergeSizeLimit *int + LinesToSample *int + Quote string + ShouldTrimFields *bool + Timeout time.Duration + TimestampField string + TimestampFormat string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLFindFileStructureRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(len("/_ml/find_file_structure")) + path.WriteString("/_ml/find_file_structure") + + params = make(map[string]string) + + if r.Charset != "" { + params["charset"] = r.Charset + } + + if len(r.ColumnNames) > 0 { + params["column_names"] = strings.Join(r.ColumnNames, ",") + } + + if r.Delimiter != "" { + params["delimiter"] = r.Delimiter + } + + if r.Explain != nil { + params["explain"] = strconv.FormatBool(*r.Explain) + } + + if r.Format != "" { + params["format"] = r.Format + } + + if r.GrokPattern != "" { + params["grok_pattern"] = r.GrokPattern + } + + if r.HasHeaderRow != nil { + params["has_header_row"] = strconv.FormatBool(*r.HasHeaderRow) + } + + if r.LineMergeSizeLimit != nil { + params["line_merge_size_limit"] = strconv.FormatInt(int64(*r.LineMergeSizeLimit), 10) + } + + if r.LinesToSample != nil { + params["lines_to_sample"] = strconv.FormatInt(int64(*r.LinesToSample), 10) + } + + if r.Quote != "" { + params["quote"] = r.Quote + } + + if r.ShouldTrimFields != nil { + params["should_trim_fields"] = strconv.FormatBool(*r.ShouldTrimFields) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.TimestampField != "" { + params["timestamp_field"] = r.TimestampField + } + + if r.TimestampFormat != "" { + params["timestamp_format"] = r.TimestampFormat + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLFindFileStructure) WithContext(v context.Context) func(*MLFindFileStructureRequest) { + return func(r *MLFindFileStructureRequest) { + r.ctx = v + } +} + +// WithCharset - optional parameter to specify the character set of the file. +func (f MLFindFileStructure) WithCharset(v string) func(*MLFindFileStructureRequest) { + return func(r *MLFindFileStructureRequest) { + r.Charset = v + } +} + +// WithColumnNames - optional parameter containing a comma separated list of the column names for a delimited file. +func (f MLFindFileStructure) WithColumnNames(v ...string) func(*MLFindFileStructureRequest) { + return func(r *MLFindFileStructureRequest) { + r.ColumnNames = v + } +} + +// WithDelimiter - optional parameter to specify the delimiter character for a delimited file - must be a single character. +func (f MLFindFileStructure) WithDelimiter(v string) func(*MLFindFileStructureRequest) { + return func(r *MLFindFileStructureRequest) { + r.Delimiter = v + } +} + +// WithExplain - whether to include a commentary on how the structure was derived. +func (f MLFindFileStructure) WithExplain(v bool) func(*MLFindFileStructureRequest) { + return func(r *MLFindFileStructureRequest) { + r.Explain = &v + } +} + +// WithFormat - optional parameter to specify the high level file format. +func (f MLFindFileStructure) WithFormat(v string) func(*MLFindFileStructureRequest) { + return func(r *MLFindFileStructureRequest) { + r.Format = v + } +} + +// WithGrokPattern - optional parameter to specify the grok pattern that should be used to extract fields from messages in a semi-structured text file. +func (f MLFindFileStructure) WithGrokPattern(v string) func(*MLFindFileStructureRequest) { + return func(r *MLFindFileStructureRequest) { + r.GrokPattern = v + } +} + +// WithHasHeaderRow - optional parameter to specify whether a delimited file includes the column names in its first row. +func (f MLFindFileStructure) WithHasHeaderRow(v bool) func(*MLFindFileStructureRequest) { + return func(r *MLFindFileStructureRequest) { + r.HasHeaderRow = &v + } +} + +// WithLineMergeSizeLimit - maximum number of characters permitted in a single message when lines are merged to create messages.. +func (f MLFindFileStructure) WithLineMergeSizeLimit(v int) func(*MLFindFileStructureRequest) { + return func(r *MLFindFileStructureRequest) { + r.LineMergeSizeLimit = &v + } +} + +// WithLinesToSample - how many lines of the file should be included in the analysis. +func (f MLFindFileStructure) WithLinesToSample(v int) func(*MLFindFileStructureRequest) { + return func(r *MLFindFileStructureRequest) { + r.LinesToSample = &v + } +} + +// WithQuote - optional parameter to specify the quote character for a delimited file - must be a single character. +func (f MLFindFileStructure) WithQuote(v string) func(*MLFindFileStructureRequest) { + return func(r *MLFindFileStructureRequest) { + r.Quote = v + } +} + +// WithShouldTrimFields - optional parameter to specify whether the values between delimiters in a delimited file should have whitespace trimmed from them. +func (f MLFindFileStructure) WithShouldTrimFields(v bool) func(*MLFindFileStructureRequest) { + return func(r *MLFindFileStructureRequest) { + r.ShouldTrimFields = &v + } +} + +// WithTimeout - timeout after which the analysis will be aborted. +func (f MLFindFileStructure) WithTimeout(v time.Duration) func(*MLFindFileStructureRequest) { + return func(r *MLFindFileStructureRequest) { + r.Timeout = v + } +} + +// WithTimestampField - optional parameter to specify the timestamp field in the file. +func (f MLFindFileStructure) WithTimestampField(v string) func(*MLFindFileStructureRequest) { + return func(r *MLFindFileStructureRequest) { + r.TimestampField = v + } +} + +// WithTimestampFormat - optional parameter to specify the timestamp format in the file - may be either a joda or java time format. +func (f MLFindFileStructure) WithTimestampFormat(v string) func(*MLFindFileStructureRequest) { + return func(r *MLFindFileStructureRequest) { + r.TimestampFormat = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLFindFileStructure) WithPretty() func(*MLFindFileStructureRequest) { + return func(r *MLFindFileStructureRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLFindFileStructure) WithHuman() func(*MLFindFileStructureRequest) { + return func(r *MLFindFileStructureRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLFindFileStructure) WithErrorTrace() func(*MLFindFileStructureRequest) { + return func(r *MLFindFileStructureRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLFindFileStructure) WithFilterPath(v ...string) func(*MLFindFileStructureRequest) { + return func(r *MLFindFileStructureRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLFindFileStructure) WithHeader(h map[string]string) func(*MLFindFileStructureRequest) { + return func(r *MLFindFileStructureRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLFindFileStructure) WithOpaqueID(s string) func(*MLFindFileStructureRequest) { + return func(r *MLFindFileStructureRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.flush_job.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.flush_job.go new file mode 100644 index 00000000..2717f03c --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.flush_job.go @@ -0,0 +1,271 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" +) + +func newMLFlushJobFunc(t Transport) MLFlushJob { + return func(job_id string, o ...func(*MLFlushJobRequest)) (*Response, error) { + var r = MLFlushJobRequest{JobID: job_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLFlushJob - Forces any buffered data to be processed by the job. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-flush-job.html. +type MLFlushJob func(job_id string, o ...func(*MLFlushJobRequest)) (*Response, error) + +// MLFlushJobRequest configures the ML Flush Job API request. +type MLFlushJobRequest struct { + Body io.Reader + + JobID string + + AdvanceTime string + CalcInterim *bool + End string + SkipTime string + Start string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLFlushJobRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_ml") + 1 + len("anomaly_detectors") + 1 + len(r.JobID) + 1 + len("_flush")) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("anomaly_detectors") + path.WriteString("/") + path.WriteString(r.JobID) + path.WriteString("/") + path.WriteString("_flush") + + params = make(map[string]string) + + if r.AdvanceTime != "" { + params["advance_time"] = r.AdvanceTime + } + + if r.CalcInterim != nil { + params["calc_interim"] = strconv.FormatBool(*r.CalcInterim) + } + + if r.End != "" { + params["end"] = r.End + } + + if r.SkipTime != "" { + params["skip_time"] = r.SkipTime + } + + if r.Start != "" { + params["start"] = r.Start + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLFlushJob) WithContext(v context.Context) func(*MLFlushJobRequest) { + return func(r *MLFlushJobRequest) { + r.ctx = v + } +} + +// WithBody - Flush parameters. +func (f MLFlushJob) WithBody(v io.Reader) func(*MLFlushJobRequest) { + return func(r *MLFlushJobRequest) { + r.Body = v + } +} + +// WithAdvanceTime - advances time to the given value generating results and updating the model for the advanced interval. +func (f MLFlushJob) WithAdvanceTime(v string) func(*MLFlushJobRequest) { + return func(r *MLFlushJobRequest) { + r.AdvanceTime = v + } +} + +// WithCalcInterim - calculates interim results for the most recent bucket or all buckets within the latency period. +func (f MLFlushJob) WithCalcInterim(v bool) func(*MLFlushJobRequest) { + return func(r *MLFlushJobRequest) { + r.CalcInterim = &v + } +} + +// WithEnd - when used in conjunction with calc_interim, specifies the range of buckets on which to calculate interim results. +func (f MLFlushJob) WithEnd(v string) func(*MLFlushJobRequest) { + return func(r *MLFlushJobRequest) { + r.End = v + } +} + +// WithSkipTime - skips time to the given value without generating results or updating the model for the skipped interval. +func (f MLFlushJob) WithSkipTime(v string) func(*MLFlushJobRequest) { + return func(r *MLFlushJobRequest) { + r.SkipTime = v + } +} + +// WithStart - when used in conjunction with calc_interim, specifies the range of buckets on which to calculate interim results. +func (f MLFlushJob) WithStart(v string) func(*MLFlushJobRequest) { + return func(r *MLFlushJobRequest) { + r.Start = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLFlushJob) WithPretty() func(*MLFlushJobRequest) { + return func(r *MLFlushJobRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLFlushJob) WithHuman() func(*MLFlushJobRequest) { + return func(r *MLFlushJobRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLFlushJob) WithErrorTrace() func(*MLFlushJobRequest) { + return func(r *MLFlushJobRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLFlushJob) WithFilterPath(v ...string) func(*MLFlushJobRequest) { + return func(r *MLFlushJobRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLFlushJob) WithHeader(h map[string]string) func(*MLFlushJobRequest) { + return func(r *MLFlushJobRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLFlushJob) WithOpaqueID(s string) func(*MLFlushJobRequest) { + return func(r *MLFlushJobRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.forecast.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.forecast.go new file mode 100644 index 00000000..f1054484 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.forecast.go @@ -0,0 +1,247 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" + "time" +) + +func newMLForecastFunc(t Transport) MLForecast { + return func(job_id string, o ...func(*MLForecastRequest)) (*Response, error) { + var r = MLForecastRequest{JobID: job_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLForecast - Predicts the future behavior of a time series by using its historical behavior. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-forecast.html. +type MLForecast func(job_id string, o ...func(*MLForecastRequest)) (*Response, error) + +// MLForecastRequest configures the ML Forecast API request. +type MLForecastRequest struct { + Body io.Reader + + JobID string + + Duration time.Duration + ExpiresIn time.Duration + MaxModelMemory string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLForecastRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_ml") + 1 + len("anomaly_detectors") + 1 + len(r.JobID) + 1 + len("_forecast")) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("anomaly_detectors") + path.WriteString("/") + path.WriteString(r.JobID) + path.WriteString("/") + path.WriteString("_forecast") + + params = make(map[string]string) + + if r.Duration != 0 { + params["duration"] = formatDuration(r.Duration) + } + + if r.ExpiresIn != 0 { + params["expires_in"] = formatDuration(r.ExpiresIn) + } + + if r.MaxModelMemory != "" { + params["max_model_memory"] = r.MaxModelMemory + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLForecast) WithContext(v context.Context) func(*MLForecastRequest) { + return func(r *MLForecastRequest) { + r.ctx = v + } +} + +// WithBody - Query parameters can be specified in the body. +func (f MLForecast) WithBody(v io.Reader) func(*MLForecastRequest) { + return func(r *MLForecastRequest) { + r.Body = v + } +} + +// WithDuration - the duration of the forecast. +func (f MLForecast) WithDuration(v time.Duration) func(*MLForecastRequest) { + return func(r *MLForecastRequest) { + r.Duration = v + } +} + +// WithExpiresIn - the time interval after which the forecast expires. expired forecasts will be deleted at the first opportunity.. +func (f MLForecast) WithExpiresIn(v time.Duration) func(*MLForecastRequest) { + return func(r *MLForecastRequest) { + r.ExpiresIn = v + } +} + +// WithMaxModelMemory - the max memory able to be used by the forecast. default is 20mb.. +func (f MLForecast) WithMaxModelMemory(v string) func(*MLForecastRequest) { + return func(r *MLForecastRequest) { + r.MaxModelMemory = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLForecast) WithPretty() func(*MLForecastRequest) { + return func(r *MLForecastRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLForecast) WithHuman() func(*MLForecastRequest) { + return func(r *MLForecastRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLForecast) WithErrorTrace() func(*MLForecastRequest) { + return func(r *MLForecastRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLForecast) WithFilterPath(v ...string) func(*MLForecastRequest) { + return func(r *MLForecastRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLForecast) WithHeader(h map[string]string) func(*MLForecastRequest) { + return func(r *MLForecastRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLForecast) WithOpaqueID(s string) func(*MLForecastRequest) { + return func(r *MLForecastRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_buckets.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_buckets.go new file mode 100644 index 00000000..769ce58a --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_buckets.go @@ -0,0 +1,334 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "fmt" + "io" + "net/http" + "strconv" + "strings" +) + +func newMLGetBucketsFunc(t Transport) MLGetBuckets { + return func(job_id string, o ...func(*MLGetBucketsRequest)) (*Response, error) { + var r = MLGetBucketsRequest{JobID: job_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLGetBuckets - Retrieves anomaly detection job results for one or more buckets. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-bucket.html. +type MLGetBuckets func(job_id string, o ...func(*MLGetBucketsRequest)) (*Response, error) + +// MLGetBucketsRequest configures the ML Get Buckets API request. +type MLGetBucketsRequest struct { + Body io.Reader + + JobID string + Timestamp string + + AnomalyScore interface{} + Desc *bool + End string + ExcludeInterim *bool + Expand *bool + From *int + Size *int + Sort string + Start string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLGetBucketsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_ml") + 1 + len("anomaly_detectors") + 1 + len(r.JobID) + 1 + len("results") + 1 + len("buckets") + 1 + len(r.Timestamp)) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("anomaly_detectors") + path.WriteString("/") + path.WriteString(r.JobID) + path.WriteString("/") + path.WriteString("results") + path.WriteString("/") + path.WriteString("buckets") + if r.Timestamp != "" { + path.WriteString("/") + path.WriteString(r.Timestamp) + } + + params = make(map[string]string) + + if r.AnomalyScore != nil { + params["anomaly_score"] = fmt.Sprintf("%v", r.AnomalyScore) + } + + if r.Desc != nil { + params["desc"] = strconv.FormatBool(*r.Desc) + } + + if r.End != "" { + params["end"] = r.End + } + + if r.ExcludeInterim != nil { + params["exclude_interim"] = strconv.FormatBool(*r.ExcludeInterim) + } + + if r.Expand != nil { + params["expand"] = strconv.FormatBool(*r.Expand) + } + + if r.From != nil { + params["from"] = strconv.FormatInt(int64(*r.From), 10) + } + + if r.Size != nil { + params["size"] = strconv.FormatInt(int64(*r.Size), 10) + } + + if r.Sort != "" { + params["sort"] = r.Sort + } + + if r.Start != "" { + params["start"] = r.Start + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLGetBuckets) WithContext(v context.Context) func(*MLGetBucketsRequest) { + return func(r *MLGetBucketsRequest) { + r.ctx = v + } +} + +// WithBody - Bucket selection details if not provided in URI. +func (f MLGetBuckets) WithBody(v io.Reader) func(*MLGetBucketsRequest) { + return func(r *MLGetBucketsRequest) { + r.Body = v + } +} + +// WithTimestamp - the timestamp of the desired single bucket result. +func (f MLGetBuckets) WithTimestamp(v string) func(*MLGetBucketsRequest) { + return func(r *MLGetBucketsRequest) { + r.Timestamp = v + } +} + +// WithAnomalyScore - filter for the most anomalous buckets. +func (f MLGetBuckets) WithAnomalyScore(v interface{}) func(*MLGetBucketsRequest) { + return func(r *MLGetBucketsRequest) { + r.AnomalyScore = v + } +} + +// WithDesc - set the sort direction. +func (f MLGetBuckets) WithDesc(v bool) func(*MLGetBucketsRequest) { + return func(r *MLGetBucketsRequest) { + r.Desc = &v + } +} + +// WithEnd - end time filter for buckets. +func (f MLGetBuckets) WithEnd(v string) func(*MLGetBucketsRequest) { + return func(r *MLGetBucketsRequest) { + r.End = v + } +} + +// WithExcludeInterim - exclude interim results. +func (f MLGetBuckets) WithExcludeInterim(v bool) func(*MLGetBucketsRequest) { + return func(r *MLGetBucketsRequest) { + r.ExcludeInterim = &v + } +} + +// WithExpand - include anomaly records. +func (f MLGetBuckets) WithExpand(v bool) func(*MLGetBucketsRequest) { + return func(r *MLGetBucketsRequest) { + r.Expand = &v + } +} + +// WithFrom - skips a number of buckets. +func (f MLGetBuckets) WithFrom(v int) func(*MLGetBucketsRequest) { + return func(r *MLGetBucketsRequest) { + r.From = &v + } +} + +// WithSize - specifies a max number of buckets to get. +func (f MLGetBuckets) WithSize(v int) func(*MLGetBucketsRequest) { + return func(r *MLGetBucketsRequest) { + r.Size = &v + } +} + +// WithSort - sort buckets by a particular field. +func (f MLGetBuckets) WithSort(v string) func(*MLGetBucketsRequest) { + return func(r *MLGetBucketsRequest) { + r.Sort = v + } +} + +// WithStart - start time filter for buckets. +func (f MLGetBuckets) WithStart(v string) func(*MLGetBucketsRequest) { + return func(r *MLGetBucketsRequest) { + r.Start = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLGetBuckets) WithPretty() func(*MLGetBucketsRequest) { + return func(r *MLGetBucketsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLGetBuckets) WithHuman() func(*MLGetBucketsRequest) { + return func(r *MLGetBucketsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLGetBuckets) WithErrorTrace() func(*MLGetBucketsRequest) { + return func(r *MLGetBucketsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLGetBuckets) WithFilterPath(v ...string) func(*MLGetBucketsRequest) { + return func(r *MLGetBucketsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLGetBuckets) WithHeader(h map[string]string) func(*MLGetBucketsRequest) { + return func(r *MLGetBucketsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLGetBuckets) WithOpaqueID(s string) func(*MLGetBucketsRequest) { + return func(r *MLGetBucketsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_calendar_events.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_calendar_events.go new file mode 100644 index 00000000..e0e82acb --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_calendar_events.go @@ -0,0 +1,258 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "fmt" + "net/http" + "strconv" + "strings" +) + +func newMLGetCalendarEventsFunc(t Transport) MLGetCalendarEvents { + return func(calendar_id string, o ...func(*MLGetCalendarEventsRequest)) (*Response, error) { + var r = MLGetCalendarEventsRequest{CalendarID: calendar_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLGetCalendarEvents - Retrieves information about the scheduled events in calendars. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-calendar-event.html. +type MLGetCalendarEvents func(calendar_id string, o ...func(*MLGetCalendarEventsRequest)) (*Response, error) + +// MLGetCalendarEventsRequest configures the ML Get Calendar Events API request. +type MLGetCalendarEventsRequest struct { + CalendarID string + + End interface{} + From *int + JobID string + Size *int + Start string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLGetCalendarEventsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_ml") + 1 + len("calendars") + 1 + len(r.CalendarID) + 1 + len("events")) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("calendars") + path.WriteString("/") + path.WriteString(r.CalendarID) + path.WriteString("/") + path.WriteString("events") + + params = make(map[string]string) + + if r.End != nil { + params["end"] = fmt.Sprintf("%v", r.End) + } + + if r.From != nil { + params["from"] = strconv.FormatInt(int64(*r.From), 10) + } + + if r.JobID != "" { + params["job_id"] = r.JobID + } + + if r.Size != nil { + params["size"] = strconv.FormatInt(int64(*r.Size), 10) + } + + if r.Start != "" { + params["start"] = r.Start + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLGetCalendarEvents) WithContext(v context.Context) func(*MLGetCalendarEventsRequest) { + return func(r *MLGetCalendarEventsRequest) { + r.ctx = v + } +} + +// WithEnd - get events before this time. +func (f MLGetCalendarEvents) WithEnd(v interface{}) func(*MLGetCalendarEventsRequest) { + return func(r *MLGetCalendarEventsRequest) { + r.End = v + } +} + +// WithFrom - skips a number of events. +func (f MLGetCalendarEvents) WithFrom(v int) func(*MLGetCalendarEventsRequest) { + return func(r *MLGetCalendarEventsRequest) { + r.From = &v + } +} + +// WithJobID - get events for the job. when this option is used calendar_id must be '_all'. +func (f MLGetCalendarEvents) WithJobID(v string) func(*MLGetCalendarEventsRequest) { + return func(r *MLGetCalendarEventsRequest) { + r.JobID = v + } +} + +// WithSize - specifies a max number of events to get. +func (f MLGetCalendarEvents) WithSize(v int) func(*MLGetCalendarEventsRequest) { + return func(r *MLGetCalendarEventsRequest) { + r.Size = &v + } +} + +// WithStart - get events after this time. +func (f MLGetCalendarEvents) WithStart(v string) func(*MLGetCalendarEventsRequest) { + return func(r *MLGetCalendarEventsRequest) { + r.Start = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLGetCalendarEvents) WithPretty() func(*MLGetCalendarEventsRequest) { + return func(r *MLGetCalendarEventsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLGetCalendarEvents) WithHuman() func(*MLGetCalendarEventsRequest) { + return func(r *MLGetCalendarEventsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLGetCalendarEvents) WithErrorTrace() func(*MLGetCalendarEventsRequest) { + return func(r *MLGetCalendarEventsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLGetCalendarEvents) WithFilterPath(v ...string) func(*MLGetCalendarEventsRequest) { + return func(r *MLGetCalendarEventsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLGetCalendarEvents) WithHeader(h map[string]string) func(*MLGetCalendarEventsRequest) { + return func(r *MLGetCalendarEventsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLGetCalendarEvents) WithOpaqueID(s string) func(*MLGetCalendarEventsRequest) { + return func(r *MLGetCalendarEventsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_calendars.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_calendars.go new file mode 100644 index 00000000..6856eddd --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_calendars.go @@ -0,0 +1,242 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" +) + +func newMLGetCalendarsFunc(t Transport) MLGetCalendars { + return func(o ...func(*MLGetCalendarsRequest)) (*Response, error) { + var r = MLGetCalendarsRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLGetCalendars - Retrieves configuration information for calendars. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-calendar.html. +type MLGetCalendars func(o ...func(*MLGetCalendarsRequest)) (*Response, error) + +// MLGetCalendarsRequest configures the ML Get Calendars API request. +type MLGetCalendarsRequest struct { + Body io.Reader + + CalendarID string + + From *int + Size *int + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLGetCalendarsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_ml") + 1 + len("calendars") + 1 + len(r.CalendarID)) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("calendars") + if r.CalendarID != "" { + path.WriteString("/") + path.WriteString(r.CalendarID) + } + + params = make(map[string]string) + + if r.From != nil { + params["from"] = strconv.FormatInt(int64(*r.From), 10) + } + + if r.Size != nil { + params["size"] = strconv.FormatInt(int64(*r.Size), 10) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLGetCalendars) WithContext(v context.Context) func(*MLGetCalendarsRequest) { + return func(r *MLGetCalendarsRequest) { + r.ctx = v + } +} + +// WithBody - The from and size parameters optionally sent in the body. +func (f MLGetCalendars) WithBody(v io.Reader) func(*MLGetCalendarsRequest) { + return func(r *MLGetCalendarsRequest) { + r.Body = v + } +} + +// WithCalendarID - the ID of the calendar to fetch. +func (f MLGetCalendars) WithCalendarID(v string) func(*MLGetCalendarsRequest) { + return func(r *MLGetCalendarsRequest) { + r.CalendarID = v + } +} + +// WithFrom - skips a number of calendars. +func (f MLGetCalendars) WithFrom(v int) func(*MLGetCalendarsRequest) { + return func(r *MLGetCalendarsRequest) { + r.From = &v + } +} + +// WithSize - specifies a max number of calendars to get. +func (f MLGetCalendars) WithSize(v int) func(*MLGetCalendarsRequest) { + return func(r *MLGetCalendarsRequest) { + r.Size = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLGetCalendars) WithPretty() func(*MLGetCalendarsRequest) { + return func(r *MLGetCalendarsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLGetCalendars) WithHuman() func(*MLGetCalendarsRequest) { + return func(r *MLGetCalendarsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLGetCalendars) WithErrorTrace() func(*MLGetCalendarsRequest) { + return func(r *MLGetCalendarsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLGetCalendars) WithFilterPath(v ...string) func(*MLGetCalendarsRequest) { + return func(r *MLGetCalendarsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLGetCalendars) WithHeader(h map[string]string) func(*MLGetCalendarsRequest) { + return func(r *MLGetCalendarsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLGetCalendars) WithOpaqueID(s string) func(*MLGetCalendarsRequest) { + return func(r *MLGetCalendarsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_categories.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_categories.go new file mode 100644 index 00000000..63f76523 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_categories.go @@ -0,0 +1,263 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" +) + +func newMLGetCategoriesFunc(t Transport) MLGetCategories { + return func(job_id string, o ...func(*MLGetCategoriesRequest)) (*Response, error) { + var r = MLGetCategoriesRequest{JobID: job_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLGetCategories - Retrieves anomaly detection job results for one or more categories. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-category.html. +type MLGetCategories func(job_id string, o ...func(*MLGetCategoriesRequest)) (*Response, error) + +// MLGetCategoriesRequest configures the ML Get Categories API request. +type MLGetCategoriesRequest struct { + Body io.Reader + + CategoryID *int + JobID string + + From *int + PartitionFieldValue string + Size *int + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLGetCategoriesRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_ml") + 1 + len("anomaly_detectors") + 1 + len(r.JobID) + 1 + len("results") + 1 + len("categories")) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("anomaly_detectors") + path.WriteString("/") + path.WriteString(r.JobID) + path.WriteString("/") + path.WriteString("results") + path.WriteString("/") + path.WriteString("categories") + if r.CategoryID != nil { + value := strconv.FormatInt(int64(*r.CategoryID), 10) + path.Grow(1 + len(value)) + path.WriteString("/") + path.WriteString(value) + } + + params = make(map[string]string) + + if r.From != nil { + params["from"] = strconv.FormatInt(int64(*r.From), 10) + } + + if r.PartitionFieldValue != "" { + params["partition_field_value"] = r.PartitionFieldValue + } + + if r.Size != nil { + params["size"] = strconv.FormatInt(int64(*r.Size), 10) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLGetCategories) WithContext(v context.Context) func(*MLGetCategoriesRequest) { + return func(r *MLGetCategoriesRequest) { + r.ctx = v + } +} + +// WithBody - Category selection details if not provided in URI. +func (f MLGetCategories) WithBody(v io.Reader) func(*MLGetCategoriesRequest) { + return func(r *MLGetCategoriesRequest) { + r.Body = v + } +} + +// WithCategoryID - the identifier of the category definition of interest. +func (f MLGetCategories) WithCategoryID(v int) func(*MLGetCategoriesRequest) { + return func(r *MLGetCategoriesRequest) { + r.CategoryID = &v + } +} + +// WithFrom - skips a number of categories. +func (f MLGetCategories) WithFrom(v int) func(*MLGetCategoriesRequest) { + return func(r *MLGetCategoriesRequest) { + r.From = &v + } +} + +// WithPartitionFieldValue - specifies the partition to retrieve categories for. this is optional, and should never be used for jobs where per-partition categorization is disabled.. +func (f MLGetCategories) WithPartitionFieldValue(v string) func(*MLGetCategoriesRequest) { + return func(r *MLGetCategoriesRequest) { + r.PartitionFieldValue = v + } +} + +// WithSize - specifies a max number of categories to get. +func (f MLGetCategories) WithSize(v int) func(*MLGetCategoriesRequest) { + return func(r *MLGetCategoriesRequest) { + r.Size = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLGetCategories) WithPretty() func(*MLGetCategoriesRequest) { + return func(r *MLGetCategoriesRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLGetCategories) WithHuman() func(*MLGetCategoriesRequest) { + return func(r *MLGetCategoriesRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLGetCategories) WithErrorTrace() func(*MLGetCategoriesRequest) { + return func(r *MLGetCategoriesRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLGetCategories) WithFilterPath(v ...string) func(*MLGetCategoriesRequest) { + return func(r *MLGetCategoriesRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLGetCategories) WithHeader(h map[string]string) func(*MLGetCategoriesRequest) { + return func(r *MLGetCategoriesRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLGetCategories) WithOpaqueID(s string) func(*MLGetCategoriesRequest) { + return func(r *MLGetCategoriesRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_data_frame_analytics.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_data_frame_analytics.go new file mode 100644 index 00000000..a327c306 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_data_frame_analytics.go @@ -0,0 +1,254 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newMLGetDataFrameAnalyticsFunc(t Transport) MLGetDataFrameAnalytics { + return func(o ...func(*MLGetDataFrameAnalyticsRequest)) (*Response, error) { + var r = MLGetDataFrameAnalyticsRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLGetDataFrameAnalytics - Retrieves configuration information for data frame analytics jobs. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/get-dfanalytics.html. +type MLGetDataFrameAnalytics func(o ...func(*MLGetDataFrameAnalyticsRequest)) (*Response, error) + +// MLGetDataFrameAnalyticsRequest configures the ML Get Data Frame Analytics API request. +type MLGetDataFrameAnalyticsRequest struct { + ID string + + AllowNoMatch *bool + ExcludeGenerated *bool + From *int + Size *int + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLGetDataFrameAnalyticsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_ml") + 1 + len("data_frame") + 1 + len("analytics") + 1 + len(r.ID)) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("data_frame") + path.WriteString("/") + path.WriteString("analytics") + if r.ID != "" { + path.WriteString("/") + path.WriteString(r.ID) + } + + params = make(map[string]string) + + if r.AllowNoMatch != nil { + params["allow_no_match"] = strconv.FormatBool(*r.AllowNoMatch) + } + + if r.ExcludeGenerated != nil { + params["exclude_generated"] = strconv.FormatBool(*r.ExcludeGenerated) + } + + if r.From != nil { + params["from"] = strconv.FormatInt(int64(*r.From), 10) + } + + if r.Size != nil { + params["size"] = strconv.FormatInt(int64(*r.Size), 10) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLGetDataFrameAnalytics) WithContext(v context.Context) func(*MLGetDataFrameAnalyticsRequest) { + return func(r *MLGetDataFrameAnalyticsRequest) { + r.ctx = v + } +} + +// WithID - the ID of the data frame analytics to fetch. +func (f MLGetDataFrameAnalytics) WithID(v string) func(*MLGetDataFrameAnalyticsRequest) { + return func(r *MLGetDataFrameAnalyticsRequest) { + r.ID = v + } +} + +// WithAllowNoMatch - whether to ignore if a wildcard expression matches no data frame analytics. (this includes `_all` string or when no data frame analytics have been specified). +func (f MLGetDataFrameAnalytics) WithAllowNoMatch(v bool) func(*MLGetDataFrameAnalyticsRequest) { + return func(r *MLGetDataFrameAnalyticsRequest) { + r.AllowNoMatch = &v + } +} + +// WithExcludeGenerated - omits fields that are illegal to set on data frame analytics put. +func (f MLGetDataFrameAnalytics) WithExcludeGenerated(v bool) func(*MLGetDataFrameAnalyticsRequest) { + return func(r *MLGetDataFrameAnalyticsRequest) { + r.ExcludeGenerated = &v + } +} + +// WithFrom - skips a number of analytics. +func (f MLGetDataFrameAnalytics) WithFrom(v int) func(*MLGetDataFrameAnalyticsRequest) { + return func(r *MLGetDataFrameAnalyticsRequest) { + r.From = &v + } +} + +// WithSize - specifies a max number of analytics to get. +func (f MLGetDataFrameAnalytics) WithSize(v int) func(*MLGetDataFrameAnalyticsRequest) { + return func(r *MLGetDataFrameAnalyticsRequest) { + r.Size = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLGetDataFrameAnalytics) WithPretty() func(*MLGetDataFrameAnalyticsRequest) { + return func(r *MLGetDataFrameAnalyticsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLGetDataFrameAnalytics) WithHuman() func(*MLGetDataFrameAnalyticsRequest) { + return func(r *MLGetDataFrameAnalyticsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLGetDataFrameAnalytics) WithErrorTrace() func(*MLGetDataFrameAnalyticsRequest) { + return func(r *MLGetDataFrameAnalyticsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLGetDataFrameAnalytics) WithFilterPath(v ...string) func(*MLGetDataFrameAnalyticsRequest) { + return func(r *MLGetDataFrameAnalyticsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLGetDataFrameAnalytics) WithHeader(h map[string]string) func(*MLGetDataFrameAnalyticsRequest) { + return func(r *MLGetDataFrameAnalyticsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLGetDataFrameAnalytics) WithOpaqueID(s string) func(*MLGetDataFrameAnalyticsRequest) { + return func(r *MLGetDataFrameAnalyticsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_data_frame_analytics_stats.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_data_frame_analytics_stats.go new file mode 100644 index 00000000..d87616b7 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_data_frame_analytics_stats.go @@ -0,0 +1,256 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newMLGetDataFrameAnalyticsStatsFunc(t Transport) MLGetDataFrameAnalyticsStats { + return func(o ...func(*MLGetDataFrameAnalyticsStatsRequest)) (*Response, error) { + var r = MLGetDataFrameAnalyticsStatsRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLGetDataFrameAnalyticsStats - Retrieves usage information for data frame analytics jobs. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/get-dfanalytics-stats.html. +type MLGetDataFrameAnalyticsStats func(o ...func(*MLGetDataFrameAnalyticsStatsRequest)) (*Response, error) + +// MLGetDataFrameAnalyticsStatsRequest configures the ML Get Data Frame Analytics Stats API request. +type MLGetDataFrameAnalyticsStatsRequest struct { + ID string + + AllowNoMatch *bool + From *int + Size *int + Verbose *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLGetDataFrameAnalyticsStatsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_ml") + 1 + len("data_frame") + 1 + len("analytics") + 1 + len(r.ID) + 1 + len("_stats")) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("data_frame") + path.WriteString("/") + path.WriteString("analytics") + if r.ID != "" { + path.WriteString("/") + path.WriteString(r.ID) + } + path.WriteString("/") + path.WriteString("_stats") + + params = make(map[string]string) + + if r.AllowNoMatch != nil { + params["allow_no_match"] = strconv.FormatBool(*r.AllowNoMatch) + } + + if r.From != nil { + params["from"] = strconv.FormatInt(int64(*r.From), 10) + } + + if r.Size != nil { + params["size"] = strconv.FormatInt(int64(*r.Size), 10) + } + + if r.Verbose != nil { + params["verbose"] = strconv.FormatBool(*r.Verbose) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLGetDataFrameAnalyticsStats) WithContext(v context.Context) func(*MLGetDataFrameAnalyticsStatsRequest) { + return func(r *MLGetDataFrameAnalyticsStatsRequest) { + r.ctx = v + } +} + +// WithID - the ID of the data frame analytics stats to fetch. +func (f MLGetDataFrameAnalyticsStats) WithID(v string) func(*MLGetDataFrameAnalyticsStatsRequest) { + return func(r *MLGetDataFrameAnalyticsStatsRequest) { + r.ID = v + } +} + +// WithAllowNoMatch - whether to ignore if a wildcard expression matches no data frame analytics. (this includes `_all` string or when no data frame analytics have been specified). +func (f MLGetDataFrameAnalyticsStats) WithAllowNoMatch(v bool) func(*MLGetDataFrameAnalyticsStatsRequest) { + return func(r *MLGetDataFrameAnalyticsStatsRequest) { + r.AllowNoMatch = &v + } +} + +// WithFrom - skips a number of analytics. +func (f MLGetDataFrameAnalyticsStats) WithFrom(v int) func(*MLGetDataFrameAnalyticsStatsRequest) { + return func(r *MLGetDataFrameAnalyticsStatsRequest) { + r.From = &v + } +} + +// WithSize - specifies a max number of analytics to get. +func (f MLGetDataFrameAnalyticsStats) WithSize(v int) func(*MLGetDataFrameAnalyticsStatsRequest) { + return func(r *MLGetDataFrameAnalyticsStatsRequest) { + r.Size = &v + } +} + +// WithVerbose - whether the stats response should be verbose. +func (f MLGetDataFrameAnalyticsStats) WithVerbose(v bool) func(*MLGetDataFrameAnalyticsStatsRequest) { + return func(r *MLGetDataFrameAnalyticsStatsRequest) { + r.Verbose = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLGetDataFrameAnalyticsStats) WithPretty() func(*MLGetDataFrameAnalyticsStatsRequest) { + return func(r *MLGetDataFrameAnalyticsStatsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLGetDataFrameAnalyticsStats) WithHuman() func(*MLGetDataFrameAnalyticsStatsRequest) { + return func(r *MLGetDataFrameAnalyticsStatsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLGetDataFrameAnalyticsStats) WithErrorTrace() func(*MLGetDataFrameAnalyticsStatsRequest) { + return func(r *MLGetDataFrameAnalyticsStatsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLGetDataFrameAnalyticsStats) WithFilterPath(v ...string) func(*MLGetDataFrameAnalyticsStatsRequest) { + return func(r *MLGetDataFrameAnalyticsStatsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLGetDataFrameAnalyticsStats) WithHeader(h map[string]string) func(*MLGetDataFrameAnalyticsStatsRequest) { + return func(r *MLGetDataFrameAnalyticsStatsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLGetDataFrameAnalyticsStats) WithOpaqueID(s string) func(*MLGetDataFrameAnalyticsStatsRequest) { + return func(r *MLGetDataFrameAnalyticsStatsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_datafeed_stats.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_datafeed_stats.go new file mode 100644 index 00000000..04a746e9 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_datafeed_stats.go @@ -0,0 +1,230 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newMLGetDatafeedStatsFunc(t Transport) MLGetDatafeedStats { + return func(o ...func(*MLGetDatafeedStatsRequest)) (*Response, error) { + var r = MLGetDatafeedStatsRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLGetDatafeedStats - Retrieves usage information for datafeeds. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-datafeed-stats.html. +type MLGetDatafeedStats func(o ...func(*MLGetDatafeedStatsRequest)) (*Response, error) + +// MLGetDatafeedStatsRequest configures the ML Get Datafeed Stats API request. +type MLGetDatafeedStatsRequest struct { + DatafeedID string + + AllowNoDatafeeds *bool + AllowNoMatch *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLGetDatafeedStatsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_ml") + 1 + len("datafeeds") + 1 + len(r.DatafeedID) + 1 + len("_stats")) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("datafeeds") + if r.DatafeedID != "" { + path.WriteString("/") + path.WriteString(r.DatafeedID) + } + path.WriteString("/") + path.WriteString("_stats") + + params = make(map[string]string) + + if r.AllowNoDatafeeds != nil { + params["allow_no_datafeeds"] = strconv.FormatBool(*r.AllowNoDatafeeds) + } + + if r.AllowNoMatch != nil { + params["allow_no_match"] = strconv.FormatBool(*r.AllowNoMatch) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLGetDatafeedStats) WithContext(v context.Context) func(*MLGetDatafeedStatsRequest) { + return func(r *MLGetDatafeedStatsRequest) { + r.ctx = v + } +} + +// WithDatafeedID - the ID of the datafeeds stats to fetch. +func (f MLGetDatafeedStats) WithDatafeedID(v string) func(*MLGetDatafeedStatsRequest) { + return func(r *MLGetDatafeedStatsRequest) { + r.DatafeedID = v + } +} + +// WithAllowNoDatafeeds - whether to ignore if a wildcard expression matches no datafeeds. (this includes `_all` string or when no datafeeds have been specified). +func (f MLGetDatafeedStats) WithAllowNoDatafeeds(v bool) func(*MLGetDatafeedStatsRequest) { + return func(r *MLGetDatafeedStatsRequest) { + r.AllowNoDatafeeds = &v + } +} + +// WithAllowNoMatch - whether to ignore if a wildcard expression matches no datafeeds. (this includes `_all` string or when no datafeeds have been specified). +func (f MLGetDatafeedStats) WithAllowNoMatch(v bool) func(*MLGetDatafeedStatsRequest) { + return func(r *MLGetDatafeedStatsRequest) { + r.AllowNoMatch = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLGetDatafeedStats) WithPretty() func(*MLGetDatafeedStatsRequest) { + return func(r *MLGetDatafeedStatsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLGetDatafeedStats) WithHuman() func(*MLGetDatafeedStatsRequest) { + return func(r *MLGetDatafeedStatsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLGetDatafeedStats) WithErrorTrace() func(*MLGetDatafeedStatsRequest) { + return func(r *MLGetDatafeedStatsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLGetDatafeedStats) WithFilterPath(v ...string) func(*MLGetDatafeedStatsRequest) { + return func(r *MLGetDatafeedStatsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLGetDatafeedStats) WithHeader(h map[string]string) func(*MLGetDatafeedStatsRequest) { + return func(r *MLGetDatafeedStatsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLGetDatafeedStats) WithOpaqueID(s string) func(*MLGetDatafeedStatsRequest) { + return func(r *MLGetDatafeedStatsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_datafeeds.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_datafeeds.go new file mode 100644 index 00000000..4038cb50 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_datafeeds.go @@ -0,0 +1,240 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newMLGetDatafeedsFunc(t Transport) MLGetDatafeeds { + return func(o ...func(*MLGetDatafeedsRequest)) (*Response, error) { + var r = MLGetDatafeedsRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLGetDatafeeds - Retrieves configuration information for datafeeds. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-datafeed.html. +type MLGetDatafeeds func(o ...func(*MLGetDatafeedsRequest)) (*Response, error) + +// MLGetDatafeedsRequest configures the ML Get Datafeeds API request. +type MLGetDatafeedsRequest struct { + DatafeedID string + + AllowNoDatafeeds *bool + AllowNoMatch *bool + ExcludeGenerated *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLGetDatafeedsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_ml") + 1 + len("datafeeds") + 1 + len(r.DatafeedID)) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("datafeeds") + if r.DatafeedID != "" { + path.WriteString("/") + path.WriteString(r.DatafeedID) + } + + params = make(map[string]string) + + if r.AllowNoDatafeeds != nil { + params["allow_no_datafeeds"] = strconv.FormatBool(*r.AllowNoDatafeeds) + } + + if r.AllowNoMatch != nil { + params["allow_no_match"] = strconv.FormatBool(*r.AllowNoMatch) + } + + if r.ExcludeGenerated != nil { + params["exclude_generated"] = strconv.FormatBool(*r.ExcludeGenerated) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLGetDatafeeds) WithContext(v context.Context) func(*MLGetDatafeedsRequest) { + return func(r *MLGetDatafeedsRequest) { + r.ctx = v + } +} + +// WithDatafeedID - the ID of the datafeeds to fetch. +func (f MLGetDatafeeds) WithDatafeedID(v string) func(*MLGetDatafeedsRequest) { + return func(r *MLGetDatafeedsRequest) { + r.DatafeedID = v + } +} + +// WithAllowNoDatafeeds - whether to ignore if a wildcard expression matches no datafeeds. (this includes `_all` string or when no datafeeds have been specified). +func (f MLGetDatafeeds) WithAllowNoDatafeeds(v bool) func(*MLGetDatafeedsRequest) { + return func(r *MLGetDatafeedsRequest) { + r.AllowNoDatafeeds = &v + } +} + +// WithAllowNoMatch - whether to ignore if a wildcard expression matches no datafeeds. (this includes `_all` string or when no datafeeds have been specified). +func (f MLGetDatafeeds) WithAllowNoMatch(v bool) func(*MLGetDatafeedsRequest) { + return func(r *MLGetDatafeedsRequest) { + r.AllowNoMatch = &v + } +} + +// WithExcludeGenerated - omits fields that are illegal to set on datafeed put. +func (f MLGetDatafeeds) WithExcludeGenerated(v bool) func(*MLGetDatafeedsRequest) { + return func(r *MLGetDatafeedsRequest) { + r.ExcludeGenerated = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLGetDatafeeds) WithPretty() func(*MLGetDatafeedsRequest) { + return func(r *MLGetDatafeedsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLGetDatafeeds) WithHuman() func(*MLGetDatafeedsRequest) { + return func(r *MLGetDatafeedsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLGetDatafeeds) WithErrorTrace() func(*MLGetDatafeedsRequest) { + return func(r *MLGetDatafeedsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLGetDatafeeds) WithFilterPath(v ...string) func(*MLGetDatafeedsRequest) { + return func(r *MLGetDatafeedsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLGetDatafeeds) WithHeader(h map[string]string) func(*MLGetDatafeedsRequest) { + return func(r *MLGetDatafeedsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLGetDatafeeds) WithOpaqueID(s string) func(*MLGetDatafeedsRequest) { + return func(r *MLGetDatafeedsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_filters.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_filters.go new file mode 100644 index 00000000..2e47b3b6 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_filters.go @@ -0,0 +1,228 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newMLGetFiltersFunc(t Transport) MLGetFilters { + return func(o ...func(*MLGetFiltersRequest)) (*Response, error) { + var r = MLGetFiltersRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLGetFilters - Retrieves filters. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-filter.html. +type MLGetFilters func(o ...func(*MLGetFiltersRequest)) (*Response, error) + +// MLGetFiltersRequest configures the ML Get Filters API request. +type MLGetFiltersRequest struct { + FilterID string + + From *int + Size *int + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLGetFiltersRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_ml") + 1 + len("filters") + 1 + len(r.FilterID)) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("filters") + if r.FilterID != "" { + path.WriteString("/") + path.WriteString(r.FilterID) + } + + params = make(map[string]string) + + if r.From != nil { + params["from"] = strconv.FormatInt(int64(*r.From), 10) + } + + if r.Size != nil { + params["size"] = strconv.FormatInt(int64(*r.Size), 10) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLGetFilters) WithContext(v context.Context) func(*MLGetFiltersRequest) { + return func(r *MLGetFiltersRequest) { + r.ctx = v + } +} + +// WithFilterID - the ID of the filter to fetch. +func (f MLGetFilters) WithFilterID(v string) func(*MLGetFiltersRequest) { + return func(r *MLGetFiltersRequest) { + r.FilterID = v + } +} + +// WithFrom - skips a number of filters. +func (f MLGetFilters) WithFrom(v int) func(*MLGetFiltersRequest) { + return func(r *MLGetFiltersRequest) { + r.From = &v + } +} + +// WithSize - specifies a max number of filters to get. +func (f MLGetFilters) WithSize(v int) func(*MLGetFiltersRequest) { + return func(r *MLGetFiltersRequest) { + r.Size = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLGetFilters) WithPretty() func(*MLGetFiltersRequest) { + return func(r *MLGetFiltersRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLGetFilters) WithHuman() func(*MLGetFiltersRequest) { + return func(r *MLGetFiltersRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLGetFilters) WithErrorTrace() func(*MLGetFiltersRequest) { + return func(r *MLGetFiltersRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLGetFilters) WithFilterPath(v ...string) func(*MLGetFiltersRequest) { + return func(r *MLGetFiltersRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLGetFilters) WithHeader(h map[string]string) func(*MLGetFiltersRequest) { + return func(r *MLGetFiltersRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLGetFilters) WithOpaqueID(s string) func(*MLGetFiltersRequest) { + return func(r *MLGetFiltersRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_influencers.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_influencers.go new file mode 100644 index 00000000..8f46361f --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_influencers.go @@ -0,0 +1,310 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "fmt" + "io" + "net/http" + "strconv" + "strings" +) + +func newMLGetInfluencersFunc(t Transport) MLGetInfluencers { + return func(job_id string, o ...func(*MLGetInfluencersRequest)) (*Response, error) { + var r = MLGetInfluencersRequest{JobID: job_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLGetInfluencers - Retrieves anomaly detection job results for one or more influencers. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-influencer.html. +type MLGetInfluencers func(job_id string, o ...func(*MLGetInfluencersRequest)) (*Response, error) + +// MLGetInfluencersRequest configures the ML Get Influencers API request. +type MLGetInfluencersRequest struct { + Body io.Reader + + JobID string + + Desc *bool + End string + ExcludeInterim *bool + From *int + InfluencerScore interface{} + Size *int + Sort string + Start string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLGetInfluencersRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_ml") + 1 + len("anomaly_detectors") + 1 + len(r.JobID) + 1 + len("results") + 1 + len("influencers")) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("anomaly_detectors") + path.WriteString("/") + path.WriteString(r.JobID) + path.WriteString("/") + path.WriteString("results") + path.WriteString("/") + path.WriteString("influencers") + + params = make(map[string]string) + + if r.Desc != nil { + params["desc"] = strconv.FormatBool(*r.Desc) + } + + if r.End != "" { + params["end"] = r.End + } + + if r.ExcludeInterim != nil { + params["exclude_interim"] = strconv.FormatBool(*r.ExcludeInterim) + } + + if r.From != nil { + params["from"] = strconv.FormatInt(int64(*r.From), 10) + } + + if r.InfluencerScore != nil { + params["influencer_score"] = fmt.Sprintf("%v", r.InfluencerScore) + } + + if r.Size != nil { + params["size"] = strconv.FormatInt(int64(*r.Size), 10) + } + + if r.Sort != "" { + params["sort"] = r.Sort + } + + if r.Start != "" { + params["start"] = r.Start + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLGetInfluencers) WithContext(v context.Context) func(*MLGetInfluencersRequest) { + return func(r *MLGetInfluencersRequest) { + r.ctx = v + } +} + +// WithBody - Influencer selection criteria. +func (f MLGetInfluencers) WithBody(v io.Reader) func(*MLGetInfluencersRequest) { + return func(r *MLGetInfluencersRequest) { + r.Body = v + } +} + +// WithDesc - whether the results should be sorted in decending order. +func (f MLGetInfluencers) WithDesc(v bool) func(*MLGetInfluencersRequest) { + return func(r *MLGetInfluencersRequest) { + r.Desc = &v + } +} + +// WithEnd - end timestamp for the requested influencers. +func (f MLGetInfluencers) WithEnd(v string) func(*MLGetInfluencersRequest) { + return func(r *MLGetInfluencersRequest) { + r.End = v + } +} + +// WithExcludeInterim - exclude interim results. +func (f MLGetInfluencers) WithExcludeInterim(v bool) func(*MLGetInfluencersRequest) { + return func(r *MLGetInfluencersRequest) { + r.ExcludeInterim = &v + } +} + +// WithFrom - skips a number of influencers. +func (f MLGetInfluencers) WithFrom(v int) func(*MLGetInfluencersRequest) { + return func(r *MLGetInfluencersRequest) { + r.From = &v + } +} + +// WithInfluencerScore - influencer score threshold for the requested influencers. +func (f MLGetInfluencers) WithInfluencerScore(v interface{}) func(*MLGetInfluencersRequest) { + return func(r *MLGetInfluencersRequest) { + r.InfluencerScore = v + } +} + +// WithSize - specifies a max number of influencers to get. +func (f MLGetInfluencers) WithSize(v int) func(*MLGetInfluencersRequest) { + return func(r *MLGetInfluencersRequest) { + r.Size = &v + } +} + +// WithSort - sort field for the requested influencers. +func (f MLGetInfluencers) WithSort(v string) func(*MLGetInfluencersRequest) { + return func(r *MLGetInfluencersRequest) { + r.Sort = v + } +} + +// WithStart - start timestamp for the requested influencers. +func (f MLGetInfluencers) WithStart(v string) func(*MLGetInfluencersRequest) { + return func(r *MLGetInfluencersRequest) { + r.Start = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLGetInfluencers) WithPretty() func(*MLGetInfluencersRequest) { + return func(r *MLGetInfluencersRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLGetInfluencers) WithHuman() func(*MLGetInfluencersRequest) { + return func(r *MLGetInfluencersRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLGetInfluencers) WithErrorTrace() func(*MLGetInfluencersRequest) { + return func(r *MLGetInfluencersRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLGetInfluencers) WithFilterPath(v ...string) func(*MLGetInfluencersRequest) { + return func(r *MLGetInfluencersRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLGetInfluencers) WithHeader(h map[string]string) func(*MLGetInfluencersRequest) { + return func(r *MLGetInfluencersRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLGetInfluencers) WithOpaqueID(s string) func(*MLGetInfluencersRequest) { + return func(r *MLGetInfluencersRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_job_stats.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_job_stats.go new file mode 100644 index 00000000..cadbd1bd --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_job_stats.go @@ -0,0 +1,230 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newMLGetJobStatsFunc(t Transport) MLGetJobStats { + return func(o ...func(*MLGetJobStatsRequest)) (*Response, error) { + var r = MLGetJobStatsRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLGetJobStats - Retrieves usage information for anomaly detection jobs. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-job-stats.html. +type MLGetJobStats func(o ...func(*MLGetJobStatsRequest)) (*Response, error) + +// MLGetJobStatsRequest configures the ML Get Job Stats API request. +type MLGetJobStatsRequest struct { + JobID string + + AllowNoJobs *bool + AllowNoMatch *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLGetJobStatsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_ml") + 1 + len("anomaly_detectors") + 1 + len(r.JobID) + 1 + len("_stats")) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("anomaly_detectors") + if r.JobID != "" { + path.WriteString("/") + path.WriteString(r.JobID) + } + path.WriteString("/") + path.WriteString("_stats") + + params = make(map[string]string) + + if r.AllowNoJobs != nil { + params["allow_no_jobs"] = strconv.FormatBool(*r.AllowNoJobs) + } + + if r.AllowNoMatch != nil { + params["allow_no_match"] = strconv.FormatBool(*r.AllowNoMatch) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLGetJobStats) WithContext(v context.Context) func(*MLGetJobStatsRequest) { + return func(r *MLGetJobStatsRequest) { + r.ctx = v + } +} + +// WithJobID - the ID of the jobs stats to fetch. +func (f MLGetJobStats) WithJobID(v string) func(*MLGetJobStatsRequest) { + return func(r *MLGetJobStatsRequest) { + r.JobID = v + } +} + +// WithAllowNoJobs - whether to ignore if a wildcard expression matches no jobs. (this includes `_all` string or when no jobs have been specified). +func (f MLGetJobStats) WithAllowNoJobs(v bool) func(*MLGetJobStatsRequest) { + return func(r *MLGetJobStatsRequest) { + r.AllowNoJobs = &v + } +} + +// WithAllowNoMatch - whether to ignore if a wildcard expression matches no jobs. (this includes `_all` string or when no jobs have been specified). +func (f MLGetJobStats) WithAllowNoMatch(v bool) func(*MLGetJobStatsRequest) { + return func(r *MLGetJobStatsRequest) { + r.AllowNoMatch = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLGetJobStats) WithPretty() func(*MLGetJobStatsRequest) { + return func(r *MLGetJobStatsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLGetJobStats) WithHuman() func(*MLGetJobStatsRequest) { + return func(r *MLGetJobStatsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLGetJobStats) WithErrorTrace() func(*MLGetJobStatsRequest) { + return func(r *MLGetJobStatsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLGetJobStats) WithFilterPath(v ...string) func(*MLGetJobStatsRequest) { + return func(r *MLGetJobStatsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLGetJobStats) WithHeader(h map[string]string) func(*MLGetJobStatsRequest) { + return func(r *MLGetJobStatsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLGetJobStats) WithOpaqueID(s string) func(*MLGetJobStatsRequest) { + return func(r *MLGetJobStatsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_jobs.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_jobs.go new file mode 100644 index 00000000..9340d64a --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_jobs.go @@ -0,0 +1,240 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newMLGetJobsFunc(t Transport) MLGetJobs { + return func(o ...func(*MLGetJobsRequest)) (*Response, error) { + var r = MLGetJobsRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLGetJobs - Retrieves configuration information for anomaly detection jobs. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-job.html. +type MLGetJobs func(o ...func(*MLGetJobsRequest)) (*Response, error) + +// MLGetJobsRequest configures the ML Get Jobs API request. +type MLGetJobsRequest struct { + JobID string + + AllowNoJobs *bool + AllowNoMatch *bool + ExcludeGenerated *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLGetJobsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_ml") + 1 + len("anomaly_detectors") + 1 + len(r.JobID)) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("anomaly_detectors") + if r.JobID != "" { + path.WriteString("/") + path.WriteString(r.JobID) + } + + params = make(map[string]string) + + if r.AllowNoJobs != nil { + params["allow_no_jobs"] = strconv.FormatBool(*r.AllowNoJobs) + } + + if r.AllowNoMatch != nil { + params["allow_no_match"] = strconv.FormatBool(*r.AllowNoMatch) + } + + if r.ExcludeGenerated != nil { + params["exclude_generated"] = strconv.FormatBool(*r.ExcludeGenerated) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLGetJobs) WithContext(v context.Context) func(*MLGetJobsRequest) { + return func(r *MLGetJobsRequest) { + r.ctx = v + } +} + +// WithJobID - the ID of the jobs to fetch. +func (f MLGetJobs) WithJobID(v string) func(*MLGetJobsRequest) { + return func(r *MLGetJobsRequest) { + r.JobID = v + } +} + +// WithAllowNoJobs - whether to ignore if a wildcard expression matches no jobs. (this includes `_all` string or when no jobs have been specified). +func (f MLGetJobs) WithAllowNoJobs(v bool) func(*MLGetJobsRequest) { + return func(r *MLGetJobsRequest) { + r.AllowNoJobs = &v + } +} + +// WithAllowNoMatch - whether to ignore if a wildcard expression matches no jobs. (this includes `_all` string or when no jobs have been specified). +func (f MLGetJobs) WithAllowNoMatch(v bool) func(*MLGetJobsRequest) { + return func(r *MLGetJobsRequest) { + r.AllowNoMatch = &v + } +} + +// WithExcludeGenerated - omits fields that are illegal to set on job put. +func (f MLGetJobs) WithExcludeGenerated(v bool) func(*MLGetJobsRequest) { + return func(r *MLGetJobsRequest) { + r.ExcludeGenerated = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLGetJobs) WithPretty() func(*MLGetJobsRequest) { + return func(r *MLGetJobsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLGetJobs) WithHuman() func(*MLGetJobsRequest) { + return func(r *MLGetJobsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLGetJobs) WithErrorTrace() func(*MLGetJobsRequest) { + return func(r *MLGetJobsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLGetJobs) WithFilterPath(v ...string) func(*MLGetJobsRequest) { + return func(r *MLGetJobsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLGetJobs) WithHeader(h map[string]string) func(*MLGetJobsRequest) { + return func(r *MLGetJobsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLGetJobs) WithOpaqueID(s string) func(*MLGetJobsRequest) { + return func(r *MLGetJobsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_model_snapshot_upgrade_stats.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_model_snapshot_upgrade_stats.go new file mode 100644 index 00000000..eadc4495 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_model_snapshot_upgrade_stats.go @@ -0,0 +1,216 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newMLGetModelSnapshotUpgradeStatsFunc(t Transport) MLGetModelSnapshotUpgradeStats { + return func(snapshot_id string, job_id string, o ...func(*MLGetModelSnapshotUpgradeStatsRequest)) (*Response, error) { + var r = MLGetModelSnapshotUpgradeStatsRequest{SnapshotID: snapshot_id, JobID: job_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLGetModelSnapshotUpgradeStats - Gets stats for anomaly detection job model snapshot upgrades that are in progress. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-job-model-snapshot-upgrade-stats.html. +type MLGetModelSnapshotUpgradeStats func(snapshot_id string, job_id string, o ...func(*MLGetModelSnapshotUpgradeStatsRequest)) (*Response, error) + +// MLGetModelSnapshotUpgradeStatsRequest configures the ML Get Model Snapshot Upgrade Stats API request. +type MLGetModelSnapshotUpgradeStatsRequest struct { + JobID string + SnapshotID string + + AllowNoMatch *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLGetModelSnapshotUpgradeStatsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_ml") + 1 + len("anomaly_detectors") + 1 + len(r.JobID) + 1 + len("model_snapshots") + 1 + len(r.SnapshotID) + 1 + len("_upgrade") + 1 + len("_stats")) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("anomaly_detectors") + path.WriteString("/") + path.WriteString(r.JobID) + path.WriteString("/") + path.WriteString("model_snapshots") + path.WriteString("/") + path.WriteString(r.SnapshotID) + path.WriteString("/") + path.WriteString("_upgrade") + path.WriteString("/") + path.WriteString("_stats") + + params = make(map[string]string) + + if r.AllowNoMatch != nil { + params["allow_no_match"] = strconv.FormatBool(*r.AllowNoMatch) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLGetModelSnapshotUpgradeStats) WithContext(v context.Context) func(*MLGetModelSnapshotUpgradeStatsRequest) { + return func(r *MLGetModelSnapshotUpgradeStatsRequest) { + r.ctx = v + } +} + +// WithAllowNoMatch - whether to ignore if a wildcard expression matches no jobs or no snapshots. (this includes the `_all` string.). +func (f MLGetModelSnapshotUpgradeStats) WithAllowNoMatch(v bool) func(*MLGetModelSnapshotUpgradeStatsRequest) { + return func(r *MLGetModelSnapshotUpgradeStatsRequest) { + r.AllowNoMatch = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLGetModelSnapshotUpgradeStats) WithPretty() func(*MLGetModelSnapshotUpgradeStatsRequest) { + return func(r *MLGetModelSnapshotUpgradeStatsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLGetModelSnapshotUpgradeStats) WithHuman() func(*MLGetModelSnapshotUpgradeStatsRequest) { + return func(r *MLGetModelSnapshotUpgradeStatsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLGetModelSnapshotUpgradeStats) WithErrorTrace() func(*MLGetModelSnapshotUpgradeStatsRequest) { + return func(r *MLGetModelSnapshotUpgradeStatsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLGetModelSnapshotUpgradeStats) WithFilterPath(v ...string) func(*MLGetModelSnapshotUpgradeStatsRequest) { + return func(r *MLGetModelSnapshotUpgradeStatsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLGetModelSnapshotUpgradeStats) WithHeader(h map[string]string) func(*MLGetModelSnapshotUpgradeStatsRequest) { + return func(r *MLGetModelSnapshotUpgradeStatsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLGetModelSnapshotUpgradeStats) WithOpaqueID(s string) func(*MLGetModelSnapshotUpgradeStatsRequest) { + return func(r *MLGetModelSnapshotUpgradeStatsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_model_snapshots.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_model_snapshots.go new file mode 100644 index 00000000..ff7ad602 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_model_snapshots.go @@ -0,0 +1,296 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "fmt" + "io" + "net/http" + "strconv" + "strings" +) + +func newMLGetModelSnapshotsFunc(t Transport) MLGetModelSnapshots { + return func(job_id string, o ...func(*MLGetModelSnapshotsRequest)) (*Response, error) { + var r = MLGetModelSnapshotsRequest{JobID: job_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLGetModelSnapshots - Retrieves information about model snapshots. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-snapshot.html. +type MLGetModelSnapshots func(job_id string, o ...func(*MLGetModelSnapshotsRequest)) (*Response, error) + +// MLGetModelSnapshotsRequest configures the ML Get Model Snapshots API request. +type MLGetModelSnapshotsRequest struct { + Body io.Reader + + JobID string + SnapshotID string + + Desc *bool + End interface{} + From *int + Size *int + Sort string + Start interface{} + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLGetModelSnapshotsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_ml") + 1 + len("anomaly_detectors") + 1 + len(r.JobID) + 1 + len("model_snapshots") + 1 + len(r.SnapshotID)) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("anomaly_detectors") + path.WriteString("/") + path.WriteString(r.JobID) + path.WriteString("/") + path.WriteString("model_snapshots") + if r.SnapshotID != "" { + path.WriteString("/") + path.WriteString(r.SnapshotID) + } + + params = make(map[string]string) + + if r.Desc != nil { + params["desc"] = strconv.FormatBool(*r.Desc) + } + + if r.End != nil { + params["end"] = fmt.Sprintf("%v", r.End) + } + + if r.From != nil { + params["from"] = strconv.FormatInt(int64(*r.From), 10) + } + + if r.Size != nil { + params["size"] = strconv.FormatInt(int64(*r.Size), 10) + } + + if r.Sort != "" { + params["sort"] = r.Sort + } + + if r.Start != nil { + params["start"] = fmt.Sprintf("%v", r.Start) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLGetModelSnapshots) WithContext(v context.Context) func(*MLGetModelSnapshotsRequest) { + return func(r *MLGetModelSnapshotsRequest) { + r.ctx = v + } +} + +// WithBody - Model snapshot selection criteria. +func (f MLGetModelSnapshots) WithBody(v io.Reader) func(*MLGetModelSnapshotsRequest) { + return func(r *MLGetModelSnapshotsRequest) { + r.Body = v + } +} + +// WithSnapshotID - the ID of the snapshot to fetch. +func (f MLGetModelSnapshots) WithSnapshotID(v string) func(*MLGetModelSnapshotsRequest) { + return func(r *MLGetModelSnapshotsRequest) { + r.SnapshotID = v + } +} + +// WithDesc - true if the results should be sorted in descending order. +func (f MLGetModelSnapshots) WithDesc(v bool) func(*MLGetModelSnapshotsRequest) { + return func(r *MLGetModelSnapshotsRequest) { + r.Desc = &v + } +} + +// WithEnd - the filter 'end' query parameter. +func (f MLGetModelSnapshots) WithEnd(v interface{}) func(*MLGetModelSnapshotsRequest) { + return func(r *MLGetModelSnapshotsRequest) { + r.End = v + } +} + +// WithFrom - skips a number of documents. +func (f MLGetModelSnapshots) WithFrom(v int) func(*MLGetModelSnapshotsRequest) { + return func(r *MLGetModelSnapshotsRequest) { + r.From = &v + } +} + +// WithSize - the default number of documents returned in queries as a string.. +func (f MLGetModelSnapshots) WithSize(v int) func(*MLGetModelSnapshotsRequest) { + return func(r *MLGetModelSnapshotsRequest) { + r.Size = &v + } +} + +// WithSort - name of the field to sort on. +func (f MLGetModelSnapshots) WithSort(v string) func(*MLGetModelSnapshotsRequest) { + return func(r *MLGetModelSnapshotsRequest) { + r.Sort = v + } +} + +// WithStart - the filter 'start' query parameter. +func (f MLGetModelSnapshots) WithStart(v interface{}) func(*MLGetModelSnapshotsRequest) { + return func(r *MLGetModelSnapshotsRequest) { + r.Start = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLGetModelSnapshots) WithPretty() func(*MLGetModelSnapshotsRequest) { + return func(r *MLGetModelSnapshotsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLGetModelSnapshots) WithHuman() func(*MLGetModelSnapshotsRequest) { + return func(r *MLGetModelSnapshotsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLGetModelSnapshots) WithErrorTrace() func(*MLGetModelSnapshotsRequest) { + return func(r *MLGetModelSnapshotsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLGetModelSnapshots) WithFilterPath(v ...string) func(*MLGetModelSnapshotsRequest) { + return func(r *MLGetModelSnapshotsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLGetModelSnapshots) WithHeader(h map[string]string) func(*MLGetModelSnapshotsRequest) { + return func(r *MLGetModelSnapshotsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLGetModelSnapshots) WithOpaqueID(s string) func(*MLGetModelSnapshotsRequest) { + return func(r *MLGetModelSnapshotsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_overall_buckets.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_overall_buckets.go new file mode 100644 index 00000000..86c78ce3 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_overall_buckets.go @@ -0,0 +1,310 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "fmt" + "io" + "net/http" + "strconv" + "strings" +) + +func newMLGetOverallBucketsFunc(t Transport) MLGetOverallBuckets { + return func(job_id string, o ...func(*MLGetOverallBucketsRequest)) (*Response, error) { + var r = MLGetOverallBucketsRequest{JobID: job_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLGetOverallBuckets - Retrieves overall bucket results that summarize the bucket results of multiple anomaly detection jobs. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-overall-buckets.html. +type MLGetOverallBuckets func(job_id string, o ...func(*MLGetOverallBucketsRequest)) (*Response, error) + +// MLGetOverallBucketsRequest configures the ML Get Overall Buckets API request. +type MLGetOverallBucketsRequest struct { + Body io.Reader + + JobID string + + AllowNoJobs *bool + AllowNoMatch *bool + BucketSpan string + End string + ExcludeInterim *bool + OverallScore interface{} + Start string + TopN *int + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLGetOverallBucketsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_ml") + 1 + len("anomaly_detectors") + 1 + len(r.JobID) + 1 + len("results") + 1 + len("overall_buckets")) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("anomaly_detectors") + path.WriteString("/") + path.WriteString(r.JobID) + path.WriteString("/") + path.WriteString("results") + path.WriteString("/") + path.WriteString("overall_buckets") + + params = make(map[string]string) + + if r.AllowNoJobs != nil { + params["allow_no_jobs"] = strconv.FormatBool(*r.AllowNoJobs) + } + + if r.AllowNoMatch != nil { + params["allow_no_match"] = strconv.FormatBool(*r.AllowNoMatch) + } + + if r.BucketSpan != "" { + params["bucket_span"] = r.BucketSpan + } + + if r.End != "" { + params["end"] = r.End + } + + if r.ExcludeInterim != nil { + params["exclude_interim"] = strconv.FormatBool(*r.ExcludeInterim) + } + + if r.OverallScore != nil { + params["overall_score"] = fmt.Sprintf("%v", r.OverallScore) + } + + if r.Start != "" { + params["start"] = r.Start + } + + if r.TopN != nil { + params["top_n"] = strconv.FormatInt(int64(*r.TopN), 10) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLGetOverallBuckets) WithContext(v context.Context) func(*MLGetOverallBucketsRequest) { + return func(r *MLGetOverallBucketsRequest) { + r.ctx = v + } +} + +// WithBody - Overall bucket selection details if not provided in URI. +func (f MLGetOverallBuckets) WithBody(v io.Reader) func(*MLGetOverallBucketsRequest) { + return func(r *MLGetOverallBucketsRequest) { + r.Body = v + } +} + +// WithAllowNoJobs - whether to ignore if a wildcard expression matches no jobs. (this includes `_all` string or when no jobs have been specified). +func (f MLGetOverallBuckets) WithAllowNoJobs(v bool) func(*MLGetOverallBucketsRequest) { + return func(r *MLGetOverallBucketsRequest) { + r.AllowNoJobs = &v + } +} + +// WithAllowNoMatch - whether to ignore if a wildcard expression matches no jobs. (this includes `_all` string or when no jobs have been specified). +func (f MLGetOverallBuckets) WithAllowNoMatch(v bool) func(*MLGetOverallBucketsRequest) { + return func(r *MLGetOverallBucketsRequest) { + r.AllowNoMatch = &v + } +} + +// WithBucketSpan - the span of the overall buckets. defaults to the longest job bucket_span. +func (f MLGetOverallBuckets) WithBucketSpan(v string) func(*MLGetOverallBucketsRequest) { + return func(r *MLGetOverallBucketsRequest) { + r.BucketSpan = v + } +} + +// WithEnd - returns overall buckets with timestamps earlier than this time. +func (f MLGetOverallBuckets) WithEnd(v string) func(*MLGetOverallBucketsRequest) { + return func(r *MLGetOverallBucketsRequest) { + r.End = v + } +} + +// WithExcludeInterim - if true overall buckets that include interim buckets will be excluded. +func (f MLGetOverallBuckets) WithExcludeInterim(v bool) func(*MLGetOverallBucketsRequest) { + return func(r *MLGetOverallBucketsRequest) { + r.ExcludeInterim = &v + } +} + +// WithOverallScore - returns overall buckets with overall scores higher than this value. +func (f MLGetOverallBuckets) WithOverallScore(v interface{}) func(*MLGetOverallBucketsRequest) { + return func(r *MLGetOverallBucketsRequest) { + r.OverallScore = v + } +} + +// WithStart - returns overall buckets with timestamps after this time. +func (f MLGetOverallBuckets) WithStart(v string) func(*MLGetOverallBucketsRequest) { + return func(r *MLGetOverallBucketsRequest) { + r.Start = v + } +} + +// WithTopN - the number of top job bucket scores to be used in the overall_score calculation. +func (f MLGetOverallBuckets) WithTopN(v int) func(*MLGetOverallBucketsRequest) { + return func(r *MLGetOverallBucketsRequest) { + r.TopN = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLGetOverallBuckets) WithPretty() func(*MLGetOverallBucketsRequest) { + return func(r *MLGetOverallBucketsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLGetOverallBuckets) WithHuman() func(*MLGetOverallBucketsRequest) { + return func(r *MLGetOverallBucketsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLGetOverallBuckets) WithErrorTrace() func(*MLGetOverallBucketsRequest) { + return func(r *MLGetOverallBucketsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLGetOverallBuckets) WithFilterPath(v ...string) func(*MLGetOverallBucketsRequest) { + return func(r *MLGetOverallBucketsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLGetOverallBuckets) WithHeader(h map[string]string) func(*MLGetOverallBucketsRequest) { + return func(r *MLGetOverallBucketsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLGetOverallBuckets) WithOpaqueID(s string) func(*MLGetOverallBucketsRequest) { + return func(r *MLGetOverallBucketsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_records.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_records.go new file mode 100644 index 00000000..6babb526 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_records.go @@ -0,0 +1,310 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "fmt" + "io" + "net/http" + "strconv" + "strings" +) + +func newMLGetRecordsFunc(t Transport) MLGetRecords { + return func(job_id string, o ...func(*MLGetRecordsRequest)) (*Response, error) { + var r = MLGetRecordsRequest{JobID: job_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLGetRecords - Retrieves anomaly records for an anomaly detection job. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-record.html. +type MLGetRecords func(job_id string, o ...func(*MLGetRecordsRequest)) (*Response, error) + +// MLGetRecordsRequest configures the ML Get Records API request. +type MLGetRecordsRequest struct { + Body io.Reader + + JobID string + + Desc *bool + End string + ExcludeInterim *bool + From *int + RecordScore interface{} + Size *int + Sort string + Start string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLGetRecordsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_ml") + 1 + len("anomaly_detectors") + 1 + len(r.JobID) + 1 + len("results") + 1 + len("records")) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("anomaly_detectors") + path.WriteString("/") + path.WriteString(r.JobID) + path.WriteString("/") + path.WriteString("results") + path.WriteString("/") + path.WriteString("records") + + params = make(map[string]string) + + if r.Desc != nil { + params["desc"] = strconv.FormatBool(*r.Desc) + } + + if r.End != "" { + params["end"] = r.End + } + + if r.ExcludeInterim != nil { + params["exclude_interim"] = strconv.FormatBool(*r.ExcludeInterim) + } + + if r.From != nil { + params["from"] = strconv.FormatInt(int64(*r.From), 10) + } + + if r.RecordScore != nil { + params["record_score"] = fmt.Sprintf("%v", r.RecordScore) + } + + if r.Size != nil { + params["size"] = strconv.FormatInt(int64(*r.Size), 10) + } + + if r.Sort != "" { + params["sort"] = r.Sort + } + + if r.Start != "" { + params["start"] = r.Start + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLGetRecords) WithContext(v context.Context) func(*MLGetRecordsRequest) { + return func(r *MLGetRecordsRequest) { + r.ctx = v + } +} + +// WithBody - Record selection criteria. +func (f MLGetRecords) WithBody(v io.Reader) func(*MLGetRecordsRequest) { + return func(r *MLGetRecordsRequest) { + r.Body = v + } +} + +// WithDesc - set the sort direction. +func (f MLGetRecords) WithDesc(v bool) func(*MLGetRecordsRequest) { + return func(r *MLGetRecordsRequest) { + r.Desc = &v + } +} + +// WithEnd - end time filter for records. +func (f MLGetRecords) WithEnd(v string) func(*MLGetRecordsRequest) { + return func(r *MLGetRecordsRequest) { + r.End = v + } +} + +// WithExcludeInterim - exclude interim results. +func (f MLGetRecords) WithExcludeInterim(v bool) func(*MLGetRecordsRequest) { + return func(r *MLGetRecordsRequest) { + r.ExcludeInterim = &v + } +} + +// WithFrom - skips a number of records. +func (f MLGetRecords) WithFrom(v int) func(*MLGetRecordsRequest) { + return func(r *MLGetRecordsRequest) { + r.From = &v + } +} + +// WithRecordScore - returns records with anomaly scores greater or equal than this value. +func (f MLGetRecords) WithRecordScore(v interface{}) func(*MLGetRecordsRequest) { + return func(r *MLGetRecordsRequest) { + r.RecordScore = v + } +} + +// WithSize - specifies a max number of records to get. +func (f MLGetRecords) WithSize(v int) func(*MLGetRecordsRequest) { + return func(r *MLGetRecordsRequest) { + r.Size = &v + } +} + +// WithSort - sort records by a particular field. +func (f MLGetRecords) WithSort(v string) func(*MLGetRecordsRequest) { + return func(r *MLGetRecordsRequest) { + r.Sort = v + } +} + +// WithStart - start time filter for records. +func (f MLGetRecords) WithStart(v string) func(*MLGetRecordsRequest) { + return func(r *MLGetRecordsRequest) { + r.Start = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLGetRecords) WithPretty() func(*MLGetRecordsRequest) { + return func(r *MLGetRecordsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLGetRecords) WithHuman() func(*MLGetRecordsRequest) { + return func(r *MLGetRecordsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLGetRecords) WithErrorTrace() func(*MLGetRecordsRequest) { + return func(r *MLGetRecordsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLGetRecords) WithFilterPath(v ...string) func(*MLGetRecordsRequest) { + return func(r *MLGetRecordsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLGetRecords) WithHeader(h map[string]string) func(*MLGetRecordsRequest) { + return func(r *MLGetRecordsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLGetRecords) WithOpaqueID(s string) func(*MLGetRecordsRequest) { + return func(r *MLGetRecordsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_trained_models.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_trained_models.go new file mode 100644 index 00000000..9f1e6d1d --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_trained_models.go @@ -0,0 +1,300 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newMLGetTrainedModelsFunc(t Transport) MLGetTrainedModels { + return func(o ...func(*MLGetTrainedModelsRequest)) (*Response, error) { + var r = MLGetTrainedModelsRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLGetTrainedModels - Retrieves configuration information for a trained inference model. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/get-trained-models.html. +type MLGetTrainedModels func(o ...func(*MLGetTrainedModelsRequest)) (*Response, error) + +// MLGetTrainedModelsRequest configures the ML Get Trained Models API request. +type MLGetTrainedModelsRequest struct { + ModelID string + + AllowNoMatch *bool + DecompressDefinition *bool + ExcludeGenerated *bool + From *int + Include string + IncludeModelDefinition *bool + Size *int + Tags []string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLGetTrainedModelsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_ml") + 1 + len("trained_models") + 1 + len(r.ModelID)) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("trained_models") + if r.ModelID != "" { + path.WriteString("/") + path.WriteString(r.ModelID) + } + + params = make(map[string]string) + + if r.AllowNoMatch != nil { + params["allow_no_match"] = strconv.FormatBool(*r.AllowNoMatch) + } + + if r.DecompressDefinition != nil { + params["decompress_definition"] = strconv.FormatBool(*r.DecompressDefinition) + } + + if r.ExcludeGenerated != nil { + params["exclude_generated"] = strconv.FormatBool(*r.ExcludeGenerated) + } + + if r.From != nil { + params["from"] = strconv.FormatInt(int64(*r.From), 10) + } + + if r.Include != "" { + params["include"] = r.Include + } + + if r.IncludeModelDefinition != nil { + params["include_model_definition"] = strconv.FormatBool(*r.IncludeModelDefinition) + } + + if r.Size != nil { + params["size"] = strconv.FormatInt(int64(*r.Size), 10) + } + + if len(r.Tags) > 0 { + params["tags"] = strings.Join(r.Tags, ",") + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLGetTrainedModels) WithContext(v context.Context) func(*MLGetTrainedModelsRequest) { + return func(r *MLGetTrainedModelsRequest) { + r.ctx = v + } +} + +// WithModelID - the ID of the trained models to fetch. +func (f MLGetTrainedModels) WithModelID(v string) func(*MLGetTrainedModelsRequest) { + return func(r *MLGetTrainedModelsRequest) { + r.ModelID = v + } +} + +// WithAllowNoMatch - whether to ignore if a wildcard expression matches no trained models. (this includes `_all` string or when no trained models have been specified). +func (f MLGetTrainedModels) WithAllowNoMatch(v bool) func(*MLGetTrainedModelsRequest) { + return func(r *MLGetTrainedModelsRequest) { + r.AllowNoMatch = &v + } +} + +// WithDecompressDefinition - should the model definition be decompressed into valid json or returned in a custom compressed format. defaults to true.. +func (f MLGetTrainedModels) WithDecompressDefinition(v bool) func(*MLGetTrainedModelsRequest) { + return func(r *MLGetTrainedModelsRequest) { + r.DecompressDefinition = &v + } +} + +// WithExcludeGenerated - omits fields that are illegal to set on model put. +func (f MLGetTrainedModels) WithExcludeGenerated(v bool) func(*MLGetTrainedModelsRequest) { + return func(r *MLGetTrainedModelsRequest) { + r.ExcludeGenerated = &v + } +} + +// WithFrom - skips a number of trained models. +func (f MLGetTrainedModels) WithFrom(v int) func(*MLGetTrainedModelsRequest) { + return func(r *MLGetTrainedModelsRequest) { + r.From = &v + } +} + +// WithInclude - a comma-separate list of fields to optionally include. valid options are 'definition' and 'total_feature_importance'. default is none.. +func (f MLGetTrainedModels) WithInclude(v string) func(*MLGetTrainedModelsRequest) { + return func(r *MLGetTrainedModelsRequest) { + r.Include = v + } +} + +// WithIncludeModelDefinition - should the full model definition be included in the results. these definitions can be large. so be cautious when including them. defaults to false.. +func (f MLGetTrainedModels) WithIncludeModelDefinition(v bool) func(*MLGetTrainedModelsRequest) { + return func(r *MLGetTrainedModelsRequest) { + r.IncludeModelDefinition = &v + } +} + +// WithSize - specifies a max number of trained models to get. +func (f MLGetTrainedModels) WithSize(v int) func(*MLGetTrainedModelsRequest) { + return func(r *MLGetTrainedModelsRequest) { + r.Size = &v + } +} + +// WithTags - a list of tags that the model must have.. +func (f MLGetTrainedModels) WithTags(v ...string) func(*MLGetTrainedModelsRequest) { + return func(r *MLGetTrainedModelsRequest) { + r.Tags = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLGetTrainedModels) WithPretty() func(*MLGetTrainedModelsRequest) { + return func(r *MLGetTrainedModelsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLGetTrainedModels) WithHuman() func(*MLGetTrainedModelsRequest) { + return func(r *MLGetTrainedModelsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLGetTrainedModels) WithErrorTrace() func(*MLGetTrainedModelsRequest) { + return func(r *MLGetTrainedModelsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLGetTrainedModels) WithFilterPath(v ...string) func(*MLGetTrainedModelsRequest) { + return func(r *MLGetTrainedModelsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLGetTrainedModels) WithHeader(h map[string]string) func(*MLGetTrainedModelsRequest) { + return func(r *MLGetTrainedModelsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLGetTrainedModels) WithOpaqueID(s string) func(*MLGetTrainedModelsRequest) { + return func(r *MLGetTrainedModelsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_trained_models_stats.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_trained_models_stats.go new file mode 100644 index 00000000..9c24d973 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.get_trained_models_stats.go @@ -0,0 +1,242 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newMLGetTrainedModelsStatsFunc(t Transport) MLGetTrainedModelsStats { + return func(o ...func(*MLGetTrainedModelsStatsRequest)) (*Response, error) { + var r = MLGetTrainedModelsStatsRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLGetTrainedModelsStats - Retrieves usage information for trained inference models. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/get-trained-models-stats.html. +type MLGetTrainedModelsStats func(o ...func(*MLGetTrainedModelsStatsRequest)) (*Response, error) + +// MLGetTrainedModelsStatsRequest configures the ML Get Trained Models Stats API request. +type MLGetTrainedModelsStatsRequest struct { + ModelID string + + AllowNoMatch *bool + From *int + Size *int + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLGetTrainedModelsStatsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_ml") + 1 + len("trained_models") + 1 + len(r.ModelID) + 1 + len("_stats")) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("trained_models") + if r.ModelID != "" { + path.WriteString("/") + path.WriteString(r.ModelID) + } + path.WriteString("/") + path.WriteString("_stats") + + params = make(map[string]string) + + if r.AllowNoMatch != nil { + params["allow_no_match"] = strconv.FormatBool(*r.AllowNoMatch) + } + + if r.From != nil { + params["from"] = strconv.FormatInt(int64(*r.From), 10) + } + + if r.Size != nil { + params["size"] = strconv.FormatInt(int64(*r.Size), 10) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLGetTrainedModelsStats) WithContext(v context.Context) func(*MLGetTrainedModelsStatsRequest) { + return func(r *MLGetTrainedModelsStatsRequest) { + r.ctx = v + } +} + +// WithModelID - the ID of the trained models stats to fetch. +func (f MLGetTrainedModelsStats) WithModelID(v string) func(*MLGetTrainedModelsStatsRequest) { + return func(r *MLGetTrainedModelsStatsRequest) { + r.ModelID = v + } +} + +// WithAllowNoMatch - whether to ignore if a wildcard expression matches no trained models. (this includes `_all` string or when no trained models have been specified). +func (f MLGetTrainedModelsStats) WithAllowNoMatch(v bool) func(*MLGetTrainedModelsStatsRequest) { + return func(r *MLGetTrainedModelsStatsRequest) { + r.AllowNoMatch = &v + } +} + +// WithFrom - skips a number of trained models. +func (f MLGetTrainedModelsStats) WithFrom(v int) func(*MLGetTrainedModelsStatsRequest) { + return func(r *MLGetTrainedModelsStatsRequest) { + r.From = &v + } +} + +// WithSize - specifies a max number of trained models to get. +func (f MLGetTrainedModelsStats) WithSize(v int) func(*MLGetTrainedModelsStatsRequest) { + return func(r *MLGetTrainedModelsStatsRequest) { + r.Size = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLGetTrainedModelsStats) WithPretty() func(*MLGetTrainedModelsStatsRequest) { + return func(r *MLGetTrainedModelsStatsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLGetTrainedModelsStats) WithHuman() func(*MLGetTrainedModelsStatsRequest) { + return func(r *MLGetTrainedModelsStatsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLGetTrainedModelsStats) WithErrorTrace() func(*MLGetTrainedModelsStatsRequest) { + return func(r *MLGetTrainedModelsStatsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLGetTrainedModelsStats) WithFilterPath(v ...string) func(*MLGetTrainedModelsStatsRequest) { + return func(r *MLGetTrainedModelsStatsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLGetTrainedModelsStats) WithHeader(h map[string]string) func(*MLGetTrainedModelsStatsRequest) { + return func(r *MLGetTrainedModelsStatsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLGetTrainedModelsStats) WithOpaqueID(s string) func(*MLGetTrainedModelsStatsRequest) { + return func(r *MLGetTrainedModelsStatsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.info.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.info.go new file mode 100644 index 00000000..517616c2 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.info.go @@ -0,0 +1,186 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newMLInfoFunc(t Transport) MLInfo { + return func(o ...func(*MLInfoRequest)) (*Response, error) { + var r = MLInfoRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLInfo - Returns defaults and limits used by machine learning. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/get-ml-info.html. +type MLInfo func(o ...func(*MLInfoRequest)) (*Response, error) + +// MLInfoRequest configures the ML Info API request. +type MLInfoRequest struct { + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLInfoRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(len("/_ml/info")) + path.WriteString("/_ml/info") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLInfo) WithContext(v context.Context) func(*MLInfoRequest) { + return func(r *MLInfoRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLInfo) WithPretty() func(*MLInfoRequest) { + return func(r *MLInfoRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLInfo) WithHuman() func(*MLInfoRequest) { + return func(r *MLInfoRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLInfo) WithErrorTrace() func(*MLInfoRequest) { + return func(r *MLInfoRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLInfo) WithFilterPath(v ...string) func(*MLInfoRequest) { + return func(r *MLInfoRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLInfo) WithHeader(h map[string]string) func(*MLInfoRequest) { + return func(r *MLInfoRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLInfo) WithOpaqueID(s string) func(*MLInfoRequest) { + return func(r *MLInfoRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.open_job.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.open_job.go new file mode 100644 index 00000000..df29de9a --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.open_job.go @@ -0,0 +1,209 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newMLOpenJobFunc(t Transport) MLOpenJob { + return func(job_id string, o ...func(*MLOpenJobRequest)) (*Response, error) { + var r = MLOpenJobRequest{JobID: job_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLOpenJob - Opens one or more anomaly detection jobs. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-open-job.html. +type MLOpenJob func(job_id string, o ...func(*MLOpenJobRequest)) (*Response, error) + +// MLOpenJobRequest configures the ML Open Job API request. +type MLOpenJobRequest struct { + Body io.Reader + + JobID string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLOpenJobRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_ml") + 1 + len("anomaly_detectors") + 1 + len(r.JobID) + 1 + len("_open")) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("anomaly_detectors") + path.WriteString("/") + path.WriteString(r.JobID) + path.WriteString("/") + path.WriteString("_open") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLOpenJob) WithContext(v context.Context) func(*MLOpenJobRequest) { + return func(r *MLOpenJobRequest) { + r.ctx = v + } +} + +// WithBody - Query parameters can be specified in the body. +func (f MLOpenJob) WithBody(v io.Reader) func(*MLOpenJobRequest) { + return func(r *MLOpenJobRequest) { + r.Body = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLOpenJob) WithPretty() func(*MLOpenJobRequest) { + return func(r *MLOpenJobRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLOpenJob) WithHuman() func(*MLOpenJobRequest) { + return func(r *MLOpenJobRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLOpenJob) WithErrorTrace() func(*MLOpenJobRequest) { + return func(r *MLOpenJobRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLOpenJob) WithFilterPath(v ...string) func(*MLOpenJobRequest) { + return func(r *MLOpenJobRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLOpenJob) WithHeader(h map[string]string) func(*MLOpenJobRequest) { + return func(r *MLOpenJobRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLOpenJob) WithOpaqueID(s string) func(*MLOpenJobRequest) { + return func(r *MLOpenJobRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.post_calendar_events.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.post_calendar_events.go new file mode 100644 index 00000000..ba140bff --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.post_calendar_events.go @@ -0,0 +1,202 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newMLPostCalendarEventsFunc(t Transport) MLPostCalendarEvents { + return func(calendar_id string, body io.Reader, o ...func(*MLPostCalendarEventsRequest)) (*Response, error) { + var r = MLPostCalendarEventsRequest{CalendarID: calendar_id, Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLPostCalendarEvents - Posts scheduled events in a calendar. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-post-calendar-event.html. +type MLPostCalendarEvents func(calendar_id string, body io.Reader, o ...func(*MLPostCalendarEventsRequest)) (*Response, error) + +// MLPostCalendarEventsRequest configures the ML Post Calendar Events API request. +type MLPostCalendarEventsRequest struct { + Body io.Reader + + CalendarID string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLPostCalendarEventsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_ml") + 1 + len("calendars") + 1 + len(r.CalendarID) + 1 + len("events")) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("calendars") + path.WriteString("/") + path.WriteString(r.CalendarID) + path.WriteString("/") + path.WriteString("events") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLPostCalendarEvents) WithContext(v context.Context) func(*MLPostCalendarEventsRequest) { + return func(r *MLPostCalendarEventsRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLPostCalendarEvents) WithPretty() func(*MLPostCalendarEventsRequest) { + return func(r *MLPostCalendarEventsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLPostCalendarEvents) WithHuman() func(*MLPostCalendarEventsRequest) { + return func(r *MLPostCalendarEventsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLPostCalendarEvents) WithErrorTrace() func(*MLPostCalendarEventsRequest) { + return func(r *MLPostCalendarEventsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLPostCalendarEvents) WithFilterPath(v ...string) func(*MLPostCalendarEventsRequest) { + return func(r *MLPostCalendarEventsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLPostCalendarEvents) WithHeader(h map[string]string) func(*MLPostCalendarEventsRequest) { + return func(r *MLPostCalendarEventsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLPostCalendarEvents) WithOpaqueID(s string) func(*MLPostCalendarEventsRequest) { + return func(r *MLPostCalendarEventsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.post_data.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.post_data.go new file mode 100644 index 00000000..00c047e7 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.post_data.go @@ -0,0 +1,227 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newMLPostDataFunc(t Transport) MLPostData { + return func(job_id string, body io.Reader, o ...func(*MLPostDataRequest)) (*Response, error) { + var r = MLPostDataRequest{JobID: job_id, Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLPostData - Sends data to an anomaly detection job for analysis. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-post-data.html. +type MLPostData func(job_id string, body io.Reader, o ...func(*MLPostDataRequest)) (*Response, error) + +// MLPostDataRequest configures the ML Post Data API request. +type MLPostDataRequest struct { + Body io.Reader + + JobID string + + ResetEnd string + ResetStart string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLPostDataRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_ml") + 1 + len("anomaly_detectors") + 1 + len(r.JobID) + 1 + len("_data")) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("anomaly_detectors") + path.WriteString("/") + path.WriteString(r.JobID) + path.WriteString("/") + path.WriteString("_data") + + params = make(map[string]string) + + if r.ResetEnd != "" { + params["reset_end"] = r.ResetEnd + } + + if r.ResetStart != "" { + params["reset_start"] = r.ResetStart + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLPostData) WithContext(v context.Context) func(*MLPostDataRequest) { + return func(r *MLPostDataRequest) { + r.ctx = v + } +} + +// WithResetEnd - optional parameter to specify the end of the bucket resetting range. +func (f MLPostData) WithResetEnd(v string) func(*MLPostDataRequest) { + return func(r *MLPostDataRequest) { + r.ResetEnd = v + } +} + +// WithResetStart - optional parameter to specify the start of the bucket resetting range. +func (f MLPostData) WithResetStart(v string) func(*MLPostDataRequest) { + return func(r *MLPostDataRequest) { + r.ResetStart = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLPostData) WithPretty() func(*MLPostDataRequest) { + return func(r *MLPostDataRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLPostData) WithHuman() func(*MLPostDataRequest) { + return func(r *MLPostDataRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLPostData) WithErrorTrace() func(*MLPostDataRequest) { + return func(r *MLPostDataRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLPostData) WithFilterPath(v ...string) func(*MLPostDataRequest) { + return func(r *MLPostDataRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLPostData) WithHeader(h map[string]string) func(*MLPostDataRequest) { + return func(r *MLPostDataRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLPostData) WithOpaqueID(s string) func(*MLPostDataRequest) { + return func(r *MLPostDataRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.preview_data_frame_analytics.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.preview_data_frame_analytics.go new file mode 100644 index 00000000..fdac7927 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.preview_data_frame_analytics.go @@ -0,0 +1,220 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newMLPreviewDataFrameAnalyticsFunc(t Transport) MLPreviewDataFrameAnalytics { + return func(o ...func(*MLPreviewDataFrameAnalyticsRequest)) (*Response, error) { + var r = MLPreviewDataFrameAnalyticsRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLPreviewDataFrameAnalytics - Previews that will be analyzed given a data frame analytics config. +// +// See full documentation at http://www.elastic.co/guide/en/elasticsearch/reference/current/preview-dfanalytics.html. +type MLPreviewDataFrameAnalytics func(o ...func(*MLPreviewDataFrameAnalyticsRequest)) (*Response, error) + +// MLPreviewDataFrameAnalyticsRequest configures the ML Preview Data Frame Analytics API request. +type MLPreviewDataFrameAnalyticsRequest struct { + DocumentID string + + Body io.Reader + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLPreviewDataFrameAnalyticsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_ml") + 1 + len("data_frame") + 1 + len("analytics") + 1 + len(r.DocumentID) + 1 + len("_preview")) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("data_frame") + path.WriteString("/") + path.WriteString("analytics") + if r.DocumentID != "" { + path.WriteString("/") + path.WriteString(r.DocumentID) + } + path.WriteString("/") + path.WriteString("_preview") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLPreviewDataFrameAnalytics) WithContext(v context.Context) func(*MLPreviewDataFrameAnalyticsRequest) { + return func(r *MLPreviewDataFrameAnalyticsRequest) { + r.ctx = v + } +} + +// WithBody - The data frame analytics config to preview. +func (f MLPreviewDataFrameAnalytics) WithBody(v io.Reader) func(*MLPreviewDataFrameAnalyticsRequest) { + return func(r *MLPreviewDataFrameAnalyticsRequest) { + r.Body = v + } +} + +// WithDocumentID - the ID of the data frame analytics to preview. +func (f MLPreviewDataFrameAnalytics) WithDocumentID(v string) func(*MLPreviewDataFrameAnalyticsRequest) { + return func(r *MLPreviewDataFrameAnalyticsRequest) { + r.DocumentID = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLPreviewDataFrameAnalytics) WithPretty() func(*MLPreviewDataFrameAnalyticsRequest) { + return func(r *MLPreviewDataFrameAnalyticsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLPreviewDataFrameAnalytics) WithHuman() func(*MLPreviewDataFrameAnalyticsRequest) { + return func(r *MLPreviewDataFrameAnalyticsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLPreviewDataFrameAnalytics) WithErrorTrace() func(*MLPreviewDataFrameAnalyticsRequest) { + return func(r *MLPreviewDataFrameAnalyticsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLPreviewDataFrameAnalytics) WithFilterPath(v ...string) func(*MLPreviewDataFrameAnalyticsRequest) { + return func(r *MLPreviewDataFrameAnalyticsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLPreviewDataFrameAnalytics) WithHeader(h map[string]string) func(*MLPreviewDataFrameAnalyticsRequest) { + return func(r *MLPreviewDataFrameAnalyticsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLPreviewDataFrameAnalytics) WithOpaqueID(s string) func(*MLPreviewDataFrameAnalyticsRequest) { + return func(r *MLPreviewDataFrameAnalyticsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.preview_datafeed.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.preview_datafeed.go new file mode 100644 index 00000000..5c606ce3 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.preview_datafeed.go @@ -0,0 +1,218 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newMLPreviewDatafeedFunc(t Transport) MLPreviewDatafeed { + return func(o ...func(*MLPreviewDatafeedRequest)) (*Response, error) { + var r = MLPreviewDatafeedRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLPreviewDatafeed - Previews a datafeed. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-preview-datafeed.html. +type MLPreviewDatafeed func(o ...func(*MLPreviewDatafeedRequest)) (*Response, error) + +// MLPreviewDatafeedRequest configures the ML Preview Datafeed API request. +type MLPreviewDatafeedRequest struct { + Body io.Reader + + DatafeedID string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLPreviewDatafeedRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_ml") + 1 + len("datafeeds") + 1 + len(r.DatafeedID) + 1 + len("_preview")) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("datafeeds") + if r.DatafeedID != "" { + path.WriteString("/") + path.WriteString(r.DatafeedID) + } + path.WriteString("/") + path.WriteString("_preview") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLPreviewDatafeed) WithContext(v context.Context) func(*MLPreviewDatafeedRequest) { + return func(r *MLPreviewDatafeedRequest) { + r.ctx = v + } +} + +// WithBody - The datafeed config and job config with which to execute the preview. +func (f MLPreviewDatafeed) WithBody(v io.Reader) func(*MLPreviewDatafeedRequest) { + return func(r *MLPreviewDatafeedRequest) { + r.Body = v + } +} + +// WithDatafeedID - the ID of the datafeed to preview. +func (f MLPreviewDatafeed) WithDatafeedID(v string) func(*MLPreviewDatafeedRequest) { + return func(r *MLPreviewDatafeedRequest) { + r.DatafeedID = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLPreviewDatafeed) WithPretty() func(*MLPreviewDatafeedRequest) { + return func(r *MLPreviewDatafeedRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLPreviewDatafeed) WithHuman() func(*MLPreviewDatafeedRequest) { + return func(r *MLPreviewDatafeedRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLPreviewDatafeed) WithErrorTrace() func(*MLPreviewDatafeedRequest) { + return func(r *MLPreviewDatafeedRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLPreviewDatafeed) WithFilterPath(v ...string) func(*MLPreviewDatafeedRequest) { + return func(r *MLPreviewDatafeedRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLPreviewDatafeed) WithHeader(h map[string]string) func(*MLPreviewDatafeedRequest) { + return func(r *MLPreviewDatafeedRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLPreviewDatafeed) WithOpaqueID(s string) func(*MLPreviewDatafeedRequest) { + return func(r *MLPreviewDatafeedRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.put_calendar.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.put_calendar.go new file mode 100644 index 00000000..8a45212d --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.put_calendar.go @@ -0,0 +1,207 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newMLPutCalendarFunc(t Transport) MLPutCalendar { + return func(calendar_id string, o ...func(*MLPutCalendarRequest)) (*Response, error) { + var r = MLPutCalendarRequest{CalendarID: calendar_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLPutCalendar - Instantiates a calendar. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-calendar.html. +type MLPutCalendar func(calendar_id string, o ...func(*MLPutCalendarRequest)) (*Response, error) + +// MLPutCalendarRequest configures the ML Put Calendar API request. +type MLPutCalendarRequest struct { + Body io.Reader + + CalendarID string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLPutCalendarRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(1 + len("_ml") + 1 + len("calendars") + 1 + len(r.CalendarID)) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("calendars") + path.WriteString("/") + path.WriteString(r.CalendarID) + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLPutCalendar) WithContext(v context.Context) func(*MLPutCalendarRequest) { + return func(r *MLPutCalendarRequest) { + r.ctx = v + } +} + +// WithBody - The calendar details. +func (f MLPutCalendar) WithBody(v io.Reader) func(*MLPutCalendarRequest) { + return func(r *MLPutCalendarRequest) { + r.Body = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLPutCalendar) WithPretty() func(*MLPutCalendarRequest) { + return func(r *MLPutCalendarRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLPutCalendar) WithHuman() func(*MLPutCalendarRequest) { + return func(r *MLPutCalendarRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLPutCalendar) WithErrorTrace() func(*MLPutCalendarRequest) { + return func(r *MLPutCalendarRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLPutCalendar) WithFilterPath(v ...string) func(*MLPutCalendarRequest) { + return func(r *MLPutCalendarRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLPutCalendar) WithHeader(h map[string]string) func(*MLPutCalendarRequest) { + return func(r *MLPutCalendarRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLPutCalendar) WithOpaqueID(s string) func(*MLPutCalendarRequest) { + return func(r *MLPutCalendarRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.put_calendar_job.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.put_calendar_job.go new file mode 100644 index 00000000..f62ff573 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.put_calendar_job.go @@ -0,0 +1,198 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newMLPutCalendarJobFunc(t Transport) MLPutCalendarJob { + return func(calendar_id string, job_id string, o ...func(*MLPutCalendarJobRequest)) (*Response, error) { + var r = MLPutCalendarJobRequest{CalendarID: calendar_id, JobID: job_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLPutCalendarJob - Adds an anomaly detection job to a calendar. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-calendar-job.html. +type MLPutCalendarJob func(calendar_id string, job_id string, o ...func(*MLPutCalendarJobRequest)) (*Response, error) + +// MLPutCalendarJobRequest configures the ML Put Calendar Job API request. +type MLPutCalendarJobRequest struct { + CalendarID string + JobID string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLPutCalendarJobRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(1 + len("_ml") + 1 + len("calendars") + 1 + len(r.CalendarID) + 1 + len("jobs") + 1 + len(r.JobID)) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("calendars") + path.WriteString("/") + path.WriteString(r.CalendarID) + path.WriteString("/") + path.WriteString("jobs") + path.WriteString("/") + path.WriteString(r.JobID) + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLPutCalendarJob) WithContext(v context.Context) func(*MLPutCalendarJobRequest) { + return func(r *MLPutCalendarJobRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLPutCalendarJob) WithPretty() func(*MLPutCalendarJobRequest) { + return func(r *MLPutCalendarJobRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLPutCalendarJob) WithHuman() func(*MLPutCalendarJobRequest) { + return func(r *MLPutCalendarJobRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLPutCalendarJob) WithErrorTrace() func(*MLPutCalendarJobRequest) { + return func(r *MLPutCalendarJobRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLPutCalendarJob) WithFilterPath(v ...string) func(*MLPutCalendarJobRequest) { + return func(r *MLPutCalendarJobRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLPutCalendarJob) WithHeader(h map[string]string) func(*MLPutCalendarJobRequest) { + return func(r *MLPutCalendarJobRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLPutCalendarJob) WithOpaqueID(s string) func(*MLPutCalendarJobRequest) { + return func(r *MLPutCalendarJobRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.put_data_frame_analytics.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.put_data_frame_analytics.go new file mode 100644 index 00000000..8ff6b251 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.put_data_frame_analytics.go @@ -0,0 +1,202 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newMLPutDataFrameAnalyticsFunc(t Transport) MLPutDataFrameAnalytics { + return func(id string, body io.Reader, o ...func(*MLPutDataFrameAnalyticsRequest)) (*Response, error) { + var r = MLPutDataFrameAnalyticsRequest{ID: id, Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLPutDataFrameAnalytics - Instantiates a data frame analytics job. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/put-dfanalytics.html. +type MLPutDataFrameAnalytics func(id string, body io.Reader, o ...func(*MLPutDataFrameAnalyticsRequest)) (*Response, error) + +// MLPutDataFrameAnalyticsRequest configures the ML Put Data Frame Analytics API request. +type MLPutDataFrameAnalyticsRequest struct { + ID string + + Body io.Reader + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLPutDataFrameAnalyticsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(1 + len("_ml") + 1 + len("data_frame") + 1 + len("analytics") + 1 + len(r.ID)) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("data_frame") + path.WriteString("/") + path.WriteString("analytics") + path.WriteString("/") + path.WriteString(r.ID) + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLPutDataFrameAnalytics) WithContext(v context.Context) func(*MLPutDataFrameAnalyticsRequest) { + return func(r *MLPutDataFrameAnalyticsRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLPutDataFrameAnalytics) WithPretty() func(*MLPutDataFrameAnalyticsRequest) { + return func(r *MLPutDataFrameAnalyticsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLPutDataFrameAnalytics) WithHuman() func(*MLPutDataFrameAnalyticsRequest) { + return func(r *MLPutDataFrameAnalyticsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLPutDataFrameAnalytics) WithErrorTrace() func(*MLPutDataFrameAnalyticsRequest) { + return func(r *MLPutDataFrameAnalyticsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLPutDataFrameAnalytics) WithFilterPath(v ...string) func(*MLPutDataFrameAnalyticsRequest) { + return func(r *MLPutDataFrameAnalyticsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLPutDataFrameAnalytics) WithHeader(h map[string]string) func(*MLPutDataFrameAnalyticsRequest) { + return func(r *MLPutDataFrameAnalyticsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLPutDataFrameAnalytics) WithOpaqueID(s string) func(*MLPutDataFrameAnalyticsRequest) { + return func(r *MLPutDataFrameAnalyticsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.put_datafeed.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.put_datafeed.go new file mode 100644 index 00000000..2af00870 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.put_datafeed.go @@ -0,0 +1,250 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" +) + +func newMLPutDatafeedFunc(t Transport) MLPutDatafeed { + return func(body io.Reader, datafeed_id string, o ...func(*MLPutDatafeedRequest)) (*Response, error) { + var r = MLPutDatafeedRequest{Body: body, DatafeedID: datafeed_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLPutDatafeed - Instantiates a datafeed. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-datafeed.html. +type MLPutDatafeed func(body io.Reader, datafeed_id string, o ...func(*MLPutDatafeedRequest)) (*Response, error) + +// MLPutDatafeedRequest configures the ML Put Datafeed API request. +type MLPutDatafeedRequest struct { + Body io.Reader + + DatafeedID string + + AllowNoIndices *bool + ExpandWildcards string + IgnoreThrottled *bool + IgnoreUnavailable *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLPutDatafeedRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(1 + len("_ml") + 1 + len("datafeeds") + 1 + len(r.DatafeedID)) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("datafeeds") + path.WriteString("/") + path.WriteString(r.DatafeedID) + + params = make(map[string]string) + + if r.AllowNoIndices != nil { + params["allow_no_indices"] = strconv.FormatBool(*r.AllowNoIndices) + } + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if r.IgnoreThrottled != nil { + params["ignore_throttled"] = strconv.FormatBool(*r.IgnoreThrottled) + } + + if r.IgnoreUnavailable != nil { + params["ignore_unavailable"] = strconv.FormatBool(*r.IgnoreUnavailable) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLPutDatafeed) WithContext(v context.Context) func(*MLPutDatafeedRequest) { + return func(r *MLPutDatafeedRequest) { + r.ctx = v + } +} + +// WithAllowNoIndices - ignore if the source indices expressions resolves to no concrete indices (default: true). +func (f MLPutDatafeed) WithAllowNoIndices(v bool) func(*MLPutDatafeedRequest) { + return func(r *MLPutDatafeedRequest) { + r.AllowNoIndices = &v + } +} + +// WithExpandWildcards - whether source index expressions should get expanded to open or closed indices (default: open). +func (f MLPutDatafeed) WithExpandWildcards(v string) func(*MLPutDatafeedRequest) { + return func(r *MLPutDatafeedRequest) { + r.ExpandWildcards = v + } +} + +// WithIgnoreThrottled - ignore indices that are marked as throttled (default: true). +func (f MLPutDatafeed) WithIgnoreThrottled(v bool) func(*MLPutDatafeedRequest) { + return func(r *MLPutDatafeedRequest) { + r.IgnoreThrottled = &v + } +} + +// WithIgnoreUnavailable - ignore unavailable indexes (default: false). +func (f MLPutDatafeed) WithIgnoreUnavailable(v bool) func(*MLPutDatafeedRequest) { + return func(r *MLPutDatafeedRequest) { + r.IgnoreUnavailable = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLPutDatafeed) WithPretty() func(*MLPutDatafeedRequest) { + return func(r *MLPutDatafeedRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLPutDatafeed) WithHuman() func(*MLPutDatafeedRequest) { + return func(r *MLPutDatafeedRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLPutDatafeed) WithErrorTrace() func(*MLPutDatafeedRequest) { + return func(r *MLPutDatafeedRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLPutDatafeed) WithFilterPath(v ...string) func(*MLPutDatafeedRequest) { + return func(r *MLPutDatafeedRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLPutDatafeed) WithHeader(h map[string]string) func(*MLPutDatafeedRequest) { + return func(r *MLPutDatafeedRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLPutDatafeed) WithOpaqueID(s string) func(*MLPutDatafeedRequest) { + return func(r *MLPutDatafeedRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.put_filter.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.put_filter.go new file mode 100644 index 00000000..f42e89c0 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.put_filter.go @@ -0,0 +1,200 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newMLPutFilterFunc(t Transport) MLPutFilter { + return func(body io.Reader, filter_id string, o ...func(*MLPutFilterRequest)) (*Response, error) { + var r = MLPutFilterRequest{Body: body, FilterID: filter_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLPutFilter - Instantiates a filter. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-filter.html. +type MLPutFilter func(body io.Reader, filter_id string, o ...func(*MLPutFilterRequest)) (*Response, error) + +// MLPutFilterRequest configures the ML Put Filter API request. +type MLPutFilterRequest struct { + Body io.Reader + + FilterID string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLPutFilterRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(1 + len("_ml") + 1 + len("filters") + 1 + len(r.FilterID)) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("filters") + path.WriteString("/") + path.WriteString(r.FilterID) + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLPutFilter) WithContext(v context.Context) func(*MLPutFilterRequest) { + return func(r *MLPutFilterRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLPutFilter) WithPretty() func(*MLPutFilterRequest) { + return func(r *MLPutFilterRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLPutFilter) WithHuman() func(*MLPutFilterRequest) { + return func(r *MLPutFilterRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLPutFilter) WithErrorTrace() func(*MLPutFilterRequest) { + return func(r *MLPutFilterRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLPutFilter) WithFilterPath(v ...string) func(*MLPutFilterRequest) { + return func(r *MLPutFilterRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLPutFilter) WithHeader(h map[string]string) func(*MLPutFilterRequest) { + return func(r *MLPutFilterRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLPutFilter) WithOpaqueID(s string) func(*MLPutFilterRequest) { + return func(r *MLPutFilterRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.put_job.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.put_job.go new file mode 100644 index 00000000..febf3b60 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.put_job.go @@ -0,0 +1,250 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" +) + +func newMLPutJobFunc(t Transport) MLPutJob { + return func(job_id string, body io.Reader, o ...func(*MLPutJobRequest)) (*Response, error) { + var r = MLPutJobRequest{JobID: job_id, Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLPutJob - Instantiates an anomaly detection job. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-job.html. +type MLPutJob func(job_id string, body io.Reader, o ...func(*MLPutJobRequest)) (*Response, error) + +// MLPutJobRequest configures the ML Put Job API request. +type MLPutJobRequest struct { + Body io.Reader + + JobID string + + AllowNoIndices *bool + ExpandWildcards string + IgnoreThrottled *bool + IgnoreUnavailable *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLPutJobRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(1 + len("_ml") + 1 + len("anomaly_detectors") + 1 + len(r.JobID)) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("anomaly_detectors") + path.WriteString("/") + path.WriteString(r.JobID) + + params = make(map[string]string) + + if r.AllowNoIndices != nil { + params["allow_no_indices"] = strconv.FormatBool(*r.AllowNoIndices) + } + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if r.IgnoreThrottled != nil { + params["ignore_throttled"] = strconv.FormatBool(*r.IgnoreThrottled) + } + + if r.IgnoreUnavailable != nil { + params["ignore_unavailable"] = strconv.FormatBool(*r.IgnoreUnavailable) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLPutJob) WithContext(v context.Context) func(*MLPutJobRequest) { + return func(r *MLPutJobRequest) { + r.ctx = v + } +} + +// WithAllowNoIndices - ignore if the source indices expressions resolves to no concrete indices (default: true). only set if datafeed_config is provided.. +func (f MLPutJob) WithAllowNoIndices(v bool) func(*MLPutJobRequest) { + return func(r *MLPutJobRequest) { + r.AllowNoIndices = &v + } +} + +// WithExpandWildcards - whether source index expressions should get expanded to open or closed indices (default: open). only set if datafeed_config is provided.. +func (f MLPutJob) WithExpandWildcards(v string) func(*MLPutJobRequest) { + return func(r *MLPutJobRequest) { + r.ExpandWildcards = v + } +} + +// WithIgnoreThrottled - ignore indices that are marked as throttled (default: true). only set if datafeed_config is provided.. +func (f MLPutJob) WithIgnoreThrottled(v bool) func(*MLPutJobRequest) { + return func(r *MLPutJobRequest) { + r.IgnoreThrottled = &v + } +} + +// WithIgnoreUnavailable - ignore unavailable indexes (default: false). only set if datafeed_config is provided.. +func (f MLPutJob) WithIgnoreUnavailable(v bool) func(*MLPutJobRequest) { + return func(r *MLPutJobRequest) { + r.IgnoreUnavailable = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLPutJob) WithPretty() func(*MLPutJobRequest) { + return func(r *MLPutJobRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLPutJob) WithHuman() func(*MLPutJobRequest) { + return func(r *MLPutJobRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLPutJob) WithErrorTrace() func(*MLPutJobRequest) { + return func(r *MLPutJobRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLPutJob) WithFilterPath(v ...string) func(*MLPutJobRequest) { + return func(r *MLPutJobRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLPutJob) WithHeader(h map[string]string) func(*MLPutJobRequest) { + return func(r *MLPutJobRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLPutJob) WithOpaqueID(s string) func(*MLPutJobRequest) { + return func(r *MLPutJobRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.put_trained_model.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.put_trained_model.go new file mode 100644 index 00000000..3a888560 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.put_trained_model.go @@ -0,0 +1,214 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" +) + +func newMLPutTrainedModelFunc(t Transport) MLPutTrainedModel { + return func(body io.Reader, model_id string, o ...func(*MLPutTrainedModelRequest)) (*Response, error) { + var r = MLPutTrainedModelRequest{Body: body, ModelID: model_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLPutTrainedModel - Creates an inference trained model. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/put-trained-models.html. +type MLPutTrainedModel func(body io.Reader, model_id string, o ...func(*MLPutTrainedModelRequest)) (*Response, error) + +// MLPutTrainedModelRequest configures the ML Put Trained Model API request. +type MLPutTrainedModelRequest struct { + Body io.Reader + + ModelID string + + DeferDefinitionDecompression *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLPutTrainedModelRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(1 + len("_ml") + 1 + len("trained_models") + 1 + len(r.ModelID)) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("trained_models") + path.WriteString("/") + path.WriteString(r.ModelID) + + params = make(map[string]string) + + if r.DeferDefinitionDecompression != nil { + params["defer_definition_decompression"] = strconv.FormatBool(*r.DeferDefinitionDecompression) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLPutTrainedModel) WithContext(v context.Context) func(*MLPutTrainedModelRequest) { + return func(r *MLPutTrainedModelRequest) { + r.ctx = v + } +} + +// WithDeferDefinitionDecompression - if set to `true` and a `compressed_definition` is provided, the request defers definition decompression and skips relevant validations.. +func (f MLPutTrainedModel) WithDeferDefinitionDecompression(v bool) func(*MLPutTrainedModelRequest) { + return func(r *MLPutTrainedModelRequest) { + r.DeferDefinitionDecompression = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLPutTrainedModel) WithPretty() func(*MLPutTrainedModelRequest) { + return func(r *MLPutTrainedModelRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLPutTrainedModel) WithHuman() func(*MLPutTrainedModelRequest) { + return func(r *MLPutTrainedModelRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLPutTrainedModel) WithErrorTrace() func(*MLPutTrainedModelRequest) { + return func(r *MLPutTrainedModelRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLPutTrainedModel) WithFilterPath(v ...string) func(*MLPutTrainedModelRequest) { + return func(r *MLPutTrainedModelRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLPutTrainedModel) WithHeader(h map[string]string) func(*MLPutTrainedModelRequest) { + return func(r *MLPutTrainedModelRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLPutTrainedModel) WithOpaqueID(s string) func(*MLPutTrainedModelRequest) { + return func(r *MLPutTrainedModelRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.put_trained_model_alias.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.put_trained_model_alias.go new file mode 100644 index 00000000..57f6efb8 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.put_trained_model_alias.go @@ -0,0 +1,212 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newMLPutTrainedModelAliasFunc(t Transport) MLPutTrainedModelAlias { + return func(model_alias string, model_id string, o ...func(*MLPutTrainedModelAliasRequest)) (*Response, error) { + var r = MLPutTrainedModelAliasRequest{ModelAlias: model_alias, ModelID: model_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLPutTrainedModelAlias - Creates a new model alias (or reassigns an existing one) to refer to the trained model +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/put-trained-models-aliases.html. +type MLPutTrainedModelAlias func(model_alias string, model_id string, o ...func(*MLPutTrainedModelAliasRequest)) (*Response, error) + +// MLPutTrainedModelAliasRequest configures the ML Put Trained Model Alias API request. +type MLPutTrainedModelAliasRequest struct { + ModelAlias string + ModelID string + + Reassign *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLPutTrainedModelAliasRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(1 + len("_ml") + 1 + len("trained_models") + 1 + len(r.ModelID) + 1 + len("model_aliases") + 1 + len(r.ModelAlias)) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("trained_models") + path.WriteString("/") + path.WriteString(r.ModelID) + path.WriteString("/") + path.WriteString("model_aliases") + path.WriteString("/") + path.WriteString(r.ModelAlias) + + params = make(map[string]string) + + if r.Reassign != nil { + params["reassign"] = strconv.FormatBool(*r.Reassign) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLPutTrainedModelAlias) WithContext(v context.Context) func(*MLPutTrainedModelAliasRequest) { + return func(r *MLPutTrainedModelAliasRequest) { + r.ctx = v + } +} + +// WithReassign - if the model_alias already exists and points to a separate model_id, this parameter must be true. defaults to false.. +func (f MLPutTrainedModelAlias) WithReassign(v bool) func(*MLPutTrainedModelAliasRequest) { + return func(r *MLPutTrainedModelAliasRequest) { + r.Reassign = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLPutTrainedModelAlias) WithPretty() func(*MLPutTrainedModelAliasRequest) { + return func(r *MLPutTrainedModelAliasRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLPutTrainedModelAlias) WithHuman() func(*MLPutTrainedModelAliasRequest) { + return func(r *MLPutTrainedModelAliasRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLPutTrainedModelAlias) WithErrorTrace() func(*MLPutTrainedModelAliasRequest) { + return func(r *MLPutTrainedModelAliasRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLPutTrainedModelAlias) WithFilterPath(v ...string) func(*MLPutTrainedModelAliasRequest) { + return func(r *MLPutTrainedModelAliasRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLPutTrainedModelAlias) WithHeader(h map[string]string) func(*MLPutTrainedModelAliasRequest) { + return func(r *MLPutTrainedModelAliasRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLPutTrainedModelAlias) WithOpaqueID(s string) func(*MLPutTrainedModelAliasRequest) { + return func(r *MLPutTrainedModelAliasRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.reset_job.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.reset_job.go new file mode 100644 index 00000000..0f626c68 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.reset_job.go @@ -0,0 +1,209 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newMLResetJobFunc(t Transport) MLResetJob { + return func(job_id string, o ...func(*MLResetJobRequest)) (*Response, error) { + var r = MLResetJobRequest{JobID: job_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLResetJob - Resets an existing anomaly detection job. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-reset-job.html. +type MLResetJob func(job_id string, o ...func(*MLResetJobRequest)) (*Response, error) + +// MLResetJobRequest configures the ML Reset Job API request. +type MLResetJobRequest struct { + JobID string + + WaitForCompletion *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLResetJobRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_ml") + 1 + len("anomaly_detectors") + 1 + len(r.JobID) + 1 + len("_reset")) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("anomaly_detectors") + path.WriteString("/") + path.WriteString(r.JobID) + path.WriteString("/") + path.WriteString("_reset") + + params = make(map[string]string) + + if r.WaitForCompletion != nil { + params["wait_for_completion"] = strconv.FormatBool(*r.WaitForCompletion) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLResetJob) WithContext(v context.Context) func(*MLResetJobRequest) { + return func(r *MLResetJobRequest) { + r.ctx = v + } +} + +// WithWaitForCompletion - should this request wait until the operation has completed before returning. +func (f MLResetJob) WithWaitForCompletion(v bool) func(*MLResetJobRequest) { + return func(r *MLResetJobRequest) { + r.WaitForCompletion = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLResetJob) WithPretty() func(*MLResetJobRequest) { + return func(r *MLResetJobRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLResetJob) WithHuman() func(*MLResetJobRequest) { + return func(r *MLResetJobRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLResetJob) WithErrorTrace() func(*MLResetJobRequest) { + return func(r *MLResetJobRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLResetJob) WithFilterPath(v ...string) func(*MLResetJobRequest) { + return func(r *MLResetJobRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLResetJob) WithHeader(h map[string]string) func(*MLResetJobRequest) { + return func(r *MLResetJobRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLResetJob) WithOpaqueID(s string) func(*MLResetJobRequest) { + return func(r *MLResetJobRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.revert_model_snapshot.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.revert_model_snapshot.go new file mode 100644 index 00000000..92e7329a --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.revert_model_snapshot.go @@ -0,0 +1,228 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" +) + +func newMLRevertModelSnapshotFunc(t Transport) MLRevertModelSnapshot { + return func(snapshot_id string, job_id string, o ...func(*MLRevertModelSnapshotRequest)) (*Response, error) { + var r = MLRevertModelSnapshotRequest{SnapshotID: snapshot_id, JobID: job_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLRevertModelSnapshot - Reverts to a specific snapshot. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-revert-snapshot.html. +type MLRevertModelSnapshot func(snapshot_id string, job_id string, o ...func(*MLRevertModelSnapshotRequest)) (*Response, error) + +// MLRevertModelSnapshotRequest configures the ML Revert Model Snapshot API request. +type MLRevertModelSnapshotRequest struct { + Body io.Reader + + JobID string + SnapshotID string + + DeleteInterveningResults *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLRevertModelSnapshotRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_ml") + 1 + len("anomaly_detectors") + 1 + len(r.JobID) + 1 + len("model_snapshots") + 1 + len(r.SnapshotID) + 1 + len("_revert")) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("anomaly_detectors") + path.WriteString("/") + path.WriteString(r.JobID) + path.WriteString("/") + path.WriteString("model_snapshots") + path.WriteString("/") + path.WriteString(r.SnapshotID) + path.WriteString("/") + path.WriteString("_revert") + + params = make(map[string]string) + + if r.DeleteInterveningResults != nil { + params["delete_intervening_results"] = strconv.FormatBool(*r.DeleteInterveningResults) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLRevertModelSnapshot) WithContext(v context.Context) func(*MLRevertModelSnapshotRequest) { + return func(r *MLRevertModelSnapshotRequest) { + r.ctx = v + } +} + +// WithBody - Reversion options. +func (f MLRevertModelSnapshot) WithBody(v io.Reader) func(*MLRevertModelSnapshotRequest) { + return func(r *MLRevertModelSnapshotRequest) { + r.Body = v + } +} + +// WithDeleteInterveningResults - should we reset the results back to the time of the snapshot?. +func (f MLRevertModelSnapshot) WithDeleteInterveningResults(v bool) func(*MLRevertModelSnapshotRequest) { + return func(r *MLRevertModelSnapshotRequest) { + r.DeleteInterveningResults = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLRevertModelSnapshot) WithPretty() func(*MLRevertModelSnapshotRequest) { + return func(r *MLRevertModelSnapshotRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLRevertModelSnapshot) WithHuman() func(*MLRevertModelSnapshotRequest) { + return func(r *MLRevertModelSnapshotRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLRevertModelSnapshot) WithErrorTrace() func(*MLRevertModelSnapshotRequest) { + return func(r *MLRevertModelSnapshotRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLRevertModelSnapshot) WithFilterPath(v ...string) func(*MLRevertModelSnapshotRequest) { + return func(r *MLRevertModelSnapshotRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLRevertModelSnapshot) WithHeader(h map[string]string) func(*MLRevertModelSnapshotRequest) { + return func(r *MLRevertModelSnapshotRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLRevertModelSnapshot) WithOpaqueID(s string) func(*MLRevertModelSnapshotRequest) { + return func(r *MLRevertModelSnapshotRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.set_upgrade_mode.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.set_upgrade_mode.go new file mode 100644 index 00000000..b339335f --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.set_upgrade_mode.go @@ -0,0 +1,213 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" + "time" +) + +func newMLSetUpgradeModeFunc(t Transport) MLSetUpgradeMode { + return func(o ...func(*MLSetUpgradeModeRequest)) (*Response, error) { + var r = MLSetUpgradeModeRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLSetUpgradeMode - Sets a cluster wide upgrade_mode setting that prepares machine learning indices for an upgrade. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-set-upgrade-mode.html. +type MLSetUpgradeMode func(o ...func(*MLSetUpgradeModeRequest)) (*Response, error) + +// MLSetUpgradeModeRequest configures the ML Set Upgrade Mode API request. +type MLSetUpgradeModeRequest struct { + Enabled *bool + Timeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLSetUpgradeModeRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(len("/_ml/set_upgrade_mode")) + path.WriteString("/_ml/set_upgrade_mode") + + params = make(map[string]string) + + if r.Enabled != nil { + params["enabled"] = strconv.FormatBool(*r.Enabled) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLSetUpgradeMode) WithContext(v context.Context) func(*MLSetUpgradeModeRequest) { + return func(r *MLSetUpgradeModeRequest) { + r.ctx = v + } +} + +// WithEnabled - whether to enable upgrade_mode ml setting or not. defaults to false.. +func (f MLSetUpgradeMode) WithEnabled(v bool) func(*MLSetUpgradeModeRequest) { + return func(r *MLSetUpgradeModeRequest) { + r.Enabled = &v + } +} + +// WithTimeout - controls the time to wait before action times out. defaults to 30 seconds. +func (f MLSetUpgradeMode) WithTimeout(v time.Duration) func(*MLSetUpgradeModeRequest) { + return func(r *MLSetUpgradeModeRequest) { + r.Timeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLSetUpgradeMode) WithPretty() func(*MLSetUpgradeModeRequest) { + return func(r *MLSetUpgradeModeRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLSetUpgradeMode) WithHuman() func(*MLSetUpgradeModeRequest) { + return func(r *MLSetUpgradeModeRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLSetUpgradeMode) WithErrorTrace() func(*MLSetUpgradeModeRequest) { + return func(r *MLSetUpgradeModeRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLSetUpgradeMode) WithFilterPath(v ...string) func(*MLSetUpgradeModeRequest) { + return func(r *MLSetUpgradeModeRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLSetUpgradeMode) WithHeader(h map[string]string) func(*MLSetUpgradeModeRequest) { + return func(r *MLSetUpgradeModeRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLSetUpgradeMode) WithOpaqueID(s string) func(*MLSetUpgradeModeRequest) { + return func(r *MLSetUpgradeModeRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.start_data_frame_analytics.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.start_data_frame_analytics.go new file mode 100644 index 00000000..2f8f38fd --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.start_data_frame_analytics.go @@ -0,0 +1,225 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" + "time" +) + +func newMLStartDataFrameAnalyticsFunc(t Transport) MLStartDataFrameAnalytics { + return func(id string, o ...func(*MLStartDataFrameAnalyticsRequest)) (*Response, error) { + var r = MLStartDataFrameAnalyticsRequest{ID: id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLStartDataFrameAnalytics - Starts a data frame analytics job. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/start-dfanalytics.html. +type MLStartDataFrameAnalytics func(id string, o ...func(*MLStartDataFrameAnalyticsRequest)) (*Response, error) + +// MLStartDataFrameAnalyticsRequest configures the ML Start Data Frame Analytics API request. +type MLStartDataFrameAnalyticsRequest struct { + ID string + + Body io.Reader + + Timeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLStartDataFrameAnalyticsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_ml") + 1 + len("data_frame") + 1 + len("analytics") + 1 + len(r.ID) + 1 + len("_start")) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("data_frame") + path.WriteString("/") + path.WriteString("analytics") + path.WriteString("/") + path.WriteString(r.ID) + path.WriteString("/") + path.WriteString("_start") + + params = make(map[string]string) + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLStartDataFrameAnalytics) WithContext(v context.Context) func(*MLStartDataFrameAnalyticsRequest) { + return func(r *MLStartDataFrameAnalyticsRequest) { + r.ctx = v + } +} + +// WithBody - The start data frame analytics parameters. +func (f MLStartDataFrameAnalytics) WithBody(v io.Reader) func(*MLStartDataFrameAnalyticsRequest) { + return func(r *MLStartDataFrameAnalyticsRequest) { + r.Body = v + } +} + +// WithTimeout - controls the time to wait until the task has started. defaults to 20 seconds. +func (f MLStartDataFrameAnalytics) WithTimeout(v time.Duration) func(*MLStartDataFrameAnalyticsRequest) { + return func(r *MLStartDataFrameAnalyticsRequest) { + r.Timeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLStartDataFrameAnalytics) WithPretty() func(*MLStartDataFrameAnalyticsRequest) { + return func(r *MLStartDataFrameAnalyticsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLStartDataFrameAnalytics) WithHuman() func(*MLStartDataFrameAnalyticsRequest) { + return func(r *MLStartDataFrameAnalyticsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLStartDataFrameAnalytics) WithErrorTrace() func(*MLStartDataFrameAnalyticsRequest) { + return func(r *MLStartDataFrameAnalyticsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLStartDataFrameAnalytics) WithFilterPath(v ...string) func(*MLStartDataFrameAnalyticsRequest) { + return func(r *MLStartDataFrameAnalyticsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLStartDataFrameAnalytics) WithHeader(h map[string]string) func(*MLStartDataFrameAnalyticsRequest) { + return func(r *MLStartDataFrameAnalyticsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLStartDataFrameAnalytics) WithOpaqueID(s string) func(*MLStartDataFrameAnalyticsRequest) { + return func(r *MLStartDataFrameAnalyticsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.start_datafeed.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.start_datafeed.go new file mode 100644 index 00000000..455184b5 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.start_datafeed.go @@ -0,0 +1,247 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" + "time" +) + +func newMLStartDatafeedFunc(t Transport) MLStartDatafeed { + return func(datafeed_id string, o ...func(*MLStartDatafeedRequest)) (*Response, error) { + var r = MLStartDatafeedRequest{DatafeedID: datafeed_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLStartDatafeed - Starts one or more datafeeds. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-start-datafeed.html. +type MLStartDatafeed func(datafeed_id string, o ...func(*MLStartDatafeedRequest)) (*Response, error) + +// MLStartDatafeedRequest configures the ML Start Datafeed API request. +type MLStartDatafeedRequest struct { + Body io.Reader + + DatafeedID string + + End string + Start string + Timeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLStartDatafeedRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_ml") + 1 + len("datafeeds") + 1 + len(r.DatafeedID) + 1 + len("_start")) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("datafeeds") + path.WriteString("/") + path.WriteString(r.DatafeedID) + path.WriteString("/") + path.WriteString("_start") + + params = make(map[string]string) + + if r.End != "" { + params["end"] = r.End + } + + if r.Start != "" { + params["start"] = r.Start + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLStartDatafeed) WithContext(v context.Context) func(*MLStartDatafeedRequest) { + return func(r *MLStartDatafeedRequest) { + r.ctx = v + } +} + +// WithBody - The start datafeed parameters. +func (f MLStartDatafeed) WithBody(v io.Reader) func(*MLStartDatafeedRequest) { + return func(r *MLStartDatafeedRequest) { + r.Body = v + } +} + +// WithEnd - the end time when the datafeed should stop. when not set, the datafeed continues in real time. +func (f MLStartDatafeed) WithEnd(v string) func(*MLStartDatafeedRequest) { + return func(r *MLStartDatafeedRequest) { + r.End = v + } +} + +// WithStart - the start time from where the datafeed should begin. +func (f MLStartDatafeed) WithStart(v string) func(*MLStartDatafeedRequest) { + return func(r *MLStartDatafeedRequest) { + r.Start = v + } +} + +// WithTimeout - controls the time to wait until a datafeed has started. default to 20 seconds. +func (f MLStartDatafeed) WithTimeout(v time.Duration) func(*MLStartDatafeedRequest) { + return func(r *MLStartDatafeedRequest) { + r.Timeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLStartDatafeed) WithPretty() func(*MLStartDatafeedRequest) { + return func(r *MLStartDatafeedRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLStartDatafeed) WithHuman() func(*MLStartDatafeedRequest) { + return func(r *MLStartDatafeedRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLStartDatafeed) WithErrorTrace() func(*MLStartDatafeedRequest) { + return func(r *MLStartDatafeedRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLStartDatafeed) WithFilterPath(v ...string) func(*MLStartDatafeedRequest) { + return func(r *MLStartDatafeedRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLStartDatafeed) WithHeader(h map[string]string) func(*MLStartDatafeedRequest) { + return func(r *MLStartDatafeedRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLStartDatafeed) WithOpaqueID(s string) func(*MLStartDatafeedRequest) { + return func(r *MLStartDatafeedRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.stop_data_frame_analytics.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.stop_data_frame_analytics.go new file mode 100644 index 00000000..380c65e5 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.stop_data_frame_analytics.go @@ -0,0 +1,250 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" + "time" +) + +func newMLStopDataFrameAnalyticsFunc(t Transport) MLStopDataFrameAnalytics { + return func(id string, o ...func(*MLStopDataFrameAnalyticsRequest)) (*Response, error) { + var r = MLStopDataFrameAnalyticsRequest{ID: id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLStopDataFrameAnalytics - Stops one or more data frame analytics jobs. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/stop-dfanalytics.html. +type MLStopDataFrameAnalytics func(id string, o ...func(*MLStopDataFrameAnalyticsRequest)) (*Response, error) + +// MLStopDataFrameAnalyticsRequest configures the ML Stop Data Frame Analytics API request. +type MLStopDataFrameAnalyticsRequest struct { + ID string + + Body io.Reader + + AllowNoMatch *bool + Force *bool + Timeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLStopDataFrameAnalyticsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_ml") + 1 + len("data_frame") + 1 + len("analytics") + 1 + len(r.ID) + 1 + len("_stop")) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("data_frame") + path.WriteString("/") + path.WriteString("analytics") + path.WriteString("/") + path.WriteString(r.ID) + path.WriteString("/") + path.WriteString("_stop") + + params = make(map[string]string) + + if r.AllowNoMatch != nil { + params["allow_no_match"] = strconv.FormatBool(*r.AllowNoMatch) + } + + if r.Force != nil { + params["force"] = strconv.FormatBool(*r.Force) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLStopDataFrameAnalytics) WithContext(v context.Context) func(*MLStopDataFrameAnalyticsRequest) { + return func(r *MLStopDataFrameAnalyticsRequest) { + r.ctx = v + } +} + +// WithBody - The stop data frame analytics parameters. +func (f MLStopDataFrameAnalytics) WithBody(v io.Reader) func(*MLStopDataFrameAnalyticsRequest) { + return func(r *MLStopDataFrameAnalyticsRequest) { + r.Body = v + } +} + +// WithAllowNoMatch - whether to ignore if a wildcard expression matches no data frame analytics. (this includes `_all` string or when no data frame analytics have been specified). +func (f MLStopDataFrameAnalytics) WithAllowNoMatch(v bool) func(*MLStopDataFrameAnalyticsRequest) { + return func(r *MLStopDataFrameAnalyticsRequest) { + r.AllowNoMatch = &v + } +} + +// WithForce - true if the data frame analytics should be forcefully stopped. +func (f MLStopDataFrameAnalytics) WithForce(v bool) func(*MLStopDataFrameAnalyticsRequest) { + return func(r *MLStopDataFrameAnalyticsRequest) { + r.Force = &v + } +} + +// WithTimeout - controls the time to wait until the task has stopped. defaults to 20 seconds. +func (f MLStopDataFrameAnalytics) WithTimeout(v time.Duration) func(*MLStopDataFrameAnalyticsRequest) { + return func(r *MLStopDataFrameAnalyticsRequest) { + r.Timeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLStopDataFrameAnalytics) WithPretty() func(*MLStopDataFrameAnalyticsRequest) { + return func(r *MLStopDataFrameAnalyticsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLStopDataFrameAnalytics) WithHuman() func(*MLStopDataFrameAnalyticsRequest) { + return func(r *MLStopDataFrameAnalyticsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLStopDataFrameAnalytics) WithErrorTrace() func(*MLStopDataFrameAnalyticsRequest) { + return func(r *MLStopDataFrameAnalyticsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLStopDataFrameAnalytics) WithFilterPath(v ...string) func(*MLStopDataFrameAnalyticsRequest) { + return func(r *MLStopDataFrameAnalyticsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLStopDataFrameAnalytics) WithHeader(h map[string]string) func(*MLStopDataFrameAnalyticsRequest) { + return func(r *MLStopDataFrameAnalyticsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLStopDataFrameAnalytics) WithOpaqueID(s string) func(*MLStopDataFrameAnalyticsRequest) { + return func(r *MLStopDataFrameAnalyticsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.stop_datafeed.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.stop_datafeed.go new file mode 100644 index 00000000..6162e405 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.stop_datafeed.go @@ -0,0 +1,260 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" + "time" +) + +func newMLStopDatafeedFunc(t Transport) MLStopDatafeed { + return func(datafeed_id string, o ...func(*MLStopDatafeedRequest)) (*Response, error) { + var r = MLStopDatafeedRequest{DatafeedID: datafeed_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLStopDatafeed - Stops one or more datafeeds. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-stop-datafeed.html. +type MLStopDatafeed func(datafeed_id string, o ...func(*MLStopDatafeedRequest)) (*Response, error) + +// MLStopDatafeedRequest configures the ML Stop Datafeed API request. +type MLStopDatafeedRequest struct { + Body io.Reader + + DatafeedID string + + AllowNoDatafeeds *bool + AllowNoMatch *bool + Force *bool + Timeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLStopDatafeedRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_ml") + 1 + len("datafeeds") + 1 + len(r.DatafeedID) + 1 + len("_stop")) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("datafeeds") + path.WriteString("/") + path.WriteString(r.DatafeedID) + path.WriteString("/") + path.WriteString("_stop") + + params = make(map[string]string) + + if r.AllowNoDatafeeds != nil { + params["allow_no_datafeeds"] = strconv.FormatBool(*r.AllowNoDatafeeds) + } + + if r.AllowNoMatch != nil { + params["allow_no_match"] = strconv.FormatBool(*r.AllowNoMatch) + } + + if r.Force != nil { + params["force"] = strconv.FormatBool(*r.Force) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLStopDatafeed) WithContext(v context.Context) func(*MLStopDatafeedRequest) { + return func(r *MLStopDatafeedRequest) { + r.ctx = v + } +} + +// WithBody - The URL params optionally sent in the body. +func (f MLStopDatafeed) WithBody(v io.Reader) func(*MLStopDatafeedRequest) { + return func(r *MLStopDatafeedRequest) { + r.Body = v + } +} + +// WithAllowNoDatafeeds - whether to ignore if a wildcard expression matches no datafeeds. (this includes `_all` string or when no datafeeds have been specified). +func (f MLStopDatafeed) WithAllowNoDatafeeds(v bool) func(*MLStopDatafeedRequest) { + return func(r *MLStopDatafeedRequest) { + r.AllowNoDatafeeds = &v + } +} + +// WithAllowNoMatch - whether to ignore if a wildcard expression matches no datafeeds. (this includes `_all` string or when no datafeeds have been specified). +func (f MLStopDatafeed) WithAllowNoMatch(v bool) func(*MLStopDatafeedRequest) { + return func(r *MLStopDatafeedRequest) { + r.AllowNoMatch = &v + } +} + +// WithForce - true if the datafeed should be forcefully stopped.. +func (f MLStopDatafeed) WithForce(v bool) func(*MLStopDatafeedRequest) { + return func(r *MLStopDatafeedRequest) { + r.Force = &v + } +} + +// WithTimeout - controls the time to wait until a datafeed has stopped. default to 20 seconds. +func (f MLStopDatafeed) WithTimeout(v time.Duration) func(*MLStopDatafeedRequest) { + return func(r *MLStopDatafeedRequest) { + r.Timeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLStopDatafeed) WithPretty() func(*MLStopDatafeedRequest) { + return func(r *MLStopDatafeedRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLStopDatafeed) WithHuman() func(*MLStopDatafeedRequest) { + return func(r *MLStopDatafeedRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLStopDatafeed) WithErrorTrace() func(*MLStopDatafeedRequest) { + return func(r *MLStopDatafeedRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLStopDatafeed) WithFilterPath(v ...string) func(*MLStopDatafeedRequest) { + return func(r *MLStopDatafeedRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLStopDatafeed) WithHeader(h map[string]string) func(*MLStopDatafeedRequest) { + return func(r *MLStopDatafeedRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLStopDatafeed) WithOpaqueID(s string) func(*MLStopDatafeedRequest) { + return func(r *MLStopDatafeedRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.update_data_frame_analytics.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.update_data_frame_analytics.go new file mode 100644 index 00000000..96ccf1f9 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.update_data_frame_analytics.go @@ -0,0 +1,204 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newMLUpdateDataFrameAnalyticsFunc(t Transport) MLUpdateDataFrameAnalytics { + return func(id string, body io.Reader, o ...func(*MLUpdateDataFrameAnalyticsRequest)) (*Response, error) { + var r = MLUpdateDataFrameAnalyticsRequest{DocumentID: id, Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLUpdateDataFrameAnalytics - Updates certain properties of a data frame analytics job. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/update-dfanalytics.html. +type MLUpdateDataFrameAnalytics func(id string, body io.Reader, o ...func(*MLUpdateDataFrameAnalyticsRequest)) (*Response, error) + +// MLUpdateDataFrameAnalyticsRequest configures the ML Update Data Frame Analytics API request. +type MLUpdateDataFrameAnalyticsRequest struct { + DocumentID string + + Body io.Reader + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLUpdateDataFrameAnalyticsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_ml") + 1 + len("data_frame") + 1 + len("analytics") + 1 + len(r.DocumentID) + 1 + len("_update")) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("data_frame") + path.WriteString("/") + path.WriteString("analytics") + path.WriteString("/") + path.WriteString(r.DocumentID) + path.WriteString("/") + path.WriteString("_update") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLUpdateDataFrameAnalytics) WithContext(v context.Context) func(*MLUpdateDataFrameAnalyticsRequest) { + return func(r *MLUpdateDataFrameAnalyticsRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLUpdateDataFrameAnalytics) WithPretty() func(*MLUpdateDataFrameAnalyticsRequest) { + return func(r *MLUpdateDataFrameAnalyticsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLUpdateDataFrameAnalytics) WithHuman() func(*MLUpdateDataFrameAnalyticsRequest) { + return func(r *MLUpdateDataFrameAnalyticsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLUpdateDataFrameAnalytics) WithErrorTrace() func(*MLUpdateDataFrameAnalyticsRequest) { + return func(r *MLUpdateDataFrameAnalyticsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLUpdateDataFrameAnalytics) WithFilterPath(v ...string) func(*MLUpdateDataFrameAnalyticsRequest) { + return func(r *MLUpdateDataFrameAnalyticsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLUpdateDataFrameAnalytics) WithHeader(h map[string]string) func(*MLUpdateDataFrameAnalyticsRequest) { + return func(r *MLUpdateDataFrameAnalyticsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLUpdateDataFrameAnalytics) WithOpaqueID(s string) func(*MLUpdateDataFrameAnalyticsRequest) { + return func(r *MLUpdateDataFrameAnalyticsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.update_datafeed.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.update_datafeed.go new file mode 100644 index 00000000..bfc2a5db --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.update_datafeed.go @@ -0,0 +1,252 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" +) + +func newMLUpdateDatafeedFunc(t Transport) MLUpdateDatafeed { + return func(body io.Reader, datafeed_id string, o ...func(*MLUpdateDatafeedRequest)) (*Response, error) { + var r = MLUpdateDatafeedRequest{Body: body, DatafeedID: datafeed_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLUpdateDatafeed - Updates certain properties of a datafeed. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-datafeed.html. +type MLUpdateDatafeed func(body io.Reader, datafeed_id string, o ...func(*MLUpdateDatafeedRequest)) (*Response, error) + +// MLUpdateDatafeedRequest configures the ML Update Datafeed API request. +type MLUpdateDatafeedRequest struct { + Body io.Reader + + DatafeedID string + + AllowNoIndices *bool + ExpandWildcards string + IgnoreThrottled *bool + IgnoreUnavailable *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLUpdateDatafeedRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_ml") + 1 + len("datafeeds") + 1 + len(r.DatafeedID) + 1 + len("_update")) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("datafeeds") + path.WriteString("/") + path.WriteString(r.DatafeedID) + path.WriteString("/") + path.WriteString("_update") + + params = make(map[string]string) + + if r.AllowNoIndices != nil { + params["allow_no_indices"] = strconv.FormatBool(*r.AllowNoIndices) + } + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if r.IgnoreThrottled != nil { + params["ignore_throttled"] = strconv.FormatBool(*r.IgnoreThrottled) + } + + if r.IgnoreUnavailable != nil { + params["ignore_unavailable"] = strconv.FormatBool(*r.IgnoreUnavailable) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLUpdateDatafeed) WithContext(v context.Context) func(*MLUpdateDatafeedRequest) { + return func(r *MLUpdateDatafeedRequest) { + r.ctx = v + } +} + +// WithAllowNoIndices - ignore if the source indices expressions resolves to no concrete indices (default: true). +func (f MLUpdateDatafeed) WithAllowNoIndices(v bool) func(*MLUpdateDatafeedRequest) { + return func(r *MLUpdateDatafeedRequest) { + r.AllowNoIndices = &v + } +} + +// WithExpandWildcards - whether source index expressions should get expanded to open or closed indices (default: open). +func (f MLUpdateDatafeed) WithExpandWildcards(v string) func(*MLUpdateDatafeedRequest) { + return func(r *MLUpdateDatafeedRequest) { + r.ExpandWildcards = v + } +} + +// WithIgnoreThrottled - ignore indices that are marked as throttled (default: true). +func (f MLUpdateDatafeed) WithIgnoreThrottled(v bool) func(*MLUpdateDatafeedRequest) { + return func(r *MLUpdateDatafeedRequest) { + r.IgnoreThrottled = &v + } +} + +// WithIgnoreUnavailable - ignore unavailable indexes (default: false). +func (f MLUpdateDatafeed) WithIgnoreUnavailable(v bool) func(*MLUpdateDatafeedRequest) { + return func(r *MLUpdateDatafeedRequest) { + r.IgnoreUnavailable = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLUpdateDatafeed) WithPretty() func(*MLUpdateDatafeedRequest) { + return func(r *MLUpdateDatafeedRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLUpdateDatafeed) WithHuman() func(*MLUpdateDatafeedRequest) { + return func(r *MLUpdateDatafeedRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLUpdateDatafeed) WithErrorTrace() func(*MLUpdateDatafeedRequest) { + return func(r *MLUpdateDatafeedRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLUpdateDatafeed) WithFilterPath(v ...string) func(*MLUpdateDatafeedRequest) { + return func(r *MLUpdateDatafeedRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLUpdateDatafeed) WithHeader(h map[string]string) func(*MLUpdateDatafeedRequest) { + return func(r *MLUpdateDatafeedRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLUpdateDatafeed) WithOpaqueID(s string) func(*MLUpdateDatafeedRequest) { + return func(r *MLUpdateDatafeedRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.update_filter.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.update_filter.go new file mode 100644 index 00000000..734ee75b --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.update_filter.go @@ -0,0 +1,202 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newMLUpdateFilterFunc(t Transport) MLUpdateFilter { + return func(body io.Reader, filter_id string, o ...func(*MLUpdateFilterRequest)) (*Response, error) { + var r = MLUpdateFilterRequest{Body: body, FilterID: filter_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLUpdateFilter - Updates the description of a filter, adds items, or removes items. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-filter.html. +type MLUpdateFilter func(body io.Reader, filter_id string, o ...func(*MLUpdateFilterRequest)) (*Response, error) + +// MLUpdateFilterRequest configures the ML Update Filter API request. +type MLUpdateFilterRequest struct { + Body io.Reader + + FilterID string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLUpdateFilterRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_ml") + 1 + len("filters") + 1 + len(r.FilterID) + 1 + len("_update")) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("filters") + path.WriteString("/") + path.WriteString(r.FilterID) + path.WriteString("/") + path.WriteString("_update") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLUpdateFilter) WithContext(v context.Context) func(*MLUpdateFilterRequest) { + return func(r *MLUpdateFilterRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLUpdateFilter) WithPretty() func(*MLUpdateFilterRequest) { + return func(r *MLUpdateFilterRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLUpdateFilter) WithHuman() func(*MLUpdateFilterRequest) { + return func(r *MLUpdateFilterRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLUpdateFilter) WithErrorTrace() func(*MLUpdateFilterRequest) { + return func(r *MLUpdateFilterRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLUpdateFilter) WithFilterPath(v ...string) func(*MLUpdateFilterRequest) { + return func(r *MLUpdateFilterRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLUpdateFilter) WithHeader(h map[string]string) func(*MLUpdateFilterRequest) { + return func(r *MLUpdateFilterRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLUpdateFilter) WithOpaqueID(s string) func(*MLUpdateFilterRequest) { + return func(r *MLUpdateFilterRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.update_job.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.update_job.go new file mode 100644 index 00000000..67c778c9 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.update_job.go @@ -0,0 +1,202 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newMLUpdateJobFunc(t Transport) MLUpdateJob { + return func(job_id string, body io.Reader, o ...func(*MLUpdateJobRequest)) (*Response, error) { + var r = MLUpdateJobRequest{JobID: job_id, Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLUpdateJob - Updates certain properties of an anomaly detection job. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-job.html. +type MLUpdateJob func(job_id string, body io.Reader, o ...func(*MLUpdateJobRequest)) (*Response, error) + +// MLUpdateJobRequest configures the ML Update Job API request. +type MLUpdateJobRequest struct { + Body io.Reader + + JobID string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLUpdateJobRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_ml") + 1 + len("anomaly_detectors") + 1 + len(r.JobID) + 1 + len("_update")) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("anomaly_detectors") + path.WriteString("/") + path.WriteString(r.JobID) + path.WriteString("/") + path.WriteString("_update") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLUpdateJob) WithContext(v context.Context) func(*MLUpdateJobRequest) { + return func(r *MLUpdateJobRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLUpdateJob) WithPretty() func(*MLUpdateJobRequest) { + return func(r *MLUpdateJobRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLUpdateJob) WithHuman() func(*MLUpdateJobRequest) { + return func(r *MLUpdateJobRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLUpdateJob) WithErrorTrace() func(*MLUpdateJobRequest) { + return func(r *MLUpdateJobRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLUpdateJob) WithFilterPath(v ...string) func(*MLUpdateJobRequest) { + return func(r *MLUpdateJobRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLUpdateJob) WithHeader(h map[string]string) func(*MLUpdateJobRequest) { + return func(r *MLUpdateJobRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLUpdateJob) WithOpaqueID(s string) func(*MLUpdateJobRequest) { + return func(r *MLUpdateJobRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.update_model_snapshot.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.update_model_snapshot.go new file mode 100644 index 00000000..56fd7952 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.update_model_snapshot.go @@ -0,0 +1,207 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newMLUpdateModelSnapshotFunc(t Transport) MLUpdateModelSnapshot { + return func(snapshot_id string, job_id string, body io.Reader, o ...func(*MLUpdateModelSnapshotRequest)) (*Response, error) { + var r = MLUpdateModelSnapshotRequest{SnapshotID: snapshot_id, JobID: job_id, Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLUpdateModelSnapshot - Updates certain properties of a snapshot. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-snapshot.html. +type MLUpdateModelSnapshot func(snapshot_id string, job_id string, body io.Reader, o ...func(*MLUpdateModelSnapshotRequest)) (*Response, error) + +// MLUpdateModelSnapshotRequest configures the ML Update Model Snapshot API request. +type MLUpdateModelSnapshotRequest struct { + Body io.Reader + + JobID string + SnapshotID string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLUpdateModelSnapshotRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_ml") + 1 + len("anomaly_detectors") + 1 + len(r.JobID) + 1 + len("model_snapshots") + 1 + len(r.SnapshotID) + 1 + len("_update")) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("anomaly_detectors") + path.WriteString("/") + path.WriteString(r.JobID) + path.WriteString("/") + path.WriteString("model_snapshots") + path.WriteString("/") + path.WriteString(r.SnapshotID) + path.WriteString("/") + path.WriteString("_update") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLUpdateModelSnapshot) WithContext(v context.Context) func(*MLUpdateModelSnapshotRequest) { + return func(r *MLUpdateModelSnapshotRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLUpdateModelSnapshot) WithPretty() func(*MLUpdateModelSnapshotRequest) { + return func(r *MLUpdateModelSnapshotRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLUpdateModelSnapshot) WithHuman() func(*MLUpdateModelSnapshotRequest) { + return func(r *MLUpdateModelSnapshotRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLUpdateModelSnapshot) WithErrorTrace() func(*MLUpdateModelSnapshotRequest) { + return func(r *MLUpdateModelSnapshotRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLUpdateModelSnapshot) WithFilterPath(v ...string) func(*MLUpdateModelSnapshotRequest) { + return func(r *MLUpdateModelSnapshotRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLUpdateModelSnapshot) WithHeader(h map[string]string) func(*MLUpdateModelSnapshotRequest) { + return func(r *MLUpdateModelSnapshotRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLUpdateModelSnapshot) WithOpaqueID(s string) func(*MLUpdateModelSnapshotRequest) { + return func(r *MLUpdateModelSnapshotRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.upgrade_job_snapshot.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.upgrade_job_snapshot.go new file mode 100644 index 00000000..827f7ea4 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.upgrade_job_snapshot.go @@ -0,0 +1,227 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" + "time" +) + +func newMLUpgradeJobSnapshotFunc(t Transport) MLUpgradeJobSnapshot { + return func(snapshot_id string, job_id string, o ...func(*MLUpgradeJobSnapshotRequest)) (*Response, error) { + var r = MLUpgradeJobSnapshotRequest{SnapshotID: snapshot_id, JobID: job_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLUpgradeJobSnapshot - Upgrades a given job snapshot to the current major version. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-upgrade-job-model-snapshot.html. +type MLUpgradeJobSnapshot func(snapshot_id string, job_id string, o ...func(*MLUpgradeJobSnapshotRequest)) (*Response, error) + +// MLUpgradeJobSnapshotRequest configures the ML Upgrade Job Snapshot API request. +type MLUpgradeJobSnapshotRequest struct { + JobID string + SnapshotID string + + Timeout time.Duration + WaitForCompletion *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLUpgradeJobSnapshotRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_ml") + 1 + len("anomaly_detectors") + 1 + len(r.JobID) + 1 + len("model_snapshots") + 1 + len(r.SnapshotID) + 1 + len("_upgrade")) + path.WriteString("/") + path.WriteString("_ml") + path.WriteString("/") + path.WriteString("anomaly_detectors") + path.WriteString("/") + path.WriteString(r.JobID) + path.WriteString("/") + path.WriteString("model_snapshots") + path.WriteString("/") + path.WriteString(r.SnapshotID) + path.WriteString("/") + path.WriteString("_upgrade") + + params = make(map[string]string) + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.WaitForCompletion != nil { + params["wait_for_completion"] = strconv.FormatBool(*r.WaitForCompletion) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLUpgradeJobSnapshot) WithContext(v context.Context) func(*MLUpgradeJobSnapshotRequest) { + return func(r *MLUpgradeJobSnapshotRequest) { + r.ctx = v + } +} + +// WithTimeout - how long should the api wait for the job to be opened and the old snapshot to be loaded.. +func (f MLUpgradeJobSnapshot) WithTimeout(v time.Duration) func(*MLUpgradeJobSnapshotRequest) { + return func(r *MLUpgradeJobSnapshotRequest) { + r.Timeout = v + } +} + +// WithWaitForCompletion - should the request wait until the task is complete before responding to the caller. default is false.. +func (f MLUpgradeJobSnapshot) WithWaitForCompletion(v bool) func(*MLUpgradeJobSnapshotRequest) { + return func(r *MLUpgradeJobSnapshotRequest) { + r.WaitForCompletion = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLUpgradeJobSnapshot) WithPretty() func(*MLUpgradeJobSnapshotRequest) { + return func(r *MLUpgradeJobSnapshotRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLUpgradeJobSnapshot) WithHuman() func(*MLUpgradeJobSnapshotRequest) { + return func(r *MLUpgradeJobSnapshotRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLUpgradeJobSnapshot) WithErrorTrace() func(*MLUpgradeJobSnapshotRequest) { + return func(r *MLUpgradeJobSnapshotRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLUpgradeJobSnapshot) WithFilterPath(v ...string) func(*MLUpgradeJobSnapshotRequest) { + return func(r *MLUpgradeJobSnapshotRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLUpgradeJobSnapshot) WithHeader(h map[string]string) func(*MLUpgradeJobSnapshotRequest) { + return func(r *MLUpgradeJobSnapshotRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLUpgradeJobSnapshot) WithOpaqueID(s string) func(*MLUpgradeJobSnapshotRequest) { + return func(r *MLUpgradeJobSnapshotRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.validate.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.validate.go new file mode 100644 index 00000000..ded4d9b0 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.validate.go @@ -0,0 +1,193 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newMLValidateFunc(t Transport) MLValidate { + return func(body io.Reader, o ...func(*MLValidateRequest)) (*Response, error) { + var r = MLValidateRequest{Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLValidate - Validates an anomaly detection job. +// +// See full documentation at https://www.elastic.co/guide/en/machine-learning/current/ml-jobs.html. +type MLValidate func(body io.Reader, o ...func(*MLValidateRequest)) (*Response, error) + +// MLValidateRequest configures the ML Validate API request. +type MLValidateRequest struct { + Body io.Reader + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLValidateRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(len("/_ml/anomaly_detectors/_validate")) + path.WriteString("/_ml/anomaly_detectors/_validate") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLValidate) WithContext(v context.Context) func(*MLValidateRequest) { + return func(r *MLValidateRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLValidate) WithPretty() func(*MLValidateRequest) { + return func(r *MLValidateRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLValidate) WithHuman() func(*MLValidateRequest) { + return func(r *MLValidateRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLValidate) WithErrorTrace() func(*MLValidateRequest) { + return func(r *MLValidateRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLValidate) WithFilterPath(v ...string) func(*MLValidateRequest) { + return func(r *MLValidateRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLValidate) WithHeader(h map[string]string) func(*MLValidateRequest) { + return func(r *MLValidateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLValidate) WithOpaqueID(s string) func(*MLValidateRequest) { + return func(r *MLValidateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.validate_detector.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.validate_detector.go new file mode 100644 index 00000000..e5225a73 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ml.validate_detector.go @@ -0,0 +1,193 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newMLValidateDetectorFunc(t Transport) MLValidateDetector { + return func(body io.Reader, o ...func(*MLValidateDetectorRequest)) (*Response, error) { + var r = MLValidateDetectorRequest{Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MLValidateDetector - Validates an anomaly detection detector. +// +// See full documentation at https://www.elastic.co/guide/en/machine-learning/current/ml-jobs.html. +type MLValidateDetector func(body io.Reader, o ...func(*MLValidateDetectorRequest)) (*Response, error) + +// MLValidateDetectorRequest configures the ML Validate Detector API request. +type MLValidateDetectorRequest struct { + Body io.Reader + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MLValidateDetectorRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(len("/_ml/anomaly_detectors/_validate/detector")) + path.WriteString("/_ml/anomaly_detectors/_validate/detector") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MLValidateDetector) WithContext(v context.Context) func(*MLValidateDetectorRequest) { + return func(r *MLValidateDetectorRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MLValidateDetector) WithPretty() func(*MLValidateDetectorRequest) { + return func(r *MLValidateDetectorRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MLValidateDetector) WithHuman() func(*MLValidateDetectorRequest) { + return func(r *MLValidateDetectorRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MLValidateDetector) WithErrorTrace() func(*MLValidateDetectorRequest) { + return func(r *MLValidateDetectorRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MLValidateDetector) WithFilterPath(v ...string) func(*MLValidateDetectorRequest) { + return func(r *MLValidateDetectorRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MLValidateDetector) WithHeader(h map[string]string) func(*MLValidateDetectorRequest) { + return func(r *MLValidateDetectorRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MLValidateDetector) WithOpaqueID(s string) func(*MLValidateDetectorRequest) { + return func(r *MLValidateDetectorRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.monitoring.bulk.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.monitoring.bulk.go new file mode 100644 index 00000000..27c3d403 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.monitoring.bulk.go @@ -0,0 +1,246 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newMonitoringBulkFunc(t Transport) MonitoringBulk { + return func(body io.Reader, o ...func(*MonitoringBulkRequest)) (*Response, error) { + var r = MonitoringBulkRequest{Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// MonitoringBulk - Used by the monitoring features to send monitoring data. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/monitor-elasticsearch-cluster.html. +type MonitoringBulk func(body io.Reader, o ...func(*MonitoringBulkRequest)) (*Response, error) + +// MonitoringBulkRequest configures the Monitoring Bulk API request. +type MonitoringBulkRequest struct { + DocumentType string + + Body io.Reader + + Interval string + SystemAPIVersion string + SystemID string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r MonitoringBulkRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_monitoring") + 1 + len(r.DocumentType) + 1 + len("bulk")) + path.WriteString("/") + path.WriteString("_monitoring") + if r.DocumentType != "" { + path.WriteString("/") + path.WriteString(r.DocumentType) + } + path.WriteString("/") + path.WriteString("bulk") + + params = make(map[string]string) + + if r.Interval != "" { + params["interval"] = r.Interval + } + + if r.SystemAPIVersion != "" { + params["system_api_version"] = r.SystemAPIVersion + } + + if r.SystemID != "" { + params["system_id"] = r.SystemID + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f MonitoringBulk) WithContext(v context.Context) func(*MonitoringBulkRequest) { + return func(r *MonitoringBulkRequest) { + r.ctx = v + } +} + +// WithDocumentType - default document type for items which don't provide one. +func (f MonitoringBulk) WithDocumentType(v string) func(*MonitoringBulkRequest) { + return func(r *MonitoringBulkRequest) { + r.DocumentType = v + } +} + +// WithInterval - collection interval (e.g., '10s' or '10000ms') of the payload. +func (f MonitoringBulk) WithInterval(v string) func(*MonitoringBulkRequest) { + return func(r *MonitoringBulkRequest) { + r.Interval = v + } +} + +// WithSystemAPIVersion - api version of the monitored system. +func (f MonitoringBulk) WithSystemAPIVersion(v string) func(*MonitoringBulkRequest) { + return func(r *MonitoringBulkRequest) { + r.SystemAPIVersion = v + } +} + +// WithSystemID - identifier of the monitored system. +func (f MonitoringBulk) WithSystemID(v string) func(*MonitoringBulkRequest) { + return func(r *MonitoringBulkRequest) { + r.SystemID = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f MonitoringBulk) WithPretty() func(*MonitoringBulkRequest) { + return func(r *MonitoringBulkRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f MonitoringBulk) WithHuman() func(*MonitoringBulkRequest) { + return func(r *MonitoringBulkRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f MonitoringBulk) WithErrorTrace() func(*MonitoringBulkRequest) { + return func(r *MonitoringBulkRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f MonitoringBulk) WithFilterPath(v ...string) func(*MonitoringBulkRequest) { + return func(r *MonitoringBulkRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f MonitoringBulk) WithHeader(h map[string]string) func(*MonitoringBulkRequest) { + return func(r *MonitoringBulkRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f MonitoringBulk) WithOpaqueID(s string) func(*MonitoringBulkRequest) { + return func(r *MonitoringBulkRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.open_point_in_time.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.open_point_in_time.go new file mode 100644 index 00000000..cab2a99f --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.open_point_in_time.go @@ -0,0 +1,258 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "errors" + "net/http" + "strconv" + "strings" +) + +func newOpenPointInTimeFunc(t Transport) OpenPointInTime { + return func(index []string, keep_alive string, o ...func(*OpenPointInTimeRequest)) (*Response, error) { + var r = OpenPointInTimeRequest{Index: index, KeepAlive: keep_alive} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// OpenPointInTime - Open a point in time that can be used in subsequent searches +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/point-in-time-api.html. +type OpenPointInTime func(index []string, keep_alive string, o ...func(*OpenPointInTimeRequest)) (*Response, error) + +// OpenPointInTimeRequest configures the Open Point In Time API request. +type OpenPointInTimeRequest struct { + Index []string + + ExpandWildcards string + IgnoreUnavailable *bool + KeepAlive string + Preference string + Routing string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r OpenPointInTimeRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + if len(r.Index) == 0 { + return nil, errors.New("index is required and cannot be nil or empty") + } + + path.Grow(1 + len(strings.Join(r.Index, ",")) + 1 + len("_pit")) + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + path.WriteString("/") + path.WriteString("_pit") + + params = make(map[string]string) + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if r.IgnoreUnavailable != nil { + params["ignore_unavailable"] = strconv.FormatBool(*r.IgnoreUnavailable) + } + + if r.KeepAlive != "" { + params["keep_alive"] = r.KeepAlive + } + + if r.Preference != "" { + params["preference"] = r.Preference + } + + if r.Routing != "" { + params["routing"] = r.Routing + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f OpenPointInTime) WithContext(v context.Context) func(*OpenPointInTimeRequest) { + return func(r *OpenPointInTimeRequest) { + r.ctx = v + } +} + +// WithExpandWildcards - whether to expand wildcard expression to concrete indices that are open, closed or both.. +func (f OpenPointInTime) WithExpandWildcards(v string) func(*OpenPointInTimeRequest) { + return func(r *OpenPointInTimeRequest) { + r.ExpandWildcards = v + } +} + +// WithIgnoreUnavailable - whether specified concrete indices should be ignored when unavailable (missing or closed). +func (f OpenPointInTime) WithIgnoreUnavailable(v bool) func(*OpenPointInTimeRequest) { + return func(r *OpenPointInTimeRequest) { + r.IgnoreUnavailable = &v + } +} + +// WithKeepAlive - specific the time to live for the point in time. +func (f OpenPointInTime) WithKeepAlive(v string) func(*OpenPointInTimeRequest) { + return func(r *OpenPointInTimeRequest) { + r.KeepAlive = v + } +} + +// WithPreference - specify the node or shard the operation should be performed on (default: random). +func (f OpenPointInTime) WithPreference(v string) func(*OpenPointInTimeRequest) { + return func(r *OpenPointInTimeRequest) { + r.Preference = v + } +} + +// WithRouting - specific routing value. +func (f OpenPointInTime) WithRouting(v string) func(*OpenPointInTimeRequest) { + return func(r *OpenPointInTimeRequest) { + r.Routing = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f OpenPointInTime) WithPretty() func(*OpenPointInTimeRequest) { + return func(r *OpenPointInTimeRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f OpenPointInTime) WithHuman() func(*OpenPointInTimeRequest) { + return func(r *OpenPointInTimeRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f OpenPointInTime) WithErrorTrace() func(*OpenPointInTimeRequest) { + return func(r *OpenPointInTimeRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f OpenPointInTime) WithFilterPath(v ...string) func(*OpenPointInTimeRequest) { + return func(r *OpenPointInTimeRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f OpenPointInTime) WithHeader(h map[string]string) func(*OpenPointInTimeRequest) { + return func(r *OpenPointInTimeRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f OpenPointInTime) WithOpaqueID(s string) func(*OpenPointInTimeRequest) { + return func(r *OpenPointInTimeRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.rollup.delete_job.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.rollup.delete_job.go new file mode 100644 index 00000000..3e461f2d --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.rollup.delete_job.go @@ -0,0 +1,195 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newRollupDeleteJobFunc(t Transport) RollupDeleteJob { + return func(id string, o ...func(*RollupDeleteJobRequest)) (*Response, error) { + var r = RollupDeleteJobRequest{JobID: id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// RollupDeleteJob - Deletes an existing rollup job. +// +// This API is experimental. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/rollup-delete-job.html. +type RollupDeleteJob func(id string, o ...func(*RollupDeleteJobRequest)) (*Response, error) + +// RollupDeleteJobRequest configures the Rollup Delete Job API request. +type RollupDeleteJobRequest struct { + JobID string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r RollupDeleteJobRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + path.Grow(1 + len("_rollup") + 1 + len("job") + 1 + len(r.JobID)) + path.WriteString("/") + path.WriteString("_rollup") + path.WriteString("/") + path.WriteString("job") + path.WriteString("/") + path.WriteString(r.JobID) + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f RollupDeleteJob) WithContext(v context.Context) func(*RollupDeleteJobRequest) { + return func(r *RollupDeleteJobRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f RollupDeleteJob) WithPretty() func(*RollupDeleteJobRequest) { + return func(r *RollupDeleteJobRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f RollupDeleteJob) WithHuman() func(*RollupDeleteJobRequest) { + return func(r *RollupDeleteJobRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f RollupDeleteJob) WithErrorTrace() func(*RollupDeleteJobRequest) { + return func(r *RollupDeleteJobRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f RollupDeleteJob) WithFilterPath(v ...string) func(*RollupDeleteJobRequest) { + return func(r *RollupDeleteJobRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f RollupDeleteJob) WithHeader(h map[string]string) func(*RollupDeleteJobRequest) { + return func(r *RollupDeleteJobRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f RollupDeleteJob) WithOpaqueID(s string) func(*RollupDeleteJobRequest) { + return func(r *RollupDeleteJobRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.rollup.get_jobs.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.rollup.get_jobs.go new file mode 100644 index 00000000..957b1a74 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.rollup.get_jobs.go @@ -0,0 +1,204 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newRollupGetJobsFunc(t Transport) RollupGetJobs { + return func(o ...func(*RollupGetJobsRequest)) (*Response, error) { + var r = RollupGetJobsRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// RollupGetJobs - Retrieves the configuration, stats, and status of rollup jobs. +// +// This API is experimental. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/rollup-get-job.html. +type RollupGetJobs func(o ...func(*RollupGetJobsRequest)) (*Response, error) + +// RollupGetJobsRequest configures the Rollup Get Jobs API request. +type RollupGetJobsRequest struct { + JobID string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r RollupGetJobsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_rollup") + 1 + len("job") + 1 + len(r.JobID)) + path.WriteString("/") + path.WriteString("_rollup") + path.WriteString("/") + path.WriteString("job") + if r.JobID != "" { + path.WriteString("/") + path.WriteString(r.JobID) + } + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f RollupGetJobs) WithContext(v context.Context) func(*RollupGetJobsRequest) { + return func(r *RollupGetJobsRequest) { + r.ctx = v + } +} + +// WithJobID - the ID of the job(s) to fetch. accepts glob patterns, or left blank for all jobs. +func (f RollupGetJobs) WithJobID(v string) func(*RollupGetJobsRequest) { + return func(r *RollupGetJobsRequest) { + r.JobID = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f RollupGetJobs) WithPretty() func(*RollupGetJobsRequest) { + return func(r *RollupGetJobsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f RollupGetJobs) WithHuman() func(*RollupGetJobsRequest) { + return func(r *RollupGetJobsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f RollupGetJobs) WithErrorTrace() func(*RollupGetJobsRequest) { + return func(r *RollupGetJobsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f RollupGetJobs) WithFilterPath(v ...string) func(*RollupGetJobsRequest) { + return func(r *RollupGetJobsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f RollupGetJobs) WithHeader(h map[string]string) func(*RollupGetJobsRequest) { + return func(r *RollupGetJobsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f RollupGetJobs) WithOpaqueID(s string) func(*RollupGetJobsRequest) { + return func(r *RollupGetJobsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.rollup.get_rollup_caps.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.rollup.get_rollup_caps.go new file mode 100644 index 00000000..4d5c1403 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.rollup.get_rollup_caps.go @@ -0,0 +1,204 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newRollupGetRollupCapsFunc(t Transport) RollupGetRollupCaps { + return func(o ...func(*RollupGetRollupCapsRequest)) (*Response, error) { + var r = RollupGetRollupCapsRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// RollupGetRollupCaps - Returns the capabilities of any rollup jobs that have been configured for a specific index or index pattern. +// +// This API is experimental. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/rollup-get-rollup-caps.html. +type RollupGetRollupCaps func(o ...func(*RollupGetRollupCapsRequest)) (*Response, error) + +// RollupGetRollupCapsRequest configures the Rollup Get Rollup Caps API request. +type RollupGetRollupCapsRequest struct { + Index string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r RollupGetRollupCapsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_rollup") + 1 + len("data") + 1 + len(r.Index)) + path.WriteString("/") + path.WriteString("_rollup") + path.WriteString("/") + path.WriteString("data") + if r.Index != "" { + path.WriteString("/") + path.WriteString(r.Index) + } + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f RollupGetRollupCaps) WithContext(v context.Context) func(*RollupGetRollupCapsRequest) { + return func(r *RollupGetRollupCapsRequest) { + r.ctx = v + } +} + +// WithIndex - the ID of the index to check rollup capabilities on, or left blank for all jobs. +func (f RollupGetRollupCaps) WithIndex(v string) func(*RollupGetRollupCapsRequest) { + return func(r *RollupGetRollupCapsRequest) { + r.Index = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f RollupGetRollupCaps) WithPretty() func(*RollupGetRollupCapsRequest) { + return func(r *RollupGetRollupCapsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f RollupGetRollupCaps) WithHuman() func(*RollupGetRollupCapsRequest) { + return func(r *RollupGetRollupCapsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f RollupGetRollupCaps) WithErrorTrace() func(*RollupGetRollupCapsRequest) { + return func(r *RollupGetRollupCapsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f RollupGetRollupCaps) WithFilterPath(v ...string) func(*RollupGetRollupCapsRequest) { + return func(r *RollupGetRollupCapsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f RollupGetRollupCaps) WithHeader(h map[string]string) func(*RollupGetRollupCapsRequest) { + return func(r *RollupGetRollupCapsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f RollupGetRollupCaps) WithOpaqueID(s string) func(*RollupGetRollupCapsRequest) { + return func(r *RollupGetRollupCapsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.rollup.get_rollup_index_caps.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.rollup.get_rollup_index_caps.go new file mode 100644 index 00000000..caf026e6 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.rollup.get_rollup_index_caps.go @@ -0,0 +1,195 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newRollupGetRollupIndexCapsFunc(t Transport) RollupGetRollupIndexCaps { + return func(index string, o ...func(*RollupGetRollupIndexCapsRequest)) (*Response, error) { + var r = RollupGetRollupIndexCapsRequest{Index: index} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// RollupGetRollupIndexCaps - Returns the rollup capabilities of all jobs inside of a rollup index (e.g. the index where rollup data is stored). +// +// This API is experimental. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/rollup-get-rollup-index-caps.html. +type RollupGetRollupIndexCaps func(index string, o ...func(*RollupGetRollupIndexCapsRequest)) (*Response, error) + +// RollupGetRollupIndexCapsRequest configures the Rollup Get Rollup Index Caps API request. +type RollupGetRollupIndexCapsRequest struct { + Index string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r RollupGetRollupIndexCapsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len(r.Index) + 1 + len("_rollup") + 1 + len("data")) + path.WriteString("/") + path.WriteString(r.Index) + path.WriteString("/") + path.WriteString("_rollup") + path.WriteString("/") + path.WriteString("data") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f RollupGetRollupIndexCaps) WithContext(v context.Context) func(*RollupGetRollupIndexCapsRequest) { + return func(r *RollupGetRollupIndexCapsRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f RollupGetRollupIndexCaps) WithPretty() func(*RollupGetRollupIndexCapsRequest) { + return func(r *RollupGetRollupIndexCapsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f RollupGetRollupIndexCaps) WithHuman() func(*RollupGetRollupIndexCapsRequest) { + return func(r *RollupGetRollupIndexCapsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f RollupGetRollupIndexCaps) WithErrorTrace() func(*RollupGetRollupIndexCapsRequest) { + return func(r *RollupGetRollupIndexCapsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f RollupGetRollupIndexCaps) WithFilterPath(v ...string) func(*RollupGetRollupIndexCapsRequest) { + return func(r *RollupGetRollupIndexCapsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f RollupGetRollupIndexCaps) WithHeader(h map[string]string) func(*RollupGetRollupIndexCapsRequest) { + return func(r *RollupGetRollupIndexCapsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f RollupGetRollupIndexCaps) WithOpaqueID(s string) func(*RollupGetRollupIndexCapsRequest) { + return func(r *RollupGetRollupIndexCapsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.rollup.put_job.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.rollup.put_job.go new file mode 100644 index 00000000..2143892f --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.rollup.put_job.go @@ -0,0 +1,202 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newRollupPutJobFunc(t Transport) RollupPutJob { + return func(id string, body io.Reader, o ...func(*RollupPutJobRequest)) (*Response, error) { + var r = RollupPutJobRequest{JobID: id, Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// RollupPutJob - Creates a rollup job. +// +// This API is experimental. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/rollup-put-job.html. +type RollupPutJob func(id string, body io.Reader, o ...func(*RollupPutJobRequest)) (*Response, error) + +// RollupPutJobRequest configures the Rollup Put Job API request. +type RollupPutJobRequest struct { + JobID string + + Body io.Reader + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r RollupPutJobRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(1 + len("_rollup") + 1 + len("job") + 1 + len(r.JobID)) + path.WriteString("/") + path.WriteString("_rollup") + path.WriteString("/") + path.WriteString("job") + path.WriteString("/") + path.WriteString(r.JobID) + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f RollupPutJob) WithContext(v context.Context) func(*RollupPutJobRequest) { + return func(r *RollupPutJobRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f RollupPutJob) WithPretty() func(*RollupPutJobRequest) { + return func(r *RollupPutJobRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f RollupPutJob) WithHuman() func(*RollupPutJobRequest) { + return func(r *RollupPutJobRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f RollupPutJob) WithErrorTrace() func(*RollupPutJobRequest) { + return func(r *RollupPutJobRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f RollupPutJob) WithFilterPath(v ...string) func(*RollupPutJobRequest) { + return func(r *RollupPutJobRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f RollupPutJob) WithHeader(h map[string]string) func(*RollupPutJobRequest) { + return func(r *RollupPutJobRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f RollupPutJob) WithOpaqueID(s string) func(*RollupPutJobRequest) { + return func(r *RollupPutJobRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.rollup.rollup.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.rollup.rollup.go new file mode 100644 index 00000000..c8d8cb85 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.rollup.rollup.go @@ -0,0 +1,204 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newRollupRollupFunc(t Transport) RollupRollup { + return func(index string, body io.Reader, rollup_index string, o ...func(*RollupRollupRequest)) (*Response, error) { + var r = RollupRollupRequest{Index: index, Body: body, RollupIndex: rollup_index} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// RollupRollup - Rollup an index +// +// This API is experimental. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/xpack-rollup.html. +type RollupRollup func(index string, body io.Reader, rollup_index string, o ...func(*RollupRollupRequest)) (*Response, error) + +// RollupRollupRequest configures the Rollup Rollup API request. +type RollupRollupRequest struct { + Index string + + Body io.Reader + + RollupIndex string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r RollupRollupRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len(r.Index) + 1 + len("_rollup") + 1 + len(r.RollupIndex)) + path.WriteString("/") + path.WriteString(r.Index) + path.WriteString("/") + path.WriteString("_rollup") + path.WriteString("/") + path.WriteString(r.RollupIndex) + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f RollupRollup) WithContext(v context.Context) func(*RollupRollupRequest) { + return func(r *RollupRollupRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f RollupRollup) WithPretty() func(*RollupRollupRequest) { + return func(r *RollupRollupRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f RollupRollup) WithHuman() func(*RollupRollupRequest) { + return func(r *RollupRollupRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f RollupRollup) WithErrorTrace() func(*RollupRollupRequest) { + return func(r *RollupRollupRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f RollupRollup) WithFilterPath(v ...string) func(*RollupRollupRequest) { + return func(r *RollupRollupRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f RollupRollup) WithHeader(h map[string]string) func(*RollupRollupRequest) { + return func(r *RollupRollupRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f RollupRollup) WithOpaqueID(s string) func(*RollupRollupRequest) { + return func(r *RollupRollupRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.rollup.rollup_search.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.rollup.rollup_search.go new file mode 100644 index 00000000..96fb4ccb --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.rollup.rollup_search.go @@ -0,0 +1,243 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "errors" + "io" + "net/http" + "strconv" + "strings" +) + +func newRollupRollupSearchFunc(t Transport) RollupRollupSearch { + return func(index []string, body io.Reader, o ...func(*RollupRollupSearchRequest)) (*Response, error) { + var r = RollupRollupSearchRequest{Index: index, Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// RollupRollupSearch - Enables searching rolled-up data using the standard query DSL. +// +// This API is experimental. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/rollup-search.html. +type RollupRollupSearch func(index []string, body io.Reader, o ...func(*RollupRollupSearchRequest)) (*Response, error) + +// RollupRollupSearchRequest configures the Rollup Rollup Search API request. +type RollupRollupSearchRequest struct { + Index []string + DocumentType string + + Body io.Reader + + RestTotalHitsAsInt *bool + TypedKeys *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r RollupRollupSearchRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + if len(r.Index) == 0 { + return nil, errors.New("index is required and cannot be nil or empty") + } + + path.Grow(1 + len(strings.Join(r.Index, ",")) + 1 + len(r.DocumentType) + 1 + len("_rollup_search")) + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + if r.DocumentType != "" { + path.WriteString("/") + path.WriteString(r.DocumentType) + } + path.WriteString("/") + path.WriteString("_rollup_search") + + params = make(map[string]string) + + if r.RestTotalHitsAsInt != nil { + params["rest_total_hits_as_int"] = strconv.FormatBool(*r.RestTotalHitsAsInt) + } + + if r.TypedKeys != nil { + params["typed_keys"] = strconv.FormatBool(*r.TypedKeys) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f RollupRollupSearch) WithContext(v context.Context) func(*RollupRollupSearchRequest) { + return func(r *RollupRollupSearchRequest) { + r.ctx = v + } +} + +// WithDocumentType - the doc type inside the index. +func (f RollupRollupSearch) WithDocumentType(v string) func(*RollupRollupSearchRequest) { + return func(r *RollupRollupSearchRequest) { + r.DocumentType = v + } +} + +// WithRestTotalHitsAsInt - indicates whether hits.total should be rendered as an integer or an object in the rest search response. +func (f RollupRollupSearch) WithRestTotalHitsAsInt(v bool) func(*RollupRollupSearchRequest) { + return func(r *RollupRollupSearchRequest) { + r.RestTotalHitsAsInt = &v + } +} + +// WithTypedKeys - specify whether aggregation and suggester names should be prefixed by their respective types in the response. +func (f RollupRollupSearch) WithTypedKeys(v bool) func(*RollupRollupSearchRequest) { + return func(r *RollupRollupSearchRequest) { + r.TypedKeys = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f RollupRollupSearch) WithPretty() func(*RollupRollupSearchRequest) { + return func(r *RollupRollupSearchRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f RollupRollupSearch) WithHuman() func(*RollupRollupSearchRequest) { + return func(r *RollupRollupSearchRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f RollupRollupSearch) WithErrorTrace() func(*RollupRollupSearchRequest) { + return func(r *RollupRollupSearchRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f RollupRollupSearch) WithFilterPath(v ...string) func(*RollupRollupSearchRequest) { + return func(r *RollupRollupSearchRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f RollupRollupSearch) WithHeader(h map[string]string) func(*RollupRollupSearchRequest) { + return func(r *RollupRollupSearchRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f RollupRollupSearch) WithOpaqueID(s string) func(*RollupRollupSearchRequest) { + return func(r *RollupRollupSearchRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.rollup.start_job.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.rollup.start_job.go new file mode 100644 index 00000000..27b32b2b --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.rollup.start_job.go @@ -0,0 +1,197 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newRollupStartJobFunc(t Transport) RollupStartJob { + return func(id string, o ...func(*RollupStartJobRequest)) (*Response, error) { + var r = RollupStartJobRequest{JobID: id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// RollupStartJob - Starts an existing, stopped rollup job. +// +// This API is experimental. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/rollup-start-job.html. +type RollupStartJob func(id string, o ...func(*RollupStartJobRequest)) (*Response, error) + +// RollupStartJobRequest configures the Rollup Start Job API request. +type RollupStartJobRequest struct { + JobID string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r RollupStartJobRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_rollup") + 1 + len("job") + 1 + len(r.JobID) + 1 + len("_start")) + path.WriteString("/") + path.WriteString("_rollup") + path.WriteString("/") + path.WriteString("job") + path.WriteString("/") + path.WriteString(r.JobID) + path.WriteString("/") + path.WriteString("_start") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f RollupStartJob) WithContext(v context.Context) func(*RollupStartJobRequest) { + return func(r *RollupStartJobRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f RollupStartJob) WithPretty() func(*RollupStartJobRequest) { + return func(r *RollupStartJobRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f RollupStartJob) WithHuman() func(*RollupStartJobRequest) { + return func(r *RollupStartJobRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f RollupStartJob) WithErrorTrace() func(*RollupStartJobRequest) { + return func(r *RollupStartJobRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f RollupStartJob) WithFilterPath(v ...string) func(*RollupStartJobRequest) { + return func(r *RollupStartJobRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f RollupStartJob) WithHeader(h map[string]string) func(*RollupStartJobRequest) { + return func(r *RollupStartJobRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f RollupStartJob) WithOpaqueID(s string) func(*RollupStartJobRequest) { + return func(r *RollupStartJobRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.rollup.stop_job.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.rollup.stop_job.go new file mode 100644 index 00000000..c6a92456 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.rollup.stop_job.go @@ -0,0 +1,224 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" + "time" +) + +func newRollupStopJobFunc(t Transport) RollupStopJob { + return func(id string, o ...func(*RollupStopJobRequest)) (*Response, error) { + var r = RollupStopJobRequest{JobID: id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// RollupStopJob - Stops an existing, started rollup job. +// +// This API is experimental. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/rollup-stop-job.html. +type RollupStopJob func(id string, o ...func(*RollupStopJobRequest)) (*Response, error) + +// RollupStopJobRequest configures the Rollup Stop Job API request. +type RollupStopJobRequest struct { + JobID string + + Timeout time.Duration + WaitForCompletion *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r RollupStopJobRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_rollup") + 1 + len("job") + 1 + len(r.JobID) + 1 + len("_stop")) + path.WriteString("/") + path.WriteString("_rollup") + path.WriteString("/") + path.WriteString("job") + path.WriteString("/") + path.WriteString(r.JobID) + path.WriteString("/") + path.WriteString("_stop") + + params = make(map[string]string) + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.WaitForCompletion != nil { + params["wait_for_completion"] = strconv.FormatBool(*r.WaitForCompletion) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f RollupStopJob) WithContext(v context.Context) func(*RollupStopJobRequest) { + return func(r *RollupStopJobRequest) { + r.ctx = v + } +} + +// WithTimeout - block for (at maximum) the specified duration while waiting for the job to stop. defaults to 30s.. +func (f RollupStopJob) WithTimeout(v time.Duration) func(*RollupStopJobRequest) { + return func(r *RollupStopJobRequest) { + r.Timeout = v + } +} + +// WithWaitForCompletion - true if the api should block until the job has fully stopped, false if should be executed async. defaults to false.. +func (f RollupStopJob) WithWaitForCompletion(v bool) func(*RollupStopJobRequest) { + return func(r *RollupStopJobRequest) { + r.WaitForCompletion = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f RollupStopJob) WithPretty() func(*RollupStopJobRequest) { + return func(r *RollupStopJobRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f RollupStopJob) WithHuman() func(*RollupStopJobRequest) { + return func(r *RollupStopJobRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f RollupStopJob) WithErrorTrace() func(*RollupStopJobRequest) { + return func(r *RollupStopJobRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f RollupStopJob) WithFilterPath(v ...string) func(*RollupStopJobRequest) { + return func(r *RollupStopJobRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f RollupStopJob) WithHeader(h map[string]string) func(*RollupStopJobRequest) { + return func(r *RollupStopJobRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f RollupStopJob) WithOpaqueID(s string) func(*RollupStopJobRequest) { + return func(r *RollupStopJobRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.searchable_snapshots.cache_stats.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.searchable_snapshots.cache_stats.go new file mode 100644 index 00000000..a21822af --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.searchable_snapshots.cache_stats.go @@ -0,0 +1,206 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newSearchableSnapshotsCacheStatsFunc(t Transport) SearchableSnapshotsCacheStats { + return func(o ...func(*SearchableSnapshotsCacheStatsRequest)) (*Response, error) { + var r = SearchableSnapshotsCacheStatsRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SearchableSnapshotsCacheStats - Retrieve node-level cache statistics about searchable snapshots. +// +// This API is experimental. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/searchable-snapshots-apis.html. +type SearchableSnapshotsCacheStats func(o ...func(*SearchableSnapshotsCacheStatsRequest)) (*Response, error) + +// SearchableSnapshotsCacheStatsRequest configures the Searchable Snapshots Cache Stats API request. +type SearchableSnapshotsCacheStatsRequest struct { + NodeID []string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SearchableSnapshotsCacheStatsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_searchable_snapshots") + 1 + len(strings.Join(r.NodeID, ",")) + 1 + len("cache") + 1 + len("stats")) + path.WriteString("/") + path.WriteString("_searchable_snapshots") + if len(r.NodeID) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.NodeID, ",")) + } + path.WriteString("/") + path.WriteString("cache") + path.WriteString("/") + path.WriteString("stats") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SearchableSnapshotsCacheStats) WithContext(v context.Context) func(*SearchableSnapshotsCacheStatsRequest) { + return func(r *SearchableSnapshotsCacheStatsRequest) { + r.ctx = v + } +} + +// WithNodeID - a list of node ids or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes. +func (f SearchableSnapshotsCacheStats) WithNodeID(v ...string) func(*SearchableSnapshotsCacheStatsRequest) { + return func(r *SearchableSnapshotsCacheStatsRequest) { + r.NodeID = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SearchableSnapshotsCacheStats) WithPretty() func(*SearchableSnapshotsCacheStatsRequest) { + return func(r *SearchableSnapshotsCacheStatsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SearchableSnapshotsCacheStats) WithHuman() func(*SearchableSnapshotsCacheStatsRequest) { + return func(r *SearchableSnapshotsCacheStatsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SearchableSnapshotsCacheStats) WithErrorTrace() func(*SearchableSnapshotsCacheStatsRequest) { + return func(r *SearchableSnapshotsCacheStatsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SearchableSnapshotsCacheStats) WithFilterPath(v ...string) func(*SearchableSnapshotsCacheStatsRequest) { + return func(r *SearchableSnapshotsCacheStatsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SearchableSnapshotsCacheStats) WithHeader(h map[string]string) func(*SearchableSnapshotsCacheStatsRequest) { + return func(r *SearchableSnapshotsCacheStatsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SearchableSnapshotsCacheStats) WithOpaqueID(s string) func(*SearchableSnapshotsCacheStatsRequest) { + return func(r *SearchableSnapshotsCacheStatsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.searchable_snapshots.clear_cache.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.searchable_snapshots.clear_cache.go new file mode 100644 index 00000000..9f826051 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.searchable_snapshots.clear_cache.go @@ -0,0 +1,248 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newSearchableSnapshotsClearCacheFunc(t Transport) SearchableSnapshotsClearCache { + return func(o ...func(*SearchableSnapshotsClearCacheRequest)) (*Response, error) { + var r = SearchableSnapshotsClearCacheRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SearchableSnapshotsClearCache - Clear the cache of searchable snapshots. +// +// This API is experimental. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/searchable-snapshots-apis.html. +type SearchableSnapshotsClearCache func(o ...func(*SearchableSnapshotsClearCacheRequest)) (*Response, error) + +// SearchableSnapshotsClearCacheRequest configures the Searchable Snapshots Clear Cache API request. +type SearchableSnapshotsClearCacheRequest struct { + Index []string + + AllowNoIndices *bool + ExpandWildcards string + IgnoreUnavailable *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SearchableSnapshotsClearCacheRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len(strings.Join(r.Index, ",")) + 1 + len("_searchable_snapshots") + 1 + len("cache") + 1 + len("clear")) + if len(r.Index) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + } + path.WriteString("/") + path.WriteString("_searchable_snapshots") + path.WriteString("/") + path.WriteString("cache") + path.WriteString("/") + path.WriteString("clear") + + params = make(map[string]string) + + if r.AllowNoIndices != nil { + params["allow_no_indices"] = strconv.FormatBool(*r.AllowNoIndices) + } + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if r.IgnoreUnavailable != nil { + params["ignore_unavailable"] = strconv.FormatBool(*r.IgnoreUnavailable) + } + + if len(r.Index) > 0 { + params["index"] = strings.Join(r.Index, ",") + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SearchableSnapshotsClearCache) WithContext(v context.Context) func(*SearchableSnapshotsClearCacheRequest) { + return func(r *SearchableSnapshotsClearCacheRequest) { + r.ctx = v + } +} + +// WithIndex - a list of index names. +func (f SearchableSnapshotsClearCache) WithIndex(v ...string) func(*SearchableSnapshotsClearCacheRequest) { + return func(r *SearchableSnapshotsClearCacheRequest) { + r.Index = v + } +} + +// WithAllowNoIndices - whether to ignore if a wildcard indices expression resolves into no concrete indices. (this includes `_all` string or when no indices have been specified). +func (f SearchableSnapshotsClearCache) WithAllowNoIndices(v bool) func(*SearchableSnapshotsClearCacheRequest) { + return func(r *SearchableSnapshotsClearCacheRequest) { + r.AllowNoIndices = &v + } +} + +// WithExpandWildcards - whether to expand wildcard expression to concrete indices that are open, closed or both.. +func (f SearchableSnapshotsClearCache) WithExpandWildcards(v string) func(*SearchableSnapshotsClearCacheRequest) { + return func(r *SearchableSnapshotsClearCacheRequest) { + r.ExpandWildcards = v + } +} + +// WithIgnoreUnavailable - whether specified concrete indices should be ignored when unavailable (missing or closed). +func (f SearchableSnapshotsClearCache) WithIgnoreUnavailable(v bool) func(*SearchableSnapshotsClearCacheRequest) { + return func(r *SearchableSnapshotsClearCacheRequest) { + r.IgnoreUnavailable = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SearchableSnapshotsClearCache) WithPretty() func(*SearchableSnapshotsClearCacheRequest) { + return func(r *SearchableSnapshotsClearCacheRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SearchableSnapshotsClearCache) WithHuman() func(*SearchableSnapshotsClearCacheRequest) { + return func(r *SearchableSnapshotsClearCacheRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SearchableSnapshotsClearCache) WithErrorTrace() func(*SearchableSnapshotsClearCacheRequest) { + return func(r *SearchableSnapshotsClearCacheRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SearchableSnapshotsClearCache) WithFilterPath(v ...string) func(*SearchableSnapshotsClearCacheRequest) { + return func(r *SearchableSnapshotsClearCacheRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SearchableSnapshotsClearCache) WithHeader(h map[string]string) func(*SearchableSnapshotsClearCacheRequest) { + return func(r *SearchableSnapshotsClearCacheRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SearchableSnapshotsClearCache) WithOpaqueID(s string) func(*SearchableSnapshotsClearCacheRequest) { + return func(r *SearchableSnapshotsClearCacheRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.searchable_snapshots.mount.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.searchable_snapshots.mount.go new file mode 100644 index 00000000..38a90839 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.searchable_snapshots.mount.go @@ -0,0 +1,242 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" + "time" +) + +func newSearchableSnapshotsMountFunc(t Transport) SearchableSnapshotsMount { + return func(repository string, snapshot string, body io.Reader, o ...func(*SearchableSnapshotsMountRequest)) (*Response, error) { + var r = SearchableSnapshotsMountRequest{Repository: repository, Snapshot: snapshot, Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SearchableSnapshotsMount - Mount a snapshot as a searchable index. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/searchable-snapshots-api-mount-snapshot.html. +type SearchableSnapshotsMount func(repository string, snapshot string, body io.Reader, o ...func(*SearchableSnapshotsMountRequest)) (*Response, error) + +// SearchableSnapshotsMountRequest configures the Searchable Snapshots Mount API request. +type SearchableSnapshotsMountRequest struct { + Body io.Reader + + Repository string + Snapshot string + + MasterTimeout time.Duration + Storage string + WaitForCompletion *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SearchableSnapshotsMountRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_snapshot") + 1 + len(r.Repository) + 1 + len(r.Snapshot) + 1 + len("_mount")) + path.WriteString("/") + path.WriteString("_snapshot") + path.WriteString("/") + path.WriteString(r.Repository) + path.WriteString("/") + path.WriteString(r.Snapshot) + path.WriteString("/") + path.WriteString("_mount") + + params = make(map[string]string) + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Storage != "" { + params["storage"] = r.Storage + } + + if r.WaitForCompletion != nil { + params["wait_for_completion"] = strconv.FormatBool(*r.WaitForCompletion) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SearchableSnapshotsMount) WithContext(v context.Context) func(*SearchableSnapshotsMountRequest) { + return func(r *SearchableSnapshotsMountRequest) { + r.ctx = v + } +} + +// WithMasterTimeout - explicit operation timeout for connection to master node. +func (f SearchableSnapshotsMount) WithMasterTimeout(v time.Duration) func(*SearchableSnapshotsMountRequest) { + return func(r *SearchableSnapshotsMountRequest) { + r.MasterTimeout = v + } +} + +// WithStorage - selects the kind of local storage used to accelerate searches. experimental, and defaults to `full_copy`. +func (f SearchableSnapshotsMount) WithStorage(v string) func(*SearchableSnapshotsMountRequest) { + return func(r *SearchableSnapshotsMountRequest) { + r.Storage = v + } +} + +// WithWaitForCompletion - should this request wait until the operation has completed before returning. +func (f SearchableSnapshotsMount) WithWaitForCompletion(v bool) func(*SearchableSnapshotsMountRequest) { + return func(r *SearchableSnapshotsMountRequest) { + r.WaitForCompletion = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SearchableSnapshotsMount) WithPretty() func(*SearchableSnapshotsMountRequest) { + return func(r *SearchableSnapshotsMountRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SearchableSnapshotsMount) WithHuman() func(*SearchableSnapshotsMountRequest) { + return func(r *SearchableSnapshotsMountRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SearchableSnapshotsMount) WithErrorTrace() func(*SearchableSnapshotsMountRequest) { + return func(r *SearchableSnapshotsMountRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SearchableSnapshotsMount) WithFilterPath(v ...string) func(*SearchableSnapshotsMountRequest) { + return func(r *SearchableSnapshotsMountRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SearchableSnapshotsMount) WithHeader(h map[string]string) func(*SearchableSnapshotsMountRequest) { + return func(r *SearchableSnapshotsMountRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SearchableSnapshotsMount) WithOpaqueID(s string) func(*SearchableSnapshotsMountRequest) { + return func(r *SearchableSnapshotsMountRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.searchable_snapshots.repository_stats.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.searchable_snapshots.repository_stats.go new file mode 100644 index 00000000..1ea97091 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.searchable_snapshots.repository_stats.go @@ -0,0 +1,195 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newSearchableSnapshotsRepositoryStatsFunc(t Transport) SearchableSnapshotsRepositoryStats { + return func(repository string, o ...func(*SearchableSnapshotsRepositoryStatsRequest)) (*Response, error) { + var r = SearchableSnapshotsRepositoryStatsRequest{Repository: repository} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SearchableSnapshotsRepositoryStats - DEPRECATED: This API is replaced by the Repositories Metering API. +// +// This API is experimental. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/searchable-snapshots-apis.html. +type SearchableSnapshotsRepositoryStats func(repository string, o ...func(*SearchableSnapshotsRepositoryStatsRequest)) (*Response, error) + +// SearchableSnapshotsRepositoryStatsRequest configures the Searchable Snapshots Repository Stats API request. +type SearchableSnapshotsRepositoryStatsRequest struct { + Repository string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SearchableSnapshotsRepositoryStatsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_snapshot") + 1 + len(r.Repository) + 1 + len("_stats")) + path.WriteString("/") + path.WriteString("_snapshot") + path.WriteString("/") + path.WriteString(r.Repository) + path.WriteString("/") + path.WriteString("_stats") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SearchableSnapshotsRepositoryStats) WithContext(v context.Context) func(*SearchableSnapshotsRepositoryStatsRequest) { + return func(r *SearchableSnapshotsRepositoryStatsRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SearchableSnapshotsRepositoryStats) WithPretty() func(*SearchableSnapshotsRepositoryStatsRequest) { + return func(r *SearchableSnapshotsRepositoryStatsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SearchableSnapshotsRepositoryStats) WithHuman() func(*SearchableSnapshotsRepositoryStatsRequest) { + return func(r *SearchableSnapshotsRepositoryStatsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SearchableSnapshotsRepositoryStats) WithErrorTrace() func(*SearchableSnapshotsRepositoryStatsRequest) { + return func(r *SearchableSnapshotsRepositoryStatsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SearchableSnapshotsRepositoryStats) WithFilterPath(v ...string) func(*SearchableSnapshotsRepositoryStatsRequest) { + return func(r *SearchableSnapshotsRepositoryStatsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SearchableSnapshotsRepositoryStats) WithHeader(h map[string]string) func(*SearchableSnapshotsRepositoryStatsRequest) { + return func(r *SearchableSnapshotsRepositoryStatsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SearchableSnapshotsRepositoryStats) WithOpaqueID(s string) func(*SearchableSnapshotsRepositoryStatsRequest) { + return func(r *SearchableSnapshotsRepositoryStatsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.searchable_snapshots.stats.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.searchable_snapshots.stats.go new file mode 100644 index 00000000..c11f19a5 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.searchable_snapshots.stats.go @@ -0,0 +1,215 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newSearchableSnapshotsStatsFunc(t Transport) SearchableSnapshotsStats { + return func(o ...func(*SearchableSnapshotsStatsRequest)) (*Response, error) { + var r = SearchableSnapshotsStatsRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SearchableSnapshotsStats - Retrieve shard-level statistics about searchable snapshots. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/searchable-snapshots-apis.html. +type SearchableSnapshotsStats func(o ...func(*SearchableSnapshotsStatsRequest)) (*Response, error) + +// SearchableSnapshotsStatsRequest configures the Searchable Snapshots Stats API request. +type SearchableSnapshotsStatsRequest struct { + Index []string + + Level string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SearchableSnapshotsStatsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len(strings.Join(r.Index, ",")) + 1 + len("_searchable_snapshots") + 1 + len("stats")) + if len(r.Index) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + } + path.WriteString("/") + path.WriteString("_searchable_snapshots") + path.WriteString("/") + path.WriteString("stats") + + params = make(map[string]string) + + if r.Level != "" { + params["level"] = r.Level + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SearchableSnapshotsStats) WithContext(v context.Context) func(*SearchableSnapshotsStatsRequest) { + return func(r *SearchableSnapshotsStatsRequest) { + r.ctx = v + } +} + +// WithIndex - a list of index names. +func (f SearchableSnapshotsStats) WithIndex(v ...string) func(*SearchableSnapshotsStatsRequest) { + return func(r *SearchableSnapshotsStatsRequest) { + r.Index = v + } +} + +// WithLevel - return stats aggregated at cluster, index or shard level. +func (f SearchableSnapshotsStats) WithLevel(v string) func(*SearchableSnapshotsStatsRequest) { + return func(r *SearchableSnapshotsStatsRequest) { + r.Level = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SearchableSnapshotsStats) WithPretty() func(*SearchableSnapshotsStatsRequest) { + return func(r *SearchableSnapshotsStatsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SearchableSnapshotsStats) WithHuman() func(*SearchableSnapshotsStatsRequest) { + return func(r *SearchableSnapshotsStatsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SearchableSnapshotsStats) WithErrorTrace() func(*SearchableSnapshotsStatsRequest) { + return func(r *SearchableSnapshotsStatsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SearchableSnapshotsStats) WithFilterPath(v ...string) func(*SearchableSnapshotsStatsRequest) { + return func(r *SearchableSnapshotsStatsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SearchableSnapshotsStats) WithHeader(h map[string]string) func(*SearchableSnapshotsStatsRequest) { + return func(r *SearchableSnapshotsStatsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SearchableSnapshotsStats) WithOpaqueID(s string) func(*SearchableSnapshotsStatsRequest) { + return func(r *SearchableSnapshotsStatsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.authenticate.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.authenticate.go new file mode 100644 index 00000000..d9b1c49e --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.authenticate.go @@ -0,0 +1,186 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newSecurityAuthenticateFunc(t Transport) SecurityAuthenticate { + return func(o ...func(*SecurityAuthenticateRequest)) (*Response, error) { + var r = SecurityAuthenticateRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SecurityAuthenticate - Enables authentication as a user and retrieve information about the authenticated user. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-authenticate.html. +type SecurityAuthenticate func(o ...func(*SecurityAuthenticateRequest)) (*Response, error) + +// SecurityAuthenticateRequest configures the Security Authenticate API request. +type SecurityAuthenticateRequest struct { + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SecurityAuthenticateRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(len("/_security/_authenticate")) + path.WriteString("/_security/_authenticate") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SecurityAuthenticate) WithContext(v context.Context) func(*SecurityAuthenticateRequest) { + return func(r *SecurityAuthenticateRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SecurityAuthenticate) WithPretty() func(*SecurityAuthenticateRequest) { + return func(r *SecurityAuthenticateRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SecurityAuthenticate) WithHuman() func(*SecurityAuthenticateRequest) { + return func(r *SecurityAuthenticateRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SecurityAuthenticate) WithErrorTrace() func(*SecurityAuthenticateRequest) { + return func(r *SecurityAuthenticateRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SecurityAuthenticate) WithFilterPath(v ...string) func(*SecurityAuthenticateRequest) { + return func(r *SecurityAuthenticateRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SecurityAuthenticate) WithHeader(h map[string]string) func(*SecurityAuthenticateRequest) { + return func(r *SecurityAuthenticateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SecurityAuthenticate) WithOpaqueID(s string) func(*SecurityAuthenticateRequest) { + return func(r *SecurityAuthenticateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.change_password.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.change_password.go new file mode 100644 index 00000000..4a0549f3 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.change_password.go @@ -0,0 +1,224 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newSecurityChangePasswordFunc(t Transport) SecurityChangePassword { + return func(body io.Reader, o ...func(*SecurityChangePasswordRequest)) (*Response, error) { + var r = SecurityChangePasswordRequest{Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SecurityChangePassword - Changes the passwords of users in the native realm and built-in users. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-change-password.html. +type SecurityChangePassword func(body io.Reader, o ...func(*SecurityChangePasswordRequest)) (*Response, error) + +// SecurityChangePasswordRequest configures the Security Change Password API request. +type SecurityChangePasswordRequest struct { + Body io.Reader + + Username string + + Refresh string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SecurityChangePasswordRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(1 + len("_security") + 1 + len("user") + 1 + len(r.Username) + 1 + len("_password")) + path.WriteString("/") + path.WriteString("_security") + path.WriteString("/") + path.WriteString("user") + if r.Username != "" { + path.WriteString("/") + path.WriteString(r.Username) + } + path.WriteString("/") + path.WriteString("_password") + + params = make(map[string]string) + + if r.Refresh != "" { + params["refresh"] = r.Refresh + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SecurityChangePassword) WithContext(v context.Context) func(*SecurityChangePasswordRequest) { + return func(r *SecurityChangePasswordRequest) { + r.ctx = v + } +} + +// WithUsername - the username of the user to change the password for. +func (f SecurityChangePassword) WithUsername(v string) func(*SecurityChangePasswordRequest) { + return func(r *SecurityChangePasswordRequest) { + r.Username = v + } +} + +// WithRefresh - if `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes.. +func (f SecurityChangePassword) WithRefresh(v string) func(*SecurityChangePasswordRequest) { + return func(r *SecurityChangePasswordRequest) { + r.Refresh = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SecurityChangePassword) WithPretty() func(*SecurityChangePasswordRequest) { + return func(r *SecurityChangePasswordRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SecurityChangePassword) WithHuman() func(*SecurityChangePasswordRequest) { + return func(r *SecurityChangePasswordRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SecurityChangePassword) WithErrorTrace() func(*SecurityChangePasswordRequest) { + return func(r *SecurityChangePasswordRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SecurityChangePassword) WithFilterPath(v ...string) func(*SecurityChangePasswordRequest) { + return func(r *SecurityChangePasswordRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SecurityChangePassword) WithHeader(h map[string]string) func(*SecurityChangePasswordRequest) { + return func(r *SecurityChangePasswordRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SecurityChangePassword) WithOpaqueID(s string) func(*SecurityChangePasswordRequest) { + return func(r *SecurityChangePasswordRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.clear_api_key_cache.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.clear_api_key_cache.go new file mode 100644 index 00000000..0fef90b8 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.clear_api_key_cache.go @@ -0,0 +1,200 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "errors" + "net/http" + "strings" +) + +func newSecurityClearAPIKeyCacheFunc(t Transport) SecurityClearAPIKeyCache { + return func(ids []string, o ...func(*SecurityClearAPIKeyCacheRequest)) (*Response, error) { + var r = SecurityClearAPIKeyCacheRequest{Ids: ids} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SecurityClearAPIKeyCache - Clear a subset or all entries from the API key cache. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-clear-api-key-cache.html. +type SecurityClearAPIKeyCache func(ids []string, o ...func(*SecurityClearAPIKeyCacheRequest)) (*Response, error) + +// SecurityClearAPIKeyCacheRequest configures the Security ClearAPI Key Cache API request. +type SecurityClearAPIKeyCacheRequest struct { + Ids []string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SecurityClearAPIKeyCacheRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + if len(r.Ids) == 0 { + return nil, errors.New("ids is required and cannot be nil or empty") + } + + path.Grow(1 + len("_security") + 1 + len("api_key") + 1 + len(strings.Join(r.Ids, ",")) + 1 + len("_clear_cache")) + path.WriteString("/") + path.WriteString("_security") + path.WriteString("/") + path.WriteString("api_key") + path.WriteString("/") + path.WriteString(strings.Join(r.Ids, ",")) + path.WriteString("/") + path.WriteString("_clear_cache") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SecurityClearAPIKeyCache) WithContext(v context.Context) func(*SecurityClearAPIKeyCacheRequest) { + return func(r *SecurityClearAPIKeyCacheRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SecurityClearAPIKeyCache) WithPretty() func(*SecurityClearAPIKeyCacheRequest) { + return func(r *SecurityClearAPIKeyCacheRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SecurityClearAPIKeyCache) WithHuman() func(*SecurityClearAPIKeyCacheRequest) { + return func(r *SecurityClearAPIKeyCacheRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SecurityClearAPIKeyCache) WithErrorTrace() func(*SecurityClearAPIKeyCacheRequest) { + return func(r *SecurityClearAPIKeyCacheRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SecurityClearAPIKeyCache) WithFilterPath(v ...string) func(*SecurityClearAPIKeyCacheRequest) { + return func(r *SecurityClearAPIKeyCacheRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SecurityClearAPIKeyCache) WithHeader(h map[string]string) func(*SecurityClearAPIKeyCacheRequest) { + return func(r *SecurityClearAPIKeyCacheRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SecurityClearAPIKeyCache) WithOpaqueID(s string) func(*SecurityClearAPIKeyCacheRequest) { + return func(r *SecurityClearAPIKeyCacheRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.clear_cached_privileges.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.clear_cached_privileges.go new file mode 100644 index 00000000..9203ff64 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.clear_cached_privileges.go @@ -0,0 +1,200 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "errors" + "net/http" + "strings" +) + +func newSecurityClearCachedPrivilegesFunc(t Transport) SecurityClearCachedPrivileges { + return func(application []string, o ...func(*SecurityClearCachedPrivilegesRequest)) (*Response, error) { + var r = SecurityClearCachedPrivilegesRequest{Application: application} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SecurityClearCachedPrivileges - Evicts application privileges from the native application privileges cache. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-clear-privilege-cache.html. +type SecurityClearCachedPrivileges func(application []string, o ...func(*SecurityClearCachedPrivilegesRequest)) (*Response, error) + +// SecurityClearCachedPrivilegesRequest configures the Security Clear Cached Privileges API request. +type SecurityClearCachedPrivilegesRequest struct { + Application []string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SecurityClearCachedPrivilegesRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + if len(r.Application) == 0 { + return nil, errors.New("application is required and cannot be nil or empty") + } + + path.Grow(1 + len("_security") + 1 + len("privilege") + 1 + len(strings.Join(r.Application, ",")) + 1 + len("_clear_cache")) + path.WriteString("/") + path.WriteString("_security") + path.WriteString("/") + path.WriteString("privilege") + path.WriteString("/") + path.WriteString(strings.Join(r.Application, ",")) + path.WriteString("/") + path.WriteString("_clear_cache") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SecurityClearCachedPrivileges) WithContext(v context.Context) func(*SecurityClearCachedPrivilegesRequest) { + return func(r *SecurityClearCachedPrivilegesRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SecurityClearCachedPrivileges) WithPretty() func(*SecurityClearCachedPrivilegesRequest) { + return func(r *SecurityClearCachedPrivilegesRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SecurityClearCachedPrivileges) WithHuman() func(*SecurityClearCachedPrivilegesRequest) { + return func(r *SecurityClearCachedPrivilegesRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SecurityClearCachedPrivileges) WithErrorTrace() func(*SecurityClearCachedPrivilegesRequest) { + return func(r *SecurityClearCachedPrivilegesRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SecurityClearCachedPrivileges) WithFilterPath(v ...string) func(*SecurityClearCachedPrivilegesRequest) { + return func(r *SecurityClearCachedPrivilegesRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SecurityClearCachedPrivileges) WithHeader(h map[string]string) func(*SecurityClearCachedPrivilegesRequest) { + return func(r *SecurityClearCachedPrivilegesRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SecurityClearCachedPrivileges) WithOpaqueID(s string) func(*SecurityClearCachedPrivilegesRequest) { + return func(r *SecurityClearCachedPrivilegesRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.clear_cached_realms.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.clear_cached_realms.go new file mode 100644 index 00000000..7fd9fa43 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.clear_cached_realms.go @@ -0,0 +1,213 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "errors" + "net/http" + "strings" +) + +func newSecurityClearCachedRealmsFunc(t Transport) SecurityClearCachedRealms { + return func(realms []string, o ...func(*SecurityClearCachedRealmsRequest)) (*Response, error) { + var r = SecurityClearCachedRealmsRequest{Realms: realms} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SecurityClearCachedRealms - Evicts users from the user cache. Can completely clear the cache or evict specific users. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-clear-cache.html. +type SecurityClearCachedRealms func(realms []string, o ...func(*SecurityClearCachedRealmsRequest)) (*Response, error) + +// SecurityClearCachedRealmsRequest configures the Security Clear Cached Realms API request. +type SecurityClearCachedRealmsRequest struct { + Realms []string + + Usernames []string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SecurityClearCachedRealmsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + if len(r.Realms) == 0 { + return nil, errors.New("realms is required and cannot be nil or empty") + } + + path.Grow(1 + len("_security") + 1 + len("realm") + 1 + len(strings.Join(r.Realms, ",")) + 1 + len("_clear_cache")) + path.WriteString("/") + path.WriteString("_security") + path.WriteString("/") + path.WriteString("realm") + path.WriteString("/") + path.WriteString(strings.Join(r.Realms, ",")) + path.WriteString("/") + path.WriteString("_clear_cache") + + params = make(map[string]string) + + if len(r.Usernames) > 0 { + params["usernames"] = strings.Join(r.Usernames, ",") + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SecurityClearCachedRealms) WithContext(v context.Context) func(*SecurityClearCachedRealmsRequest) { + return func(r *SecurityClearCachedRealmsRequest) { + r.ctx = v + } +} + +// WithUsernames - comma-separated list of usernames to clear from the cache. +func (f SecurityClearCachedRealms) WithUsernames(v ...string) func(*SecurityClearCachedRealmsRequest) { + return func(r *SecurityClearCachedRealmsRequest) { + r.Usernames = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SecurityClearCachedRealms) WithPretty() func(*SecurityClearCachedRealmsRequest) { + return func(r *SecurityClearCachedRealmsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SecurityClearCachedRealms) WithHuman() func(*SecurityClearCachedRealmsRequest) { + return func(r *SecurityClearCachedRealmsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SecurityClearCachedRealms) WithErrorTrace() func(*SecurityClearCachedRealmsRequest) { + return func(r *SecurityClearCachedRealmsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SecurityClearCachedRealms) WithFilterPath(v ...string) func(*SecurityClearCachedRealmsRequest) { + return func(r *SecurityClearCachedRealmsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SecurityClearCachedRealms) WithHeader(h map[string]string) func(*SecurityClearCachedRealmsRequest) { + return func(r *SecurityClearCachedRealmsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SecurityClearCachedRealms) WithOpaqueID(s string) func(*SecurityClearCachedRealmsRequest) { + return func(r *SecurityClearCachedRealmsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.clear_cached_roles.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.clear_cached_roles.go new file mode 100644 index 00000000..666a8f51 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.clear_cached_roles.go @@ -0,0 +1,200 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "errors" + "net/http" + "strings" +) + +func newSecurityClearCachedRolesFunc(t Transport) SecurityClearCachedRoles { + return func(name []string, o ...func(*SecurityClearCachedRolesRequest)) (*Response, error) { + var r = SecurityClearCachedRolesRequest{Name: name} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SecurityClearCachedRoles - Evicts roles from the native role cache. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-clear-role-cache.html. +type SecurityClearCachedRoles func(name []string, o ...func(*SecurityClearCachedRolesRequest)) (*Response, error) + +// SecurityClearCachedRolesRequest configures the Security Clear Cached Roles API request. +type SecurityClearCachedRolesRequest struct { + Name []string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SecurityClearCachedRolesRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + if len(r.Name) == 0 { + return nil, errors.New("name is required and cannot be nil or empty") + } + + path.Grow(1 + len("_security") + 1 + len("role") + 1 + len(strings.Join(r.Name, ",")) + 1 + len("_clear_cache")) + path.WriteString("/") + path.WriteString("_security") + path.WriteString("/") + path.WriteString("role") + path.WriteString("/") + path.WriteString(strings.Join(r.Name, ",")) + path.WriteString("/") + path.WriteString("_clear_cache") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SecurityClearCachedRoles) WithContext(v context.Context) func(*SecurityClearCachedRolesRequest) { + return func(r *SecurityClearCachedRolesRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SecurityClearCachedRoles) WithPretty() func(*SecurityClearCachedRolesRequest) { + return func(r *SecurityClearCachedRolesRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SecurityClearCachedRoles) WithHuman() func(*SecurityClearCachedRolesRequest) { + return func(r *SecurityClearCachedRolesRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SecurityClearCachedRoles) WithErrorTrace() func(*SecurityClearCachedRolesRequest) { + return func(r *SecurityClearCachedRolesRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SecurityClearCachedRoles) WithFilterPath(v ...string) func(*SecurityClearCachedRolesRequest) { + return func(r *SecurityClearCachedRolesRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SecurityClearCachedRoles) WithHeader(h map[string]string) func(*SecurityClearCachedRolesRequest) { + return func(r *SecurityClearCachedRolesRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SecurityClearCachedRoles) WithOpaqueID(s string) func(*SecurityClearCachedRolesRequest) { + return func(r *SecurityClearCachedRolesRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.clear_cached_service_tokens.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.clear_cached_service_tokens.go new file mode 100644 index 00000000..4d19c9f4 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.clear_cached_service_tokens.go @@ -0,0 +1,210 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "errors" + "net/http" + "strings" +) + +func newSecurityClearCachedServiceTokensFunc(t Transport) SecurityClearCachedServiceTokens { + return func(name []string, namespace string, service string, o ...func(*SecurityClearCachedServiceTokensRequest)) (*Response, error) { + var r = SecurityClearCachedServiceTokensRequest{Name: name, Service: service, Namespace: namespace} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SecurityClearCachedServiceTokens - Evicts tokens from the service account token caches. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-clear-service-token-caches.html. +type SecurityClearCachedServiceTokens func(name []string, namespace string, service string, o ...func(*SecurityClearCachedServiceTokensRequest)) (*Response, error) + +// SecurityClearCachedServiceTokensRequest configures the Security Clear Cached Service Tokens API request. +type SecurityClearCachedServiceTokensRequest struct { + Name []string + Namespace string + Service string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SecurityClearCachedServiceTokensRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + if len(r.Name) == 0 { + return nil, errors.New("name is required and cannot be nil or empty") + } + + path.Grow(1 + len("_security") + 1 + len("service") + 1 + len(r.Namespace) + 1 + len(r.Service) + 1 + len("credential") + 1 + len("token") + 1 + len(strings.Join(r.Name, ",")) + 1 + len("_clear_cache")) + path.WriteString("/") + path.WriteString("_security") + path.WriteString("/") + path.WriteString("service") + path.WriteString("/") + path.WriteString(r.Namespace) + path.WriteString("/") + path.WriteString(r.Service) + path.WriteString("/") + path.WriteString("credential") + path.WriteString("/") + path.WriteString("token") + path.WriteString("/") + path.WriteString(strings.Join(r.Name, ",")) + path.WriteString("/") + path.WriteString("_clear_cache") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SecurityClearCachedServiceTokens) WithContext(v context.Context) func(*SecurityClearCachedServiceTokensRequest) { + return func(r *SecurityClearCachedServiceTokensRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SecurityClearCachedServiceTokens) WithPretty() func(*SecurityClearCachedServiceTokensRequest) { + return func(r *SecurityClearCachedServiceTokensRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SecurityClearCachedServiceTokens) WithHuman() func(*SecurityClearCachedServiceTokensRequest) { + return func(r *SecurityClearCachedServiceTokensRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SecurityClearCachedServiceTokens) WithErrorTrace() func(*SecurityClearCachedServiceTokensRequest) { + return func(r *SecurityClearCachedServiceTokensRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SecurityClearCachedServiceTokens) WithFilterPath(v ...string) func(*SecurityClearCachedServiceTokensRequest) { + return func(r *SecurityClearCachedServiceTokensRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SecurityClearCachedServiceTokens) WithHeader(h map[string]string) func(*SecurityClearCachedServiceTokensRequest) { + return func(r *SecurityClearCachedServiceTokensRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SecurityClearCachedServiceTokens) WithOpaqueID(s string) func(*SecurityClearCachedServiceTokensRequest) { + return func(r *SecurityClearCachedServiceTokensRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.create_api_key.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.create_api_key.go new file mode 100644 index 00000000..52e1f572 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.create_api_key.go @@ -0,0 +1,206 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newSecurityCreateAPIKeyFunc(t Transport) SecurityCreateAPIKey { + return func(body io.Reader, o ...func(*SecurityCreateAPIKeyRequest)) (*Response, error) { + var r = SecurityCreateAPIKeyRequest{Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SecurityCreateAPIKey - Creates an API key for access without requiring basic authentication. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-api-key.html. +type SecurityCreateAPIKey func(body io.Reader, o ...func(*SecurityCreateAPIKeyRequest)) (*Response, error) + +// SecurityCreateAPIKeyRequest configures the Security CreateAPI Key API request. +type SecurityCreateAPIKeyRequest struct { + Body io.Reader + + Refresh string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SecurityCreateAPIKeyRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(len("/_security/api_key")) + path.WriteString("/_security/api_key") + + params = make(map[string]string) + + if r.Refresh != "" { + params["refresh"] = r.Refresh + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SecurityCreateAPIKey) WithContext(v context.Context) func(*SecurityCreateAPIKeyRequest) { + return func(r *SecurityCreateAPIKeyRequest) { + r.ctx = v + } +} + +// WithRefresh - if `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes.. +func (f SecurityCreateAPIKey) WithRefresh(v string) func(*SecurityCreateAPIKeyRequest) { + return func(r *SecurityCreateAPIKeyRequest) { + r.Refresh = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SecurityCreateAPIKey) WithPretty() func(*SecurityCreateAPIKeyRequest) { + return func(r *SecurityCreateAPIKeyRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SecurityCreateAPIKey) WithHuman() func(*SecurityCreateAPIKeyRequest) { + return func(r *SecurityCreateAPIKeyRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SecurityCreateAPIKey) WithErrorTrace() func(*SecurityCreateAPIKeyRequest) { + return func(r *SecurityCreateAPIKeyRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SecurityCreateAPIKey) WithFilterPath(v ...string) func(*SecurityCreateAPIKeyRequest) { + return func(r *SecurityCreateAPIKeyRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SecurityCreateAPIKey) WithHeader(h map[string]string) func(*SecurityCreateAPIKeyRequest) { + return func(r *SecurityCreateAPIKeyRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SecurityCreateAPIKey) WithOpaqueID(s string) func(*SecurityCreateAPIKeyRequest) { + return func(r *SecurityCreateAPIKeyRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.create_service_token.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.create_service_token.go new file mode 100644 index 00000000..993c1530 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.create_service_token.go @@ -0,0 +1,225 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newSecurityCreateServiceTokenFunc(t Transport) SecurityCreateServiceToken { + return func(namespace string, service string, o ...func(*SecurityCreateServiceTokenRequest)) (*Response, error) { + var r = SecurityCreateServiceTokenRequest{Namespace: namespace, Service: service} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SecurityCreateServiceToken - Creates a service account token for access without requiring basic authentication. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-service-token.html. +type SecurityCreateServiceToken func(namespace string, service string, o ...func(*SecurityCreateServiceTokenRequest)) (*Response, error) + +// SecurityCreateServiceTokenRequest configures the Security Create Service Token API request. +type SecurityCreateServiceTokenRequest struct { + Name string + Namespace string + Service string + + Refresh string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SecurityCreateServiceTokenRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(1 + len("_security") + 1 + len("service") + 1 + len(r.Namespace) + 1 + len(r.Service) + 1 + len("credential") + 1 + len("token") + 1 + len(r.Name)) + path.WriteString("/") + path.WriteString("_security") + path.WriteString("/") + path.WriteString("service") + path.WriteString("/") + path.WriteString(r.Namespace) + path.WriteString("/") + path.WriteString(r.Service) + path.WriteString("/") + path.WriteString("credential") + path.WriteString("/") + path.WriteString("token") + if r.Name != "" { + path.WriteString("/") + path.WriteString(r.Name) + } + + params = make(map[string]string) + + if r.Refresh != "" { + params["refresh"] = r.Refresh + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SecurityCreateServiceToken) WithContext(v context.Context) func(*SecurityCreateServiceTokenRequest) { + return func(r *SecurityCreateServiceTokenRequest) { + r.ctx = v + } +} + +// WithName - an identifier for the token name. +func (f SecurityCreateServiceToken) WithName(v string) func(*SecurityCreateServiceTokenRequest) { + return func(r *SecurityCreateServiceTokenRequest) { + r.Name = v + } +} + +// WithRefresh - if `true` then refresh the affected shards to make this operation visible to search, if `wait_for` (the default) then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes.. +func (f SecurityCreateServiceToken) WithRefresh(v string) func(*SecurityCreateServiceTokenRequest) { + return func(r *SecurityCreateServiceTokenRequest) { + r.Refresh = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SecurityCreateServiceToken) WithPretty() func(*SecurityCreateServiceTokenRequest) { + return func(r *SecurityCreateServiceTokenRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SecurityCreateServiceToken) WithHuman() func(*SecurityCreateServiceTokenRequest) { + return func(r *SecurityCreateServiceTokenRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SecurityCreateServiceToken) WithErrorTrace() func(*SecurityCreateServiceTokenRequest) { + return func(r *SecurityCreateServiceTokenRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SecurityCreateServiceToken) WithFilterPath(v ...string) func(*SecurityCreateServiceTokenRequest) { + return func(r *SecurityCreateServiceTokenRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SecurityCreateServiceToken) WithHeader(h map[string]string) func(*SecurityCreateServiceTokenRequest) { + return func(r *SecurityCreateServiceTokenRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SecurityCreateServiceToken) WithOpaqueID(s string) func(*SecurityCreateServiceTokenRequest) { + return func(r *SecurityCreateServiceTokenRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.delete_privileges.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.delete_privileges.go new file mode 100644 index 00000000..9f735fb1 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.delete_privileges.go @@ -0,0 +1,209 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newSecurityDeletePrivilegesFunc(t Transport) SecurityDeletePrivileges { + return func(name string, application string, o ...func(*SecurityDeletePrivilegesRequest)) (*Response, error) { + var r = SecurityDeletePrivilegesRequest{Name: name, Application: application} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SecurityDeletePrivileges - Removes application privileges. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-privilege.html. +type SecurityDeletePrivileges func(name string, application string, o ...func(*SecurityDeletePrivilegesRequest)) (*Response, error) + +// SecurityDeletePrivilegesRequest configures the Security Delete Privileges API request. +type SecurityDeletePrivilegesRequest struct { + Application string + Name string + + Refresh string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SecurityDeletePrivilegesRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + path.Grow(1 + len("_security") + 1 + len("privilege") + 1 + len(r.Application) + 1 + len(r.Name)) + path.WriteString("/") + path.WriteString("_security") + path.WriteString("/") + path.WriteString("privilege") + path.WriteString("/") + path.WriteString(r.Application) + path.WriteString("/") + path.WriteString(r.Name) + + params = make(map[string]string) + + if r.Refresh != "" { + params["refresh"] = r.Refresh + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SecurityDeletePrivileges) WithContext(v context.Context) func(*SecurityDeletePrivilegesRequest) { + return func(r *SecurityDeletePrivilegesRequest) { + r.ctx = v + } +} + +// WithRefresh - if `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes.. +func (f SecurityDeletePrivileges) WithRefresh(v string) func(*SecurityDeletePrivilegesRequest) { + return func(r *SecurityDeletePrivilegesRequest) { + r.Refresh = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SecurityDeletePrivileges) WithPretty() func(*SecurityDeletePrivilegesRequest) { + return func(r *SecurityDeletePrivilegesRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SecurityDeletePrivileges) WithHuman() func(*SecurityDeletePrivilegesRequest) { + return func(r *SecurityDeletePrivilegesRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SecurityDeletePrivileges) WithErrorTrace() func(*SecurityDeletePrivilegesRequest) { + return func(r *SecurityDeletePrivilegesRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SecurityDeletePrivileges) WithFilterPath(v ...string) func(*SecurityDeletePrivilegesRequest) { + return func(r *SecurityDeletePrivilegesRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SecurityDeletePrivileges) WithHeader(h map[string]string) func(*SecurityDeletePrivilegesRequest) { + return func(r *SecurityDeletePrivilegesRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SecurityDeletePrivileges) WithOpaqueID(s string) func(*SecurityDeletePrivilegesRequest) { + return func(r *SecurityDeletePrivilegesRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.delete_role.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.delete_role.go new file mode 100644 index 00000000..5b19fa41 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.delete_role.go @@ -0,0 +1,206 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newSecurityDeleteRoleFunc(t Transport) SecurityDeleteRole { + return func(name string, o ...func(*SecurityDeleteRoleRequest)) (*Response, error) { + var r = SecurityDeleteRoleRequest{Name: name} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SecurityDeleteRole - Removes roles in the native realm. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-role.html. +type SecurityDeleteRole func(name string, o ...func(*SecurityDeleteRoleRequest)) (*Response, error) + +// SecurityDeleteRoleRequest configures the Security Delete Role API request. +type SecurityDeleteRoleRequest struct { + Name string + + Refresh string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SecurityDeleteRoleRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + path.Grow(1 + len("_security") + 1 + len("role") + 1 + len(r.Name)) + path.WriteString("/") + path.WriteString("_security") + path.WriteString("/") + path.WriteString("role") + path.WriteString("/") + path.WriteString(r.Name) + + params = make(map[string]string) + + if r.Refresh != "" { + params["refresh"] = r.Refresh + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SecurityDeleteRole) WithContext(v context.Context) func(*SecurityDeleteRoleRequest) { + return func(r *SecurityDeleteRoleRequest) { + r.ctx = v + } +} + +// WithRefresh - if `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes.. +func (f SecurityDeleteRole) WithRefresh(v string) func(*SecurityDeleteRoleRequest) { + return func(r *SecurityDeleteRoleRequest) { + r.Refresh = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SecurityDeleteRole) WithPretty() func(*SecurityDeleteRoleRequest) { + return func(r *SecurityDeleteRoleRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SecurityDeleteRole) WithHuman() func(*SecurityDeleteRoleRequest) { + return func(r *SecurityDeleteRoleRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SecurityDeleteRole) WithErrorTrace() func(*SecurityDeleteRoleRequest) { + return func(r *SecurityDeleteRoleRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SecurityDeleteRole) WithFilterPath(v ...string) func(*SecurityDeleteRoleRequest) { + return func(r *SecurityDeleteRoleRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SecurityDeleteRole) WithHeader(h map[string]string) func(*SecurityDeleteRoleRequest) { + return func(r *SecurityDeleteRoleRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SecurityDeleteRole) WithOpaqueID(s string) func(*SecurityDeleteRoleRequest) { + return func(r *SecurityDeleteRoleRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.delete_role_mapping.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.delete_role_mapping.go new file mode 100644 index 00000000..bc8a1707 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.delete_role_mapping.go @@ -0,0 +1,206 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newSecurityDeleteRoleMappingFunc(t Transport) SecurityDeleteRoleMapping { + return func(name string, o ...func(*SecurityDeleteRoleMappingRequest)) (*Response, error) { + var r = SecurityDeleteRoleMappingRequest{Name: name} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SecurityDeleteRoleMapping - Removes role mappings. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-role-mapping.html. +type SecurityDeleteRoleMapping func(name string, o ...func(*SecurityDeleteRoleMappingRequest)) (*Response, error) + +// SecurityDeleteRoleMappingRequest configures the Security Delete Role Mapping API request. +type SecurityDeleteRoleMappingRequest struct { + Name string + + Refresh string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SecurityDeleteRoleMappingRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + path.Grow(1 + len("_security") + 1 + len("role_mapping") + 1 + len(r.Name)) + path.WriteString("/") + path.WriteString("_security") + path.WriteString("/") + path.WriteString("role_mapping") + path.WriteString("/") + path.WriteString(r.Name) + + params = make(map[string]string) + + if r.Refresh != "" { + params["refresh"] = r.Refresh + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SecurityDeleteRoleMapping) WithContext(v context.Context) func(*SecurityDeleteRoleMappingRequest) { + return func(r *SecurityDeleteRoleMappingRequest) { + r.ctx = v + } +} + +// WithRefresh - if `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes.. +func (f SecurityDeleteRoleMapping) WithRefresh(v string) func(*SecurityDeleteRoleMappingRequest) { + return func(r *SecurityDeleteRoleMappingRequest) { + r.Refresh = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SecurityDeleteRoleMapping) WithPretty() func(*SecurityDeleteRoleMappingRequest) { + return func(r *SecurityDeleteRoleMappingRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SecurityDeleteRoleMapping) WithHuman() func(*SecurityDeleteRoleMappingRequest) { + return func(r *SecurityDeleteRoleMappingRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SecurityDeleteRoleMapping) WithErrorTrace() func(*SecurityDeleteRoleMappingRequest) { + return func(r *SecurityDeleteRoleMappingRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SecurityDeleteRoleMapping) WithFilterPath(v ...string) func(*SecurityDeleteRoleMappingRequest) { + return func(r *SecurityDeleteRoleMappingRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SecurityDeleteRoleMapping) WithHeader(h map[string]string) func(*SecurityDeleteRoleMappingRequest) { + return func(r *SecurityDeleteRoleMappingRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SecurityDeleteRoleMapping) WithOpaqueID(s string) func(*SecurityDeleteRoleMappingRequest) { + return func(r *SecurityDeleteRoleMappingRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.delete_service_token.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.delete_service_token.go new file mode 100644 index 00000000..1711acdd --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.delete_service_token.go @@ -0,0 +1,216 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newSecurityDeleteServiceTokenFunc(t Transport) SecurityDeleteServiceToken { + return func(name string, namespace string, service string, o ...func(*SecurityDeleteServiceTokenRequest)) (*Response, error) { + var r = SecurityDeleteServiceTokenRequest{Name: name, Namespace: namespace, Service: service} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SecurityDeleteServiceToken - Deletes a service account token. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-service-token.html. +type SecurityDeleteServiceToken func(name string, namespace string, service string, o ...func(*SecurityDeleteServiceTokenRequest)) (*Response, error) + +// SecurityDeleteServiceTokenRequest configures the Security Delete Service Token API request. +type SecurityDeleteServiceTokenRequest struct { + Name string + Namespace string + Service string + + Refresh string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SecurityDeleteServiceTokenRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + path.Grow(1 + len("_security") + 1 + len("service") + 1 + len(r.Namespace) + 1 + len(r.Service) + 1 + len("credential") + 1 + len("token") + 1 + len(r.Name)) + path.WriteString("/") + path.WriteString("_security") + path.WriteString("/") + path.WriteString("service") + path.WriteString("/") + path.WriteString(r.Namespace) + path.WriteString("/") + path.WriteString(r.Service) + path.WriteString("/") + path.WriteString("credential") + path.WriteString("/") + path.WriteString("token") + path.WriteString("/") + path.WriteString(r.Name) + + params = make(map[string]string) + + if r.Refresh != "" { + params["refresh"] = r.Refresh + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SecurityDeleteServiceToken) WithContext(v context.Context) func(*SecurityDeleteServiceTokenRequest) { + return func(r *SecurityDeleteServiceTokenRequest) { + r.ctx = v + } +} + +// WithRefresh - if `true` then refresh the affected shards to make this operation visible to search, if `wait_for` (the default) then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes.. +func (f SecurityDeleteServiceToken) WithRefresh(v string) func(*SecurityDeleteServiceTokenRequest) { + return func(r *SecurityDeleteServiceTokenRequest) { + r.Refresh = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SecurityDeleteServiceToken) WithPretty() func(*SecurityDeleteServiceTokenRequest) { + return func(r *SecurityDeleteServiceTokenRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SecurityDeleteServiceToken) WithHuman() func(*SecurityDeleteServiceTokenRequest) { + return func(r *SecurityDeleteServiceTokenRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SecurityDeleteServiceToken) WithErrorTrace() func(*SecurityDeleteServiceTokenRequest) { + return func(r *SecurityDeleteServiceTokenRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SecurityDeleteServiceToken) WithFilterPath(v ...string) func(*SecurityDeleteServiceTokenRequest) { + return func(r *SecurityDeleteServiceTokenRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SecurityDeleteServiceToken) WithHeader(h map[string]string) func(*SecurityDeleteServiceTokenRequest) { + return func(r *SecurityDeleteServiceTokenRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SecurityDeleteServiceToken) WithOpaqueID(s string) func(*SecurityDeleteServiceTokenRequest) { + return func(r *SecurityDeleteServiceTokenRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.delete_user.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.delete_user.go new file mode 100644 index 00000000..71eb3beb --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.delete_user.go @@ -0,0 +1,206 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newSecurityDeleteUserFunc(t Transport) SecurityDeleteUser { + return func(username string, o ...func(*SecurityDeleteUserRequest)) (*Response, error) { + var r = SecurityDeleteUserRequest{Username: username} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SecurityDeleteUser - Deletes users from the native realm. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-user.html. +type SecurityDeleteUser func(username string, o ...func(*SecurityDeleteUserRequest)) (*Response, error) + +// SecurityDeleteUserRequest configures the Security Delete User API request. +type SecurityDeleteUserRequest struct { + Username string + + Refresh string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SecurityDeleteUserRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + path.Grow(1 + len("_security") + 1 + len("user") + 1 + len(r.Username)) + path.WriteString("/") + path.WriteString("_security") + path.WriteString("/") + path.WriteString("user") + path.WriteString("/") + path.WriteString(r.Username) + + params = make(map[string]string) + + if r.Refresh != "" { + params["refresh"] = r.Refresh + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SecurityDeleteUser) WithContext(v context.Context) func(*SecurityDeleteUserRequest) { + return func(r *SecurityDeleteUserRequest) { + r.ctx = v + } +} + +// WithRefresh - if `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes.. +func (f SecurityDeleteUser) WithRefresh(v string) func(*SecurityDeleteUserRequest) { + return func(r *SecurityDeleteUserRequest) { + r.Refresh = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SecurityDeleteUser) WithPretty() func(*SecurityDeleteUserRequest) { + return func(r *SecurityDeleteUserRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SecurityDeleteUser) WithHuman() func(*SecurityDeleteUserRequest) { + return func(r *SecurityDeleteUserRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SecurityDeleteUser) WithErrorTrace() func(*SecurityDeleteUserRequest) { + return func(r *SecurityDeleteUserRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SecurityDeleteUser) WithFilterPath(v ...string) func(*SecurityDeleteUserRequest) { + return func(r *SecurityDeleteUserRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SecurityDeleteUser) WithHeader(h map[string]string) func(*SecurityDeleteUserRequest) { + return func(r *SecurityDeleteUserRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SecurityDeleteUser) WithOpaqueID(s string) func(*SecurityDeleteUserRequest) { + return func(r *SecurityDeleteUserRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.disable_user.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.disable_user.go new file mode 100644 index 00000000..df0fc2fe --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.disable_user.go @@ -0,0 +1,208 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newSecurityDisableUserFunc(t Transport) SecurityDisableUser { + return func(username string, o ...func(*SecurityDisableUserRequest)) (*Response, error) { + var r = SecurityDisableUserRequest{Username: username} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SecurityDisableUser - Disables users in the native realm. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-disable-user.html. +type SecurityDisableUser func(username string, o ...func(*SecurityDisableUserRequest)) (*Response, error) + +// SecurityDisableUserRequest configures the Security Disable User API request. +type SecurityDisableUserRequest struct { + Username string + + Refresh string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SecurityDisableUserRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(1 + len("_security") + 1 + len("user") + 1 + len(r.Username) + 1 + len("_disable")) + path.WriteString("/") + path.WriteString("_security") + path.WriteString("/") + path.WriteString("user") + path.WriteString("/") + path.WriteString(r.Username) + path.WriteString("/") + path.WriteString("_disable") + + params = make(map[string]string) + + if r.Refresh != "" { + params["refresh"] = r.Refresh + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SecurityDisableUser) WithContext(v context.Context) func(*SecurityDisableUserRequest) { + return func(r *SecurityDisableUserRequest) { + r.ctx = v + } +} + +// WithRefresh - if `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes.. +func (f SecurityDisableUser) WithRefresh(v string) func(*SecurityDisableUserRequest) { + return func(r *SecurityDisableUserRequest) { + r.Refresh = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SecurityDisableUser) WithPretty() func(*SecurityDisableUserRequest) { + return func(r *SecurityDisableUserRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SecurityDisableUser) WithHuman() func(*SecurityDisableUserRequest) { + return func(r *SecurityDisableUserRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SecurityDisableUser) WithErrorTrace() func(*SecurityDisableUserRequest) { + return func(r *SecurityDisableUserRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SecurityDisableUser) WithFilterPath(v ...string) func(*SecurityDisableUserRequest) { + return func(r *SecurityDisableUserRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SecurityDisableUser) WithHeader(h map[string]string) func(*SecurityDisableUserRequest) { + return func(r *SecurityDisableUserRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SecurityDisableUser) WithOpaqueID(s string) func(*SecurityDisableUserRequest) { + return func(r *SecurityDisableUserRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.enable_user.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.enable_user.go new file mode 100644 index 00000000..6472d168 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.enable_user.go @@ -0,0 +1,208 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newSecurityEnableUserFunc(t Transport) SecurityEnableUser { + return func(username string, o ...func(*SecurityEnableUserRequest)) (*Response, error) { + var r = SecurityEnableUserRequest{Username: username} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SecurityEnableUser - Enables users in the native realm. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-enable-user.html. +type SecurityEnableUser func(username string, o ...func(*SecurityEnableUserRequest)) (*Response, error) + +// SecurityEnableUserRequest configures the Security Enable User API request. +type SecurityEnableUserRequest struct { + Username string + + Refresh string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SecurityEnableUserRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(1 + len("_security") + 1 + len("user") + 1 + len(r.Username) + 1 + len("_enable")) + path.WriteString("/") + path.WriteString("_security") + path.WriteString("/") + path.WriteString("user") + path.WriteString("/") + path.WriteString(r.Username) + path.WriteString("/") + path.WriteString("_enable") + + params = make(map[string]string) + + if r.Refresh != "" { + params["refresh"] = r.Refresh + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SecurityEnableUser) WithContext(v context.Context) func(*SecurityEnableUserRequest) { + return func(r *SecurityEnableUserRequest) { + r.ctx = v + } +} + +// WithRefresh - if `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes.. +func (f SecurityEnableUser) WithRefresh(v string) func(*SecurityEnableUserRequest) { + return func(r *SecurityEnableUserRequest) { + r.Refresh = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SecurityEnableUser) WithPretty() func(*SecurityEnableUserRequest) { + return func(r *SecurityEnableUserRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SecurityEnableUser) WithHuman() func(*SecurityEnableUserRequest) { + return func(r *SecurityEnableUserRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SecurityEnableUser) WithErrorTrace() func(*SecurityEnableUserRequest) { + return func(r *SecurityEnableUserRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SecurityEnableUser) WithFilterPath(v ...string) func(*SecurityEnableUserRequest) { + return func(r *SecurityEnableUserRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SecurityEnableUser) WithHeader(h map[string]string) func(*SecurityEnableUserRequest) { + return func(r *SecurityEnableUserRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SecurityEnableUser) WithOpaqueID(s string) func(*SecurityEnableUserRequest) { + return func(r *SecurityEnableUserRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.get_api_key.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.get_api_key.go new file mode 100644 index 00000000..6699a8dd --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.get_api_key.go @@ -0,0 +1,248 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newSecurityGetAPIKeyFunc(t Transport) SecurityGetAPIKey { + return func(o ...func(*SecurityGetAPIKeyRequest)) (*Response, error) { + var r = SecurityGetAPIKeyRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SecurityGetAPIKey - Retrieves information for one or more API keys. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-api-key.html. +type SecurityGetAPIKey func(o ...func(*SecurityGetAPIKeyRequest)) (*Response, error) + +// SecurityGetAPIKeyRequest configures the Security GetAPI Key API request. +type SecurityGetAPIKeyRequest struct { + ID string + Name string + Owner *bool + RealmName string + Username string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SecurityGetAPIKeyRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(len("/_security/api_key")) + path.WriteString("/_security/api_key") + + params = make(map[string]string) + + if r.ID != "" { + params["id"] = r.ID + } + + if r.Name != "" { + params["name"] = r.Name + } + + if r.Owner != nil { + params["owner"] = strconv.FormatBool(*r.Owner) + } + + if r.RealmName != "" { + params["realm_name"] = r.RealmName + } + + if r.Username != "" { + params["username"] = r.Username + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SecurityGetAPIKey) WithContext(v context.Context) func(*SecurityGetAPIKeyRequest) { + return func(r *SecurityGetAPIKeyRequest) { + r.ctx = v + } +} + +// WithID - api key ID of the api key to be retrieved. +func (f SecurityGetAPIKey) WithID(v string) func(*SecurityGetAPIKeyRequest) { + return func(r *SecurityGetAPIKeyRequest) { + r.ID = v + } +} + +// WithName - api key name of the api key to be retrieved. +func (f SecurityGetAPIKey) WithName(v string) func(*SecurityGetAPIKeyRequest) { + return func(r *SecurityGetAPIKeyRequest) { + r.Name = v + } +} + +// WithOwner - flag to query api keys owned by the currently authenticated user. +func (f SecurityGetAPIKey) WithOwner(v bool) func(*SecurityGetAPIKeyRequest) { + return func(r *SecurityGetAPIKeyRequest) { + r.Owner = &v + } +} + +// WithRealmName - realm name of the user who created this api key to be retrieved. +func (f SecurityGetAPIKey) WithRealmName(v string) func(*SecurityGetAPIKeyRequest) { + return func(r *SecurityGetAPIKeyRequest) { + r.RealmName = v + } +} + +// WithUsername - user name of the user who created this api key to be retrieved. +func (f SecurityGetAPIKey) WithUsername(v string) func(*SecurityGetAPIKeyRequest) { + return func(r *SecurityGetAPIKeyRequest) { + r.Username = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SecurityGetAPIKey) WithPretty() func(*SecurityGetAPIKeyRequest) { + return func(r *SecurityGetAPIKeyRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SecurityGetAPIKey) WithHuman() func(*SecurityGetAPIKeyRequest) { + return func(r *SecurityGetAPIKeyRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SecurityGetAPIKey) WithErrorTrace() func(*SecurityGetAPIKeyRequest) { + return func(r *SecurityGetAPIKeyRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SecurityGetAPIKey) WithFilterPath(v ...string) func(*SecurityGetAPIKeyRequest) { + return func(r *SecurityGetAPIKeyRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SecurityGetAPIKey) WithHeader(h map[string]string) func(*SecurityGetAPIKeyRequest) { + return func(r *SecurityGetAPIKeyRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SecurityGetAPIKey) WithOpaqueID(s string) func(*SecurityGetAPIKeyRequest) { + return func(r *SecurityGetAPIKeyRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.get_builtin_privileges.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.get_builtin_privileges.go new file mode 100644 index 00000000..95e1410a --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.get_builtin_privileges.go @@ -0,0 +1,186 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newSecurityGetBuiltinPrivilegesFunc(t Transport) SecurityGetBuiltinPrivileges { + return func(o ...func(*SecurityGetBuiltinPrivilegesRequest)) (*Response, error) { + var r = SecurityGetBuiltinPrivilegesRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SecurityGetBuiltinPrivileges - Retrieves the list of cluster privileges and index privileges that are available in this version of Elasticsearch. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-builtin-privileges.html. +type SecurityGetBuiltinPrivileges func(o ...func(*SecurityGetBuiltinPrivilegesRequest)) (*Response, error) + +// SecurityGetBuiltinPrivilegesRequest configures the Security Get Builtin Privileges API request. +type SecurityGetBuiltinPrivilegesRequest struct { + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SecurityGetBuiltinPrivilegesRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(len("/_security/privilege/_builtin")) + path.WriteString("/_security/privilege/_builtin") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SecurityGetBuiltinPrivileges) WithContext(v context.Context) func(*SecurityGetBuiltinPrivilegesRequest) { + return func(r *SecurityGetBuiltinPrivilegesRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SecurityGetBuiltinPrivileges) WithPretty() func(*SecurityGetBuiltinPrivilegesRequest) { + return func(r *SecurityGetBuiltinPrivilegesRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SecurityGetBuiltinPrivileges) WithHuman() func(*SecurityGetBuiltinPrivilegesRequest) { + return func(r *SecurityGetBuiltinPrivilegesRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SecurityGetBuiltinPrivileges) WithErrorTrace() func(*SecurityGetBuiltinPrivilegesRequest) { + return func(r *SecurityGetBuiltinPrivilegesRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SecurityGetBuiltinPrivileges) WithFilterPath(v ...string) func(*SecurityGetBuiltinPrivilegesRequest) { + return func(r *SecurityGetBuiltinPrivilegesRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SecurityGetBuiltinPrivileges) WithHeader(h map[string]string) func(*SecurityGetBuiltinPrivilegesRequest) { + return func(r *SecurityGetBuiltinPrivilegesRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SecurityGetBuiltinPrivileges) WithOpaqueID(s string) func(*SecurityGetBuiltinPrivilegesRequest) { + return func(r *SecurityGetBuiltinPrivilegesRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.get_privileges.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.get_privileges.go new file mode 100644 index 00000000..4a710924 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.get_privileges.go @@ -0,0 +1,214 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newSecurityGetPrivilegesFunc(t Transport) SecurityGetPrivileges { + return func(o ...func(*SecurityGetPrivilegesRequest)) (*Response, error) { + var r = SecurityGetPrivilegesRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SecurityGetPrivileges - Retrieves application privileges. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-privileges.html. +type SecurityGetPrivileges func(o ...func(*SecurityGetPrivilegesRequest)) (*Response, error) + +// SecurityGetPrivilegesRequest configures the Security Get Privileges API request. +type SecurityGetPrivilegesRequest struct { + Application string + Name string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SecurityGetPrivilegesRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_security") + 1 + len("privilege") + 1 + len(r.Application) + 1 + len(r.Name)) + path.WriteString("/") + path.WriteString("_security") + path.WriteString("/") + path.WriteString("privilege") + if r.Application != "" { + path.WriteString("/") + path.WriteString(r.Application) + } + if r.Name != "" { + path.WriteString("/") + path.WriteString(r.Name) + } + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SecurityGetPrivileges) WithContext(v context.Context) func(*SecurityGetPrivilegesRequest) { + return func(r *SecurityGetPrivilegesRequest) { + r.ctx = v + } +} + +// WithApplication - application name. +func (f SecurityGetPrivileges) WithApplication(v string) func(*SecurityGetPrivilegesRequest) { + return func(r *SecurityGetPrivilegesRequest) { + r.Application = v + } +} + +// WithName - privilege name. +func (f SecurityGetPrivileges) WithName(v string) func(*SecurityGetPrivilegesRequest) { + return func(r *SecurityGetPrivilegesRequest) { + r.Name = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SecurityGetPrivileges) WithPretty() func(*SecurityGetPrivilegesRequest) { + return func(r *SecurityGetPrivilegesRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SecurityGetPrivileges) WithHuman() func(*SecurityGetPrivilegesRequest) { + return func(r *SecurityGetPrivilegesRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SecurityGetPrivileges) WithErrorTrace() func(*SecurityGetPrivilegesRequest) { + return func(r *SecurityGetPrivilegesRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SecurityGetPrivileges) WithFilterPath(v ...string) func(*SecurityGetPrivilegesRequest) { + return func(r *SecurityGetPrivilegesRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SecurityGetPrivileges) WithHeader(h map[string]string) func(*SecurityGetPrivilegesRequest) { + return func(r *SecurityGetPrivilegesRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SecurityGetPrivileges) WithOpaqueID(s string) func(*SecurityGetPrivilegesRequest) { + return func(r *SecurityGetPrivilegesRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.get_role.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.get_role.go new file mode 100644 index 00000000..f76ce836 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.get_role.go @@ -0,0 +1,202 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newSecurityGetRoleFunc(t Transport) SecurityGetRole { + return func(o ...func(*SecurityGetRoleRequest)) (*Response, error) { + var r = SecurityGetRoleRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SecurityGetRole - Retrieves roles in the native realm. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-role.html. +type SecurityGetRole func(o ...func(*SecurityGetRoleRequest)) (*Response, error) + +// SecurityGetRoleRequest configures the Security Get Role API request. +type SecurityGetRoleRequest struct { + Name []string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SecurityGetRoleRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_security") + 1 + len("role") + 1 + len(strings.Join(r.Name, ","))) + path.WriteString("/") + path.WriteString("_security") + path.WriteString("/") + path.WriteString("role") + if len(r.Name) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Name, ",")) + } + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SecurityGetRole) WithContext(v context.Context) func(*SecurityGetRoleRequest) { + return func(r *SecurityGetRoleRequest) { + r.ctx = v + } +} + +// WithName - a list of role names. +func (f SecurityGetRole) WithName(v ...string) func(*SecurityGetRoleRequest) { + return func(r *SecurityGetRoleRequest) { + r.Name = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SecurityGetRole) WithPretty() func(*SecurityGetRoleRequest) { + return func(r *SecurityGetRoleRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SecurityGetRole) WithHuman() func(*SecurityGetRoleRequest) { + return func(r *SecurityGetRoleRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SecurityGetRole) WithErrorTrace() func(*SecurityGetRoleRequest) { + return func(r *SecurityGetRoleRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SecurityGetRole) WithFilterPath(v ...string) func(*SecurityGetRoleRequest) { + return func(r *SecurityGetRoleRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SecurityGetRole) WithHeader(h map[string]string) func(*SecurityGetRoleRequest) { + return func(r *SecurityGetRoleRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SecurityGetRole) WithOpaqueID(s string) func(*SecurityGetRoleRequest) { + return func(r *SecurityGetRoleRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.get_role_mapping.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.get_role_mapping.go new file mode 100644 index 00000000..5860195b --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.get_role_mapping.go @@ -0,0 +1,202 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newSecurityGetRoleMappingFunc(t Transport) SecurityGetRoleMapping { + return func(o ...func(*SecurityGetRoleMappingRequest)) (*Response, error) { + var r = SecurityGetRoleMappingRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SecurityGetRoleMapping - Retrieves role mappings. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-role-mapping.html. +type SecurityGetRoleMapping func(o ...func(*SecurityGetRoleMappingRequest)) (*Response, error) + +// SecurityGetRoleMappingRequest configures the Security Get Role Mapping API request. +type SecurityGetRoleMappingRequest struct { + Name []string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SecurityGetRoleMappingRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_security") + 1 + len("role_mapping") + 1 + len(strings.Join(r.Name, ","))) + path.WriteString("/") + path.WriteString("_security") + path.WriteString("/") + path.WriteString("role_mapping") + if len(r.Name) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Name, ",")) + } + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SecurityGetRoleMapping) WithContext(v context.Context) func(*SecurityGetRoleMappingRequest) { + return func(r *SecurityGetRoleMappingRequest) { + r.ctx = v + } +} + +// WithName - a list of role-mapping names. +func (f SecurityGetRoleMapping) WithName(v ...string) func(*SecurityGetRoleMappingRequest) { + return func(r *SecurityGetRoleMappingRequest) { + r.Name = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SecurityGetRoleMapping) WithPretty() func(*SecurityGetRoleMappingRequest) { + return func(r *SecurityGetRoleMappingRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SecurityGetRoleMapping) WithHuman() func(*SecurityGetRoleMappingRequest) { + return func(r *SecurityGetRoleMappingRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SecurityGetRoleMapping) WithErrorTrace() func(*SecurityGetRoleMappingRequest) { + return func(r *SecurityGetRoleMappingRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SecurityGetRoleMapping) WithFilterPath(v ...string) func(*SecurityGetRoleMappingRequest) { + return func(r *SecurityGetRoleMappingRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SecurityGetRoleMapping) WithHeader(h map[string]string) func(*SecurityGetRoleMappingRequest) { + return func(r *SecurityGetRoleMappingRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SecurityGetRoleMapping) WithOpaqueID(s string) func(*SecurityGetRoleMappingRequest) { + return func(r *SecurityGetRoleMappingRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.get_service_accounts.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.get_service_accounts.go new file mode 100644 index 00000000..fb81a1f0 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.get_service_accounts.go @@ -0,0 +1,214 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newSecurityGetServiceAccountsFunc(t Transport) SecurityGetServiceAccounts { + return func(o ...func(*SecurityGetServiceAccountsRequest)) (*Response, error) { + var r = SecurityGetServiceAccountsRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SecurityGetServiceAccounts - Retrieves information about service accounts. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-service-accounts.html. +type SecurityGetServiceAccounts func(o ...func(*SecurityGetServiceAccountsRequest)) (*Response, error) + +// SecurityGetServiceAccountsRequest configures the Security Get Service Accounts API request. +type SecurityGetServiceAccountsRequest struct { + Namespace string + Service string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SecurityGetServiceAccountsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_security") + 1 + len("service") + 1 + len(r.Namespace) + 1 + len(r.Service)) + path.WriteString("/") + path.WriteString("_security") + path.WriteString("/") + path.WriteString("service") + if r.Namespace != "" { + path.WriteString("/") + path.WriteString(r.Namespace) + } + if r.Service != "" { + path.WriteString("/") + path.WriteString(r.Service) + } + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SecurityGetServiceAccounts) WithContext(v context.Context) func(*SecurityGetServiceAccountsRequest) { + return func(r *SecurityGetServiceAccountsRequest) { + r.ctx = v + } +} + +// WithNamespace - an identifier for the namespace. +func (f SecurityGetServiceAccounts) WithNamespace(v string) func(*SecurityGetServiceAccountsRequest) { + return func(r *SecurityGetServiceAccountsRequest) { + r.Namespace = v + } +} + +// WithService - an identifier for the service name. +func (f SecurityGetServiceAccounts) WithService(v string) func(*SecurityGetServiceAccountsRequest) { + return func(r *SecurityGetServiceAccountsRequest) { + r.Service = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SecurityGetServiceAccounts) WithPretty() func(*SecurityGetServiceAccountsRequest) { + return func(r *SecurityGetServiceAccountsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SecurityGetServiceAccounts) WithHuman() func(*SecurityGetServiceAccountsRequest) { + return func(r *SecurityGetServiceAccountsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SecurityGetServiceAccounts) WithErrorTrace() func(*SecurityGetServiceAccountsRequest) { + return func(r *SecurityGetServiceAccountsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SecurityGetServiceAccounts) WithFilterPath(v ...string) func(*SecurityGetServiceAccountsRequest) { + return func(r *SecurityGetServiceAccountsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SecurityGetServiceAccounts) WithHeader(h map[string]string) func(*SecurityGetServiceAccountsRequest) { + return func(r *SecurityGetServiceAccountsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SecurityGetServiceAccounts) WithOpaqueID(s string) func(*SecurityGetServiceAccountsRequest) { + return func(r *SecurityGetServiceAccountsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.get_service_credentials.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.get_service_credentials.go new file mode 100644 index 00000000..a3d2d24c --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.get_service_credentials.go @@ -0,0 +1,198 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newSecurityGetServiceCredentialsFunc(t Transport) SecurityGetServiceCredentials { + return func(namespace string, service string, o ...func(*SecurityGetServiceCredentialsRequest)) (*Response, error) { + var r = SecurityGetServiceCredentialsRequest{Namespace: namespace, Service: service} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SecurityGetServiceCredentials - Retrieves information of all service credentials for a service account. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-service-credentials.html. +type SecurityGetServiceCredentials func(namespace string, service string, o ...func(*SecurityGetServiceCredentialsRequest)) (*Response, error) + +// SecurityGetServiceCredentialsRequest configures the Security Get Service Credentials API request. +type SecurityGetServiceCredentialsRequest struct { + Namespace string + Service string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SecurityGetServiceCredentialsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_security") + 1 + len("service") + 1 + len(r.Namespace) + 1 + len(r.Service) + 1 + len("credential")) + path.WriteString("/") + path.WriteString("_security") + path.WriteString("/") + path.WriteString("service") + path.WriteString("/") + path.WriteString(r.Namespace) + path.WriteString("/") + path.WriteString(r.Service) + path.WriteString("/") + path.WriteString("credential") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SecurityGetServiceCredentials) WithContext(v context.Context) func(*SecurityGetServiceCredentialsRequest) { + return func(r *SecurityGetServiceCredentialsRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SecurityGetServiceCredentials) WithPretty() func(*SecurityGetServiceCredentialsRequest) { + return func(r *SecurityGetServiceCredentialsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SecurityGetServiceCredentials) WithHuman() func(*SecurityGetServiceCredentialsRequest) { + return func(r *SecurityGetServiceCredentialsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SecurityGetServiceCredentials) WithErrorTrace() func(*SecurityGetServiceCredentialsRequest) { + return func(r *SecurityGetServiceCredentialsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SecurityGetServiceCredentials) WithFilterPath(v ...string) func(*SecurityGetServiceCredentialsRequest) { + return func(r *SecurityGetServiceCredentialsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SecurityGetServiceCredentials) WithHeader(h map[string]string) func(*SecurityGetServiceCredentialsRequest) { + return func(r *SecurityGetServiceCredentialsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SecurityGetServiceCredentials) WithOpaqueID(s string) func(*SecurityGetServiceCredentialsRequest) { + return func(r *SecurityGetServiceCredentialsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.get_token.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.get_token.go new file mode 100644 index 00000000..5f60df39 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.get_token.go @@ -0,0 +1,193 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newSecurityGetTokenFunc(t Transport) SecurityGetToken { + return func(body io.Reader, o ...func(*SecurityGetTokenRequest)) (*Response, error) { + var r = SecurityGetTokenRequest{Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SecurityGetToken - Creates a bearer token for access without requiring basic authentication. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-token.html. +type SecurityGetToken func(body io.Reader, o ...func(*SecurityGetTokenRequest)) (*Response, error) + +// SecurityGetTokenRequest configures the Security Get Token API request. +type SecurityGetTokenRequest struct { + Body io.Reader + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SecurityGetTokenRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(len("/_security/oauth2/token")) + path.WriteString("/_security/oauth2/token") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SecurityGetToken) WithContext(v context.Context) func(*SecurityGetTokenRequest) { + return func(r *SecurityGetTokenRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SecurityGetToken) WithPretty() func(*SecurityGetTokenRequest) { + return func(r *SecurityGetTokenRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SecurityGetToken) WithHuman() func(*SecurityGetTokenRequest) { + return func(r *SecurityGetTokenRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SecurityGetToken) WithErrorTrace() func(*SecurityGetTokenRequest) { + return func(r *SecurityGetTokenRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SecurityGetToken) WithFilterPath(v ...string) func(*SecurityGetTokenRequest) { + return func(r *SecurityGetTokenRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SecurityGetToken) WithHeader(h map[string]string) func(*SecurityGetTokenRequest) { + return func(r *SecurityGetTokenRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SecurityGetToken) WithOpaqueID(s string) func(*SecurityGetTokenRequest) { + return func(r *SecurityGetTokenRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.get_user.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.get_user.go new file mode 100644 index 00000000..baf79339 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.get_user.go @@ -0,0 +1,202 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newSecurityGetUserFunc(t Transport) SecurityGetUser { + return func(o ...func(*SecurityGetUserRequest)) (*Response, error) { + var r = SecurityGetUserRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SecurityGetUser - Retrieves information about users in the native realm and built-in users. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-user.html. +type SecurityGetUser func(o ...func(*SecurityGetUserRequest)) (*Response, error) + +// SecurityGetUserRequest configures the Security Get User API request. +type SecurityGetUserRequest struct { + Username []string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SecurityGetUserRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_security") + 1 + len("user") + 1 + len(strings.Join(r.Username, ","))) + path.WriteString("/") + path.WriteString("_security") + path.WriteString("/") + path.WriteString("user") + if len(r.Username) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Username, ",")) + } + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SecurityGetUser) WithContext(v context.Context) func(*SecurityGetUserRequest) { + return func(r *SecurityGetUserRequest) { + r.ctx = v + } +} + +// WithUsername - a list of usernames. +func (f SecurityGetUser) WithUsername(v ...string) func(*SecurityGetUserRequest) { + return func(r *SecurityGetUserRequest) { + r.Username = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SecurityGetUser) WithPretty() func(*SecurityGetUserRequest) { + return func(r *SecurityGetUserRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SecurityGetUser) WithHuman() func(*SecurityGetUserRequest) { + return func(r *SecurityGetUserRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SecurityGetUser) WithErrorTrace() func(*SecurityGetUserRequest) { + return func(r *SecurityGetUserRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SecurityGetUser) WithFilterPath(v ...string) func(*SecurityGetUserRequest) { + return func(r *SecurityGetUserRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SecurityGetUser) WithHeader(h map[string]string) func(*SecurityGetUserRequest) { + return func(r *SecurityGetUserRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SecurityGetUser) WithOpaqueID(s string) func(*SecurityGetUserRequest) { + return func(r *SecurityGetUserRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.get_user_privileges.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.get_user_privileges.go new file mode 100644 index 00000000..32e1b9bd --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.get_user_privileges.go @@ -0,0 +1,186 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newSecurityGetUserPrivilegesFunc(t Transport) SecurityGetUserPrivileges { + return func(o ...func(*SecurityGetUserPrivilegesRequest)) (*Response, error) { + var r = SecurityGetUserPrivilegesRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SecurityGetUserPrivileges - Retrieves security privileges for the logged in user. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-user-privileges.html. +type SecurityGetUserPrivileges func(o ...func(*SecurityGetUserPrivilegesRequest)) (*Response, error) + +// SecurityGetUserPrivilegesRequest configures the Security Get User Privileges API request. +type SecurityGetUserPrivilegesRequest struct { + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SecurityGetUserPrivilegesRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(len("/_security/user/_privileges")) + path.WriteString("/_security/user/_privileges") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SecurityGetUserPrivileges) WithContext(v context.Context) func(*SecurityGetUserPrivilegesRequest) { + return func(r *SecurityGetUserPrivilegesRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SecurityGetUserPrivileges) WithPretty() func(*SecurityGetUserPrivilegesRequest) { + return func(r *SecurityGetUserPrivilegesRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SecurityGetUserPrivileges) WithHuman() func(*SecurityGetUserPrivilegesRequest) { + return func(r *SecurityGetUserPrivilegesRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SecurityGetUserPrivileges) WithErrorTrace() func(*SecurityGetUserPrivilegesRequest) { + return func(r *SecurityGetUserPrivilegesRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SecurityGetUserPrivileges) WithFilterPath(v ...string) func(*SecurityGetUserPrivilegesRequest) { + return func(r *SecurityGetUserPrivilegesRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SecurityGetUserPrivileges) WithHeader(h map[string]string) func(*SecurityGetUserPrivilegesRequest) { + return func(r *SecurityGetUserPrivilegesRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SecurityGetUserPrivileges) WithOpaqueID(s string) func(*SecurityGetUserPrivilegesRequest) { + return func(r *SecurityGetUserPrivilegesRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.grant_api_key.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.grant_api_key.go new file mode 100644 index 00000000..138a4519 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.grant_api_key.go @@ -0,0 +1,206 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newSecurityGrantAPIKeyFunc(t Transport) SecurityGrantAPIKey { + return func(body io.Reader, o ...func(*SecurityGrantAPIKeyRequest)) (*Response, error) { + var r = SecurityGrantAPIKeyRequest{Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SecurityGrantAPIKey - Creates an API key on behalf of another user. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-grant-api-key.html. +type SecurityGrantAPIKey func(body io.Reader, o ...func(*SecurityGrantAPIKeyRequest)) (*Response, error) + +// SecurityGrantAPIKeyRequest configures the Security GrantAPI Key API request. +type SecurityGrantAPIKeyRequest struct { + Body io.Reader + + Refresh string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SecurityGrantAPIKeyRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(len("/_security/api_key/grant")) + path.WriteString("/_security/api_key/grant") + + params = make(map[string]string) + + if r.Refresh != "" { + params["refresh"] = r.Refresh + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SecurityGrantAPIKey) WithContext(v context.Context) func(*SecurityGrantAPIKeyRequest) { + return func(r *SecurityGrantAPIKeyRequest) { + r.ctx = v + } +} + +// WithRefresh - if `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes.. +func (f SecurityGrantAPIKey) WithRefresh(v string) func(*SecurityGrantAPIKeyRequest) { + return func(r *SecurityGrantAPIKeyRequest) { + r.Refresh = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SecurityGrantAPIKey) WithPretty() func(*SecurityGrantAPIKeyRequest) { + return func(r *SecurityGrantAPIKeyRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SecurityGrantAPIKey) WithHuman() func(*SecurityGrantAPIKeyRequest) { + return func(r *SecurityGrantAPIKeyRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SecurityGrantAPIKey) WithErrorTrace() func(*SecurityGrantAPIKeyRequest) { + return func(r *SecurityGrantAPIKeyRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SecurityGrantAPIKey) WithFilterPath(v ...string) func(*SecurityGrantAPIKeyRequest) { + return func(r *SecurityGrantAPIKeyRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SecurityGrantAPIKey) WithHeader(h map[string]string) func(*SecurityGrantAPIKeyRequest) { + return func(r *SecurityGrantAPIKeyRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SecurityGrantAPIKey) WithOpaqueID(s string) func(*SecurityGrantAPIKeyRequest) { + return func(r *SecurityGrantAPIKeyRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.has_privileges.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.has_privileges.go new file mode 100644 index 00000000..dcef8ae4 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.has_privileges.go @@ -0,0 +1,211 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newSecurityHasPrivilegesFunc(t Transport) SecurityHasPrivileges { + return func(body io.Reader, o ...func(*SecurityHasPrivilegesRequest)) (*Response, error) { + var r = SecurityHasPrivilegesRequest{Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SecurityHasPrivileges - Determines whether the specified user has a specified list of privileges. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-has-privileges.html. +type SecurityHasPrivileges func(body io.Reader, o ...func(*SecurityHasPrivilegesRequest)) (*Response, error) + +// SecurityHasPrivilegesRequest configures the Security Has Privileges API request. +type SecurityHasPrivilegesRequest struct { + Body io.Reader + + User string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SecurityHasPrivilegesRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_security") + 1 + len("user") + 1 + len(r.User) + 1 + len("_has_privileges")) + path.WriteString("/") + path.WriteString("_security") + path.WriteString("/") + path.WriteString("user") + if r.User != "" { + path.WriteString("/") + path.WriteString(r.User) + } + path.WriteString("/") + path.WriteString("_has_privileges") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SecurityHasPrivileges) WithContext(v context.Context) func(*SecurityHasPrivilegesRequest) { + return func(r *SecurityHasPrivilegesRequest) { + r.ctx = v + } +} + +// WithUser - username. +func (f SecurityHasPrivileges) WithUser(v string) func(*SecurityHasPrivilegesRequest) { + return func(r *SecurityHasPrivilegesRequest) { + r.User = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SecurityHasPrivileges) WithPretty() func(*SecurityHasPrivilegesRequest) { + return func(r *SecurityHasPrivilegesRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SecurityHasPrivileges) WithHuman() func(*SecurityHasPrivilegesRequest) { + return func(r *SecurityHasPrivilegesRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SecurityHasPrivileges) WithErrorTrace() func(*SecurityHasPrivilegesRequest) { + return func(r *SecurityHasPrivilegesRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SecurityHasPrivileges) WithFilterPath(v ...string) func(*SecurityHasPrivilegesRequest) { + return func(r *SecurityHasPrivilegesRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SecurityHasPrivileges) WithHeader(h map[string]string) func(*SecurityHasPrivilegesRequest) { + return func(r *SecurityHasPrivilegesRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SecurityHasPrivileges) WithOpaqueID(s string) func(*SecurityHasPrivilegesRequest) { + return func(r *SecurityHasPrivilegesRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.invalidate_api_key.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.invalidate_api_key.go new file mode 100644 index 00000000..8f2f8ae5 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.invalidate_api_key.go @@ -0,0 +1,193 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newSecurityInvalidateAPIKeyFunc(t Transport) SecurityInvalidateAPIKey { + return func(body io.Reader, o ...func(*SecurityInvalidateAPIKeyRequest)) (*Response, error) { + var r = SecurityInvalidateAPIKeyRequest{Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SecurityInvalidateAPIKey - Invalidates one or more API keys. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-invalidate-api-key.html. +type SecurityInvalidateAPIKey func(body io.Reader, o ...func(*SecurityInvalidateAPIKeyRequest)) (*Response, error) + +// SecurityInvalidateAPIKeyRequest configures the Security InvalidateAPI Key API request. +type SecurityInvalidateAPIKeyRequest struct { + Body io.Reader + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SecurityInvalidateAPIKeyRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + path.Grow(len("/_security/api_key")) + path.WriteString("/_security/api_key") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SecurityInvalidateAPIKey) WithContext(v context.Context) func(*SecurityInvalidateAPIKeyRequest) { + return func(r *SecurityInvalidateAPIKeyRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SecurityInvalidateAPIKey) WithPretty() func(*SecurityInvalidateAPIKeyRequest) { + return func(r *SecurityInvalidateAPIKeyRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SecurityInvalidateAPIKey) WithHuman() func(*SecurityInvalidateAPIKeyRequest) { + return func(r *SecurityInvalidateAPIKeyRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SecurityInvalidateAPIKey) WithErrorTrace() func(*SecurityInvalidateAPIKeyRequest) { + return func(r *SecurityInvalidateAPIKeyRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SecurityInvalidateAPIKey) WithFilterPath(v ...string) func(*SecurityInvalidateAPIKeyRequest) { + return func(r *SecurityInvalidateAPIKeyRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SecurityInvalidateAPIKey) WithHeader(h map[string]string) func(*SecurityInvalidateAPIKeyRequest) { + return func(r *SecurityInvalidateAPIKeyRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SecurityInvalidateAPIKey) WithOpaqueID(s string) func(*SecurityInvalidateAPIKeyRequest) { + return func(r *SecurityInvalidateAPIKeyRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.invalidate_token.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.invalidate_token.go new file mode 100644 index 00000000..34419d1d --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.invalidate_token.go @@ -0,0 +1,193 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newSecurityInvalidateTokenFunc(t Transport) SecurityInvalidateToken { + return func(body io.Reader, o ...func(*SecurityInvalidateTokenRequest)) (*Response, error) { + var r = SecurityInvalidateTokenRequest{Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SecurityInvalidateToken - Invalidates one or more access tokens or refresh tokens. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-invalidate-token.html. +type SecurityInvalidateToken func(body io.Reader, o ...func(*SecurityInvalidateTokenRequest)) (*Response, error) + +// SecurityInvalidateTokenRequest configures the Security Invalidate Token API request. +type SecurityInvalidateTokenRequest struct { + Body io.Reader + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SecurityInvalidateTokenRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + path.Grow(len("/_security/oauth2/token")) + path.WriteString("/_security/oauth2/token") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SecurityInvalidateToken) WithContext(v context.Context) func(*SecurityInvalidateTokenRequest) { + return func(r *SecurityInvalidateTokenRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SecurityInvalidateToken) WithPretty() func(*SecurityInvalidateTokenRequest) { + return func(r *SecurityInvalidateTokenRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SecurityInvalidateToken) WithHuman() func(*SecurityInvalidateTokenRequest) { + return func(r *SecurityInvalidateTokenRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SecurityInvalidateToken) WithErrorTrace() func(*SecurityInvalidateTokenRequest) { + return func(r *SecurityInvalidateTokenRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SecurityInvalidateToken) WithFilterPath(v ...string) func(*SecurityInvalidateTokenRequest) { + return func(r *SecurityInvalidateTokenRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SecurityInvalidateToken) WithHeader(h map[string]string) func(*SecurityInvalidateTokenRequest) { + return func(r *SecurityInvalidateTokenRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SecurityInvalidateToken) WithOpaqueID(s string) func(*SecurityInvalidateTokenRequest) { + return func(r *SecurityInvalidateTokenRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.put_privileges.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.put_privileges.go new file mode 100644 index 00000000..1b885069 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.put_privileges.go @@ -0,0 +1,206 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newSecurityPutPrivilegesFunc(t Transport) SecurityPutPrivileges { + return func(body io.Reader, o ...func(*SecurityPutPrivilegesRequest)) (*Response, error) { + var r = SecurityPutPrivilegesRequest{Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SecurityPutPrivileges - Adds or updates application privileges. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-privileges.html. +type SecurityPutPrivileges func(body io.Reader, o ...func(*SecurityPutPrivilegesRequest)) (*Response, error) + +// SecurityPutPrivilegesRequest configures the Security Put Privileges API request. +type SecurityPutPrivilegesRequest struct { + Body io.Reader + + Refresh string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SecurityPutPrivilegesRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(len("/_security/privilege/")) + path.WriteString("/_security/privilege/") + + params = make(map[string]string) + + if r.Refresh != "" { + params["refresh"] = r.Refresh + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SecurityPutPrivileges) WithContext(v context.Context) func(*SecurityPutPrivilegesRequest) { + return func(r *SecurityPutPrivilegesRequest) { + r.ctx = v + } +} + +// WithRefresh - if `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes.. +func (f SecurityPutPrivileges) WithRefresh(v string) func(*SecurityPutPrivilegesRequest) { + return func(r *SecurityPutPrivilegesRequest) { + r.Refresh = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SecurityPutPrivileges) WithPretty() func(*SecurityPutPrivilegesRequest) { + return func(r *SecurityPutPrivilegesRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SecurityPutPrivileges) WithHuman() func(*SecurityPutPrivilegesRequest) { + return func(r *SecurityPutPrivilegesRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SecurityPutPrivileges) WithErrorTrace() func(*SecurityPutPrivilegesRequest) { + return func(r *SecurityPutPrivilegesRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SecurityPutPrivileges) WithFilterPath(v ...string) func(*SecurityPutPrivilegesRequest) { + return func(r *SecurityPutPrivilegesRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SecurityPutPrivileges) WithHeader(h map[string]string) func(*SecurityPutPrivilegesRequest) { + return func(r *SecurityPutPrivilegesRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SecurityPutPrivileges) WithOpaqueID(s string) func(*SecurityPutPrivilegesRequest) { + return func(r *SecurityPutPrivilegesRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.put_role.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.put_role.go new file mode 100644 index 00000000..e321f0d6 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.put_role.go @@ -0,0 +1,213 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newSecurityPutRoleFunc(t Transport) SecurityPutRole { + return func(name string, body io.Reader, o ...func(*SecurityPutRoleRequest)) (*Response, error) { + var r = SecurityPutRoleRequest{Name: name, Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SecurityPutRole - Adds and updates roles in the native realm. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-role.html. +type SecurityPutRole func(name string, body io.Reader, o ...func(*SecurityPutRoleRequest)) (*Response, error) + +// SecurityPutRoleRequest configures the Security Put Role API request. +type SecurityPutRoleRequest struct { + Body io.Reader + + Name string + + Refresh string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SecurityPutRoleRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(1 + len("_security") + 1 + len("role") + 1 + len(r.Name)) + path.WriteString("/") + path.WriteString("_security") + path.WriteString("/") + path.WriteString("role") + path.WriteString("/") + path.WriteString(r.Name) + + params = make(map[string]string) + + if r.Refresh != "" { + params["refresh"] = r.Refresh + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SecurityPutRole) WithContext(v context.Context) func(*SecurityPutRoleRequest) { + return func(r *SecurityPutRoleRequest) { + r.ctx = v + } +} + +// WithRefresh - if `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes.. +func (f SecurityPutRole) WithRefresh(v string) func(*SecurityPutRoleRequest) { + return func(r *SecurityPutRoleRequest) { + r.Refresh = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SecurityPutRole) WithPretty() func(*SecurityPutRoleRequest) { + return func(r *SecurityPutRoleRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SecurityPutRole) WithHuman() func(*SecurityPutRoleRequest) { + return func(r *SecurityPutRoleRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SecurityPutRole) WithErrorTrace() func(*SecurityPutRoleRequest) { + return func(r *SecurityPutRoleRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SecurityPutRole) WithFilterPath(v ...string) func(*SecurityPutRoleRequest) { + return func(r *SecurityPutRoleRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SecurityPutRole) WithHeader(h map[string]string) func(*SecurityPutRoleRequest) { + return func(r *SecurityPutRoleRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SecurityPutRole) WithOpaqueID(s string) func(*SecurityPutRoleRequest) { + return func(r *SecurityPutRoleRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.put_role_mapping.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.put_role_mapping.go new file mode 100644 index 00000000..4ee57084 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.put_role_mapping.go @@ -0,0 +1,213 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newSecurityPutRoleMappingFunc(t Transport) SecurityPutRoleMapping { + return func(name string, body io.Reader, o ...func(*SecurityPutRoleMappingRequest)) (*Response, error) { + var r = SecurityPutRoleMappingRequest{Name: name, Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SecurityPutRoleMapping - Creates and updates role mappings. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-role-mapping.html. +type SecurityPutRoleMapping func(name string, body io.Reader, o ...func(*SecurityPutRoleMappingRequest)) (*Response, error) + +// SecurityPutRoleMappingRequest configures the Security Put Role Mapping API request. +type SecurityPutRoleMappingRequest struct { + Body io.Reader + + Name string + + Refresh string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SecurityPutRoleMappingRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(1 + len("_security") + 1 + len("role_mapping") + 1 + len(r.Name)) + path.WriteString("/") + path.WriteString("_security") + path.WriteString("/") + path.WriteString("role_mapping") + path.WriteString("/") + path.WriteString(r.Name) + + params = make(map[string]string) + + if r.Refresh != "" { + params["refresh"] = r.Refresh + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SecurityPutRoleMapping) WithContext(v context.Context) func(*SecurityPutRoleMappingRequest) { + return func(r *SecurityPutRoleMappingRequest) { + r.ctx = v + } +} + +// WithRefresh - if `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes.. +func (f SecurityPutRoleMapping) WithRefresh(v string) func(*SecurityPutRoleMappingRequest) { + return func(r *SecurityPutRoleMappingRequest) { + r.Refresh = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SecurityPutRoleMapping) WithPretty() func(*SecurityPutRoleMappingRequest) { + return func(r *SecurityPutRoleMappingRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SecurityPutRoleMapping) WithHuman() func(*SecurityPutRoleMappingRequest) { + return func(r *SecurityPutRoleMappingRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SecurityPutRoleMapping) WithErrorTrace() func(*SecurityPutRoleMappingRequest) { + return func(r *SecurityPutRoleMappingRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SecurityPutRoleMapping) WithFilterPath(v ...string) func(*SecurityPutRoleMappingRequest) { + return func(r *SecurityPutRoleMappingRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SecurityPutRoleMapping) WithHeader(h map[string]string) func(*SecurityPutRoleMappingRequest) { + return func(r *SecurityPutRoleMappingRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SecurityPutRoleMapping) WithOpaqueID(s string) func(*SecurityPutRoleMappingRequest) { + return func(r *SecurityPutRoleMappingRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.put_user.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.put_user.go new file mode 100644 index 00000000..c592e789 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.put_user.go @@ -0,0 +1,213 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newSecurityPutUserFunc(t Transport) SecurityPutUser { + return func(username string, body io.Reader, o ...func(*SecurityPutUserRequest)) (*Response, error) { + var r = SecurityPutUserRequest{Username: username, Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SecurityPutUser - Adds and updates users in the native realm. These users are commonly referred to as native users. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-user.html. +type SecurityPutUser func(username string, body io.Reader, o ...func(*SecurityPutUserRequest)) (*Response, error) + +// SecurityPutUserRequest configures the Security Put User API request. +type SecurityPutUserRequest struct { + Body io.Reader + + Username string + + Refresh string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SecurityPutUserRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(1 + len("_security") + 1 + len("user") + 1 + len(r.Username)) + path.WriteString("/") + path.WriteString("_security") + path.WriteString("/") + path.WriteString("user") + path.WriteString("/") + path.WriteString(r.Username) + + params = make(map[string]string) + + if r.Refresh != "" { + params["refresh"] = r.Refresh + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SecurityPutUser) WithContext(v context.Context) func(*SecurityPutUserRequest) { + return func(r *SecurityPutUserRequest) { + r.ctx = v + } +} + +// WithRefresh - if `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes.. +func (f SecurityPutUser) WithRefresh(v string) func(*SecurityPutUserRequest) { + return func(r *SecurityPutUserRequest) { + r.Refresh = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SecurityPutUser) WithPretty() func(*SecurityPutUserRequest) { + return func(r *SecurityPutUserRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SecurityPutUser) WithHuman() func(*SecurityPutUserRequest) { + return func(r *SecurityPutUserRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SecurityPutUser) WithErrorTrace() func(*SecurityPutUserRequest) { + return func(r *SecurityPutUserRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SecurityPutUser) WithFilterPath(v ...string) func(*SecurityPutUserRequest) { + return func(r *SecurityPutUserRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SecurityPutUser) WithHeader(h map[string]string) func(*SecurityPutUserRequest) { + return func(r *SecurityPutUserRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SecurityPutUser) WithOpaqueID(s string) func(*SecurityPutUserRequest) { + return func(r *SecurityPutUserRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.query_api_keys.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.query_api_keys.go new file mode 100644 index 00000000..3e670e9c --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.query_api_keys.go @@ -0,0 +1,200 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newSecurityQueryAPIKeysFunc(t Transport) SecurityQueryAPIKeys { + return func(o ...func(*SecurityQueryAPIKeysRequest)) (*Response, error) { + var r = SecurityQueryAPIKeysRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SecurityQueryAPIKeys - Retrieves information for API keys using a subset of query DSL +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-query-api-key.html. +type SecurityQueryAPIKeys func(o ...func(*SecurityQueryAPIKeysRequest)) (*Response, error) + +// SecurityQueryAPIKeysRequest configures the Security QueryAPI Keys API request. +type SecurityQueryAPIKeysRequest struct { + Body io.Reader + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SecurityQueryAPIKeysRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(len("/_security/_query/api_key")) + path.WriteString("/_security/_query/api_key") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SecurityQueryAPIKeys) WithContext(v context.Context) func(*SecurityQueryAPIKeysRequest) { + return func(r *SecurityQueryAPIKeysRequest) { + r.ctx = v + } +} + +// WithBody - From, size, query, sort and search_after. +func (f SecurityQueryAPIKeys) WithBody(v io.Reader) func(*SecurityQueryAPIKeysRequest) { + return func(r *SecurityQueryAPIKeysRequest) { + r.Body = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SecurityQueryAPIKeys) WithPretty() func(*SecurityQueryAPIKeysRequest) { + return func(r *SecurityQueryAPIKeysRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SecurityQueryAPIKeys) WithHuman() func(*SecurityQueryAPIKeysRequest) { + return func(r *SecurityQueryAPIKeysRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SecurityQueryAPIKeys) WithErrorTrace() func(*SecurityQueryAPIKeysRequest) { + return func(r *SecurityQueryAPIKeysRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SecurityQueryAPIKeys) WithFilterPath(v ...string) func(*SecurityQueryAPIKeysRequest) { + return func(r *SecurityQueryAPIKeysRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SecurityQueryAPIKeys) WithHeader(h map[string]string) func(*SecurityQueryAPIKeysRequest) { + return func(r *SecurityQueryAPIKeysRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SecurityQueryAPIKeys) WithOpaqueID(s string) func(*SecurityQueryAPIKeysRequest) { + return func(r *SecurityQueryAPIKeysRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.saml_authenticate.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.saml_authenticate.go new file mode 100644 index 00000000..7f31eba8 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.saml_authenticate.go @@ -0,0 +1,193 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newSecuritySamlAuthenticateFunc(t Transport) SecuritySamlAuthenticate { + return func(body io.Reader, o ...func(*SecuritySamlAuthenticateRequest)) (*Response, error) { + var r = SecuritySamlAuthenticateRequest{Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SecuritySamlAuthenticate - Exchanges a SAML Response message for an Elasticsearch access token and refresh token pair +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-saml-authenticate.html. +type SecuritySamlAuthenticate func(body io.Reader, o ...func(*SecuritySamlAuthenticateRequest)) (*Response, error) + +// SecuritySamlAuthenticateRequest configures the Security Saml Authenticate API request. +type SecuritySamlAuthenticateRequest struct { + Body io.Reader + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SecuritySamlAuthenticateRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(len("/_security/saml/authenticate")) + path.WriteString("/_security/saml/authenticate") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SecuritySamlAuthenticate) WithContext(v context.Context) func(*SecuritySamlAuthenticateRequest) { + return func(r *SecuritySamlAuthenticateRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SecuritySamlAuthenticate) WithPretty() func(*SecuritySamlAuthenticateRequest) { + return func(r *SecuritySamlAuthenticateRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SecuritySamlAuthenticate) WithHuman() func(*SecuritySamlAuthenticateRequest) { + return func(r *SecuritySamlAuthenticateRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SecuritySamlAuthenticate) WithErrorTrace() func(*SecuritySamlAuthenticateRequest) { + return func(r *SecuritySamlAuthenticateRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SecuritySamlAuthenticate) WithFilterPath(v ...string) func(*SecuritySamlAuthenticateRequest) { + return func(r *SecuritySamlAuthenticateRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SecuritySamlAuthenticate) WithHeader(h map[string]string) func(*SecuritySamlAuthenticateRequest) { + return func(r *SecuritySamlAuthenticateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SecuritySamlAuthenticate) WithOpaqueID(s string) func(*SecuritySamlAuthenticateRequest) { + return func(r *SecuritySamlAuthenticateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.saml_complete_logout.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.saml_complete_logout.go new file mode 100644 index 00000000..39936bc4 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.saml_complete_logout.go @@ -0,0 +1,193 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newSecuritySamlCompleteLogoutFunc(t Transport) SecuritySamlCompleteLogout { + return func(body io.Reader, o ...func(*SecuritySamlCompleteLogoutRequest)) (*Response, error) { + var r = SecuritySamlCompleteLogoutRequest{Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SecuritySamlCompleteLogout - Verifies the logout response sent from the SAML IdP +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-saml-complete-logout.html. +type SecuritySamlCompleteLogout func(body io.Reader, o ...func(*SecuritySamlCompleteLogoutRequest)) (*Response, error) + +// SecuritySamlCompleteLogoutRequest configures the Security Saml Complete Logout API request. +type SecuritySamlCompleteLogoutRequest struct { + Body io.Reader + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SecuritySamlCompleteLogoutRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(len("/_security/saml/complete_logout")) + path.WriteString("/_security/saml/complete_logout") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SecuritySamlCompleteLogout) WithContext(v context.Context) func(*SecuritySamlCompleteLogoutRequest) { + return func(r *SecuritySamlCompleteLogoutRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SecuritySamlCompleteLogout) WithPretty() func(*SecuritySamlCompleteLogoutRequest) { + return func(r *SecuritySamlCompleteLogoutRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SecuritySamlCompleteLogout) WithHuman() func(*SecuritySamlCompleteLogoutRequest) { + return func(r *SecuritySamlCompleteLogoutRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SecuritySamlCompleteLogout) WithErrorTrace() func(*SecuritySamlCompleteLogoutRequest) { + return func(r *SecuritySamlCompleteLogoutRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SecuritySamlCompleteLogout) WithFilterPath(v ...string) func(*SecuritySamlCompleteLogoutRequest) { + return func(r *SecuritySamlCompleteLogoutRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SecuritySamlCompleteLogout) WithHeader(h map[string]string) func(*SecuritySamlCompleteLogoutRequest) { + return func(r *SecuritySamlCompleteLogoutRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SecuritySamlCompleteLogout) WithOpaqueID(s string) func(*SecuritySamlCompleteLogoutRequest) { + return func(r *SecuritySamlCompleteLogoutRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.saml_invalidate.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.saml_invalidate.go new file mode 100644 index 00000000..015f706b --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.saml_invalidate.go @@ -0,0 +1,193 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newSecuritySamlInvalidateFunc(t Transport) SecuritySamlInvalidate { + return func(body io.Reader, o ...func(*SecuritySamlInvalidateRequest)) (*Response, error) { + var r = SecuritySamlInvalidateRequest{Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SecuritySamlInvalidate - Consumes a SAML LogoutRequest +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-saml-invalidate.html. +type SecuritySamlInvalidate func(body io.Reader, o ...func(*SecuritySamlInvalidateRequest)) (*Response, error) + +// SecuritySamlInvalidateRequest configures the Security Saml Invalidate API request. +type SecuritySamlInvalidateRequest struct { + Body io.Reader + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SecuritySamlInvalidateRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(len("/_security/saml/invalidate")) + path.WriteString("/_security/saml/invalidate") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SecuritySamlInvalidate) WithContext(v context.Context) func(*SecuritySamlInvalidateRequest) { + return func(r *SecuritySamlInvalidateRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SecuritySamlInvalidate) WithPretty() func(*SecuritySamlInvalidateRequest) { + return func(r *SecuritySamlInvalidateRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SecuritySamlInvalidate) WithHuman() func(*SecuritySamlInvalidateRequest) { + return func(r *SecuritySamlInvalidateRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SecuritySamlInvalidate) WithErrorTrace() func(*SecuritySamlInvalidateRequest) { + return func(r *SecuritySamlInvalidateRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SecuritySamlInvalidate) WithFilterPath(v ...string) func(*SecuritySamlInvalidateRequest) { + return func(r *SecuritySamlInvalidateRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SecuritySamlInvalidate) WithHeader(h map[string]string) func(*SecuritySamlInvalidateRequest) { + return func(r *SecuritySamlInvalidateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SecuritySamlInvalidate) WithOpaqueID(s string) func(*SecuritySamlInvalidateRequest) { + return func(r *SecuritySamlInvalidateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.saml_logout.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.saml_logout.go new file mode 100644 index 00000000..646894c6 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.saml_logout.go @@ -0,0 +1,193 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newSecuritySamlLogoutFunc(t Transport) SecuritySamlLogout { + return func(body io.Reader, o ...func(*SecuritySamlLogoutRequest)) (*Response, error) { + var r = SecuritySamlLogoutRequest{Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SecuritySamlLogout - Invalidates an access token and a refresh token that were generated via the SAML Authenticate API +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-saml-logout.html. +type SecuritySamlLogout func(body io.Reader, o ...func(*SecuritySamlLogoutRequest)) (*Response, error) + +// SecuritySamlLogoutRequest configures the Security Saml Logout API request. +type SecuritySamlLogoutRequest struct { + Body io.Reader + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SecuritySamlLogoutRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(len("/_security/saml/logout")) + path.WriteString("/_security/saml/logout") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SecuritySamlLogout) WithContext(v context.Context) func(*SecuritySamlLogoutRequest) { + return func(r *SecuritySamlLogoutRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SecuritySamlLogout) WithPretty() func(*SecuritySamlLogoutRequest) { + return func(r *SecuritySamlLogoutRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SecuritySamlLogout) WithHuman() func(*SecuritySamlLogoutRequest) { + return func(r *SecuritySamlLogoutRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SecuritySamlLogout) WithErrorTrace() func(*SecuritySamlLogoutRequest) { + return func(r *SecuritySamlLogoutRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SecuritySamlLogout) WithFilterPath(v ...string) func(*SecuritySamlLogoutRequest) { + return func(r *SecuritySamlLogoutRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SecuritySamlLogout) WithHeader(h map[string]string) func(*SecuritySamlLogoutRequest) { + return func(r *SecuritySamlLogoutRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SecuritySamlLogout) WithOpaqueID(s string) func(*SecuritySamlLogoutRequest) { + return func(r *SecuritySamlLogoutRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.saml_prepare_authentication.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.saml_prepare_authentication.go new file mode 100644 index 00000000..2eacbcfa --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.saml_prepare_authentication.go @@ -0,0 +1,193 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newSecuritySamlPrepareAuthenticationFunc(t Transport) SecuritySamlPrepareAuthentication { + return func(body io.Reader, o ...func(*SecuritySamlPrepareAuthenticationRequest)) (*Response, error) { + var r = SecuritySamlPrepareAuthenticationRequest{Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SecuritySamlPrepareAuthentication - Creates a SAML authentication request +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-saml-prepare-authentication.html. +type SecuritySamlPrepareAuthentication func(body io.Reader, o ...func(*SecuritySamlPrepareAuthenticationRequest)) (*Response, error) + +// SecuritySamlPrepareAuthenticationRequest configures the Security Saml Prepare Authentication API request. +type SecuritySamlPrepareAuthenticationRequest struct { + Body io.Reader + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SecuritySamlPrepareAuthenticationRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(len("/_security/saml/prepare")) + path.WriteString("/_security/saml/prepare") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SecuritySamlPrepareAuthentication) WithContext(v context.Context) func(*SecuritySamlPrepareAuthenticationRequest) { + return func(r *SecuritySamlPrepareAuthenticationRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SecuritySamlPrepareAuthentication) WithPretty() func(*SecuritySamlPrepareAuthenticationRequest) { + return func(r *SecuritySamlPrepareAuthenticationRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SecuritySamlPrepareAuthentication) WithHuman() func(*SecuritySamlPrepareAuthenticationRequest) { + return func(r *SecuritySamlPrepareAuthenticationRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SecuritySamlPrepareAuthentication) WithErrorTrace() func(*SecuritySamlPrepareAuthenticationRequest) { + return func(r *SecuritySamlPrepareAuthenticationRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SecuritySamlPrepareAuthentication) WithFilterPath(v ...string) func(*SecuritySamlPrepareAuthenticationRequest) { + return func(r *SecuritySamlPrepareAuthenticationRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SecuritySamlPrepareAuthentication) WithHeader(h map[string]string) func(*SecuritySamlPrepareAuthenticationRequest) { + return func(r *SecuritySamlPrepareAuthenticationRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SecuritySamlPrepareAuthentication) WithOpaqueID(s string) func(*SecuritySamlPrepareAuthenticationRequest) { + return func(r *SecuritySamlPrepareAuthenticationRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.saml_service_provider_metadata.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.saml_service_provider_metadata.go new file mode 100644 index 00000000..75ef9292 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.security.saml_service_provider_metadata.go @@ -0,0 +1,195 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newSecuritySamlServiceProviderMetadataFunc(t Transport) SecuritySamlServiceProviderMetadata { + return func(realm_name string, o ...func(*SecuritySamlServiceProviderMetadataRequest)) (*Response, error) { + var r = SecuritySamlServiceProviderMetadataRequest{RealmName: realm_name} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SecuritySamlServiceProviderMetadata - Generates SAML metadata for the Elastic stack SAML 2.0 Service Provider +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-saml-sp-metadata.html. +type SecuritySamlServiceProviderMetadata func(realm_name string, o ...func(*SecuritySamlServiceProviderMetadataRequest)) (*Response, error) + +// SecuritySamlServiceProviderMetadataRequest configures the Security Saml Service Provider Metadata API request. +type SecuritySamlServiceProviderMetadataRequest struct { + RealmName string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SecuritySamlServiceProviderMetadataRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_security") + 1 + len("saml") + 1 + len("metadata") + 1 + len(r.RealmName)) + path.WriteString("/") + path.WriteString("_security") + path.WriteString("/") + path.WriteString("saml") + path.WriteString("/") + path.WriteString("metadata") + path.WriteString("/") + path.WriteString(r.RealmName) + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SecuritySamlServiceProviderMetadata) WithContext(v context.Context) func(*SecuritySamlServiceProviderMetadataRequest) { + return func(r *SecuritySamlServiceProviderMetadataRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SecuritySamlServiceProviderMetadata) WithPretty() func(*SecuritySamlServiceProviderMetadataRequest) { + return func(r *SecuritySamlServiceProviderMetadataRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SecuritySamlServiceProviderMetadata) WithHuman() func(*SecuritySamlServiceProviderMetadataRequest) { + return func(r *SecuritySamlServiceProviderMetadataRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SecuritySamlServiceProviderMetadata) WithErrorTrace() func(*SecuritySamlServiceProviderMetadataRequest) { + return func(r *SecuritySamlServiceProviderMetadataRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SecuritySamlServiceProviderMetadata) WithFilterPath(v ...string) func(*SecuritySamlServiceProviderMetadataRequest) { + return func(r *SecuritySamlServiceProviderMetadataRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SecuritySamlServiceProviderMetadata) WithHeader(h map[string]string) func(*SecuritySamlServiceProviderMetadataRequest) { + return func(r *SecuritySamlServiceProviderMetadataRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SecuritySamlServiceProviderMetadata) WithOpaqueID(s string) func(*SecuritySamlServiceProviderMetadataRequest) { + return func(r *SecuritySamlServiceProviderMetadataRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.slm.delete_lifecycle.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.slm.delete_lifecycle.go new file mode 100644 index 00000000..e78421bf --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.slm.delete_lifecycle.go @@ -0,0 +1,193 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newSlmDeleteLifecycleFunc(t Transport) SlmDeleteLifecycle { + return func(policy_id string, o ...func(*SlmDeleteLifecycleRequest)) (*Response, error) { + var r = SlmDeleteLifecycleRequest{PolicyID: policy_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SlmDeleteLifecycle - Deletes an existing snapshot lifecycle policy. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-delete-policy.html. +type SlmDeleteLifecycle func(policy_id string, o ...func(*SlmDeleteLifecycleRequest)) (*Response, error) + +// SlmDeleteLifecycleRequest configures the Slm Delete Lifecycle API request. +type SlmDeleteLifecycleRequest struct { + PolicyID string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SlmDeleteLifecycleRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + path.Grow(1 + len("_slm") + 1 + len("policy") + 1 + len(r.PolicyID)) + path.WriteString("/") + path.WriteString("_slm") + path.WriteString("/") + path.WriteString("policy") + path.WriteString("/") + path.WriteString(r.PolicyID) + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SlmDeleteLifecycle) WithContext(v context.Context) func(*SlmDeleteLifecycleRequest) { + return func(r *SlmDeleteLifecycleRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SlmDeleteLifecycle) WithPretty() func(*SlmDeleteLifecycleRequest) { + return func(r *SlmDeleteLifecycleRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SlmDeleteLifecycle) WithHuman() func(*SlmDeleteLifecycleRequest) { + return func(r *SlmDeleteLifecycleRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SlmDeleteLifecycle) WithErrorTrace() func(*SlmDeleteLifecycleRequest) { + return func(r *SlmDeleteLifecycleRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SlmDeleteLifecycle) WithFilterPath(v ...string) func(*SlmDeleteLifecycleRequest) { + return func(r *SlmDeleteLifecycleRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SlmDeleteLifecycle) WithHeader(h map[string]string) func(*SlmDeleteLifecycleRequest) { + return func(r *SlmDeleteLifecycleRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SlmDeleteLifecycle) WithOpaqueID(s string) func(*SlmDeleteLifecycleRequest) { + return func(r *SlmDeleteLifecycleRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.slm.execute_lifecycle.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.slm.execute_lifecycle.go new file mode 100644 index 00000000..a3caf962 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.slm.execute_lifecycle.go @@ -0,0 +1,195 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newSlmExecuteLifecycleFunc(t Transport) SlmExecuteLifecycle { + return func(policy_id string, o ...func(*SlmExecuteLifecycleRequest)) (*Response, error) { + var r = SlmExecuteLifecycleRequest{PolicyID: policy_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SlmExecuteLifecycle - Immediately creates a snapshot according to the lifecycle policy, without waiting for the scheduled time. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-execute-lifecycle.html. +type SlmExecuteLifecycle func(policy_id string, o ...func(*SlmExecuteLifecycleRequest)) (*Response, error) + +// SlmExecuteLifecycleRequest configures the Slm Execute Lifecycle API request. +type SlmExecuteLifecycleRequest struct { + PolicyID string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SlmExecuteLifecycleRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(1 + len("_slm") + 1 + len("policy") + 1 + len(r.PolicyID) + 1 + len("_execute")) + path.WriteString("/") + path.WriteString("_slm") + path.WriteString("/") + path.WriteString("policy") + path.WriteString("/") + path.WriteString(r.PolicyID) + path.WriteString("/") + path.WriteString("_execute") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SlmExecuteLifecycle) WithContext(v context.Context) func(*SlmExecuteLifecycleRequest) { + return func(r *SlmExecuteLifecycleRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SlmExecuteLifecycle) WithPretty() func(*SlmExecuteLifecycleRequest) { + return func(r *SlmExecuteLifecycleRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SlmExecuteLifecycle) WithHuman() func(*SlmExecuteLifecycleRequest) { + return func(r *SlmExecuteLifecycleRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SlmExecuteLifecycle) WithErrorTrace() func(*SlmExecuteLifecycleRequest) { + return func(r *SlmExecuteLifecycleRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SlmExecuteLifecycle) WithFilterPath(v ...string) func(*SlmExecuteLifecycleRequest) { + return func(r *SlmExecuteLifecycleRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SlmExecuteLifecycle) WithHeader(h map[string]string) func(*SlmExecuteLifecycleRequest) { + return func(r *SlmExecuteLifecycleRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SlmExecuteLifecycle) WithOpaqueID(s string) func(*SlmExecuteLifecycleRequest) { + return func(r *SlmExecuteLifecycleRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.slm.execute_retention.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.slm.execute_retention.go new file mode 100644 index 00000000..f10372fe --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.slm.execute_retention.go @@ -0,0 +1,186 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newSlmExecuteRetentionFunc(t Transport) SlmExecuteRetention { + return func(o ...func(*SlmExecuteRetentionRequest)) (*Response, error) { + var r = SlmExecuteRetentionRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SlmExecuteRetention - Deletes any snapshots that are expired according to the policy's retention rules. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-execute-retention.html. +type SlmExecuteRetention func(o ...func(*SlmExecuteRetentionRequest)) (*Response, error) + +// SlmExecuteRetentionRequest configures the Slm Execute Retention API request. +type SlmExecuteRetentionRequest struct { + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SlmExecuteRetentionRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(len("/_slm/_execute_retention")) + path.WriteString("/_slm/_execute_retention") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SlmExecuteRetention) WithContext(v context.Context) func(*SlmExecuteRetentionRequest) { + return func(r *SlmExecuteRetentionRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SlmExecuteRetention) WithPretty() func(*SlmExecuteRetentionRequest) { + return func(r *SlmExecuteRetentionRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SlmExecuteRetention) WithHuman() func(*SlmExecuteRetentionRequest) { + return func(r *SlmExecuteRetentionRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SlmExecuteRetention) WithErrorTrace() func(*SlmExecuteRetentionRequest) { + return func(r *SlmExecuteRetentionRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SlmExecuteRetention) WithFilterPath(v ...string) func(*SlmExecuteRetentionRequest) { + return func(r *SlmExecuteRetentionRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SlmExecuteRetention) WithHeader(h map[string]string) func(*SlmExecuteRetentionRequest) { + return func(r *SlmExecuteRetentionRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SlmExecuteRetention) WithOpaqueID(s string) func(*SlmExecuteRetentionRequest) { + return func(r *SlmExecuteRetentionRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.slm.get_lifecycle.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.slm.get_lifecycle.go new file mode 100644 index 00000000..0e382323 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.slm.get_lifecycle.go @@ -0,0 +1,202 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newSlmGetLifecycleFunc(t Transport) SlmGetLifecycle { + return func(o ...func(*SlmGetLifecycleRequest)) (*Response, error) { + var r = SlmGetLifecycleRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SlmGetLifecycle - Retrieves one or more snapshot lifecycle policy definitions and information about the latest snapshot attempts. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-get-policy.html. +type SlmGetLifecycle func(o ...func(*SlmGetLifecycleRequest)) (*Response, error) + +// SlmGetLifecycleRequest configures the Slm Get Lifecycle API request. +type SlmGetLifecycleRequest struct { + PolicyID []string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SlmGetLifecycleRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_slm") + 1 + len("policy") + 1 + len(strings.Join(r.PolicyID, ","))) + path.WriteString("/") + path.WriteString("_slm") + path.WriteString("/") + path.WriteString("policy") + if len(r.PolicyID) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.PolicyID, ",")) + } + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SlmGetLifecycle) WithContext(v context.Context) func(*SlmGetLifecycleRequest) { + return func(r *SlmGetLifecycleRequest) { + r.ctx = v + } +} + +// WithPolicyID - comma-separated list of snapshot lifecycle policies to retrieve. +func (f SlmGetLifecycle) WithPolicyID(v ...string) func(*SlmGetLifecycleRequest) { + return func(r *SlmGetLifecycleRequest) { + r.PolicyID = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SlmGetLifecycle) WithPretty() func(*SlmGetLifecycleRequest) { + return func(r *SlmGetLifecycleRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SlmGetLifecycle) WithHuman() func(*SlmGetLifecycleRequest) { + return func(r *SlmGetLifecycleRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SlmGetLifecycle) WithErrorTrace() func(*SlmGetLifecycleRequest) { + return func(r *SlmGetLifecycleRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SlmGetLifecycle) WithFilterPath(v ...string) func(*SlmGetLifecycleRequest) { + return func(r *SlmGetLifecycleRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SlmGetLifecycle) WithHeader(h map[string]string) func(*SlmGetLifecycleRequest) { + return func(r *SlmGetLifecycleRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SlmGetLifecycle) WithOpaqueID(s string) func(*SlmGetLifecycleRequest) { + return func(r *SlmGetLifecycleRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.slm.get_stats.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.slm.get_stats.go new file mode 100644 index 00000000..138e9e3f --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.slm.get_stats.go @@ -0,0 +1,186 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newSlmGetStatsFunc(t Transport) SlmGetStats { + return func(o ...func(*SlmGetStatsRequest)) (*Response, error) { + var r = SlmGetStatsRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SlmGetStats - Returns global and policy-level statistics about actions taken by snapshot lifecycle management. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/slm-api-get-stats.html. +type SlmGetStats func(o ...func(*SlmGetStatsRequest)) (*Response, error) + +// SlmGetStatsRequest configures the Slm Get Stats API request. +type SlmGetStatsRequest struct { + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SlmGetStatsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(len("/_slm/stats")) + path.WriteString("/_slm/stats") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SlmGetStats) WithContext(v context.Context) func(*SlmGetStatsRequest) { + return func(r *SlmGetStatsRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SlmGetStats) WithPretty() func(*SlmGetStatsRequest) { + return func(r *SlmGetStatsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SlmGetStats) WithHuman() func(*SlmGetStatsRequest) { + return func(r *SlmGetStatsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SlmGetStats) WithErrorTrace() func(*SlmGetStatsRequest) { + return func(r *SlmGetStatsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SlmGetStats) WithFilterPath(v ...string) func(*SlmGetStatsRequest) { + return func(r *SlmGetStatsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SlmGetStats) WithHeader(h map[string]string) func(*SlmGetStatsRequest) { + return func(r *SlmGetStatsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SlmGetStats) WithOpaqueID(s string) func(*SlmGetStatsRequest) { + return func(r *SlmGetStatsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.slm.get_status.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.slm.get_status.go new file mode 100644 index 00000000..a410a770 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.slm.get_status.go @@ -0,0 +1,186 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newSlmGetStatusFunc(t Transport) SlmGetStatus { + return func(o ...func(*SlmGetStatusRequest)) (*Response, error) { + var r = SlmGetStatusRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SlmGetStatus - Retrieves the status of snapshot lifecycle management (SLM). +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-get-status.html. +type SlmGetStatus func(o ...func(*SlmGetStatusRequest)) (*Response, error) + +// SlmGetStatusRequest configures the Slm Get Status API request. +type SlmGetStatusRequest struct { + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SlmGetStatusRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(len("/_slm/status")) + path.WriteString("/_slm/status") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SlmGetStatus) WithContext(v context.Context) func(*SlmGetStatusRequest) { + return func(r *SlmGetStatusRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SlmGetStatus) WithPretty() func(*SlmGetStatusRequest) { + return func(r *SlmGetStatusRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SlmGetStatus) WithHuman() func(*SlmGetStatusRequest) { + return func(r *SlmGetStatusRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SlmGetStatus) WithErrorTrace() func(*SlmGetStatusRequest) { + return func(r *SlmGetStatusRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SlmGetStatus) WithFilterPath(v ...string) func(*SlmGetStatusRequest) { + return func(r *SlmGetStatusRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SlmGetStatus) WithHeader(h map[string]string) func(*SlmGetStatusRequest) { + return func(r *SlmGetStatusRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SlmGetStatus) WithOpaqueID(s string) func(*SlmGetStatusRequest) { + return func(r *SlmGetStatusRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.slm.put_lifecycle.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.slm.put_lifecycle.go new file mode 100644 index 00000000..e94a3208 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.slm.put_lifecycle.go @@ -0,0 +1,207 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newSlmPutLifecycleFunc(t Transport) SlmPutLifecycle { + return func(policy_id string, o ...func(*SlmPutLifecycleRequest)) (*Response, error) { + var r = SlmPutLifecycleRequest{PolicyID: policy_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SlmPutLifecycle - Creates or updates a snapshot lifecycle policy. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-put-policy.html. +type SlmPutLifecycle func(policy_id string, o ...func(*SlmPutLifecycleRequest)) (*Response, error) + +// SlmPutLifecycleRequest configures the Slm Put Lifecycle API request. +type SlmPutLifecycleRequest struct { + Body io.Reader + + PolicyID string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SlmPutLifecycleRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(1 + len("_slm") + 1 + len("policy") + 1 + len(r.PolicyID)) + path.WriteString("/") + path.WriteString("_slm") + path.WriteString("/") + path.WriteString("policy") + path.WriteString("/") + path.WriteString(r.PolicyID) + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SlmPutLifecycle) WithContext(v context.Context) func(*SlmPutLifecycleRequest) { + return func(r *SlmPutLifecycleRequest) { + r.ctx = v + } +} + +// WithBody - The snapshot lifecycle policy definition to register. +func (f SlmPutLifecycle) WithBody(v io.Reader) func(*SlmPutLifecycleRequest) { + return func(r *SlmPutLifecycleRequest) { + r.Body = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SlmPutLifecycle) WithPretty() func(*SlmPutLifecycleRequest) { + return func(r *SlmPutLifecycleRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SlmPutLifecycle) WithHuman() func(*SlmPutLifecycleRequest) { + return func(r *SlmPutLifecycleRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SlmPutLifecycle) WithErrorTrace() func(*SlmPutLifecycleRequest) { + return func(r *SlmPutLifecycleRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SlmPutLifecycle) WithFilterPath(v ...string) func(*SlmPutLifecycleRequest) { + return func(r *SlmPutLifecycleRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SlmPutLifecycle) WithHeader(h map[string]string) func(*SlmPutLifecycleRequest) { + return func(r *SlmPutLifecycleRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SlmPutLifecycle) WithOpaqueID(s string) func(*SlmPutLifecycleRequest) { + return func(r *SlmPutLifecycleRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.slm.start.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.slm.start.go new file mode 100644 index 00000000..6851f8f0 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.slm.start.go @@ -0,0 +1,186 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newSlmStartFunc(t Transport) SlmStart { + return func(o ...func(*SlmStartRequest)) (*Response, error) { + var r = SlmStartRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SlmStart - Turns on snapshot lifecycle management (SLM). +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-start.html. +type SlmStart func(o ...func(*SlmStartRequest)) (*Response, error) + +// SlmStartRequest configures the Slm Start API request. +type SlmStartRequest struct { + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SlmStartRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(len("/_slm/start")) + path.WriteString("/_slm/start") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SlmStart) WithContext(v context.Context) func(*SlmStartRequest) { + return func(r *SlmStartRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SlmStart) WithPretty() func(*SlmStartRequest) { + return func(r *SlmStartRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SlmStart) WithHuman() func(*SlmStartRequest) { + return func(r *SlmStartRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SlmStart) WithErrorTrace() func(*SlmStartRequest) { + return func(r *SlmStartRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SlmStart) WithFilterPath(v ...string) func(*SlmStartRequest) { + return func(r *SlmStartRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SlmStart) WithHeader(h map[string]string) func(*SlmStartRequest) { + return func(r *SlmStartRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SlmStart) WithOpaqueID(s string) func(*SlmStartRequest) { + return func(r *SlmStartRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.slm.stop.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.slm.stop.go new file mode 100644 index 00000000..ef10a4df --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.slm.stop.go @@ -0,0 +1,186 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newSlmStopFunc(t Transport) SlmStop { + return func(o ...func(*SlmStopRequest)) (*Response, error) { + var r = SlmStopRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SlmStop - Turns off snapshot lifecycle management (SLM). +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-stop.html. +type SlmStop func(o ...func(*SlmStopRequest)) (*Response, error) + +// SlmStopRequest configures the Slm Stop API request. +type SlmStopRequest struct { + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SlmStopRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(len("/_slm/stop")) + path.WriteString("/_slm/stop") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SlmStop) WithContext(v context.Context) func(*SlmStopRequest) { + return func(r *SlmStopRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SlmStop) WithPretty() func(*SlmStopRequest) { + return func(r *SlmStopRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SlmStop) WithHuman() func(*SlmStopRequest) { + return func(r *SlmStopRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SlmStop) WithErrorTrace() func(*SlmStopRequest) { + return func(r *SlmStopRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SlmStop) WithFilterPath(v ...string) func(*SlmStopRequest) { + return func(r *SlmStopRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SlmStop) WithHeader(h map[string]string) func(*SlmStopRequest) { + return func(r *SlmStopRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SlmStop) WithOpaqueID(s string) func(*SlmStopRequest) { + return func(r *SlmStopRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.sql.clear_cursor.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.sql.clear_cursor.go new file mode 100644 index 00000000..98820400 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.sql.clear_cursor.go @@ -0,0 +1,193 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newSQLClearCursorFunc(t Transport) SQLClearCursor { + return func(body io.Reader, o ...func(*SQLClearCursorRequest)) (*Response, error) { + var r = SQLClearCursorRequest{Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SQLClearCursor - Clears the SQL cursor +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/clear-sql-cursor-api.html. +type SQLClearCursor func(body io.Reader, o ...func(*SQLClearCursorRequest)) (*Response, error) + +// SQLClearCursorRequest configures the SQL Clear Cursor API request. +type SQLClearCursorRequest struct { + Body io.Reader + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SQLClearCursorRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(len("/_sql/close")) + path.WriteString("/_sql/close") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SQLClearCursor) WithContext(v context.Context) func(*SQLClearCursorRequest) { + return func(r *SQLClearCursorRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SQLClearCursor) WithPretty() func(*SQLClearCursorRequest) { + return func(r *SQLClearCursorRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SQLClearCursor) WithHuman() func(*SQLClearCursorRequest) { + return func(r *SQLClearCursorRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SQLClearCursor) WithErrorTrace() func(*SQLClearCursorRequest) { + return func(r *SQLClearCursorRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SQLClearCursor) WithFilterPath(v ...string) func(*SQLClearCursorRequest) { + return func(r *SQLClearCursorRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SQLClearCursor) WithHeader(h map[string]string) func(*SQLClearCursorRequest) { + return func(r *SQLClearCursorRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SQLClearCursor) WithOpaqueID(s string) func(*SQLClearCursorRequest) { + return func(r *SQLClearCursorRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.sql.delete_async.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.sql.delete_async.go new file mode 100644 index 00000000..1fbd8028 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.sql.delete_async.go @@ -0,0 +1,195 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newSQLDeleteAsyncFunc(t Transport) SQLDeleteAsync { + return func(id string, o ...func(*SQLDeleteAsyncRequest)) (*Response, error) { + var r = SQLDeleteAsyncRequest{DocumentID: id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SQLDeleteAsync - Deletes an async SQL search or a stored synchronous SQL search. If the search is still running, the API cancels it. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-async-sql-search-api.html. +type SQLDeleteAsync func(id string, o ...func(*SQLDeleteAsyncRequest)) (*Response, error) + +// SQLDeleteAsyncRequest configures the SQL Delete Async API request. +type SQLDeleteAsyncRequest struct { + DocumentID string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SQLDeleteAsyncRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + path.Grow(1 + len("_sql") + 1 + len("async") + 1 + len("delete") + 1 + len(r.DocumentID)) + path.WriteString("/") + path.WriteString("_sql") + path.WriteString("/") + path.WriteString("async") + path.WriteString("/") + path.WriteString("delete") + path.WriteString("/") + path.WriteString(r.DocumentID) + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SQLDeleteAsync) WithContext(v context.Context) func(*SQLDeleteAsyncRequest) { + return func(r *SQLDeleteAsyncRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SQLDeleteAsync) WithPretty() func(*SQLDeleteAsyncRequest) { + return func(r *SQLDeleteAsyncRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SQLDeleteAsync) WithHuman() func(*SQLDeleteAsyncRequest) { + return func(r *SQLDeleteAsyncRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SQLDeleteAsync) WithErrorTrace() func(*SQLDeleteAsyncRequest) { + return func(r *SQLDeleteAsyncRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SQLDeleteAsync) WithFilterPath(v ...string) func(*SQLDeleteAsyncRequest) { + return func(r *SQLDeleteAsyncRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SQLDeleteAsync) WithHeader(h map[string]string) func(*SQLDeleteAsyncRequest) { + return func(r *SQLDeleteAsyncRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SQLDeleteAsync) WithOpaqueID(s string) func(*SQLDeleteAsyncRequest) { + return func(r *SQLDeleteAsyncRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.sql.get_async.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.sql.get_async.go new file mode 100644 index 00000000..d36f98f9 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.sql.get_async.go @@ -0,0 +1,243 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" + "time" +) + +func newSQLGetAsyncFunc(t Transport) SQLGetAsync { + return func(id string, o ...func(*SQLGetAsyncRequest)) (*Response, error) { + var r = SQLGetAsyncRequest{DocumentID: id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SQLGetAsync - Returns the current status and available results for an async SQL search or stored synchronous SQL search +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/get-async-sql-search-api.html. +type SQLGetAsync func(id string, o ...func(*SQLGetAsyncRequest)) (*Response, error) + +// SQLGetAsyncRequest configures the SQL Get Async API request. +type SQLGetAsyncRequest struct { + DocumentID string + + Delimiter string + Format string + KeepAlive time.Duration + WaitForCompletionTimeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SQLGetAsyncRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_sql") + 1 + len("async") + 1 + len(r.DocumentID)) + path.WriteString("/") + path.WriteString("_sql") + path.WriteString("/") + path.WriteString("async") + path.WriteString("/") + path.WriteString(r.DocumentID) + + params = make(map[string]string) + + if r.Delimiter != "" { + params["delimiter"] = r.Delimiter + } + + if r.Format != "" { + params["format"] = r.Format + } + + if r.KeepAlive != 0 { + params["keep_alive"] = formatDuration(r.KeepAlive) + } + + if r.WaitForCompletionTimeout != 0 { + params["wait_for_completion_timeout"] = formatDuration(r.WaitForCompletionTimeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SQLGetAsync) WithContext(v context.Context) func(*SQLGetAsyncRequest) { + return func(r *SQLGetAsyncRequest) { + r.ctx = v + } +} + +// WithDelimiter - separator for csv results. +func (f SQLGetAsync) WithDelimiter(v string) func(*SQLGetAsyncRequest) { + return func(r *SQLGetAsyncRequest) { + r.Delimiter = v + } +} + +// WithFormat - short version of the accept header, e.g. json, yaml. +func (f SQLGetAsync) WithFormat(v string) func(*SQLGetAsyncRequest) { + return func(r *SQLGetAsyncRequest) { + r.Format = v + } +} + +// WithKeepAlive - retention period for the search and its results. +func (f SQLGetAsync) WithKeepAlive(v time.Duration) func(*SQLGetAsyncRequest) { + return func(r *SQLGetAsyncRequest) { + r.KeepAlive = v + } +} + +// WithWaitForCompletionTimeout - duration to wait for complete results. +func (f SQLGetAsync) WithWaitForCompletionTimeout(v time.Duration) func(*SQLGetAsyncRequest) { + return func(r *SQLGetAsyncRequest) { + r.WaitForCompletionTimeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SQLGetAsync) WithPretty() func(*SQLGetAsyncRequest) { + return func(r *SQLGetAsyncRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SQLGetAsync) WithHuman() func(*SQLGetAsyncRequest) { + return func(r *SQLGetAsyncRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SQLGetAsync) WithErrorTrace() func(*SQLGetAsyncRequest) { + return func(r *SQLGetAsyncRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SQLGetAsync) WithFilterPath(v ...string) func(*SQLGetAsyncRequest) { + return func(r *SQLGetAsyncRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SQLGetAsync) WithHeader(h map[string]string) func(*SQLGetAsyncRequest) { + return func(r *SQLGetAsyncRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SQLGetAsync) WithOpaqueID(s string) func(*SQLGetAsyncRequest) { + return func(r *SQLGetAsyncRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.sql.get_async_status.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.sql.get_async_status.go new file mode 100644 index 00000000..1d412b25 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.sql.get_async_status.go @@ -0,0 +1,195 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newSQLGetAsyncStatusFunc(t Transport) SQLGetAsyncStatus { + return func(id string, o ...func(*SQLGetAsyncStatusRequest)) (*Response, error) { + var r = SQLGetAsyncStatusRequest{DocumentID: id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SQLGetAsyncStatus - Returns the current status of an async SQL search or a stored synchronous SQL search +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/get-async-sql-search-status-api.html. +type SQLGetAsyncStatus func(id string, o ...func(*SQLGetAsyncStatusRequest)) (*Response, error) + +// SQLGetAsyncStatusRequest configures the SQL Get Async Status API request. +type SQLGetAsyncStatusRequest struct { + DocumentID string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SQLGetAsyncStatusRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_sql") + 1 + len("async") + 1 + len("status") + 1 + len(r.DocumentID)) + path.WriteString("/") + path.WriteString("_sql") + path.WriteString("/") + path.WriteString("async") + path.WriteString("/") + path.WriteString("status") + path.WriteString("/") + path.WriteString(r.DocumentID) + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SQLGetAsyncStatus) WithContext(v context.Context) func(*SQLGetAsyncStatusRequest) { + return func(r *SQLGetAsyncStatusRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SQLGetAsyncStatus) WithPretty() func(*SQLGetAsyncStatusRequest) { + return func(r *SQLGetAsyncStatusRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SQLGetAsyncStatus) WithHuman() func(*SQLGetAsyncStatusRequest) { + return func(r *SQLGetAsyncStatusRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SQLGetAsyncStatus) WithErrorTrace() func(*SQLGetAsyncStatusRequest) { + return func(r *SQLGetAsyncStatusRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SQLGetAsyncStatus) WithFilterPath(v ...string) func(*SQLGetAsyncStatusRequest) { + return func(r *SQLGetAsyncStatusRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SQLGetAsyncStatus) WithHeader(h map[string]string) func(*SQLGetAsyncStatusRequest) { + return func(r *SQLGetAsyncStatusRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SQLGetAsyncStatus) WithOpaqueID(s string) func(*SQLGetAsyncStatusRequest) { + return func(r *SQLGetAsyncStatusRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.sql.query.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.sql.query.go new file mode 100644 index 00000000..1f4ee5dc --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.sql.query.go @@ -0,0 +1,206 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newSQLQueryFunc(t Transport) SQLQuery { + return func(body io.Reader, o ...func(*SQLQueryRequest)) (*Response, error) { + var r = SQLQueryRequest{Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SQLQuery - Executes a SQL request +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-search-api.html. +type SQLQuery func(body io.Reader, o ...func(*SQLQueryRequest)) (*Response, error) + +// SQLQueryRequest configures the SQL Query API request. +type SQLQueryRequest struct { + Body io.Reader + + Format string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SQLQueryRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(len("/_sql")) + path.WriteString("/_sql") + + params = make(map[string]string) + + if r.Format != "" { + params["format"] = r.Format + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SQLQuery) WithContext(v context.Context) func(*SQLQueryRequest) { + return func(r *SQLQueryRequest) { + r.ctx = v + } +} + +// WithFormat - a short version of the accept header, e.g. json, yaml. +func (f SQLQuery) WithFormat(v string) func(*SQLQueryRequest) { + return func(r *SQLQueryRequest) { + r.Format = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SQLQuery) WithPretty() func(*SQLQueryRequest) { + return func(r *SQLQueryRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SQLQuery) WithHuman() func(*SQLQueryRequest) { + return func(r *SQLQueryRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SQLQuery) WithErrorTrace() func(*SQLQueryRequest) { + return func(r *SQLQueryRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SQLQuery) WithFilterPath(v ...string) func(*SQLQueryRequest) { + return func(r *SQLQueryRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SQLQuery) WithHeader(h map[string]string) func(*SQLQueryRequest) { + return func(r *SQLQueryRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SQLQuery) WithOpaqueID(s string) func(*SQLQueryRequest) { + return func(r *SQLQueryRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.sql.translate.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.sql.translate.go new file mode 100644 index 00000000..a64fed36 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.sql.translate.go @@ -0,0 +1,193 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newSQLTranslateFunc(t Transport) SQLTranslate { + return func(body io.Reader, o ...func(*SQLTranslateRequest)) (*Response, error) { + var r = SQLTranslateRequest{Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SQLTranslate - Translates SQL into Elasticsearch queries +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-translate-api.html. +type SQLTranslate func(body io.Reader, o ...func(*SQLTranslateRequest)) (*Response, error) + +// SQLTranslateRequest configures the SQL Translate API request. +type SQLTranslateRequest struct { + Body io.Reader + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SQLTranslateRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(len("/_sql/translate")) + path.WriteString("/_sql/translate") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SQLTranslate) WithContext(v context.Context) func(*SQLTranslateRequest) { + return func(r *SQLTranslateRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SQLTranslate) WithPretty() func(*SQLTranslateRequest) { + return func(r *SQLTranslateRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SQLTranslate) WithHuman() func(*SQLTranslateRequest) { + return func(r *SQLTranslateRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SQLTranslate) WithErrorTrace() func(*SQLTranslateRequest) { + return func(r *SQLTranslateRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SQLTranslate) WithFilterPath(v ...string) func(*SQLTranslateRequest) { + return func(r *SQLTranslateRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SQLTranslate) WithHeader(h map[string]string) func(*SQLTranslateRequest) { + return func(r *SQLTranslateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SQLTranslate) WithOpaqueID(s string) func(*SQLTranslateRequest) { + return func(r *SQLTranslateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ssl.certificates.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ssl.certificates.go new file mode 100644 index 00000000..5ee63515 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.ssl.certificates.go @@ -0,0 +1,186 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newSSLCertificatesFunc(t Transport) SSLCertificates { + return func(o ...func(*SSLCertificatesRequest)) (*Response, error) { + var r = SSLCertificatesRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// SSLCertificates - Retrieves information about the X.509 certificates used to encrypt communications in the cluster. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-ssl.html. +type SSLCertificates func(o ...func(*SSLCertificatesRequest)) (*Response, error) + +// SSLCertificatesRequest configures the SSL Certificates API request. +type SSLCertificatesRequest struct { + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r SSLCertificatesRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(len("/_ssl/certificates")) + path.WriteString("/_ssl/certificates") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f SSLCertificates) WithContext(v context.Context) func(*SSLCertificatesRequest) { + return func(r *SSLCertificatesRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f SSLCertificates) WithPretty() func(*SSLCertificatesRequest) { + return func(r *SSLCertificatesRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f SSLCertificates) WithHuman() func(*SSLCertificatesRequest) { + return func(r *SSLCertificatesRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f SSLCertificates) WithErrorTrace() func(*SSLCertificatesRequest) { + return func(r *SSLCertificatesRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f SSLCertificates) WithFilterPath(v ...string) func(*SSLCertificatesRequest) { + return func(r *SSLCertificatesRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f SSLCertificates) WithHeader(h map[string]string) func(*SSLCertificatesRequest) { + return func(r *SSLCertificatesRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f SSLCertificates) WithOpaqueID(s string) func(*SSLCertificatesRequest) { + return func(r *SSLCertificatesRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.text_structure.find_structure.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.text_structure.find_structure.go new file mode 100644 index 00000000..49d10367 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.text_structure.find_structure.go @@ -0,0 +1,364 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" + "time" +) + +func newTextStructureFindStructureFunc(t Transport) TextStructureFindStructure { + return func(body io.Reader, o ...func(*TextStructureFindStructureRequest)) (*Response, error) { + var r = TextStructureFindStructureRequest{Body: body} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// TextStructureFindStructure - Finds the structure of a text file. The text file must contain data that is suitable to be ingested into Elasticsearch. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/find-structure.html. +type TextStructureFindStructure func(body io.Reader, o ...func(*TextStructureFindStructureRequest)) (*Response, error) + +// TextStructureFindStructureRequest configures the Text Structure Find Structure API request. +type TextStructureFindStructureRequest struct { + Body io.Reader + + Charset string + ColumnNames []string + Delimiter string + Explain *bool + Format string + GrokPattern string + HasHeaderRow *bool + LineMergeSizeLimit *int + LinesToSample *int + Quote string + ShouldTrimFields *bool + Timeout time.Duration + TimestampField string + TimestampFormat string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r TextStructureFindStructureRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(len("/_text_structure/find_structure")) + path.WriteString("/_text_structure/find_structure") + + params = make(map[string]string) + + if r.Charset != "" { + params["charset"] = r.Charset + } + + if len(r.ColumnNames) > 0 { + params["column_names"] = strings.Join(r.ColumnNames, ",") + } + + if r.Delimiter != "" { + params["delimiter"] = r.Delimiter + } + + if r.Explain != nil { + params["explain"] = strconv.FormatBool(*r.Explain) + } + + if r.Format != "" { + params["format"] = r.Format + } + + if r.GrokPattern != "" { + params["grok_pattern"] = r.GrokPattern + } + + if r.HasHeaderRow != nil { + params["has_header_row"] = strconv.FormatBool(*r.HasHeaderRow) + } + + if r.LineMergeSizeLimit != nil { + params["line_merge_size_limit"] = strconv.FormatInt(int64(*r.LineMergeSizeLimit), 10) + } + + if r.LinesToSample != nil { + params["lines_to_sample"] = strconv.FormatInt(int64(*r.LinesToSample), 10) + } + + if r.Quote != "" { + params["quote"] = r.Quote + } + + if r.ShouldTrimFields != nil { + params["should_trim_fields"] = strconv.FormatBool(*r.ShouldTrimFields) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.TimestampField != "" { + params["timestamp_field"] = r.TimestampField + } + + if r.TimestampFormat != "" { + params["timestamp_format"] = r.TimestampFormat + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f TextStructureFindStructure) WithContext(v context.Context) func(*TextStructureFindStructureRequest) { + return func(r *TextStructureFindStructureRequest) { + r.ctx = v + } +} + +// WithCharset - optional parameter to specify the character set of the file. +func (f TextStructureFindStructure) WithCharset(v string) func(*TextStructureFindStructureRequest) { + return func(r *TextStructureFindStructureRequest) { + r.Charset = v + } +} + +// WithColumnNames - optional parameter containing a comma separated list of the column names for a delimited file. +func (f TextStructureFindStructure) WithColumnNames(v ...string) func(*TextStructureFindStructureRequest) { + return func(r *TextStructureFindStructureRequest) { + r.ColumnNames = v + } +} + +// WithDelimiter - optional parameter to specify the delimiter character for a delimited file - must be a single character. +func (f TextStructureFindStructure) WithDelimiter(v string) func(*TextStructureFindStructureRequest) { + return func(r *TextStructureFindStructureRequest) { + r.Delimiter = v + } +} + +// WithExplain - whether to include a commentary on how the structure was derived. +func (f TextStructureFindStructure) WithExplain(v bool) func(*TextStructureFindStructureRequest) { + return func(r *TextStructureFindStructureRequest) { + r.Explain = &v + } +} + +// WithFormat - optional parameter to specify the high level file format. +func (f TextStructureFindStructure) WithFormat(v string) func(*TextStructureFindStructureRequest) { + return func(r *TextStructureFindStructureRequest) { + r.Format = v + } +} + +// WithGrokPattern - optional parameter to specify the grok pattern that should be used to extract fields from messages in a semi-structured text file. +func (f TextStructureFindStructure) WithGrokPattern(v string) func(*TextStructureFindStructureRequest) { + return func(r *TextStructureFindStructureRequest) { + r.GrokPattern = v + } +} + +// WithHasHeaderRow - optional parameter to specify whether a delimited file includes the column names in its first row. +func (f TextStructureFindStructure) WithHasHeaderRow(v bool) func(*TextStructureFindStructureRequest) { + return func(r *TextStructureFindStructureRequest) { + r.HasHeaderRow = &v + } +} + +// WithLineMergeSizeLimit - maximum number of characters permitted in a single message when lines are merged to create messages.. +func (f TextStructureFindStructure) WithLineMergeSizeLimit(v int) func(*TextStructureFindStructureRequest) { + return func(r *TextStructureFindStructureRequest) { + r.LineMergeSizeLimit = &v + } +} + +// WithLinesToSample - how many lines of the file should be included in the analysis. +func (f TextStructureFindStructure) WithLinesToSample(v int) func(*TextStructureFindStructureRequest) { + return func(r *TextStructureFindStructureRequest) { + r.LinesToSample = &v + } +} + +// WithQuote - optional parameter to specify the quote character for a delimited file - must be a single character. +func (f TextStructureFindStructure) WithQuote(v string) func(*TextStructureFindStructureRequest) { + return func(r *TextStructureFindStructureRequest) { + r.Quote = v + } +} + +// WithShouldTrimFields - optional parameter to specify whether the values between delimiters in a delimited file should have whitespace trimmed from them. +func (f TextStructureFindStructure) WithShouldTrimFields(v bool) func(*TextStructureFindStructureRequest) { + return func(r *TextStructureFindStructureRequest) { + r.ShouldTrimFields = &v + } +} + +// WithTimeout - timeout after which the analysis will be aborted. +func (f TextStructureFindStructure) WithTimeout(v time.Duration) func(*TextStructureFindStructureRequest) { + return func(r *TextStructureFindStructureRequest) { + r.Timeout = v + } +} + +// WithTimestampField - optional parameter to specify the timestamp field in the file. +func (f TextStructureFindStructure) WithTimestampField(v string) func(*TextStructureFindStructureRequest) { + return func(r *TextStructureFindStructureRequest) { + r.TimestampField = v + } +} + +// WithTimestampFormat - optional parameter to specify the timestamp format in the file - may be either a joda or java time format. +func (f TextStructureFindStructure) WithTimestampFormat(v string) func(*TextStructureFindStructureRequest) { + return func(r *TextStructureFindStructureRequest) { + r.TimestampFormat = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f TextStructureFindStructure) WithPretty() func(*TextStructureFindStructureRequest) { + return func(r *TextStructureFindStructureRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f TextStructureFindStructure) WithHuman() func(*TextStructureFindStructureRequest) { + return func(r *TextStructureFindStructureRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f TextStructureFindStructure) WithErrorTrace() func(*TextStructureFindStructureRequest) { + return func(r *TextStructureFindStructureRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f TextStructureFindStructure) WithFilterPath(v ...string) func(*TextStructureFindStructureRequest) { + return func(r *TextStructureFindStructureRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f TextStructureFindStructure) WithHeader(h map[string]string) func(*TextStructureFindStructureRequest) { + return func(r *TextStructureFindStructureRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f TextStructureFindStructure) WithOpaqueID(s string) func(*TextStructureFindStructureRequest) { + return func(r *TextStructureFindStructureRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.transform.delete_transform.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.transform.delete_transform.go new file mode 100644 index 00000000..28133e40 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.transform.delete_transform.go @@ -0,0 +1,218 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" + "time" +) + +func newTransformDeleteTransformFunc(t Transport) TransformDeleteTransform { + return func(transform_id string, o ...func(*TransformDeleteTransformRequest)) (*Response, error) { + var r = TransformDeleteTransformRequest{TransformID: transform_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// TransformDeleteTransform - Deletes an existing transform. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-transform.html. +type TransformDeleteTransform func(transform_id string, o ...func(*TransformDeleteTransformRequest)) (*Response, error) + +// TransformDeleteTransformRequest configures the Transform Delete Transform API request. +type TransformDeleteTransformRequest struct { + TransformID string + + Force *bool + Timeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r TransformDeleteTransformRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + path.Grow(1 + len("_transform") + 1 + len(r.TransformID)) + path.WriteString("/") + path.WriteString("_transform") + path.WriteString("/") + path.WriteString(r.TransformID) + + params = make(map[string]string) + + if r.Force != nil { + params["force"] = strconv.FormatBool(*r.Force) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f TransformDeleteTransform) WithContext(v context.Context) func(*TransformDeleteTransformRequest) { + return func(r *TransformDeleteTransformRequest) { + r.ctx = v + } +} + +// WithForce - when `true`, the transform is deleted regardless of its current state. the default value is `false`, meaning that the transform must be `stopped` before it can be deleted.. +func (f TransformDeleteTransform) WithForce(v bool) func(*TransformDeleteTransformRequest) { + return func(r *TransformDeleteTransformRequest) { + r.Force = &v + } +} + +// WithTimeout - controls the time to wait for the transform deletion. +func (f TransformDeleteTransform) WithTimeout(v time.Duration) func(*TransformDeleteTransformRequest) { + return func(r *TransformDeleteTransformRequest) { + r.Timeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f TransformDeleteTransform) WithPretty() func(*TransformDeleteTransformRequest) { + return func(r *TransformDeleteTransformRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f TransformDeleteTransform) WithHuman() func(*TransformDeleteTransformRequest) { + return func(r *TransformDeleteTransformRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f TransformDeleteTransform) WithErrorTrace() func(*TransformDeleteTransformRequest) { + return func(r *TransformDeleteTransformRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f TransformDeleteTransform) WithFilterPath(v ...string) func(*TransformDeleteTransformRequest) { + return func(r *TransformDeleteTransformRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f TransformDeleteTransform) WithHeader(h map[string]string) func(*TransformDeleteTransformRequest) { + return func(r *TransformDeleteTransformRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f TransformDeleteTransform) WithOpaqueID(s string) func(*TransformDeleteTransformRequest) { + return func(r *TransformDeleteTransformRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.transform.get_transform.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.transform.get_transform.go new file mode 100644 index 00000000..16dbbfc8 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.transform.get_transform.go @@ -0,0 +1,250 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newTransformGetTransformFunc(t Transport) TransformGetTransform { + return func(o ...func(*TransformGetTransformRequest)) (*Response, error) { + var r = TransformGetTransformRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// TransformGetTransform - Retrieves configuration information for transforms. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/get-transform.html. +type TransformGetTransform func(o ...func(*TransformGetTransformRequest)) (*Response, error) + +// TransformGetTransformRequest configures the Transform Get Transform API request. +type TransformGetTransformRequest struct { + TransformID string + + AllowNoMatch *bool + ExcludeGenerated *bool + From *int + Size *int + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r TransformGetTransformRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_transform") + 1 + len(r.TransformID)) + path.WriteString("/") + path.WriteString("_transform") + if r.TransformID != "" { + path.WriteString("/") + path.WriteString(r.TransformID) + } + + params = make(map[string]string) + + if r.AllowNoMatch != nil { + params["allow_no_match"] = strconv.FormatBool(*r.AllowNoMatch) + } + + if r.ExcludeGenerated != nil { + params["exclude_generated"] = strconv.FormatBool(*r.ExcludeGenerated) + } + + if r.From != nil { + params["from"] = strconv.FormatInt(int64(*r.From), 10) + } + + if r.Size != nil { + params["size"] = strconv.FormatInt(int64(*r.Size), 10) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f TransformGetTransform) WithContext(v context.Context) func(*TransformGetTransformRequest) { + return func(r *TransformGetTransformRequest) { + r.ctx = v + } +} + +// WithTransformID - the ID or comma delimited list of ID expressions of the transforms to get, '_all' or '*' implies get all transforms. +func (f TransformGetTransform) WithTransformID(v string) func(*TransformGetTransformRequest) { + return func(r *TransformGetTransformRequest) { + r.TransformID = v + } +} + +// WithAllowNoMatch - whether to ignore if a wildcard expression matches no transforms. (this includes `_all` string or when no transforms have been specified). +func (f TransformGetTransform) WithAllowNoMatch(v bool) func(*TransformGetTransformRequest) { + return func(r *TransformGetTransformRequest) { + r.AllowNoMatch = &v + } +} + +// WithExcludeGenerated - omits fields that are illegal to set on transform put. +func (f TransformGetTransform) WithExcludeGenerated(v bool) func(*TransformGetTransformRequest) { + return func(r *TransformGetTransformRequest) { + r.ExcludeGenerated = &v + } +} + +// WithFrom - skips a number of transform configs, defaults to 0. +func (f TransformGetTransform) WithFrom(v int) func(*TransformGetTransformRequest) { + return func(r *TransformGetTransformRequest) { + r.From = &v + } +} + +// WithSize - specifies a max number of transforms to get, defaults to 100. +func (f TransformGetTransform) WithSize(v int) func(*TransformGetTransformRequest) { + return func(r *TransformGetTransformRequest) { + r.Size = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f TransformGetTransform) WithPretty() func(*TransformGetTransformRequest) { + return func(r *TransformGetTransformRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f TransformGetTransform) WithHuman() func(*TransformGetTransformRequest) { + return func(r *TransformGetTransformRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f TransformGetTransform) WithErrorTrace() func(*TransformGetTransformRequest) { + return func(r *TransformGetTransformRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f TransformGetTransform) WithFilterPath(v ...string) func(*TransformGetTransformRequest) { + return func(r *TransformGetTransformRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f TransformGetTransform) WithHeader(h map[string]string) func(*TransformGetTransformRequest) { + return func(r *TransformGetTransformRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f TransformGetTransform) WithOpaqueID(s string) func(*TransformGetTransformRequest) { + return func(r *TransformGetTransformRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.transform.get_transform_stats.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.transform.get_transform_stats.go new file mode 100644 index 00000000..0b28e5c9 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.transform.get_transform_stats.go @@ -0,0 +1,231 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newTransformGetTransformStatsFunc(t Transport) TransformGetTransformStats { + return func(transform_id string, o ...func(*TransformGetTransformStatsRequest)) (*Response, error) { + var r = TransformGetTransformStatsRequest{TransformID: transform_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// TransformGetTransformStats - Retrieves usage information for transforms. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/get-transform-stats.html. +type TransformGetTransformStats func(transform_id string, o ...func(*TransformGetTransformStatsRequest)) (*Response, error) + +// TransformGetTransformStatsRequest configures the Transform Get Transform Stats API request. +type TransformGetTransformStatsRequest struct { + TransformID string + + AllowNoMatch *bool + From *int + Size *int + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r TransformGetTransformStatsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_transform") + 1 + len(r.TransformID) + 1 + len("_stats")) + path.WriteString("/") + path.WriteString("_transform") + path.WriteString("/") + path.WriteString(r.TransformID) + path.WriteString("/") + path.WriteString("_stats") + + params = make(map[string]string) + + if r.AllowNoMatch != nil { + params["allow_no_match"] = strconv.FormatBool(*r.AllowNoMatch) + } + + if r.From != nil { + params["from"] = strconv.FormatInt(int64(*r.From), 10) + } + + if r.Size != nil { + params["size"] = strconv.FormatInt(int64(*r.Size), 10) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f TransformGetTransformStats) WithContext(v context.Context) func(*TransformGetTransformStatsRequest) { + return func(r *TransformGetTransformStatsRequest) { + r.ctx = v + } +} + +// WithAllowNoMatch - whether to ignore if a wildcard expression matches no transforms. (this includes `_all` string or when no transforms have been specified). +func (f TransformGetTransformStats) WithAllowNoMatch(v bool) func(*TransformGetTransformStatsRequest) { + return func(r *TransformGetTransformStatsRequest) { + r.AllowNoMatch = &v + } +} + +// WithFrom - skips a number of transform stats, defaults to 0. +func (f TransformGetTransformStats) WithFrom(v int) func(*TransformGetTransformStatsRequest) { + return func(r *TransformGetTransformStatsRequest) { + r.From = &v + } +} + +// WithSize - specifies a max number of transform stats to get, defaults to 100. +func (f TransformGetTransformStats) WithSize(v int) func(*TransformGetTransformStatsRequest) { + return func(r *TransformGetTransformStatsRequest) { + r.Size = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f TransformGetTransformStats) WithPretty() func(*TransformGetTransformStatsRequest) { + return func(r *TransformGetTransformStatsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f TransformGetTransformStats) WithHuman() func(*TransformGetTransformStatsRequest) { + return func(r *TransformGetTransformStatsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f TransformGetTransformStats) WithErrorTrace() func(*TransformGetTransformStatsRequest) { + return func(r *TransformGetTransformStatsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f TransformGetTransformStats) WithFilterPath(v ...string) func(*TransformGetTransformStatsRequest) { + return func(r *TransformGetTransformStatsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f TransformGetTransformStats) WithHeader(h map[string]string) func(*TransformGetTransformStatsRequest) { + return func(r *TransformGetTransformStatsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f TransformGetTransformStats) WithOpaqueID(s string) func(*TransformGetTransformStatsRequest) { + return func(r *TransformGetTransformStatsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.transform.preview_transform.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.transform.preview_transform.go new file mode 100644 index 00000000..a5334bba --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.transform.preview_transform.go @@ -0,0 +1,230 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" + "time" +) + +func newTransformPreviewTransformFunc(t Transport) TransformPreviewTransform { + return func(o ...func(*TransformPreviewTransformRequest)) (*Response, error) { + var r = TransformPreviewTransformRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// TransformPreviewTransform - Previews a transform. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/preview-transform.html. +type TransformPreviewTransform func(o ...func(*TransformPreviewTransformRequest)) (*Response, error) + +// TransformPreviewTransformRequest configures the Transform Preview Transform API request. +type TransformPreviewTransformRequest struct { + Body io.Reader + + TransformID string + + Timeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r TransformPreviewTransformRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_transform") + 1 + len(r.TransformID) + 1 + len("_preview")) + path.WriteString("/") + path.WriteString("_transform") + if r.TransformID != "" { + path.WriteString("/") + path.WriteString(r.TransformID) + } + path.WriteString("/") + path.WriteString("_preview") + + params = make(map[string]string) + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f TransformPreviewTransform) WithContext(v context.Context) func(*TransformPreviewTransformRequest) { + return func(r *TransformPreviewTransformRequest) { + r.ctx = v + } +} + +// WithBody - The definition for the transform to preview. +func (f TransformPreviewTransform) WithBody(v io.Reader) func(*TransformPreviewTransformRequest) { + return func(r *TransformPreviewTransformRequest) { + r.Body = v + } +} + +// WithTransformID - the ID of the transform to preview.. +func (f TransformPreviewTransform) WithTransformID(v string) func(*TransformPreviewTransformRequest) { + return func(r *TransformPreviewTransformRequest) { + r.TransformID = v + } +} + +// WithTimeout - controls the time to wait for the preview. +func (f TransformPreviewTransform) WithTimeout(v time.Duration) func(*TransformPreviewTransformRequest) { + return func(r *TransformPreviewTransformRequest) { + r.Timeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f TransformPreviewTransform) WithPretty() func(*TransformPreviewTransformRequest) { + return func(r *TransformPreviewTransformRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f TransformPreviewTransform) WithHuman() func(*TransformPreviewTransformRequest) { + return func(r *TransformPreviewTransformRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f TransformPreviewTransform) WithErrorTrace() func(*TransformPreviewTransformRequest) { + return func(r *TransformPreviewTransformRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f TransformPreviewTransform) WithFilterPath(v ...string) func(*TransformPreviewTransformRequest) { + return func(r *TransformPreviewTransformRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f TransformPreviewTransform) WithHeader(h map[string]string) func(*TransformPreviewTransformRequest) { + return func(r *TransformPreviewTransformRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f TransformPreviewTransform) WithOpaqueID(s string) func(*TransformPreviewTransformRequest) { + return func(r *TransformPreviewTransformRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.transform.put_transform.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.transform.put_transform.go new file mode 100644 index 00000000..f65da4c9 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.transform.put_transform.go @@ -0,0 +1,225 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" + "time" +) + +func newTransformPutTransformFunc(t Transport) TransformPutTransform { + return func(body io.Reader, transform_id string, o ...func(*TransformPutTransformRequest)) (*Response, error) { + var r = TransformPutTransformRequest{Body: body, TransformID: transform_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// TransformPutTransform - Instantiates a transform. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/put-transform.html. +type TransformPutTransform func(body io.Reader, transform_id string, o ...func(*TransformPutTransformRequest)) (*Response, error) + +// TransformPutTransformRequest configures the Transform Put Transform API request. +type TransformPutTransformRequest struct { + Body io.Reader + + TransformID string + + DeferValidation *bool + Timeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r TransformPutTransformRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(1 + len("_transform") + 1 + len(r.TransformID)) + path.WriteString("/") + path.WriteString("_transform") + path.WriteString("/") + path.WriteString(r.TransformID) + + params = make(map[string]string) + + if r.DeferValidation != nil { + params["defer_validation"] = strconv.FormatBool(*r.DeferValidation) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f TransformPutTransform) WithContext(v context.Context) func(*TransformPutTransformRequest) { + return func(r *TransformPutTransformRequest) { + r.ctx = v + } +} + +// WithDeferValidation - if validations should be deferred until transform starts, defaults to false.. +func (f TransformPutTransform) WithDeferValidation(v bool) func(*TransformPutTransformRequest) { + return func(r *TransformPutTransformRequest) { + r.DeferValidation = &v + } +} + +// WithTimeout - controls the time to wait for the transform to start. +func (f TransformPutTransform) WithTimeout(v time.Duration) func(*TransformPutTransformRequest) { + return func(r *TransformPutTransformRequest) { + r.Timeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f TransformPutTransform) WithPretty() func(*TransformPutTransformRequest) { + return func(r *TransformPutTransformRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f TransformPutTransform) WithHuman() func(*TransformPutTransformRequest) { + return func(r *TransformPutTransformRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f TransformPutTransform) WithErrorTrace() func(*TransformPutTransformRequest) { + return func(r *TransformPutTransformRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f TransformPutTransform) WithFilterPath(v ...string) func(*TransformPutTransformRequest) { + return func(r *TransformPutTransformRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f TransformPutTransform) WithHeader(h map[string]string) func(*TransformPutTransformRequest) { + return func(r *TransformPutTransformRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f TransformPutTransform) WithOpaqueID(s string) func(*TransformPutTransformRequest) { + return func(r *TransformPutTransformRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.transform.start_transform.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.transform.start_transform.go new file mode 100644 index 00000000..14104cfd --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.transform.start_transform.go @@ -0,0 +1,207 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" + "time" +) + +func newTransformStartTransformFunc(t Transport) TransformStartTransform { + return func(transform_id string, o ...func(*TransformStartTransformRequest)) (*Response, error) { + var r = TransformStartTransformRequest{TransformID: transform_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// TransformStartTransform - Starts one or more transforms. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/start-transform.html. +type TransformStartTransform func(transform_id string, o ...func(*TransformStartTransformRequest)) (*Response, error) + +// TransformStartTransformRequest configures the Transform Start Transform API request. +type TransformStartTransformRequest struct { + TransformID string + + Timeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r TransformStartTransformRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_transform") + 1 + len(r.TransformID) + 1 + len("_start")) + path.WriteString("/") + path.WriteString("_transform") + path.WriteString("/") + path.WriteString(r.TransformID) + path.WriteString("/") + path.WriteString("_start") + + params = make(map[string]string) + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f TransformStartTransform) WithContext(v context.Context) func(*TransformStartTransformRequest) { + return func(r *TransformStartTransformRequest) { + r.ctx = v + } +} + +// WithTimeout - controls the time to wait for the transform to start. +func (f TransformStartTransform) WithTimeout(v time.Duration) func(*TransformStartTransformRequest) { + return func(r *TransformStartTransformRequest) { + r.Timeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f TransformStartTransform) WithPretty() func(*TransformStartTransformRequest) { + return func(r *TransformStartTransformRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f TransformStartTransform) WithHuman() func(*TransformStartTransformRequest) { + return func(r *TransformStartTransformRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f TransformStartTransform) WithErrorTrace() func(*TransformStartTransformRequest) { + return func(r *TransformStartTransformRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f TransformStartTransform) WithFilterPath(v ...string) func(*TransformStartTransformRequest) { + return func(r *TransformStartTransformRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f TransformStartTransform) WithHeader(h map[string]string) func(*TransformStartTransformRequest) { + return func(r *TransformStartTransformRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f TransformStartTransform) WithOpaqueID(s string) func(*TransformStartTransformRequest) { + return func(r *TransformStartTransformRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.transform.stop_transform.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.transform.stop_transform.go new file mode 100644 index 00000000..cd211f54 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.transform.stop_transform.go @@ -0,0 +1,256 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" + "time" +) + +func newTransformStopTransformFunc(t Transport) TransformStopTransform { + return func(transform_id string, o ...func(*TransformStopTransformRequest)) (*Response, error) { + var r = TransformStopTransformRequest{TransformID: transform_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// TransformStopTransform - Stops one or more transforms. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/stop-transform.html. +type TransformStopTransform func(transform_id string, o ...func(*TransformStopTransformRequest)) (*Response, error) + +// TransformStopTransformRequest configures the Transform Stop Transform API request. +type TransformStopTransformRequest struct { + TransformID string + + AllowNoMatch *bool + Force *bool + Timeout time.Duration + WaitForCheckpoint *bool + WaitForCompletion *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r TransformStopTransformRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_transform") + 1 + len(r.TransformID) + 1 + len("_stop")) + path.WriteString("/") + path.WriteString("_transform") + path.WriteString("/") + path.WriteString(r.TransformID) + path.WriteString("/") + path.WriteString("_stop") + + params = make(map[string]string) + + if r.AllowNoMatch != nil { + params["allow_no_match"] = strconv.FormatBool(*r.AllowNoMatch) + } + + if r.Force != nil { + params["force"] = strconv.FormatBool(*r.Force) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.WaitForCheckpoint != nil { + params["wait_for_checkpoint"] = strconv.FormatBool(*r.WaitForCheckpoint) + } + + if r.WaitForCompletion != nil { + params["wait_for_completion"] = strconv.FormatBool(*r.WaitForCompletion) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f TransformStopTransform) WithContext(v context.Context) func(*TransformStopTransformRequest) { + return func(r *TransformStopTransformRequest) { + r.ctx = v + } +} + +// WithAllowNoMatch - whether to ignore if a wildcard expression matches no transforms. (this includes `_all` string or when no transforms have been specified). +func (f TransformStopTransform) WithAllowNoMatch(v bool) func(*TransformStopTransformRequest) { + return func(r *TransformStopTransformRequest) { + r.AllowNoMatch = &v + } +} + +// WithForce - whether to force stop a failed transform or not. default to false. +func (f TransformStopTransform) WithForce(v bool) func(*TransformStopTransformRequest) { + return func(r *TransformStopTransformRequest) { + r.Force = &v + } +} + +// WithTimeout - controls the time to wait until the transform has stopped. default to 30 seconds. +func (f TransformStopTransform) WithTimeout(v time.Duration) func(*TransformStopTransformRequest) { + return func(r *TransformStopTransformRequest) { + r.Timeout = v + } +} + +// WithWaitForCheckpoint - whether to wait for the transform to reach a checkpoint before stopping. default to false. +func (f TransformStopTransform) WithWaitForCheckpoint(v bool) func(*TransformStopTransformRequest) { + return func(r *TransformStopTransformRequest) { + r.WaitForCheckpoint = &v + } +} + +// WithWaitForCompletion - whether to wait for the transform to fully stop before returning or not. default to false. +func (f TransformStopTransform) WithWaitForCompletion(v bool) func(*TransformStopTransformRequest) { + return func(r *TransformStopTransformRequest) { + r.WaitForCompletion = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f TransformStopTransform) WithPretty() func(*TransformStopTransformRequest) { + return func(r *TransformStopTransformRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f TransformStopTransform) WithHuman() func(*TransformStopTransformRequest) { + return func(r *TransformStopTransformRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f TransformStopTransform) WithErrorTrace() func(*TransformStopTransformRequest) { + return func(r *TransformStopTransformRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f TransformStopTransform) WithFilterPath(v ...string) func(*TransformStopTransformRequest) { + return func(r *TransformStopTransformRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f TransformStopTransform) WithHeader(h map[string]string) func(*TransformStopTransformRequest) { + return func(r *TransformStopTransformRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f TransformStopTransform) WithOpaqueID(s string) func(*TransformStopTransformRequest) { + return func(r *TransformStopTransformRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.transform.update_transform.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.transform.update_transform.go new file mode 100644 index 00000000..c5ace01f --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.transform.update_transform.go @@ -0,0 +1,227 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" + "time" +) + +func newTransformUpdateTransformFunc(t Transport) TransformUpdateTransform { + return func(body io.Reader, transform_id string, o ...func(*TransformUpdateTransformRequest)) (*Response, error) { + var r = TransformUpdateTransformRequest{Body: body, TransformID: transform_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// TransformUpdateTransform - Updates certain properties of a transform. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/update-transform.html. +type TransformUpdateTransform func(body io.Reader, transform_id string, o ...func(*TransformUpdateTransformRequest)) (*Response, error) + +// TransformUpdateTransformRequest configures the Transform Update Transform API request. +type TransformUpdateTransformRequest struct { + Body io.Reader + + TransformID string + + DeferValidation *bool + Timeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r TransformUpdateTransformRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(1 + len("_transform") + 1 + len(r.TransformID) + 1 + len("_update")) + path.WriteString("/") + path.WriteString("_transform") + path.WriteString("/") + path.WriteString(r.TransformID) + path.WriteString("/") + path.WriteString("_update") + + params = make(map[string]string) + + if r.DeferValidation != nil { + params["defer_validation"] = strconv.FormatBool(*r.DeferValidation) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f TransformUpdateTransform) WithContext(v context.Context) func(*TransformUpdateTransformRequest) { + return func(r *TransformUpdateTransformRequest) { + r.ctx = v + } +} + +// WithDeferValidation - if validations should be deferred until transform starts, defaults to false.. +func (f TransformUpdateTransform) WithDeferValidation(v bool) func(*TransformUpdateTransformRequest) { + return func(r *TransformUpdateTransformRequest) { + r.DeferValidation = &v + } +} + +// WithTimeout - controls the time to wait for the update. +func (f TransformUpdateTransform) WithTimeout(v time.Duration) func(*TransformUpdateTransformRequest) { + return func(r *TransformUpdateTransformRequest) { + r.Timeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f TransformUpdateTransform) WithPretty() func(*TransformUpdateTransformRequest) { + return func(r *TransformUpdateTransformRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f TransformUpdateTransform) WithHuman() func(*TransformUpdateTransformRequest) { + return func(r *TransformUpdateTransformRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f TransformUpdateTransform) WithErrorTrace() func(*TransformUpdateTransformRequest) { + return func(r *TransformUpdateTransformRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f TransformUpdateTransform) WithFilterPath(v ...string) func(*TransformUpdateTransformRequest) { + return func(r *TransformUpdateTransformRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f TransformUpdateTransform) WithHeader(h map[string]string) func(*TransformUpdateTransformRequest) { + return func(r *TransformUpdateTransformRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f TransformUpdateTransform) WithOpaqueID(s string) func(*TransformUpdateTransformRequest) { + return func(r *TransformUpdateTransformRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.transform.upgrade_transforms.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.transform.upgrade_transforms.go new file mode 100644 index 00000000..fca76a5c --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.transform.upgrade_transforms.go @@ -0,0 +1,213 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" + "time" +) + +func newTransformUpgradeTransformsFunc(t Transport) TransformUpgradeTransforms { + return func(o ...func(*TransformUpgradeTransformsRequest)) (*Response, error) { + var r = TransformUpgradeTransformsRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// TransformUpgradeTransforms - Upgrades all transforms. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/upgrade-transforms.html. +type TransformUpgradeTransforms func(o ...func(*TransformUpgradeTransformsRequest)) (*Response, error) + +// TransformUpgradeTransformsRequest configures the Transform Upgrade Transforms API request. +type TransformUpgradeTransformsRequest struct { + DryRun *bool + Timeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r TransformUpgradeTransformsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(len("/_transform/_upgrade")) + path.WriteString("/_transform/_upgrade") + + params = make(map[string]string) + + if r.DryRun != nil { + params["dry_run"] = strconv.FormatBool(*r.DryRun) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f TransformUpgradeTransforms) WithContext(v context.Context) func(*TransformUpgradeTransformsRequest) { + return func(r *TransformUpgradeTransformsRequest) { + r.ctx = v + } +} + +// WithDryRun - whether to only check for updates but don't execute. +func (f TransformUpgradeTransforms) WithDryRun(v bool) func(*TransformUpgradeTransformsRequest) { + return func(r *TransformUpgradeTransformsRequest) { + r.DryRun = &v + } +} + +// WithTimeout - controls the time to wait for the upgrade. +func (f TransformUpgradeTransforms) WithTimeout(v time.Duration) func(*TransformUpgradeTransformsRequest) { + return func(r *TransformUpgradeTransformsRequest) { + r.Timeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f TransformUpgradeTransforms) WithPretty() func(*TransformUpgradeTransformsRequest) { + return func(r *TransformUpgradeTransformsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f TransformUpgradeTransforms) WithHuman() func(*TransformUpgradeTransformsRequest) { + return func(r *TransformUpgradeTransformsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f TransformUpgradeTransforms) WithErrorTrace() func(*TransformUpgradeTransformsRequest) { + return func(r *TransformUpgradeTransformsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f TransformUpgradeTransforms) WithFilterPath(v ...string) func(*TransformUpgradeTransformsRequest) { + return func(r *TransformUpgradeTransformsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f TransformUpgradeTransforms) WithHeader(h map[string]string) func(*TransformUpgradeTransformsRequest) { + return func(r *TransformUpgradeTransformsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f TransformUpgradeTransforms) WithOpaqueID(s string) func(*TransformUpgradeTransformsRequest) { + return func(r *TransformUpgradeTransformsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.watcher.ack_watch.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.watcher.ack_watch.go new file mode 100644 index 00000000..83852b15 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.watcher.ack_watch.go @@ -0,0 +1,207 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newWatcherAckWatchFunc(t Transport) WatcherAckWatch { + return func(watch_id string, o ...func(*WatcherAckWatchRequest)) (*Response, error) { + var r = WatcherAckWatchRequest{WatchID: watch_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// WatcherAckWatch - Acknowledges a watch, manually throttling the execution of the watch's actions. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-ack-watch.html. +type WatcherAckWatch func(watch_id string, o ...func(*WatcherAckWatchRequest)) (*Response, error) + +// WatcherAckWatchRequest configures the Watcher Ack Watch API request. +type WatcherAckWatchRequest struct { + ActionID []string + WatchID string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r WatcherAckWatchRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(1 + len("_watcher") + 1 + len("watch") + 1 + len(r.WatchID) + 1 + len("_ack") + 1 + len(strings.Join(r.ActionID, ","))) + path.WriteString("/") + path.WriteString("_watcher") + path.WriteString("/") + path.WriteString("watch") + path.WriteString("/") + path.WriteString(r.WatchID) + path.WriteString("/") + path.WriteString("_ack") + if len(r.ActionID) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.ActionID, ",")) + } + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f WatcherAckWatch) WithContext(v context.Context) func(*WatcherAckWatchRequest) { + return func(r *WatcherAckWatchRequest) { + r.ctx = v + } +} + +// WithActionID - a list of the action ids to be acked. +func (f WatcherAckWatch) WithActionID(v ...string) func(*WatcherAckWatchRequest) { + return func(r *WatcherAckWatchRequest) { + r.ActionID = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f WatcherAckWatch) WithPretty() func(*WatcherAckWatchRequest) { + return func(r *WatcherAckWatchRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f WatcherAckWatch) WithHuman() func(*WatcherAckWatchRequest) { + return func(r *WatcherAckWatchRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f WatcherAckWatch) WithErrorTrace() func(*WatcherAckWatchRequest) { + return func(r *WatcherAckWatchRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f WatcherAckWatch) WithFilterPath(v ...string) func(*WatcherAckWatchRequest) { + return func(r *WatcherAckWatchRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f WatcherAckWatch) WithHeader(h map[string]string) func(*WatcherAckWatchRequest) { + return func(r *WatcherAckWatchRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f WatcherAckWatch) WithOpaqueID(s string) func(*WatcherAckWatchRequest) { + return func(r *WatcherAckWatchRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.watcher.activate_watch.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.watcher.activate_watch.go new file mode 100644 index 00000000..4787ae63 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.watcher.activate_watch.go @@ -0,0 +1,195 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newWatcherActivateWatchFunc(t Transport) WatcherActivateWatch { + return func(watch_id string, o ...func(*WatcherActivateWatchRequest)) (*Response, error) { + var r = WatcherActivateWatchRequest{WatchID: watch_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// WatcherActivateWatch - Activates a currently inactive watch. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-activate-watch.html. +type WatcherActivateWatch func(watch_id string, o ...func(*WatcherActivateWatchRequest)) (*Response, error) + +// WatcherActivateWatchRequest configures the Watcher Activate Watch API request. +type WatcherActivateWatchRequest struct { + WatchID string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r WatcherActivateWatchRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(1 + len("_watcher") + 1 + len("watch") + 1 + len(r.WatchID) + 1 + len("_activate")) + path.WriteString("/") + path.WriteString("_watcher") + path.WriteString("/") + path.WriteString("watch") + path.WriteString("/") + path.WriteString(r.WatchID) + path.WriteString("/") + path.WriteString("_activate") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f WatcherActivateWatch) WithContext(v context.Context) func(*WatcherActivateWatchRequest) { + return func(r *WatcherActivateWatchRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f WatcherActivateWatch) WithPretty() func(*WatcherActivateWatchRequest) { + return func(r *WatcherActivateWatchRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f WatcherActivateWatch) WithHuman() func(*WatcherActivateWatchRequest) { + return func(r *WatcherActivateWatchRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f WatcherActivateWatch) WithErrorTrace() func(*WatcherActivateWatchRequest) { + return func(r *WatcherActivateWatchRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f WatcherActivateWatch) WithFilterPath(v ...string) func(*WatcherActivateWatchRequest) { + return func(r *WatcherActivateWatchRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f WatcherActivateWatch) WithHeader(h map[string]string) func(*WatcherActivateWatchRequest) { + return func(r *WatcherActivateWatchRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f WatcherActivateWatch) WithOpaqueID(s string) func(*WatcherActivateWatchRequest) { + return func(r *WatcherActivateWatchRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.watcher.deactivate_watch.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.watcher.deactivate_watch.go new file mode 100644 index 00000000..109286e7 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.watcher.deactivate_watch.go @@ -0,0 +1,195 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newWatcherDeactivateWatchFunc(t Transport) WatcherDeactivateWatch { + return func(watch_id string, o ...func(*WatcherDeactivateWatchRequest)) (*Response, error) { + var r = WatcherDeactivateWatchRequest{WatchID: watch_id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// WatcherDeactivateWatch - Deactivates a currently active watch. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-deactivate-watch.html. +type WatcherDeactivateWatch func(watch_id string, o ...func(*WatcherDeactivateWatchRequest)) (*Response, error) + +// WatcherDeactivateWatchRequest configures the Watcher Deactivate Watch API request. +type WatcherDeactivateWatchRequest struct { + WatchID string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r WatcherDeactivateWatchRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(1 + len("_watcher") + 1 + len("watch") + 1 + len(r.WatchID) + 1 + len("_deactivate")) + path.WriteString("/") + path.WriteString("_watcher") + path.WriteString("/") + path.WriteString("watch") + path.WriteString("/") + path.WriteString(r.WatchID) + path.WriteString("/") + path.WriteString("_deactivate") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f WatcherDeactivateWatch) WithContext(v context.Context) func(*WatcherDeactivateWatchRequest) { + return func(r *WatcherDeactivateWatchRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f WatcherDeactivateWatch) WithPretty() func(*WatcherDeactivateWatchRequest) { + return func(r *WatcherDeactivateWatchRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f WatcherDeactivateWatch) WithHuman() func(*WatcherDeactivateWatchRequest) { + return func(r *WatcherDeactivateWatchRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f WatcherDeactivateWatch) WithErrorTrace() func(*WatcherDeactivateWatchRequest) { + return func(r *WatcherDeactivateWatchRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f WatcherDeactivateWatch) WithFilterPath(v ...string) func(*WatcherDeactivateWatchRequest) { + return func(r *WatcherDeactivateWatchRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f WatcherDeactivateWatch) WithHeader(h map[string]string) func(*WatcherDeactivateWatchRequest) { + return func(r *WatcherDeactivateWatchRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f WatcherDeactivateWatch) WithOpaqueID(s string) func(*WatcherDeactivateWatchRequest) { + return func(r *WatcherDeactivateWatchRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.watcher.delete_watch.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.watcher.delete_watch.go new file mode 100644 index 00000000..e9cf5f54 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.watcher.delete_watch.go @@ -0,0 +1,193 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newWatcherDeleteWatchFunc(t Transport) WatcherDeleteWatch { + return func(id string, o ...func(*WatcherDeleteWatchRequest)) (*Response, error) { + var r = WatcherDeleteWatchRequest{WatchID: id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// WatcherDeleteWatch - Removes a watch from Watcher. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-delete-watch.html. +type WatcherDeleteWatch func(id string, o ...func(*WatcherDeleteWatchRequest)) (*Response, error) + +// WatcherDeleteWatchRequest configures the Watcher Delete Watch API request. +type WatcherDeleteWatchRequest struct { + WatchID string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r WatcherDeleteWatchRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + path.Grow(1 + len("_watcher") + 1 + len("watch") + 1 + len(r.WatchID)) + path.WriteString("/") + path.WriteString("_watcher") + path.WriteString("/") + path.WriteString("watch") + path.WriteString("/") + path.WriteString(r.WatchID) + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f WatcherDeleteWatch) WithContext(v context.Context) func(*WatcherDeleteWatchRequest) { + return func(r *WatcherDeleteWatchRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f WatcherDeleteWatch) WithPretty() func(*WatcherDeleteWatchRequest) { + return func(r *WatcherDeleteWatchRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f WatcherDeleteWatch) WithHuman() func(*WatcherDeleteWatchRequest) { + return func(r *WatcherDeleteWatchRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f WatcherDeleteWatch) WithErrorTrace() func(*WatcherDeleteWatchRequest) { + return func(r *WatcherDeleteWatchRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f WatcherDeleteWatch) WithFilterPath(v ...string) func(*WatcherDeleteWatchRequest) { + return func(r *WatcherDeleteWatchRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f WatcherDeleteWatch) WithHeader(h map[string]string) func(*WatcherDeleteWatchRequest) { + return func(r *WatcherDeleteWatchRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f WatcherDeleteWatch) WithOpaqueID(s string) func(*WatcherDeleteWatchRequest) { + return func(r *WatcherDeleteWatchRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.watcher.execute_watch.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.watcher.execute_watch.go new file mode 100644 index 00000000..c4c428d9 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.watcher.execute_watch.go @@ -0,0 +1,232 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" +) + +func newWatcherExecuteWatchFunc(t Transport) WatcherExecuteWatch { + return func(o ...func(*WatcherExecuteWatchRequest)) (*Response, error) { + var r = WatcherExecuteWatchRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// WatcherExecuteWatch - Forces the execution of a stored watch. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-execute-watch.html. +type WatcherExecuteWatch func(o ...func(*WatcherExecuteWatchRequest)) (*Response, error) + +// WatcherExecuteWatchRequest configures the Watcher Execute Watch API request. +type WatcherExecuteWatchRequest struct { + WatchID string + + Body io.Reader + + Debug *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r WatcherExecuteWatchRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(1 + len("_watcher") + 1 + len("watch") + 1 + len(r.WatchID) + 1 + len("_execute")) + path.WriteString("/") + path.WriteString("_watcher") + path.WriteString("/") + path.WriteString("watch") + if r.WatchID != "" { + path.WriteString("/") + path.WriteString(r.WatchID) + } + path.WriteString("/") + path.WriteString("_execute") + + params = make(map[string]string) + + if r.Debug != nil { + params["debug"] = strconv.FormatBool(*r.Debug) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f WatcherExecuteWatch) WithContext(v context.Context) func(*WatcherExecuteWatchRequest) { + return func(r *WatcherExecuteWatchRequest) { + r.ctx = v + } +} + +// WithBody - Execution control. +func (f WatcherExecuteWatch) WithBody(v io.Reader) func(*WatcherExecuteWatchRequest) { + return func(r *WatcherExecuteWatchRequest) { + r.Body = v + } +} + +// WithWatchID - watch ID. +func (f WatcherExecuteWatch) WithWatchID(v string) func(*WatcherExecuteWatchRequest) { + return func(r *WatcherExecuteWatchRequest) { + r.WatchID = v + } +} + +// WithDebug - indicates whether the watch should execute in debug mode. +func (f WatcherExecuteWatch) WithDebug(v bool) func(*WatcherExecuteWatchRequest) { + return func(r *WatcherExecuteWatchRequest) { + r.Debug = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f WatcherExecuteWatch) WithPretty() func(*WatcherExecuteWatchRequest) { + return func(r *WatcherExecuteWatchRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f WatcherExecuteWatch) WithHuman() func(*WatcherExecuteWatchRequest) { + return func(r *WatcherExecuteWatchRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f WatcherExecuteWatch) WithErrorTrace() func(*WatcherExecuteWatchRequest) { + return func(r *WatcherExecuteWatchRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f WatcherExecuteWatch) WithFilterPath(v ...string) func(*WatcherExecuteWatchRequest) { + return func(r *WatcherExecuteWatchRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f WatcherExecuteWatch) WithHeader(h map[string]string) func(*WatcherExecuteWatchRequest) { + return func(r *WatcherExecuteWatchRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f WatcherExecuteWatch) WithOpaqueID(s string) func(*WatcherExecuteWatchRequest) { + return func(r *WatcherExecuteWatchRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.watcher.get_watch.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.watcher.get_watch.go new file mode 100644 index 00000000..531181fb --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.watcher.get_watch.go @@ -0,0 +1,193 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newWatcherGetWatchFunc(t Transport) WatcherGetWatch { + return func(id string, o ...func(*WatcherGetWatchRequest)) (*Response, error) { + var r = WatcherGetWatchRequest{WatchID: id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// WatcherGetWatch - Retrieves a watch by its ID. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-get-watch.html. +type WatcherGetWatch func(id string, o ...func(*WatcherGetWatchRequest)) (*Response, error) + +// WatcherGetWatchRequest configures the Watcher Get Watch API request. +type WatcherGetWatchRequest struct { + WatchID string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r WatcherGetWatchRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_watcher") + 1 + len("watch") + 1 + len(r.WatchID)) + path.WriteString("/") + path.WriteString("_watcher") + path.WriteString("/") + path.WriteString("watch") + path.WriteString("/") + path.WriteString(r.WatchID) + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f WatcherGetWatch) WithContext(v context.Context) func(*WatcherGetWatchRequest) { + return func(r *WatcherGetWatchRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f WatcherGetWatch) WithPretty() func(*WatcherGetWatchRequest) { + return func(r *WatcherGetWatchRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f WatcherGetWatch) WithHuman() func(*WatcherGetWatchRequest) { + return func(r *WatcherGetWatchRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f WatcherGetWatch) WithErrorTrace() func(*WatcherGetWatchRequest) { + return func(r *WatcherGetWatchRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f WatcherGetWatch) WithFilterPath(v ...string) func(*WatcherGetWatchRequest) { + return func(r *WatcherGetWatchRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f WatcherGetWatch) WithHeader(h map[string]string) func(*WatcherGetWatchRequest) { + return func(r *WatcherGetWatchRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f WatcherGetWatch) WithOpaqueID(s string) func(*WatcherGetWatchRequest) { + return func(r *WatcherGetWatchRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.watcher.put_watch.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.watcher.put_watch.go new file mode 100644 index 00000000..492b958a --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.watcher.put_watch.go @@ -0,0 +1,257 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" +) + +func newWatcherPutWatchFunc(t Transport) WatcherPutWatch { + return func(id string, o ...func(*WatcherPutWatchRequest)) (*Response, error) { + var r = WatcherPutWatchRequest{WatchID: id} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// WatcherPutWatch - Creates a new watch, or updates an existing one. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-put-watch.html. +type WatcherPutWatch func(id string, o ...func(*WatcherPutWatchRequest)) (*Response, error) + +// WatcherPutWatchRequest configures the Watcher Put Watch API request. +type WatcherPutWatchRequest struct { + WatchID string + + Body io.Reader + + Active *bool + IfPrimaryTerm *int + IfSeqNo *int + Version *int + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r WatcherPutWatchRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(1 + len("_watcher") + 1 + len("watch") + 1 + len(r.WatchID)) + path.WriteString("/") + path.WriteString("_watcher") + path.WriteString("/") + path.WriteString("watch") + path.WriteString("/") + path.WriteString(r.WatchID) + + params = make(map[string]string) + + if r.Active != nil { + params["active"] = strconv.FormatBool(*r.Active) + } + + if r.IfPrimaryTerm != nil { + params["if_primary_term"] = strconv.FormatInt(int64(*r.IfPrimaryTerm), 10) + } + + if r.IfSeqNo != nil { + params["if_seq_no"] = strconv.FormatInt(int64(*r.IfSeqNo), 10) + } + + if r.Version != nil { + params["version"] = strconv.FormatInt(int64(*r.Version), 10) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f WatcherPutWatch) WithContext(v context.Context) func(*WatcherPutWatchRequest) { + return func(r *WatcherPutWatchRequest) { + r.ctx = v + } +} + +// WithBody - The watch. +func (f WatcherPutWatch) WithBody(v io.Reader) func(*WatcherPutWatchRequest) { + return func(r *WatcherPutWatchRequest) { + r.Body = v + } +} + +// WithActive - specify whether the watch is in/active by default. +func (f WatcherPutWatch) WithActive(v bool) func(*WatcherPutWatchRequest) { + return func(r *WatcherPutWatchRequest) { + r.Active = &v + } +} + +// WithIfPrimaryTerm - only update the watch if the last operation that has changed the watch has the specified primary term. +func (f WatcherPutWatch) WithIfPrimaryTerm(v int) func(*WatcherPutWatchRequest) { + return func(r *WatcherPutWatchRequest) { + r.IfPrimaryTerm = &v + } +} + +// WithIfSeqNo - only update the watch if the last operation that has changed the watch has the specified sequence number. +func (f WatcherPutWatch) WithIfSeqNo(v int) func(*WatcherPutWatchRequest) { + return func(r *WatcherPutWatchRequest) { + r.IfSeqNo = &v + } +} + +// WithVersion - explicit version number for concurrency control. +func (f WatcherPutWatch) WithVersion(v int) func(*WatcherPutWatchRequest) { + return func(r *WatcherPutWatchRequest) { + r.Version = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f WatcherPutWatch) WithPretty() func(*WatcherPutWatchRequest) { + return func(r *WatcherPutWatchRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f WatcherPutWatch) WithHuman() func(*WatcherPutWatchRequest) { + return func(r *WatcherPutWatchRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f WatcherPutWatch) WithErrorTrace() func(*WatcherPutWatchRequest) { + return func(r *WatcherPutWatchRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f WatcherPutWatch) WithFilterPath(v ...string) func(*WatcherPutWatchRequest) { + return func(r *WatcherPutWatchRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f WatcherPutWatch) WithHeader(h map[string]string) func(*WatcherPutWatchRequest) { + return func(r *WatcherPutWatchRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f WatcherPutWatch) WithOpaqueID(s string) func(*WatcherPutWatchRequest) { + return func(r *WatcherPutWatchRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.watcher.query_watches.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.watcher.query_watches.go new file mode 100644 index 00000000..69ced400 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.watcher.query_watches.go @@ -0,0 +1,200 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "io" + "net/http" + "strings" +) + +func newWatcherQueryWatchesFunc(t Transport) WatcherQueryWatches { + return func(o ...func(*WatcherQueryWatchesRequest)) (*Response, error) { + var r = WatcherQueryWatchesRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// WatcherQueryWatches - Retrieves stored watches. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-query-watches.html. +type WatcherQueryWatches func(o ...func(*WatcherQueryWatchesRequest)) (*Response, error) + +// WatcherQueryWatchesRequest configures the Watcher Query Watches API request. +type WatcherQueryWatchesRequest struct { + Body io.Reader + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r WatcherQueryWatchesRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(len("/_watcher/_query/watches")) + path.WriteString("/_watcher/_query/watches") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), r.Body) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f WatcherQueryWatches) WithContext(v context.Context) func(*WatcherQueryWatchesRequest) { + return func(r *WatcherQueryWatchesRequest) { + r.ctx = v + } +} + +// WithBody - From, size, query, sort and search_after. +func (f WatcherQueryWatches) WithBody(v io.Reader) func(*WatcherQueryWatchesRequest) { + return func(r *WatcherQueryWatchesRequest) { + r.Body = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f WatcherQueryWatches) WithPretty() func(*WatcherQueryWatchesRequest) { + return func(r *WatcherQueryWatchesRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f WatcherQueryWatches) WithHuman() func(*WatcherQueryWatchesRequest) { + return func(r *WatcherQueryWatchesRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f WatcherQueryWatches) WithErrorTrace() func(*WatcherQueryWatchesRequest) { + return func(r *WatcherQueryWatchesRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f WatcherQueryWatches) WithFilterPath(v ...string) func(*WatcherQueryWatchesRequest) { + return func(r *WatcherQueryWatchesRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f WatcherQueryWatches) WithHeader(h map[string]string) func(*WatcherQueryWatchesRequest) { + return func(r *WatcherQueryWatchesRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f WatcherQueryWatches) WithOpaqueID(s string) func(*WatcherQueryWatchesRequest) { + return func(r *WatcherQueryWatchesRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.watcher.start.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.watcher.start.go new file mode 100644 index 00000000..3b00e4a0 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.watcher.start.go @@ -0,0 +1,186 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newWatcherStartFunc(t Transport) WatcherStart { + return func(o ...func(*WatcherStartRequest)) (*Response, error) { + var r = WatcherStartRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// WatcherStart - Starts Watcher if it is not already running. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-start.html. +type WatcherStart func(o ...func(*WatcherStartRequest)) (*Response, error) + +// WatcherStartRequest configures the Watcher Start API request. +type WatcherStartRequest struct { + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r WatcherStartRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(len("/_watcher/_start")) + path.WriteString("/_watcher/_start") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f WatcherStart) WithContext(v context.Context) func(*WatcherStartRequest) { + return func(r *WatcherStartRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f WatcherStart) WithPretty() func(*WatcherStartRequest) { + return func(r *WatcherStartRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f WatcherStart) WithHuman() func(*WatcherStartRequest) { + return func(r *WatcherStartRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f WatcherStart) WithErrorTrace() func(*WatcherStartRequest) { + return func(r *WatcherStartRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f WatcherStart) WithFilterPath(v ...string) func(*WatcherStartRequest) { + return func(r *WatcherStartRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f WatcherStart) WithHeader(h map[string]string) func(*WatcherStartRequest) { + return func(r *WatcherStartRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f WatcherStart) WithOpaqueID(s string) func(*WatcherStartRequest) { + return func(r *WatcherStartRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.watcher.stats.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.watcher.stats.go new file mode 100644 index 00000000..90aa32cd --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.watcher.stats.go @@ -0,0 +1,220 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newWatcherStatsFunc(t Transport) WatcherStats { + return func(o ...func(*WatcherStatsRequest)) (*Response, error) { + var r = WatcherStatsRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// WatcherStats - Retrieves the current Watcher metrics. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-stats.html. +type WatcherStats func(o ...func(*WatcherStatsRequest)) (*Response, error) + +// WatcherStatsRequest configures the Watcher Stats API request. +type WatcherStatsRequest struct { + Metric []string + + EmitStacktraces *bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r WatcherStatsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_watcher") + 1 + len("stats") + 1 + len(strings.Join(r.Metric, ","))) + path.WriteString("/") + path.WriteString("_watcher") + path.WriteString("/") + path.WriteString("stats") + if len(r.Metric) > 0 { + path.WriteString("/") + path.WriteString(strings.Join(r.Metric, ",")) + } + + params = make(map[string]string) + + if r.EmitStacktraces != nil { + params["emit_stacktraces"] = strconv.FormatBool(*r.EmitStacktraces) + } + + if len(r.Metric) > 0 { + params["metric"] = strings.Join(r.Metric, ",") + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f WatcherStats) WithContext(v context.Context) func(*WatcherStatsRequest) { + return func(r *WatcherStatsRequest) { + r.ctx = v + } +} + +// WithMetric - controls what additional stat metrics should be include in the response. +func (f WatcherStats) WithMetric(v ...string) func(*WatcherStatsRequest) { + return func(r *WatcherStatsRequest) { + r.Metric = v + } +} + +// WithEmitStacktraces - emits stack traces of currently running watches. +func (f WatcherStats) WithEmitStacktraces(v bool) func(*WatcherStatsRequest) { + return func(r *WatcherStatsRequest) { + r.EmitStacktraces = &v + } +} + +// WithPretty makes the response body pretty-printed. +func (f WatcherStats) WithPretty() func(*WatcherStatsRequest) { + return func(r *WatcherStatsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f WatcherStats) WithHuman() func(*WatcherStatsRequest) { + return func(r *WatcherStatsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f WatcherStats) WithErrorTrace() func(*WatcherStatsRequest) { + return func(r *WatcherStatsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f WatcherStats) WithFilterPath(v ...string) func(*WatcherStatsRequest) { + return func(r *WatcherStatsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f WatcherStats) WithHeader(h map[string]string) func(*WatcherStatsRequest) { + return func(r *WatcherStatsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f WatcherStats) WithOpaqueID(s string) func(*WatcherStatsRequest) { + return func(r *WatcherStatsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.watcher.stop.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.watcher.stop.go new file mode 100644 index 00000000..ff912f62 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.watcher.stop.go @@ -0,0 +1,186 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" +) + +func newWatcherStopFunc(t Transport) WatcherStop { + return func(o ...func(*WatcherStopRequest)) (*Response, error) { + var r = WatcherStopRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// WatcherStop - Stops Watcher if it is running. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-stop.html. +type WatcherStop func(o ...func(*WatcherStopRequest)) (*Response, error) + +// WatcherStopRequest configures the Watcher Stop API request. +type WatcherStopRequest struct { + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r WatcherStopRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "POST" + + path.Grow(len("/_watcher/_stop")) + path.WriteString("/_watcher/_stop") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f WatcherStop) WithContext(v context.Context) func(*WatcherStopRequest) { + return func(r *WatcherStopRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f WatcherStop) WithPretty() func(*WatcherStopRequest) { + return func(r *WatcherStopRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f WatcherStop) WithHuman() func(*WatcherStopRequest) { + return func(r *WatcherStopRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f WatcherStop) WithErrorTrace() func(*WatcherStopRequest) { + return func(r *WatcherStopRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f WatcherStop) WithFilterPath(v ...string) func(*WatcherStopRequest) { + return func(r *WatcherStopRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f WatcherStop) WithHeader(h map[string]string) func(*WatcherStopRequest) { + return func(r *WatcherStopRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f WatcherStop) WithOpaqueID(s string) func(*WatcherStopRequest) { + return func(r *WatcherStopRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.xpack.info.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.xpack.info.go new file mode 100644 index 00000000..2f108833 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.xpack.info.go @@ -0,0 +1,212 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strconv" + "strings" +) + +func newXPackInfoFunc(t Transport) XPackInfo { + return func(o ...func(*XPackInfoRequest)) (*Response, error) { + var r = XPackInfoRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// XPackInfo - Retrieves information about the installed X-Pack features. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/info-api.html. +type XPackInfo func(o ...func(*XPackInfoRequest)) (*Response, error) + +// XPackInfoRequest configures the X Pack Info API request. +type XPackInfoRequest struct { + AcceptEnterprise *bool + Categories []string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r XPackInfoRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(len("/_xpack")) + path.WriteString("/_xpack") + + params = make(map[string]string) + + if r.AcceptEnterprise != nil { + params["accept_enterprise"] = strconv.FormatBool(*r.AcceptEnterprise) + } + + if len(r.Categories) > 0 { + params["categories"] = strings.Join(r.Categories, ",") + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f XPackInfo) WithContext(v context.Context) func(*XPackInfoRequest) { + return func(r *XPackInfoRequest) { + r.ctx = v + } +} + +// WithAcceptEnterprise - if an enterprise license is installed, return the type and mode as 'enterprise' (default: false). +func (f XPackInfo) WithAcceptEnterprise(v bool) func(*XPackInfoRequest) { + return func(r *XPackInfoRequest) { + r.AcceptEnterprise = &v + } +} + +// WithCategories - comma-separated list of info categories. can be any of: build, license, features. +func (f XPackInfo) WithCategories(v ...string) func(*XPackInfoRequest) { + return func(r *XPackInfoRequest) { + r.Categories = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f XPackInfo) WithPretty() func(*XPackInfoRequest) { + return func(r *XPackInfoRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f XPackInfo) WithHuman() func(*XPackInfoRequest) { + return func(r *XPackInfoRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f XPackInfo) WithErrorTrace() func(*XPackInfoRequest) { + return func(r *XPackInfoRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f XPackInfo) WithFilterPath(v ...string) func(*XPackInfoRequest) { + return func(r *XPackInfoRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f XPackInfo) WithHeader(h map[string]string) func(*XPackInfoRequest) { + return func(r *XPackInfoRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f XPackInfo) WithOpaqueID(s string) func(*XPackInfoRequest) { + return func(r *XPackInfoRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.xpack.usage.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.xpack.usage.go new file mode 100644 index 00000000..f35e7663 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/api.xpack.xpack.usage.go @@ -0,0 +1,200 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// Code generated from specification version 7.17.10: DO NOT EDIT + +package esapi + +import ( + "context" + "net/http" + "strings" + "time" +) + +func newXPackUsageFunc(t Transport) XPackUsage { + return func(o ...func(*XPackUsageRequest)) (*Response, error) { + var r = XPackUsageRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// XPackUsage - Retrieves usage information about the installed X-Pack features. +// +// See full documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/usage-api.html. +type XPackUsage func(o ...func(*XPackUsageRequest)) (*Response, error) + +// XPackUsageRequest configures the X Pack Usage API request. +type XPackUsageRequest struct { + MasterTimeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do executes the request and returns response or error. +func (r XPackUsageRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(len("/_xpack/usage")) + path.WriteString("/_xpack/usage") + + params = make(map[string]string) + + if r.MasterTimeout != 0 { + params["master_timeout"] = formatDuration(r.MasterTimeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f XPackUsage) WithContext(v context.Context) func(*XPackUsageRequest) { + return func(r *XPackUsageRequest) { + r.ctx = v + } +} + +// WithMasterTimeout - specify timeout for watch write operation. +func (f XPackUsage) WithMasterTimeout(v time.Duration) func(*XPackUsageRequest) { + return func(r *XPackUsageRequest) { + r.MasterTimeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f XPackUsage) WithPretty() func(*XPackUsageRequest) { + return func(r *XPackUsageRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f XPackUsage) WithHuman() func(*XPackUsageRequest) { + return func(r *XPackUsageRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f XPackUsage) WithErrorTrace() func(*XPackUsageRequest) { + return func(r *XPackUsageRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f XPackUsage) WithFilterPath(v ...string) func(*XPackUsageRequest) { + return func(r *XPackUsageRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f XPackUsage) WithHeader(h map[string]string) func(*XPackUsageRequest) { + return func(r *XPackUsageRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f XPackUsage) WithOpaqueID(s string) func(*XPackUsageRequest) { + return func(r *XPackUsageRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/doc.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/doc.go new file mode 100644 index 00000000..404d6bca --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/doc.go @@ -0,0 +1,112 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +/* +Package esapi provides the Go API for Elasticsearch. + +It is automatically included in the client provided by the +github.com/elastic/go-elasticsearch package: + + es, _ := elasticsearch.NewDefaultClient() + res, _ := es.Info() + log.Println(res) + +For each Elasticsearch API, such as "Index", the package exports two corresponding types: +a function and a struct. + +The function type allows you to call the Elasticsearch API as a method on the client, +passing the parameters as arguments: + + res, err := es.Index( + "test", // Index name + strings.NewReader(`{"title" : "Test"}`), // Document body + es.Index.WithDocumentID("1"), // Document ID + es.Index.WithRefresh("true"), // Refresh + ) + if err != nil { + log.Fatalf("ERROR: %s", err) + } + defer res.Body.Close() + + log.Println(res) + + // => [201 Created] {"_index":"test","_type":"_doc","_id":"1" ... + +The struct type allows for a more hands-on approach, where you create a new struct, with the +request configuration as fields, and call the Do() method +with a context and the client as arguments: + + req := esapi.IndexRequest{ + Index: "test", // Index name + Body: strings.NewReader(`{"title" : "Test"}`), // Document body + DocumentID: "1", // Document ID + Refresh: "true", // Refresh + } + + res, err := req.Do(context.Background(), es) + if err != nil { + log.Fatalf("Error getting response: %s", err) + } + defer res.Body.Close() + + log.Println(res) + + // => [200 OK] {"_index":"test","_type":"_doc","_id":"1","_version":2 ... + +The function type is a wrapper around the struct, and allows +to configure and perform the request in a more expressive way. +It has a minor overhead compared to using a struct directly; +refer to the esapi_benchmark_test.go suite for concrete numbers. + +See the documentation for each API function or struct at +https://godoc.org/github.com/elastic/go-elasticsearch, +or locally by: + + go doc github.com/elastic/go-elasticsearch/v7/esapi Index + go doc github.com/elastic/go-elasticsearch/v7/esapi IndexRequest + +Response + +The esapi.Response type is a lightweight wrapper around http.Response. + +The res.Body field is an io.ReadCloser, leaving the JSON parsing to the +calling code, in the interest of performance and flexibility +(eg. to allow using a custom JSON parser). + +It is imperative to close the response body for a non-nil response. + +The Response type implements a couple of convenience methods for accessing +the status, checking an error status code or printing +the response body for debugging purposes. + +Additional Information + +See the Elasticsearch documentation at +https://www.elastic.co/guide/en/elasticsearch/reference/master/api-conventions.html for detailed information +about the API endpoints and parameters. + +The Go API is generated from the Elasticsearch JSON specification at +https://github.com/elastic/elasticsearch/tree/master/rest-api-spec/src/main/resources/rest-api-spec/api +by the internal package available at +https://github.com/elastic/go-elasticsearch/tree/master/internal/cmd/generate/commands/gensource. + +The API is tested by integration tests common to all Elasticsearch official clients, generated from the +source at https://github.com/elastic/elasticsearch/tree/master/rest-api-spec/src/main/resources/rest-api-spec/test. +The generator is provided by the internal package available at internal/cmd/generate/commands/gentests. + +*/ +package esapi diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/esapi.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/esapi.go new file mode 100644 index 00000000..2efb1c2f --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/esapi.go @@ -0,0 +1,62 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package esapi + +import ( + "net/http" + "strconv" + "time" + + "github.com/elastic/go-elasticsearch/v7/internal/version" +) + +// Version returns the package version as a string. +// +const Version = version.Client + +// Transport defines the interface for an API client. +// +type Transport interface { + Perform(*http.Request) (*http.Response, error) +} + +// BoolPtr returns a pointer to v. +// +// It is used as a convenience function for converting a bool value +// into a pointer when passing the value to a function or struct field +// which expects a pointer. +// +func BoolPtr(v bool) *bool { return &v } + +// IntPtr returns a pointer to v. +// +// It is used as a convenience function for converting an int value +// into a pointer when passing the value to a function or struct field +// which expects a pointer. +// +func IntPtr(v int) *int { return &v } + +// formatDuration converts duration to a string in the format +// accepted by Elasticsearch. +// +func formatDuration(d time.Duration) string { + if d < time.Millisecond { + return strconv.FormatInt(int64(d), 10) + "nanos" + } + return strconv.FormatInt(int64(d)/int64(time.Millisecond), 10) + "ms" +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/esapi.request.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/esapi.request.go new file mode 100644 index 00000000..23498361 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/esapi.request.go @@ -0,0 +1,44 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package esapi + +import ( + "context" + "io" + "net/http" +) + +const ( + headerContentType = "Content-Type" +) + +var ( + headerContentTypeJSON = []string{"application/json"} +) + +// Request defines the API request. +// +type Request interface { + Do(ctx context.Context, transport Transport) (*Response, error) +} + +// newRequest creates an HTTP request. +// +func newRequest(method, path string, body io.Reader) (*http.Request, error) { + return http.NewRequest(method, path, body) +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/esapi.response.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/esapi.response.go new file mode 100644 index 00000000..a657b5ee --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/esapi/esapi.response.go @@ -0,0 +1,105 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package esapi + +import ( + "bytes" + "fmt" + "io" + "io/ioutil" + "net/http" + "strconv" + "strings" +) + +// Response represents the API response. +// +type Response struct { + StatusCode int + Header http.Header + Body io.ReadCloser +} + +// String returns the response as a string. +// +// The intended usage is for testing or debugging only. +// +func (r *Response) String() string { + var ( + out = new(bytes.Buffer) + b1 = bytes.NewBuffer([]byte{}) + b2 = bytes.NewBuffer([]byte{}) + tr io.Reader + ) + + if r != nil && r.Body != nil { + tr = io.TeeReader(r.Body, b1) + defer r.Body.Close() + + if _, err := io.Copy(b2, tr); err != nil { + out.WriteString(fmt.Sprintf("", err)) + return out.String() + } + defer func() { r.Body = ioutil.NopCloser(b1) }() + } + + if r != nil { + out.WriteString(fmt.Sprintf("[%d %s]", r.StatusCode, http.StatusText(r.StatusCode))) + if r.StatusCode > 0 { + out.WriteRune(' ') + } + } else { + out.WriteString("[0 ]") + } + + if r != nil && r.Body != nil { + out.ReadFrom(b2) // errcheck exclude (*bytes.Buffer).ReadFrom + } + + return out.String() +} + +// Status returns the response status as a string. +// +func (r *Response) Status() string { + var b strings.Builder + if r != nil { + b.WriteString(strconv.Itoa(r.StatusCode)) + b.WriteString(" ") + b.WriteString(http.StatusText(r.StatusCode)) + } + return b.String() +} + +// IsError returns true when the response status indicates failure. +// +func (r *Response) IsError() bool { + return r.StatusCode > 299 +} + +// Warnings returns the deprecation warnings from response headers. +// +func (r *Response) Warnings() []string { + return r.Header["Warning"] +} + +// HasWarnings returns true when the response headers contain deprecation warnings. +// +func (r *Response) HasWarnings() bool { + return len(r.Warnings()) > 0 +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/estransport/connection.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/estransport/connection.go new file mode 100644 index 00000000..4930c8a1 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/estransport/connection.go @@ -0,0 +1,335 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package estransport + +import ( + "errors" + "fmt" + "math" + "net/url" + "sort" + "sync" + "time" +) + +var ( + defaultResurrectTimeoutInitial = 60 * time.Second + defaultResurrectTimeoutFactorCutoff = 5 +) + +// Selector defines the interface for selecting connections from the pool. +// +type Selector interface { + Select([]*Connection) (*Connection, error) +} + +// ConnectionPool defines the interface for the connection pool. +// +type ConnectionPool interface { + Next() (*Connection, error) // Next returns the next available connection. + OnSuccess(*Connection) error // OnSuccess reports that the connection was successful. + OnFailure(*Connection) error // OnFailure reports that the connection failed. + URLs() []*url.URL // URLs returns the list of URLs of available connections. +} + +// Connection represents a connection to a node. +// +type Connection struct { + sync.Mutex + + URL *url.URL + IsDead bool + DeadSince time.Time + Failures int + + ID string + Name string + Roles []string + Attributes map[string]interface{} +} + +type singleConnectionPool struct { + connection *Connection + + metrics *metrics +} + +type statusConnectionPool struct { + sync.Mutex + + live []*Connection // List of live connections + dead []*Connection // List of dead connections + selector Selector + + metrics *metrics +} + +type roundRobinSelector struct { + sync.Mutex + + curr int // Index of the current connection +} + +// NewConnectionPool creates and returns a default connection pool. +// +func NewConnectionPool(conns []*Connection, selector Selector) (ConnectionPool, error) { + if len(conns) == 1 { + return &singleConnectionPool{connection: conns[0]}, nil + } + if selector == nil { + selector = &roundRobinSelector{curr: -1} + } + return &statusConnectionPool{live: conns, selector: selector}, nil +} + +// Next returns the connection from pool. +// +func (cp *singleConnectionPool) Next() (*Connection, error) { + return cp.connection, nil +} + +// OnSuccess is a no-op for single connection pool. +func (cp *singleConnectionPool) OnSuccess(c *Connection) error { return nil } + +// OnFailure is a no-op for single connection pool. +func (cp *singleConnectionPool) OnFailure(c *Connection) error { return nil } + +// URLs returns the list of URLs of available connections. +func (cp *singleConnectionPool) URLs() []*url.URL { return []*url.URL{cp.connection.URL} } + +func (cp *singleConnectionPool) connections() []*Connection { return []*Connection{cp.connection} } + +// Next returns a connection from pool, or an error. +// +func (cp *statusConnectionPool) Next() (*Connection, error) { + cp.Lock() + defer cp.Unlock() + + // Return next live connection + if len(cp.live) > 0 { + return cp.selector.Select(cp.live) + } else if len(cp.dead) > 0 { + // No live connection is available, resurrect one of the dead ones. + c := cp.dead[len(cp.dead)-1] + cp.dead = cp.dead[:len(cp.dead)-1] + c.Lock() + defer c.Unlock() + cp.resurrect(c, false) + return c, nil + } + return nil, errors.New("no connection available") +} + +// OnSuccess marks the connection as successful. +// +func (cp *statusConnectionPool) OnSuccess(c *Connection) error { + // Short-circuit for live connection + c.Lock() + if !c.IsDead { + c.Unlock() + return nil + } + c.Unlock() + + cp.Lock() + defer cp.Unlock() + + c.Lock() + defer c.Unlock() + + if !c.IsDead { + return nil + } + + c.markAsHealthy() + return cp.resurrect(c, true) +} + +// OnFailure marks the connection as failed. +func (cp *statusConnectionPool) OnFailure(c *Connection) error { + cp.Lock() + defer cp.Unlock() + + c.Lock() + + if c.IsDead { + if debugLogger != nil { + debugLogger.Logf("Already removed %s\n", c.URL) + } + c.Unlock() + return nil + } + + if debugLogger != nil { + debugLogger.Logf("Removing %s...\n", c.URL) + } + c.markAsDead() + cp.scheduleResurrect(c) + c.Unlock() + + // Push item to dead list and sort slice by number of failures + cp.dead = append(cp.dead, c) + sort.Slice(cp.dead, func(i, j int) bool { + c1 := cp.dead[i] + c2 := cp.dead[j] + c1.Lock() + c2.Lock() + defer c1.Unlock() + defer c2.Unlock() + + res := c1.Failures > c2.Failures + return res + }) + + // Check if connection exists in the list, return error if not. + index := -1 + for i, conn := range cp.live { + if conn == c { + index = i + } + } + if index < 0 { + return errors.New("connection not in live list") + } + + // Remove item; https://github.com/golang/go/wiki/SliceTricks + copy(cp.live[index:], cp.live[index+1:]) + cp.live = cp.live[:len(cp.live)-1] + + return nil +} + +// URLs returns the list of URLs of available connections. +// +func (cp *statusConnectionPool) URLs() []*url.URL { + var urls []*url.URL + + cp.Lock() + defer cp.Unlock() + + for _, c := range cp.live { + urls = append(urls, c.URL) + } + + return urls +} + +func (cp *statusConnectionPool) connections() []*Connection { + var conns []*Connection + conns = append(conns, cp.live...) + conns = append(conns, cp.dead...) + return conns +} + +// resurrect adds the connection to the list of available connections. +// When removeDead is true, it also removes it from the dead list. +// The calling code is responsible for locking. +// +func (cp *statusConnectionPool) resurrect(c *Connection, removeDead bool) error { + if debugLogger != nil { + debugLogger.Logf("Resurrecting %s\n", c.URL) + } + + c.markAsLive() + cp.live = append(cp.live, c) + + if removeDead { + index := -1 + for i, conn := range cp.dead { + if conn == c { + index = i + } + } + if index >= 0 { + // Remove item; https://github.com/golang/go/wiki/SliceTricks + copy(cp.dead[index:], cp.dead[index+1:]) + cp.dead = cp.dead[:len(cp.dead)-1] + } + } + + return nil +} + +// scheduleResurrect schedules the connection to be resurrected. +// +func (cp *statusConnectionPool) scheduleResurrect(c *Connection) { + factor := math.Min(float64(c.Failures-1), float64(defaultResurrectTimeoutFactorCutoff)) + timeout := time.Duration(defaultResurrectTimeoutInitial.Seconds() * math.Exp2(factor) * float64(time.Second)) + if debugLogger != nil { + debugLogger.Logf("Resurrect %s (failures=%d, factor=%1.1f, timeout=%s) in %s\n", c.URL, c.Failures, factor, timeout, c.DeadSince.Add(timeout).Sub(time.Now().UTC()).Truncate(time.Second)) + } + + time.AfterFunc(timeout, func() { + cp.Lock() + defer cp.Unlock() + + c.Lock() + defer c.Unlock() + + if !c.IsDead { + if debugLogger != nil { + debugLogger.Logf("Already resurrected %s\n", c.URL) + } + return + } + + cp.resurrect(c, true) + }) +} + +// Select returns the connection in a round-robin fashion. +// +func (s *roundRobinSelector) Select(conns []*Connection) (*Connection, error) { + s.Lock() + defer s.Unlock() + + s.curr = (s.curr + 1) % len(conns) + return conns[s.curr], nil +} + +// markAsDead marks the connection as dead. +// +func (c *Connection) markAsDead() { + c.IsDead = true + if c.DeadSince.IsZero() { + c.DeadSince = time.Now().UTC() + } + c.Failures++ +} + +// markAsLive marks the connection as alive. +// +func (c *Connection) markAsLive() { + c.IsDead = false +} + +// markAsHealthy marks the connection as healthy. +// +func (c *Connection) markAsHealthy() { + c.IsDead = false + c.DeadSince = time.Time{} + c.Failures = 0 +} + +// String returns a readable connection representation. +// +func (c *Connection) String() string { + c.Lock() + defer c.Unlock() + return fmt.Sprintf("<%s> dead=%v failures=%d", c.URL, c.IsDead, c.Failures) +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/estransport/discovery.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/estransport/discovery.go new file mode 100644 index 00000000..ccbb586a --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/estransport/discovery.go @@ -0,0 +1,218 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package estransport + +import ( + "encoding/json" + "fmt" + "io/ioutil" + "net/http" + "net/url" + "sort" + "strings" + "sync" + "time" +) + +// Discoverable defines the interface for transports supporting node discovery. +// +type Discoverable interface { + DiscoverNodes() error +} + +// nodeInfo represents the information about node in a cluster. +// +// See: https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-nodes-info.html +// +type nodeInfo struct { + ID string + Name string + URL *url.URL + Roles []string `json:"roles"` + Attributes map[string]interface{} + HTTP struct { + PublishAddress string `json:"publish_address"` + } +} + +// DiscoverNodes reloads the client connections by fetching information from the cluster. +// +func (c *Client) DiscoverNodes() error { + var conns []*Connection + + nodes, err := c.getNodesInfo() + if err != nil { + if debugLogger != nil { + debugLogger.Logf("Error getting nodes info: %s\n", err) + } + return fmt.Errorf("discovery: get nodes: %s", err) + } + + for _, node := range nodes { + var ( + isMasterOnlyNode bool + ) + + roles := append(node.Roles[:0:0], node.Roles...) + sort.Strings(roles) + + if len(roles) == 1 && roles[0] == "master" { + isMasterOnlyNode = true + } + + if debugLogger != nil { + var skip string + if isMasterOnlyNode { + skip = "; [SKIP]" + } + debugLogger.Logf("Discovered node [%s]; %s; roles=%s%s\n", node.Name, node.URL, node.Roles, skip) + } + + // Skip master only nodes + // TODO(karmi): Move logic to Selector? + if isMasterOnlyNode { + continue + } + + conns = append(conns, &Connection{ + URL: node.URL, + ID: node.ID, + Name: node.Name, + Roles: node.Roles, + Attributes: node.Attributes, + }) + } + + c.Lock() + defer c.Unlock() + + if lockable, ok := c.pool.(sync.Locker); ok { + lockable.Lock() + defer lockable.Unlock() + } + + if c.poolFunc != nil { + c.pool = c.poolFunc(conns, c.selector) + } else { + // TODO(karmi): Replace only live connections, leave dead scheduled for resurrect? + c.pool, err = NewConnectionPool(conns, c.selector) + if err != nil { + return err + } + } + + return nil +} + +func (c *Client) getNodesInfo() ([]nodeInfo, error) { + var ( + out []nodeInfo + scheme = c.urls[0].Scheme + ) + + req, err := http.NewRequest("GET", "/_nodes/http", nil) + if err != nil { + return out, err + } + + c.Lock() + conn, err := c.pool.Next() + c.Unlock() + // TODO(karmi): If no connection is returned, fallback to original URLs + if err != nil { + return out, err + } + + c.setReqURL(conn.URL, req) + c.setReqAuth(conn.URL, req) + c.setReqUserAgent(req) + + if c.disableMetaHeader == false { + c.setMetaHeader(req) + } + + res, err := c.transport.RoundTrip(req) + if err != nil { + return out, err + } + defer res.Body.Close() + + if res.StatusCode > 200 { + body, _ := ioutil.ReadAll(res.Body) + return out, fmt.Errorf("server error: %s: %s", res.Status, body) + } + + var env map[string]json.RawMessage + if err := json.NewDecoder(res.Body).Decode(&env); err != nil { + return out, err + } + + var nodes map[string]nodeInfo + if err := json.Unmarshal(env["nodes"], &nodes); err != nil { + return out, err + } + + for id, node := range nodes { + node.ID = id + u, err := c.getNodeURL(node, scheme) + if err != nil { + return out, err + } + node.URL = u + out = append(out, node) + } + + return out, nil +} + +func (c *Client) getNodeURL(node nodeInfo, scheme string) (*url.URL, error) { + var ( + host string + port string + + addrs = strings.Split(node.HTTP.PublishAddress, "/") + ports = strings.Split(node.HTTP.PublishAddress, ":") + ) + + if len(addrs) > 1 { + host = addrs[0] + } else { + host = strings.Split(addrs[0], ":")[0] + } + port = ports[len(ports)-1] + + u := &url.URL{ + Scheme: scheme, + Host: host + ":" + port, + } + + return u, nil +} + +func (c *Client) scheduleDiscoverNodes(d time.Duration) { + go c.DiscoverNodes() + + c.Lock() + defer c.Unlock() + if c.discoverNodesTimer != nil { + c.discoverNodesTimer.Stop() + } + c.discoverNodesTimer = time.AfterFunc(c.discoverNodesInterval, func() { + c.scheduleDiscoverNodes(c.discoverNodesInterval) + }) +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/estransport/doc.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/estransport/doc.go new file mode 100644 index 00000000..56731074 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/estransport/doc.go @@ -0,0 +1,51 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +/* +Package estransport provides the transport layer for the Elasticsearch client. + +It is automatically included in the client provided by the github.com/elastic/go-elasticsearch package +and is not intended for direct use: to configure the client, use the elasticsearch.Config struct. + +The default HTTP transport of the client is http.Transport; use the Transport option to customize it; +see the _examples/coniguration.go and _examples/customization.go files in this repository for information. + +The package will automatically retry requests on network-related errors, and on specific +response status codes (by default 502, 503, 504). Use the RetryOnStatus option to customize the list. +The transport will not retry a timeout network error, unless enabled by setting EnableRetryOnTimeout to true. + +Use the MaxRetries option to configure the number of retries, and set DisableRetry to true +to disable the retry behaviour altogether. + +By default, the retry will be performed without any delay; to configure a backoff interval, +implement the RetryBackoff option function; see an example in the package unit tests for information. + +When multiple addresses are passed in configuration, the package will use them in a round-robin fashion, +and will keep track of live and dead nodes. The status of dead nodes is checked periodically. + +To customize the node selection behaviour, provide a Selector implementation in the configuration. +To replace the connection pool entirely, provide a custom ConnectionPool implementation via +the ConnectionPoolFunc option. + +The package defines the Logger interface for logging information about request and response. +It comes with several bundled loggers for logging in text and JSON. + +Use the EnableDebugLogger option to enable the debugging logger for connection management. + +Use the EnableMetrics option to enable metric collection and export. +*/ +package estransport diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/estransport/estransport.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/estransport/estransport.go new file mode 100644 index 00000000..613de02c --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/estransport/estransport.go @@ -0,0 +1,600 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package estransport + +import ( + "bytes" + "compress/gzip" + "crypto/sha256" + "crypto/tls" + "crypto/x509" + "encoding/hex" + "errors" + "fmt" + "io" + "io/ioutil" + "net" + "net/http" + "net/url" + "os" + "regexp" + "runtime" + "strconv" + "strings" + "sync" + "time" + + "github.com/elastic/go-elasticsearch/v7/internal/version" +) + +const ( + // Version returns the package version as a string. + Version = version.Client + + // esCompatHeader defines the env var for Compatibility header. + esCompatHeader = "ELASTIC_CLIENT_APIVERSIONING" + + userAgentHeader = "User-Agent" +) + +var ( + userAgent string + metaHeader string + compatibilityHeader bool + reGoVersion = regexp.MustCompile(`go(\d+\.\d+\..+)`) + + defaultMaxRetries = 3 + defaultRetryOnStatus = [...]int{502, 503, 504} +) + +func init() { + userAgent = initUserAgent() + metaHeader = initMetaHeader() + + compatHeaderEnv := os.Getenv(esCompatHeader) + compatibilityHeader, _ = strconv.ParseBool(compatHeaderEnv) +} + +// Interface defines the interface for HTTP client. +// +type Interface interface { + Perform(*http.Request) (*http.Response, error) +} + +// Config represents the configuration of HTTP client. +// +type Config struct { + URLs []*url.URL + Username string + Password string + APIKey string + ServiceToken string + + Header http.Header + CACert []byte + + RetryOnStatus []int + DisableRetry bool + EnableRetryOnTimeout bool + MaxRetries int + RetryBackoff func(attempt int) time.Duration + + CompressRequestBody bool + CompatibilityHeader bool + + EnableMetrics bool + EnableDebugLogger bool + + DisableMetaHeader bool + + DiscoverNodesInterval time.Duration + + Transport http.RoundTripper + Logger Logger + Selector Selector + + ConnectionPoolFunc func([]*Connection, Selector) ConnectionPool + + CertificateFingerprint string +} + +// Client represents the HTTP client. +// +type Client struct { + sync.Mutex + + urls []*url.URL + username string + password string + apikey string + servicetoken string + fingerprint string + header http.Header + + retryOnStatus []int + disableRetry bool + enableRetryOnTimeout bool + disableMetaHeader bool + maxRetries int + retryBackoff func(attempt int) time.Duration + discoverNodesInterval time.Duration + discoverNodesTimer *time.Timer + + compressRequestBody bool + compatibilityHeader bool + + metrics *metrics + + transport http.RoundTripper + logger Logger + selector Selector + pool ConnectionPool + poolFunc func([]*Connection, Selector) ConnectionPool +} + +// New creates new transport client. +// +// http.DefaultTransport will be used if no transport is passed in the configuration. +// +func New(cfg Config) (*Client, error) { + if cfg.Transport == nil { + cfg.Transport = http.DefaultTransport + } + + if transport, ok := cfg.Transport.(*http.Transport); ok { + if cfg.CertificateFingerprint != "" { + transport.DialTLS = func(network, addr string) (net.Conn, error) { + fingerprint, _ := hex.DecodeString(cfg.CertificateFingerprint) + + c, err := tls.Dial(network, addr, &tls.Config{InsecureSkipVerify: true}) + if err != nil { + return nil, err + } + + // Retrieve the connection state from the remote server. + cState := c.ConnectionState() + for _, cert := range cState.PeerCertificates { + // Compute digest for each certificate. + digest := sha256.Sum256(cert.Raw) + + // Provided fingerprint should match at least one certificate from remote before we continue. + if bytes.Compare(digest[0:], fingerprint) == 0 { + return c, nil + } + } + return nil, fmt.Errorf("fingerprint mismatch, provided: %s", cfg.CertificateFingerprint) + } + } + } + + if cfg.CACert != nil { + httpTransport, ok := cfg.Transport.(*http.Transport) + if !ok { + return nil, fmt.Errorf("unable to set CA certificate for transport of type %T", cfg.Transport) + } + + httpTransport = httpTransport.Clone() + httpTransport.TLSClientConfig.RootCAs = x509.NewCertPool() + + if ok := httpTransport.TLSClientConfig.RootCAs.AppendCertsFromPEM(cfg.CACert); !ok { + return nil, errors.New("unable to add CA certificate") + } + + cfg.Transport = httpTransport + } + + if len(cfg.RetryOnStatus) == 0 { + cfg.RetryOnStatus = defaultRetryOnStatus[:] + } + + if cfg.MaxRetries == 0 { + cfg.MaxRetries = defaultMaxRetries + } + + var conns []*Connection + for _, u := range cfg.URLs { + conns = append(conns, &Connection{URL: u}) + } + + client := Client{ + urls: cfg.URLs, + username: cfg.Username, + password: cfg.Password, + apikey: cfg.APIKey, + servicetoken: cfg.ServiceToken, + header: cfg.Header, + + retryOnStatus: cfg.RetryOnStatus, + disableRetry: cfg.DisableRetry, + enableRetryOnTimeout: cfg.EnableRetryOnTimeout, + disableMetaHeader: cfg.DisableMetaHeader, + maxRetries: cfg.MaxRetries, + retryBackoff: cfg.RetryBackoff, + discoverNodesInterval: cfg.DiscoverNodesInterval, + + compressRequestBody: cfg.CompressRequestBody, + compatibilityHeader: cfg.CompatibilityHeader, + + transport: cfg.Transport, + logger: cfg.Logger, + selector: cfg.Selector, + poolFunc: cfg.ConnectionPoolFunc, + } + + if client.poolFunc != nil { + client.pool = client.poolFunc(conns, client.selector) + } else { + client.pool, _ = NewConnectionPool(conns, client.selector) + } + + if cfg.EnableDebugLogger { + debugLogger = &debuggingLogger{Output: os.Stdout} + } + + if cfg.EnableMetrics { + client.metrics = &metrics{responses: make(map[int]int)} + // TODO(karmi): Type assertion to interface + if pool, ok := client.pool.(*singleConnectionPool); ok { + pool.metrics = client.metrics + } + if pool, ok := client.pool.(*statusConnectionPool); ok { + pool.metrics = client.metrics + } + } + + if client.discoverNodesInterval > 0 { + time.AfterFunc(client.discoverNodesInterval, func() { + client.scheduleDiscoverNodes(client.discoverNodesInterval) + }) + } + + return &client, nil +} + +// Perform executes the request and returns a response or error. +// +func (c *Client) Perform(req *http.Request) (*http.Response, error) { + var ( + res *http.Response + err error + ) + + // Compatibility Header + if compatibilityHeader || c.compatibilityHeader { + if req.Body != nil { + req.Header.Set("Content-Type", "application/vnd.elasticsearch+json;compatible-with=7") + } + req.Header.Set("Accept", "application/vnd.elasticsearch+json;compatible-with=7") + } + + // Record metrics, when enabled + if c.metrics != nil { + c.metrics.Lock() + c.metrics.requests++ + c.metrics.Unlock() + } + + // Update request + c.setReqUserAgent(req) + c.setReqGlobalHeader(req) + c.setMetaHeader(req) + + if req.Body != nil && req.Body != http.NoBody { + if c.compressRequestBody { + var buf bytes.Buffer + zw := gzip.NewWriter(&buf) + if _, err := io.Copy(zw, req.Body); err != nil { + return nil, fmt.Errorf("failed to compress request body: %s", err) + } + if err := zw.Close(); err != nil { + return nil, fmt.Errorf("failed to compress request body (during close): %s", err) + } + + req.GetBody = func() (io.ReadCloser, error) { + r := buf + return ioutil.NopCloser(&r), nil + } + req.Body, _ = req.GetBody() + + req.Header.Set("Content-Encoding", "gzip") + req.ContentLength = int64(buf.Len()) + + } else if req.GetBody == nil { + if !c.disableRetry || (c.logger != nil && c.logger.RequestBodyEnabled()) { + var buf bytes.Buffer + buf.ReadFrom(req.Body) + + req.GetBody = func() (io.ReadCloser, error) { + r := buf + return ioutil.NopCloser(&r), nil + } + req.Body, _ = req.GetBody() + } + } + } + + originalPath := req.URL.Path + for i := 0; i <= c.maxRetries; i++ { + var ( + conn *Connection + shouldRetry bool + shouldCloseBody bool + ) + + // Get connection from the pool + c.Lock() + conn, err = c.pool.Next() + c.Unlock() + if err != nil { + if c.logger != nil { + c.logRoundTrip(req, nil, err, time.Time{}, time.Duration(0)) + } + return nil, fmt.Errorf("cannot get connection: %s", err) + } + + // Update request + c.setReqURL(conn.URL, req) + c.setReqAuth(conn.URL, req) + + if !c.disableRetry && i > 0 && req.Body != nil && req.Body != http.NoBody { + body, err := req.GetBody() + if err != nil { + return nil, fmt.Errorf("cannot get request body: %s", err) + } + req.Body = body + } + + // Set up time measures and execute the request + start := time.Now().UTC() + res, err = c.transport.RoundTrip(req) + dur := time.Since(start) + + // Log request and response + if c.logger != nil { + if c.logger.RequestBodyEnabled() && req.Body != nil && req.Body != http.NoBody { + req.Body, _ = req.GetBody() + } + c.logRoundTrip(req, res, err, start, dur) + } + + if err != nil { + // Record metrics, when enabled + if c.metrics != nil { + c.metrics.Lock() + c.metrics.failures++ + c.metrics.Unlock() + } + + // Report the connection as unsuccessful + c.Lock() + c.pool.OnFailure(conn) + c.Unlock() + + // Retry on EOF errors + if err == io.EOF { + shouldRetry = true + } + + // Retry on network errors, but not on timeout errors, unless configured + if err, ok := err.(net.Error); ok { + if (!err.Timeout() || c.enableRetryOnTimeout) && !c.disableRetry { + shouldRetry = true + } + } + } else { + // Report the connection as succesfull + c.Lock() + c.pool.OnSuccess(conn) + c.Unlock() + } + + if res != nil && c.metrics != nil { + c.metrics.Lock() + c.metrics.responses[res.StatusCode]++ + c.metrics.Unlock() + } + + // Retry on configured response statuses + if res != nil && !c.disableRetry { + for _, code := range c.retryOnStatus { + if res.StatusCode == code { + shouldRetry = true + shouldCloseBody = true + } + } + } + + // Break if retry should not be performed + if !shouldRetry { + break + } + + // Drain and close body when retrying after response + if shouldCloseBody && i < c.maxRetries { + if res.Body != nil { + io.Copy(ioutil.Discard, res.Body) + res.Body.Close() + } + } + + // Delay the retry if a backoff function is configured + if c.retryBackoff != nil { + var cancelled bool + backoff := c.retryBackoff(i + 1) + timer := time.NewTimer(backoff) + select { + case <-req.Context().Done(): + err = req.Context().Err() + cancelled = true + timer.Stop() + case <-timer.C: + } + if cancelled { + break + } + } + + // Re-init the path of the request to its original state + // This will be re-enriched by the connection upon retry + req.URL.Path = originalPath + } + + // TODO(karmi): Wrap error + return res, err +} + +// URLs returns a list of transport URLs. +// +// +func (c *Client) URLs() []*url.URL { + return c.pool.URLs() +} + +func (c *Client) setReqURL(u *url.URL, req *http.Request) *http.Request { + req.URL.Scheme = u.Scheme + req.URL.Host = u.Host + + if u.Path != "" { + var b strings.Builder + b.Grow(len(u.Path) + len(req.URL.Path)) + b.WriteString(u.Path) + b.WriteString(req.URL.Path) + req.URL.Path = b.String() + } + + return req +} + +func (c *Client) setReqAuth(u *url.URL, req *http.Request) *http.Request { + if _, ok := req.Header["Authorization"]; !ok { + if u.User != nil { + password, _ := u.User.Password() + req.SetBasicAuth(u.User.Username(), password) + return req + } + + if c.apikey != "" { + var b bytes.Buffer + b.Grow(len("APIKey ") + len(c.apikey)) + b.WriteString("APIKey ") + b.WriteString(c.apikey) + req.Header.Set("Authorization", b.String()) + return req + } + + if c.servicetoken != "" { + var b bytes.Buffer + b.Grow(len("Bearer ") + len(c.servicetoken)) + b.WriteString("Bearer ") + b.WriteString(c.servicetoken) + req.Header.Set("Authorization", b.String()) + return req + } + + if c.username != "" && c.password != "" { + req.SetBasicAuth(c.username, c.password) + return req + } + } + + return req +} + +func (c *Client) setReqUserAgent(req *http.Request) *http.Request { + if len(c.header) > 0 { + ua := c.header.Get(userAgentHeader) + if ua != "" { + req.Header.Set(userAgentHeader, ua) + return req + } + } + req.Header.Set(userAgentHeader, userAgent) + return req +} + +func (c *Client) setReqGlobalHeader(req *http.Request) *http.Request { + if len(c.header) > 0 { + for k, v := range c.header { + if req.Header.Get(k) != k { + for _, vv := range v { + req.Header.Add(k, vv) + } + } + } + } + return req +} + +func (c *Client) setMetaHeader(req *http.Request) *http.Request { + if c.disableMetaHeader { + req.Header.Del(HeaderClientMeta) + return req + } + + existingMetaHeader := req.Header.Get(HeaderClientMeta) + if existingMetaHeader != "" { + req.Header.Set(HeaderClientMeta, strings.Join([]string{metaHeader, existingMetaHeader}, ",")) + } else { + req.Header.Add(HeaderClientMeta, metaHeader) + } + return req +} + +func (c *Client) logRoundTrip( + req *http.Request, + res *http.Response, + err error, + start time.Time, + dur time.Duration, +) { + var dupRes http.Response + if res != nil { + dupRes = *res + } + if c.logger.ResponseBodyEnabled() { + if res != nil && res.Body != nil && res.Body != http.NoBody { + b1, b2, _ := duplicateBody(res.Body) + dupRes.Body = b1 + res.Body = b2 + } + } + c.logger.LogRoundTrip(req, &dupRes, err, start, dur) // errcheck exclude +} + +func initUserAgent() string { + var b strings.Builder + + b.WriteString("go-elasticsearch") + b.WriteRune('/') + b.WriteString(Version) + b.WriteRune(' ') + b.WriteRune('(') + b.WriteString(runtime.GOOS) + b.WriteRune(' ') + b.WriteString(runtime.GOARCH) + b.WriteString("; ") + b.WriteString("Go ") + if v := reGoVersion.ReplaceAllString(runtime.Version(), "$1"); v != "" { + b.WriteString(v) + } else { + b.WriteString(runtime.Version()) + } + b.WriteRune(')') + + return b.String() +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/estransport/logger.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/estransport/logger.go new file mode 100644 index 00000000..6ebfcbd9 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/estransport/logger.go @@ -0,0 +1,457 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package estransport + +import ( + "bufio" + "bytes" + "encoding/json" + "fmt" + "io" + "io/ioutil" + "net/http" + "net/url" + "strconv" + "strings" + "time" +) + +var debugLogger DebuggingLogger + +// Logger defines an interface for logging request and response. +// +type Logger interface { + // LogRoundTrip should not modify the request or response, except for consuming and closing the body. + // Implementations have to check for nil values in request and response. + LogRoundTrip(*http.Request, *http.Response, error, time.Time, time.Duration) error + // RequestBodyEnabled makes the client pass a copy of request body to the logger. + RequestBodyEnabled() bool + // ResponseBodyEnabled makes the client pass a copy of response body to the logger. + ResponseBodyEnabled() bool +} + +// DebuggingLogger defines the interface for a debugging logger. +// +type DebuggingLogger interface { + Log(a ...interface{}) error + Logf(format string, a ...interface{}) error +} + +// TextLogger prints the log message in plain text. +// +type TextLogger struct { + Output io.Writer + EnableRequestBody bool + EnableResponseBody bool +} + +// ColorLogger prints the log message in a terminal-optimized plain text. +// +type ColorLogger struct { + Output io.Writer + EnableRequestBody bool + EnableResponseBody bool +} + +// CurlLogger prints the log message as a runnable curl command. +// +type CurlLogger struct { + Output io.Writer + EnableRequestBody bool + EnableResponseBody bool +} + +// JSONLogger prints the log message as JSON. +// +type JSONLogger struct { + Output io.Writer + EnableRequestBody bool + EnableResponseBody bool +} + +// debuggingLogger prints debug messages as plain text. +// +type debuggingLogger struct { + Output io.Writer +} + +// LogRoundTrip prints the information about request and response. +// +func (l *TextLogger) LogRoundTrip(req *http.Request, res *http.Response, err error, start time.Time, dur time.Duration) error { + fmt.Fprintf(l.Output, "%s %s %s [status:%d request:%s]\n", + start.Format(time.RFC3339), + req.Method, + req.URL.String(), + resStatusCode(res), + dur.Truncate(time.Millisecond), + ) + if l.RequestBodyEnabled() && req != nil && req.Body != nil && req.Body != http.NoBody { + var buf bytes.Buffer + if req.GetBody != nil { + b, _ := req.GetBody() + buf.ReadFrom(b) + } else { + buf.ReadFrom(req.Body) + } + logBodyAsText(l.Output, &buf, ">") + } + if l.ResponseBodyEnabled() && res != nil && res.Body != nil && res.Body != http.NoBody { + defer res.Body.Close() + var buf bytes.Buffer + buf.ReadFrom(res.Body) + logBodyAsText(l.Output, &buf, "<") + } + if err != nil { + fmt.Fprintf(l.Output, "! ERROR: %v\n", err) + } + return nil +} + +// RequestBodyEnabled returns true when the request body should be logged. +func (l *TextLogger) RequestBodyEnabled() bool { return l.EnableRequestBody } + +// ResponseBodyEnabled returns true when the response body should be logged. +func (l *TextLogger) ResponseBodyEnabled() bool { return l.EnableResponseBody } + +// LogRoundTrip prints the information about request and response. +// +func (l *ColorLogger) LogRoundTrip(req *http.Request, res *http.Response, err error, start time.Time, dur time.Duration) error { + query, _ := url.QueryUnescape(req.URL.RawQuery) + if query != "" { + query = "?" + query + } + + var ( + status string + color string + ) + + status = res.Status + switch { + case res.StatusCode > 0 && res.StatusCode < 300: + color = "\x1b[32m" + case res.StatusCode > 299 && res.StatusCode < 500: + color = "\x1b[33m" + case res.StatusCode > 499: + color = "\x1b[31m" + default: + status = "ERROR" + color = "\x1b[31;4m" + } + + fmt.Fprintf(l.Output, "%6s \x1b[1;4m%s://%s%s\x1b[0m%s %s%s\x1b[0m \x1b[2m%s\x1b[0m\n", + req.Method, + req.URL.Scheme, + req.URL.Host, + req.URL.Path, + query, + color, + status, + dur.Truncate(time.Millisecond), + ) + + if l.RequestBodyEnabled() && req != nil && req.Body != nil && req.Body != http.NoBody { + var buf bytes.Buffer + if req.GetBody != nil { + b, _ := req.GetBody() + buf.ReadFrom(b) + } else { + buf.ReadFrom(req.Body) + } + fmt.Fprint(l.Output, "\x1b[2m") + logBodyAsText(l.Output, &buf, " »") + fmt.Fprint(l.Output, "\x1b[0m") + } + + if l.ResponseBodyEnabled() && res != nil && res.Body != nil && res.Body != http.NoBody { + defer res.Body.Close() + var buf bytes.Buffer + buf.ReadFrom(res.Body) + fmt.Fprint(l.Output, "\x1b[2m") + logBodyAsText(l.Output, &buf, " «") + fmt.Fprint(l.Output, "\x1b[0m") + } + + if err != nil { + fmt.Fprintf(l.Output, "\x1b[31;1m» ERROR \x1b[31m%v\x1b[0m\n", err) + } + + if l.RequestBodyEnabled() || l.ResponseBodyEnabled() { + fmt.Fprintf(l.Output, "\x1b[2m%s\x1b[0m\n", strings.Repeat("─", 80)) + } + return nil +} + +// RequestBodyEnabled returns true when the request body should be logged. +func (l *ColorLogger) RequestBodyEnabled() bool { return l.EnableRequestBody } + +// ResponseBodyEnabled returns true when the response body should be logged. +func (l *ColorLogger) ResponseBodyEnabled() bool { return l.EnableResponseBody } + +// LogRoundTrip prints the information about request and response. +// +func (l *CurlLogger) LogRoundTrip(req *http.Request, res *http.Response, err error, start time.Time, dur time.Duration) error { + var b bytes.Buffer + + var query string + qvalues := url.Values{} + for k, v := range req.URL.Query() { + if k == "pretty" { + continue + } + for _, qv := range v { + qvalues.Add(k, qv) + } + } + if len(qvalues) > 0 { + query = qvalues.Encode() + } + + b.WriteString(`curl`) + if req.Method == "HEAD" { + b.WriteString(" --head") + } else { + fmt.Fprintf(&b, " -X %s", req.Method) + } + + if len(req.Header) > 0 { + for k, vv := range req.Header { + if k == "Authorization" || k == "User-Agent" { + continue + } + v := strings.Join(vv, ",") + b.WriteString(fmt.Sprintf(" -H '%s: %s'", k, v)) + } + } + + b.WriteString(" '") + b.WriteString(req.URL.Scheme) + b.WriteString("://") + b.WriteString(req.URL.Host) + b.WriteString(req.URL.Path) + b.WriteString("?pretty") + if query != "" { + fmt.Fprintf(&b, "&%s", query) + } + b.WriteString("'") + + if req != nil && req.Body != nil && req.Body != http.NoBody { + var buf bytes.Buffer + if req.GetBody != nil { + b, _ := req.GetBody() + buf.ReadFrom(b) + } else { + buf.ReadFrom(req.Body) + } + + b.Grow(buf.Len()) + b.WriteString(" -d \\\n'") + json.Indent(&b, buf.Bytes(), "", " ") + b.WriteString("'") + } + + b.WriteRune('\n') + + var status string + status = res.Status + + fmt.Fprintf(&b, "# => %s [%s] %s\n", start.UTC().Format(time.RFC3339), status, dur.Truncate(time.Millisecond)) + if l.ResponseBodyEnabled() && res != nil && res.Body != nil && res.Body != http.NoBody { + var buf bytes.Buffer + buf.ReadFrom(res.Body) + + b.Grow(buf.Len()) + b.WriteString("# ") + json.Indent(&b, buf.Bytes(), "# ", " ") + } + + b.WriteString("\n") + if l.ResponseBodyEnabled() && res != nil && res.Body != nil && res.Body != http.NoBody { + b.WriteString("\n") + } + + b.WriteTo(l.Output) + + return nil +} + +// RequestBodyEnabled returns true when the request body should be logged. +func (l *CurlLogger) RequestBodyEnabled() bool { return l.EnableRequestBody } + +// ResponseBodyEnabled returns true when the response body should be logged. +func (l *CurlLogger) ResponseBodyEnabled() bool { return l.EnableResponseBody } + +// LogRoundTrip prints the information about request and response. +// +func (l *JSONLogger) LogRoundTrip(req *http.Request, res *http.Response, err error, start time.Time, dur time.Duration) error { + // https://github.com/elastic/ecs/blob/master/schemas/http.yml + // + // TODO(karmi): Research performance optimization of using sync.Pool + + bsize := 200 + var b = bytes.NewBuffer(make([]byte, 0, bsize)) + var v = make([]byte, 0, bsize) + + appendTime := func(t time.Time) { + v = v[:0] + v = t.AppendFormat(v, time.RFC3339) + b.Write(v) + } + + appendQuote := func(s string) { + v = v[:0] + v = strconv.AppendQuote(v, s) + b.Write(v) + } + + appendInt := func(i int64) { + v = v[:0] + v = strconv.AppendInt(v, i, 10) + b.Write(v) + } + + port := req.URL.Port() + + b.WriteRune('{') + // -- Timestamp + b.WriteString(`"@timestamp":"`) + appendTime(start.UTC()) + b.WriteRune('"') + // -- Event + b.WriteString(`,"event":{`) + b.WriteString(`"duration":`) + appendInt(dur.Nanoseconds()) + b.WriteRune('}') + // -- URL + b.WriteString(`,"url":{`) + b.WriteString(`"scheme":`) + appendQuote(req.URL.Scheme) + b.WriteString(`,"domain":`) + appendQuote(req.URL.Hostname()) + if port != "" { + b.WriteString(`,"port":`) + b.WriteString(port) + } + b.WriteString(`,"path":`) + appendQuote(req.URL.Path) + b.WriteString(`,"query":`) + appendQuote(req.URL.RawQuery) + b.WriteRune('}') // Close "url" + // -- HTTP + b.WriteString(`,"http":`) + // ---- Request + b.WriteString(`{"request":{`) + b.WriteString(`"method":`) + appendQuote(req.Method) + if l.RequestBodyEnabled() && req != nil && req.Body != nil && req.Body != http.NoBody { + var buf bytes.Buffer + if req.GetBody != nil { + b, _ := req.GetBody() + buf.ReadFrom(b) + } else { + buf.ReadFrom(req.Body) + } + + b.Grow(buf.Len() + 8) + b.WriteString(`,"body":`) + appendQuote(buf.String()) + } + b.WriteRune('}') // Close "http.request" + // ---- Response + b.WriteString(`,"response":{`) + b.WriteString(`"status_code":`) + appendInt(int64(resStatusCode(res))) + if l.ResponseBodyEnabled() && res != nil && res.Body != nil && res.Body != http.NoBody { + defer res.Body.Close() + var buf bytes.Buffer + buf.ReadFrom(res.Body) + + b.Grow(buf.Len() + 8) + b.WriteString(`,"body":`) + appendQuote(buf.String()) + } + b.WriteRune('}') // Close "http.response" + b.WriteRune('}') // Close "http" + // -- Error + if err != nil { + b.WriteString(`,"error":{"message":`) + appendQuote(err.Error()) + b.WriteRune('}') // Close "error" + } + b.WriteRune('}') + b.WriteRune('\n') + b.WriteTo(l.Output) + + return nil +} + +// RequestBodyEnabled returns true when the request body should be logged. +func (l *JSONLogger) RequestBodyEnabled() bool { return l.EnableRequestBody } + +// ResponseBodyEnabled returns true when the response body should be logged. +func (l *JSONLogger) ResponseBodyEnabled() bool { return l.EnableResponseBody } + +// Log prints the arguments to output in default format. +// +func (l *debuggingLogger) Log(a ...interface{}) error { + _, err := fmt.Fprint(l.Output, a...) + return err +} + +// Logf prints formats the arguments and prints them to output. +// +func (l *debuggingLogger) Logf(format string, a ...interface{}) error { + _, err := fmt.Fprintf(l.Output, format, a...) + return err +} + +func logBodyAsText(dst io.Writer, body io.Reader, prefix string) { + scanner := bufio.NewScanner(body) + for scanner.Scan() { + s := scanner.Text() + if s != "" { + fmt.Fprintf(dst, "%s %s\n", prefix, s) + } + } +} + +func duplicateBody(body io.ReadCloser) (io.ReadCloser, io.ReadCloser, error) { + var ( + b1 bytes.Buffer + b2 bytes.Buffer + tr = io.TeeReader(body, &b2) + ) + _, err := b1.ReadFrom(tr) + if err != nil { + return ioutil.NopCloser(io.MultiReader(&b1, errorReader{err: err})), ioutil.NopCloser(io.MultiReader(&b2, errorReader{err: err})), err + } + defer func() { body.Close() }() + + return ioutil.NopCloser(&b1), ioutil.NopCloser(&b2), nil +} + +func resStatusCode(res *http.Response) int { + if res == nil { + return -1 + } + return res.StatusCode +} + +type errorReader struct{ err error } + +func (r errorReader) Read(p []byte) (int, error) { return 0, r.err } diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/estransport/metaheader.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/estransport/metaheader.go new file mode 100644 index 00000000..190c5a0f --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/estransport/metaheader.go @@ -0,0 +1,81 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package estransport + +import ( + "regexp" + "runtime" + "strings" +) + +// HeaderClientMeta Key for the HTTP Header related to telemetry data sent with +// each request to Elasticsearch. +const HeaderClientMeta = "x-elastic-client-meta" + +var metaReVersion = regexp.MustCompile("([0-9.]+)(.*)") + +func initMetaHeader() string { + var b strings.Builder + var strippedGoVersion string + var strippedEsVersion string + + strippedEsVersion = buildStrippedVersion(Version) + strippedGoVersion = buildStrippedVersion(runtime.Version()) + + var duos = [][]string{ + { + "es", + strippedEsVersion, + }, + { + "go", + strippedGoVersion, + }, + { + "t", + strippedEsVersion, + }, + { + "hc", + strippedGoVersion, + }, + } + + var arr []string + for _, duo := range duos { + arr = append(arr, strings.Join(duo, "=")) + } + b.WriteString(strings.Join(arr, ",")) + + return b.String() +} + +func buildStrippedVersion(version string) string { + v := metaReVersion.FindStringSubmatch(version) + + if len(v) == 3 && !strings.Contains(version, "devel") { + switch { + case v[2] != "": + return v[1] + "p" + default: + return v[1] + } + } + + return "0.0p" +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/estransport/metrics.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/estransport/metrics.go new file mode 100644 index 00000000..a25b1a6d --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/estransport/metrics.go @@ -0,0 +1,198 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package estransport + +import ( + "errors" + "fmt" + "strconv" + "strings" + "sync" + "time" +) + +// Measurable defines the interface for transports supporting metrics. +// +type Measurable interface { + Metrics() (Metrics, error) +} + +// connectionable defines the interface for transports returning a list of connections. +// +type connectionable interface { + connections() []*Connection +} + +// Metrics represents the transport metrics. +// +type Metrics struct { + Requests int `json:"requests"` + Failures int `json:"failures"` + Responses map[int]int `json:"responses"` + + Connections []fmt.Stringer `json:"connections"` +} + +// ConnectionMetric represents metric information for a connection. +// +type ConnectionMetric struct { + URL string `json:"url"` + Failures int `json:"failures,omitempty"` + IsDead bool `json:"dead,omitempty"` + DeadSince *time.Time `json:"dead_since,omitempty"` + + Meta struct { + ID string `json:"id"` + Name string `json:"name"` + Roles []string `json:"roles"` + } `json:"meta"` +} + +// metrics represents the inner state of metrics. +// +type metrics struct { + sync.RWMutex + + requests int + failures int + responses map[int]int + + connections []*Connection +} + +// Metrics returns the transport metrics. +// +func (c *Client) Metrics() (Metrics, error) { + if c.metrics == nil { + return Metrics{}, errors.New("transport metrics not enabled") + } + c.metrics.RLock() + defer c.metrics.RUnlock() + + if lockable, ok := c.pool.(sync.Locker); ok { + lockable.Lock() + defer lockable.Unlock() + } + + m := Metrics{ + Requests: c.metrics.requests, + Failures: c.metrics.failures, + Responses: make(map[int]int, len(c.metrics.responses)), + } + + for code, num := range c.metrics.responses { + m.Responses[code] = num + } + + if pool, ok := c.pool.(connectionable); ok { + for _, c := range pool.connections() { + c.Lock() + + cm := ConnectionMetric{ + URL: c.URL.String(), + IsDead: c.IsDead, + Failures: c.Failures, + } + + if !c.DeadSince.IsZero() { + cm.DeadSince = &c.DeadSince + } + + if c.ID != "" { + cm.Meta.ID = c.ID + } + + if c.Name != "" { + cm.Meta.Name = c.Name + } + + if len(c.Roles) > 0 { + cm.Meta.Roles = c.Roles + } + + m.Connections = append(m.Connections, cm) + c.Unlock() + } + } + + return m, nil +} + +// String returns the metrics as a string. +// +func (m Metrics) String() string { + var ( + i int + b strings.Builder + ) + b.WriteString("{") + + b.WriteString("Requests:") + b.WriteString(strconv.Itoa(m.Requests)) + + b.WriteString(" Failures:") + b.WriteString(strconv.Itoa(m.Failures)) + + if len(m.Responses) > 0 { + b.WriteString(" Responses: ") + b.WriteString("[") + + for code, num := range m.Responses { + b.WriteString(strconv.Itoa(code)) + b.WriteString(":") + b.WriteString(strconv.Itoa(num)) + if i+1 < len(m.Responses) { + b.WriteString(", ") + } + i++ + } + b.WriteString("]") + } + + b.WriteString(" Connections: [") + for i, c := range m.Connections { + b.WriteString(c.String()) + if i+1 < len(m.Connections) { + b.WriteString(", ") + } + i++ + } + b.WriteString("]") + + b.WriteString("}") + return b.String() +} + +// String returns the connection information as a string. +// +func (cm ConnectionMetric) String() string { + var b strings.Builder + b.WriteString("{") + b.WriteString(cm.URL) + if cm.IsDead { + fmt.Fprintf(&b, " dead=%v", cm.IsDead) + } + if cm.Failures > 0 { + fmt.Fprintf(&b, " failures=%d", cm.Failures) + } + if cm.DeadSince != nil { + fmt.Fprintf(&b, " dead_since=%s", cm.DeadSince.Local().Format(time.Stamp)) + } + b.WriteString("}") + return b.String() +} diff --git a/elk/vendor/github.com/elastic/go-elasticsearch/v7/internal/version/version.go b/elk/vendor/github.com/elastic/go-elasticsearch/v7/internal/version/version.go new file mode 100644 index 00000000..7b3b9539 --- /dev/null +++ b/elk/vendor/github.com/elastic/go-elasticsearch/v7/internal/version/version.go @@ -0,0 +1,21 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package version + +// Client returns the client version as a string. +const Client = "7.17.10" diff --git a/elk/vendor/modules.txt b/elk/vendor/modules.txt index 6ffb6e30..0c99b06e 100644 --- a/elk/vendor/modules.txt +++ b/elk/vendor/modules.txt @@ -60,6 +60,12 @@ github.com/elastic/elastic-agent-libs/transport/tlscommon github.com/elastic/elastic-agent-libs/upgrade/details github.com/elastic/elastic-agent-libs/useragent github.com/elastic/elastic-agent-libs/version +# github.com/elastic/go-elasticsearch/v7 v7.17.10 +## explicit; go 1.11 +github.com/elastic/go-elasticsearch/v7 +github.com/elastic/go-elasticsearch/v7/esapi +github.com/elastic/go-elasticsearch/v7/estransport +github.com/elastic/go-elasticsearch/v7/internal/version # github.com/elastic/go-licenser v0.4.0 ## explicit; go 1.13 github.com/elastic/go-licenser -- Gitee