From aa55eea4411905d3de872b7df459c3f1a221ad30 Mon Sep 17 00:00:00 2001 From: Vincent Ni Date: Tue, 28 Feb 2023 11:06:25 -0800 Subject: [PATCH 2/3] generate swagger models and restapis --- src/server/v2.0/models/access.go | 49 + src/server/v2.0/models/accessory.go | 89 + src/server/v2.0/models/action_request.go | 103 + src/server/v2.0/models/addition_link.go | 46 + src/server/v2.0/models/addition_links.go | 40 + src/server/v2.0/models/annotations.go | 20 + src/server/v2.0/models/artifact.go | 338 + src/server/v2.0/models/audit_log.go | 83 + src/server/v2.0/models/authproxy_setting.go | 55 + src/server/v2.0/models/bool_config_item.go | 46 + src/server/v2.0/models/chart_metadata.go | 164 + src/server/v2.0/models/chart_version.go | 188 + .../v2.0/models/component_health_status.go | 49 + src/server/v2.0/models/configurations.go | 193 + .../v2.0/models/configurations_response.go | 1390 + src/server/v2.0/models/cve_allowlist.go | 132 + src/server/v2.0/models/cve_allowlist_item.go | 43 + src/server/v2.0/models/error.go | 46 + src/server/v2.0/models/errors.go | 80 + src/server/v2.0/models/event_type.go | 20 + src/server/v2.0/models/exec_history.go | 132 + src/server/v2.0/models/execution.go | 118 + src/server/v2.0/models/extra_attrs.go | 20 + src/server/v2.0/models/filter_style.go | 49 + src/server/v2.0/models/gc_history.go | 132 + src/server/v2.0/models/general_info.go | 129 + src/server/v2.0/models/icon.go | 46 + src/server/v2.0/models/immutable_rule.go | 134 + src/server/v2.0/models/immutable_selector.go | 52 + src/server/v2.0/models/instance.go | 76 + src/server/v2.0/models/integer_config_item.go | 46 + .../models/internal_configuration_value.go | 46 + .../internal_configurations_response.go | 40 + src/server/v2.0/models/is_default.go | 43 + src/server/v2.0/models/job_queue.go | 52 + src/server/v2.0/models/label.go | 107 + src/server/v2.0/models/ldap_conf.go | 67 + .../v2.0/models/ldap_failed_import_user.go | 46 + src/server/v2.0/models/ldap_import_users.go | 43 + src/server/v2.0/models/ldap_ping_result.go | 46 + src/server/v2.0/models/ldap_user.go | 49 + src/server/v2.0/models/metadata.go | 58 + src/server/v2.0/models/metrics.go | 61 + .../v2.0/models/native_report_summary.go | 154 + src/server/v2.0/models/notify_type.go | 20 + src/server/v2.0/models/oidc_cli_secret_req.go | 43 + src/server/v2.0/models/oidc_user_info.go | 101 + .../v2.0/models/overall_health_status.go | 83 + src/server/v2.0/models/password_req.go | 46 + src/server/v2.0/models/permission.go | 46 + src/server/v2.0/models/platform.go | 55 + src/server/v2.0/models/preheat_policy.go | 116 + src/server/v2.0/models/project.go | 172 + src/server/v2.0/models/project_deletable.go | 46 + src/server/v2.0/models/project_member.go | 99 + .../v2.0/models/project_member_entity.go | 61 + src/server/v2.0/models/project_metadata.go | 64 + src/server/v2.0/models/project_req.go | 127 + src/server/v2.0/models/project_scanner.go | 64 + src/server/v2.0/models/project_summary.go | 117 + .../v2.0/models/project_summary_quota.go | 92 + .../v2.0/models/provider_under_project.go | 52 + src/server/v2.0/models/quota.go | 141 + src/server/v2.0/models/quota_ref_object.go | 11 + src/server/v2.0/models/quota_update_req.go | 69 + src/server/v2.0/models/reference.go | 106 + src/server/v2.0/models/registry.go | 135 + src/server/v2.0/models/registry_credential.go | 49 + src/server/v2.0/models/registry_endpoint.go | 46 + src/server/v2.0/models/registry_info.go | 92 + src/server/v2.0/models/registry_ping.go | 61 + .../registry_provider_credential_pattern.go | 52 + .../registry_provider_endpoint_pattern.go | 83 + .../v2.0/models/registry_provider_info.go | 96 + src/server/v2.0/models/registry_update.go | 61 + .../v2.0/models/replication_execution.go | 119 + src/server/v2.0/models/replication_filter.go | 49 + src/server/v2.0/models/replication_policy.go | 232 + src/server/v2.0/models/replication_task.go | 113 + src/server/v2.0/models/replication_trigger.go | 74 + .../models/replication_trigger_settings.go | 43 + src/server/v2.0/models/repository.go | 107 + src/server/v2.0/models/resource_list.go | 20 + src/server/v2.0/models/retention_execution.go | 61 + .../v2.0/models/retention_execution_task.go | 73 + src/server/v2.0/models/retention_metadata.go | 144 + src/server/v2.0/models/retention_policy.go | 136 + .../v2.0/models/retention_policy_scope.go | 46 + src/server/v2.0/models/retention_rule.go | 134 + .../v2.0/models/retention_rule_metadata.go | 89 + .../models/retention_rule_param_metadata.go | 49 + .../v2.0/models/retention_rule_trigger.go | 49 + src/server/v2.0/models/retention_selector.go | 52 + .../models/retention_selector_metadata.go | 49 + src/server/v2.0/models/robot.go | 150 + src/server/v2.0/models/robot_create.go | 98 + src/server/v2.0/models/robot_create_v1.go | 89 + src/server/v2.0/models/robot_created.go | 80 + src/server/v2.0/models/robot_permission.go | 86 + src/server/v2.0/models/robot_sec.go | 43 + src/server/v2.0/models/role_request.go | 43 + .../v2.0/models/scan_data_export_execution.go | 110 + .../models/scan_data_export_execution_list.go | 80 + .../v2.0/models/scan_data_export_job.go | 43 + .../v2.0/models/scan_data_export_request.go | 58 + src/server/v2.0/models/scan_overview.go | 40 + src/server/v2.0/models/scanner.go | 49 + .../v2.0/models/scanner_adapter_metadata.go | 108 + src/server/v2.0/models/scanner_capability.go | 46 + .../v2.0/models/scanner_registration.go | 135 + .../v2.0/models/scanner_registration_req.go | 107 + .../models/scanner_registration_settings.go | 95 + src/server/v2.0/models/schedule.go | 127 + src/server/v2.0/models/schedule_obj.go | 138 + src/server/v2.0/models/schedule_task.go | 80 + src/server/v2.0/models/scheduler_status.go | 43 + src/server/v2.0/models/search.go | 144 + src/server/v2.0/models/search_repository.go | 58 + src/server/v2.0/models/search_result.go | 77 + .../models/start_replication_execution.go | 43 + src/server/v2.0/models/statistic.go | 61 + src/server/v2.0/models/stats.go | 115 + src/server/v2.0/models/storage.go | 46 + src/server/v2.0/models/string_config_item.go | 46 + .../models/supported_webhook_event_types.go | 102 + src/server/v2.0/models/system_info.go | 80 + src/server/v2.0/models/tag.go | 107 + src/server/v2.0/models/task.go | 96 + src/server/v2.0/models/user_creation_req.go | 98 + src/server/v2.0/models/user_entity.go | 46 + src/server/v2.0/models/user_group.go | 52 + .../v2.0/models/user_group_search_item.go | 49 + src/server/v2.0/models/user_profile.go | 49 + src/server/v2.0/models/user_resp.go | 135 + src/server/v2.0/models/user_search.go | 46 + .../v2.0/models/user_search_resp_item.go | 46 + src/server/v2.0/models/user_sys_admin_flag.go | 43 + .../v2.0/models/vulnerability_summary.go | 50 + src/server/v2.0/models/webhook_job.go | 107 + .../v2.0/models/webhook_last_trigger.go | 98 + src/server/v2.0/models/webhook_policy.go | 144 + .../v2.0/models/webhook_target_object.go | 52 + src/server/v2.0/models/worker.go | 104 + src/server/v2.0/models/worker_pool.go | 101 + src/server/v2.0/restapi/configure_harbor.go | 3637 ++ src/server/v2.0/restapi/doc.go | 23 + src/server/v2.0/restapi/embedded_spec.go | 37979 ++++++++++++++++ .../restapi/operations/artifact/add_label.go | 73 + .../artifact/add_label_parameters.go | 195 + .../artifact/add_label_responses.go | 456 + .../artifact/add_label_urlbuilder.go | 115 + .../operations/artifact/copy_artifact.go | 73 + .../artifact/copy_artifact_parameters.go | 173 + .../artifact/copy_artifact_responses.go | 478 + .../artifact/copy_artifact_urlbuilder.go | 118 + .../restapi/operations/artifact/create_tag.go | 73 + .../artifact/create_tag_parameters.go | 195 + .../artifact/create_tag_responses.go | 544 + .../artifact/create_tag_urlbuilder.go | 115 + .../operations/artifact/delete_artifact.go | 73 + .../artifact/delete_artifact_parameters.go | 164 + .../artifact/delete_artifact_responses.go | 324 + .../artifact/delete_artifact_urlbuilder.go | 115 + .../restapi/operations/artifact/delete_tag.go | 73 + .../artifact/delete_tag_parameters.go | 189 + .../artifact/delete_tag_responses.go | 324 + .../artifact/delete_tag_urlbuilder.go | 123 + .../operations/artifact/get_addition.go | 73 + .../artifact/get_addition_parameters.go | 203 + .../artifact/get_addition_responses.go | 408 + .../artifact/get_addition_urlbuilder.go | 123 + .../operations/artifact/get_artifact.go | 73 + .../artifact/get_artifact_parameters.go | 510 + .../artifact/get_artifact_responses.go | 388 + .../artifact/get_artifact_urlbuilder.go | 194 + .../artifact/get_vulnerabilities_addition.go | 73 + ...get_vulnerabilities_addition_parameters.go | 201 + .../get_vulnerabilities_addition_responses.go | 408 + ...get_vulnerabilities_addition_urlbuilder.go | 115 + .../operations/artifact/list_accessories.go | 73 + .../artifact/list_accessories_parameters.go | 314 + .../artifact/list_accessories_responses.go | 436 + .../artifact/list_accessories_urlbuilder.go | 158 + .../operations/artifact/list_artifacts.go | 73 + .../artifact/list_artifacts_parameters.go | 539 + .../artifact/list_artifacts_responses.go | 436 + .../artifact/list_artifacts_urlbuilder.go | 204 + .../restapi/operations/artifact/list_tags.go | 73 + .../artifact/list_tags_parameters.go | 387 + .../artifact/list_tags_responses.go | 436 + .../artifact/list_tags_urlbuilder.go | 176 + .../operations/artifact/remove_label.go | 73 + .../artifact/remove_label_parameters.go | 194 + .../artifact/remove_label_responses.go | 390 + .../artifact/remove_label_urlbuilder.go | 125 + .../operations/auditlog/list_audit_logs.go | 74 + .../auditlog/list_audit_logs_parameters.go | 239 + .../auditlog/list_audit_logs_responses.go | 304 + .../auditlog/list_audit_logs_urlbuilder.go | 132 + .../configure/get_configurations.go | 74 + .../get_configurations_parameters.go | 89 + .../configure/get_configurations_responses.go | 130 + .../get_configurations_urlbuilder.go | 87 + .../configure/get_internalconfig.go | 74 + .../get_internalconfig_parameters.go | 89 + .../configure/get_internalconfig_responses.go | 133 + .../get_internalconfig_urlbuilder.go | 87 + .../configure/update_configurations.go | 74 + .../update_configurations_parameters.go | 120 + .../update_configurations_responses.go | 108 + .../update_configurations_urlbuilder.go | 87 + .../operations/gc/create_gc_schedule.go | 74 + .../gc/create_gc_schedule_parameters.go | 120 + .../gc/create_gc_schedule_responses.go | 412 + .../gc/create_gc_schedule_urlbuilder.go | 87 + .../v2.0/restapi/operations/gc/get_gc.go | 73 + .../restapi/operations/gc/get_gc_history.go | 73 + .../gc/get_gc_history_parameters.go | 239 + .../operations/gc/get_gc_history_responses.go | 304 + .../gc/get_gc_history_urlbuilder.go | 132 + .../v2.0/restapi/operations/gc/get_gc_log.go | 73 + .../operations/gc/get_gc_log_parameters.go | 119 + .../operations/gc/get_gc_log_responses.go | 386 + .../operations/gc/get_gc_log_urlbuilder.go | 101 + .../operations/gc/get_gc_parameters.go | 119 + .../restapi/operations/gc/get_gc_responses.go | 322 + .../restapi/operations/gc/get_gc_schedule.go | 73 + .../gc/get_gc_schedule_parameters.go | 89 + .../gc/get_gc_schedule_responses.go | 256 + .../gc/get_gc_schedule_urlbuilder.go | 87 + .../operations/gc/get_gc_urlbuilder.go | 101 + .../v2.0/restapi/operations/gc/stop_gc.go | 73 + .../operations/gc/stop_gc_parameters.go | 119 + .../operations/gc/stop_gc_responses.go | 324 + .../operations/gc/stop_gc_urlbuilder.go | 101 + .../operations/gc/update_gc_schedule.go | 74 + .../gc/update_gc_schedule_parameters.go | 120 + .../gc/update_gc_schedule_responses.go | 302 + .../gc/update_gc_schedule_urlbuilder.go | 87 + .../v2.0/restapi/operations/harbor_api.go | 2768 ++ .../restapi/operations/health/get_health.go | 73 + .../health/get_health_parameters.go | 89 + .../operations/health/get_health_responses.go | 124 + .../health/get_health_urlbuilder.go | 87 + .../v2.0/restapi/operations/icon/get_icon.go | 73 + .../operations/icon/get_icon_parameters.go | 114 + .../operations/icon/get_icon_responses.go | 256 + .../operations/icon/get_icon_urlbuilder.go | 99 + .../operations/immutable/create_immu_rule.go | 74 + .../immutable/create_immu_rule_parameters.go | 186 + .../immutable/create_immu_rule_responses.go | 412 + .../immutable/create_immu_rule_urlbuilder.go | 99 + .../operations/immutable/delete_immu_rule.go | 71 + .../immutable/delete_immu_rule_parameters.go | 184 + .../immutable/delete_immu_rule_responses.go | 324 + .../immutable/delete_immu_rule_urlbuilder.go | 109 + .../operations/immutable/list_immu_rules.go | 74 + .../immutable/list_immu_rules_parameters.go | 300 + .../immutable/list_immu_rules_responses.go | 370 + .../immutable/list_immu_rules_urlbuilder.go | 142 + .../operations/immutable/update_immu_rule.go | 71 + .../immutable/update_immu_rule_parameters.go | 215 + .../immutable/update_immu_rule_responses.go | 324 + .../immutable/update_immu_rule_urlbuilder.go | 109 + .../jobservice/action_pending_jobs.go | 73 + .../action_pending_jobs_parameters.go | 145 + .../action_pending_jobs_responses.go | 302 + .../action_pending_jobs_urlbuilder.go | 99 + .../operations/jobservice/get_worker_pools.go | 73 + .../jobservice/get_worker_pools_parameters.go | 89 + .../jobservice/get_worker_pools_responses.go | 259 + .../jobservice/get_worker_pools_urlbuilder.go | 87 + .../operations/jobservice/get_workers.go | 73 + .../jobservice/get_workers_parameters.go | 114 + .../jobservice/get_workers_responses.go | 325 + .../jobservice/get_workers_urlbuilder.go | 99 + .../operations/jobservice/list_job_queues.go | 73 + .../jobservice/list_job_queues_parameters.go | 89 + .../jobservice/list_job_queues_responses.go | 325 + .../jobservice/list_job_queues_urlbuilder.go | 87 + .../operations/jobservice/stop_running_job.go | 73 + .../jobservice/stop_running_job_parameters.go | 114 + .../jobservice/stop_running_job_responses.go | 302 + .../jobservice/stop_running_job_urlbuilder.go | 99 + .../restapi/operations/label/create_label.go | 74 + .../label/create_label_parameters.go | 120 + .../label/create_label_responses.go | 390 + .../label/create_label_urlbuilder.go | 87 + .../restapi/operations/label/delete_label.go | 74 + .../label/delete_label_parameters.go | 119 + .../label/delete_label_responses.go | 324 + .../label/delete_label_urlbuilder.go | 101 + .../operations/label/get_label_by_id.go | 74 + .../label/get_label_by_id_parameters.go | 119 + .../label/get_label_by_id_responses.go | 256 + .../label/get_label_by_id_urlbuilder.go | 101 + .../restapi/operations/label/list_labels.go | 74 + .../label/list_labels_parameters.go | 324 + .../operations/label/list_labels_responses.go | 304 + .../label/list_labels_urlbuilder.go | 159 + .../restapi/operations/label/update_label.go | 74 + .../label/update_label_parameters.go | 150 + .../label/update_label_responses.go | 390 + .../label/update_label_urlbuilder.go | 101 + .../operations/ldap/import_ldap_user.go | 74 + .../ldap/import_ldap_user_parameters.go | 120 + .../ldap/import_ldap_user_responses.go | 349 + .../ldap/import_ldap_user_urlbuilder.go | 87 + .../v2.0/restapi/operations/ldap/ping_ldap.go | 74 + .../operations/ldap/ping_ldap_parameters.go | 112 + .../operations/ldap/ping_ldap_responses.go | 322 + .../operations/ldap/ping_ldap_urlbuilder.go | 87 + .../operations/ldap/search_ldap_group.go | 74 + .../ldap/search_ldap_group_parameters.go | 146 + .../ldap/search_ldap_group_responses.go | 325 + .../ldap/search_ldap_group_urlbuilder.go | 112 + .../operations/ldap/search_ldap_user.go | 74 + .../ldap/search_ldap_user_parameters.go | 119 + .../ldap/search_ldap_user_responses.go | 325 + .../ldap/search_ldap_user_urlbuilder.go | 103 + .../member/create_project_member.go | 73 + .../create_project_member_parameters.go | 178 + .../member/create_project_member_responses.go | 390 + .../create_project_member_urlbuilder.go | 99 + .../member/delete_project_member.go | 71 + .../delete_project_member_parameters.go | 184 + .../member/delete_project_member_responses.go | 324 + .../delete_project_member_urlbuilder.go | 109 + .../operations/member/get_project_member.go | 73 + .../member/get_project_member_parameters.go | 184 + .../member/get_project_member_responses.go | 388 + .../member/get_project_member_urlbuilder.go | 109 + .../operations/member/list_project_members.go | 73 + .../member/list_project_members_parameters.go | 273 + .../member/list_project_members_responses.go | 436 + .../member/list_project_members_urlbuilder.go | 133 + .../member/update_project_member.go | 73 + .../update_project_member_parameters.go | 207 + .../member/update_project_member_responses.go | 390 + .../update_project_member_urlbuilder.go | 109 + .../v2.0/restapi/operations/oidc/ping_oidc.go | 111 + .../operations/oidc/ping_oidc_parameters.go | 118 + .../operations/oidc/ping_oidc_responses.go | 258 + .../operations/oidc/ping_oidc_urlbuilder.go | 87 + .../v2.0/restapi/operations/ping/get_ping.go | 73 + .../operations/ping/get_ping_parameters.go | 89 + .../operations/ping/get_ping_responses.go | 54 + .../operations/ping/get_ping_urlbuilder.go | 87 + .../operations/preheat/create_instance.go | 73 + .../preheat/create_instance_parameters.go | 120 + .../preheat/create_instance_responses.go | 478 + .../preheat/create_instance_urlbuilder.go | 87 + .../operations/preheat/create_policy.go | 73 + .../preheat/create_policy_parameters.go | 145 + .../preheat/create_policy_responses.go | 412 + .../preheat/create_policy_urlbuilder.go | 99 + .../operations/preheat/delete_instance.go | 73 + .../preheat/delete_instance_parameters.go | 114 + .../preheat/delete_instance_responses.go | 324 + .../preheat/delete_instance_urlbuilder.go | 99 + .../operations/preheat/delete_policy.go | 73 + .../preheat/delete_policy_parameters.go | 139 + .../preheat/delete_policy_responses.go | 390 + .../preheat/delete_policy_urlbuilder.go | 107 + .../operations/preheat/get_execution.go | 73 + .../preheat/get_execution_parameters.go | 169 + .../preheat/get_execution_responses.go | 388 + .../preheat/get_execution_urlbuilder.go | 117 + .../operations/preheat/get_instance.go | 73 + .../preheat/get_instance_parameters.go | 114 + .../preheat/get_instance_responses.go | 388 + .../preheat/get_instance_urlbuilder.go | 99 + .../restapi/operations/preheat/get_policy.go | 73 + .../preheat/get_policy_parameters.go | 139 + .../preheat/get_policy_responses.go | 388 + .../preheat/get_policy_urlbuilder.go | 107 + .../operations/preheat/get_preheat_log.go | 73 + .../preheat/get_preheat_log_parameters.go | 198 + .../preheat/get_preheat_log_responses.go | 408 + .../preheat/get_preheat_log_urlbuilder.go | 125 + .../operations/preheat/list_executions.go | 73 + .../preheat/list_executions_parameters.go | 289 + .../preheat/list_executions_responses.go | 436 + .../preheat/list_executions_urlbuilder.go | 150 + .../operations/preheat/list_instances.go | 73 + .../preheat/list_instances_parameters.go | 239 + .../preheat/list_instances_responses.go | 436 + .../preheat/list_instances_urlbuilder.go | 132 + .../operations/preheat/list_policies.go | 73 + .../preheat/list_policies_parameters.go | 264 + .../preheat/list_policies_responses.go | 370 + .../preheat/list_policies_urlbuilder.go | 142 + .../operations/preheat/list_providers.go | 73 + .../preheat/list_providers_parameters.go | 89 + .../preheat/list_providers_responses.go | 391 + .../preheat/list_providers_under_project.go | 73 + ...list_providers_under_project_parameters.go | 114 + .../list_providers_under_project_responses.go | 391 + ...list_providers_under_project_urlbuilder.go | 99 + .../preheat/list_providers_urlbuilder.go | 87 + .../restapi/operations/preheat/list_tasks.go | 73 + .../preheat/list_tasks_parameters.go | 318 + .../preheat/list_tasks_responses.go | 436 + .../preheat/list_tasks_urlbuilder.go | 158 + .../operations/preheat/manual_preheat.go | 73 + .../preheat/manual_preheat_parameters.go | 170 + .../preheat/manual_preheat_responses.go | 412 + .../preheat/manual_preheat_urlbuilder.go | 107 + .../operations/preheat/ping_instances.go | 74 + .../preheat/ping_instances_parameters.go | 120 + .../preheat/ping_instances_responses.go | 282 + .../preheat/ping_instances_urlbuilder.go | 87 + .../operations/preheat/stop_execution.go | 73 + .../preheat/stop_execution_parameters.go | 200 + .../preheat/stop_execution_responses.go | 390 + .../preheat/stop_execution_urlbuilder.go | 117 + .../operations/preheat/update_instance.go | 73 + .../preheat/update_instance_parameters.go | 145 + .../preheat/update_instance_responses.go | 390 + .../preheat/update_instance_urlbuilder.go | 99 + .../operations/preheat/update_policy.go | 73 + .../preheat/update_policy_parameters.go | 170 + .../preheat/update_policy_responses.go | 456 + .../preheat/update_policy_urlbuilder.go | 107 + .../operations/project/create_project.go | 73 + .../project/create_project_parameters.go | 161 + .../project/create_project_responses.go | 346 + .../project/create_project_urlbuilder.go | 87 + .../operations/project/delete_project.go | 73 + .../project/delete_project_parameters.go | 155 + .../project/delete_project_responses.go | 390 + .../project/delete_project_urlbuilder.go | 99 + .../restapi/operations/project/get_logs.go | 73 + .../operations/project/get_logs_parameters.go | 264 + .../operations/project/get_logs_responses.go | 304 + .../operations/project/get_logs_urlbuilder.go | 142 + .../restapi/operations/project/get_project.go | 73 + .../project/get_project_deletable.go | 73 + .../get_project_deletable_parameters.go | 155 + .../get_project_deletable_responses.go | 322 + .../get_project_deletable_urlbuilder.go | 99 + .../project/get_project_parameters.go | 155 + .../project/get_project_responses.go | 190 + .../operations/project/get_project_summary.go | 73 + .../project/get_project_summary_parameters.go | 155 + .../project/get_project_summary_responses.go | 388 + .../project/get_project_summary_urlbuilder.go | 99 + .../project/get_project_urlbuilder.go | 99 + .../project/get_scanner_of_project.go | 73 + .../get_scanner_of_project_parameters.go | 155 + .../get_scanner_of_project_responses.go | 178 + .../get_scanner_of_project_urlbuilder.go | 99 + .../operations/project/head_project.go | 73 + .../project/head_project_parameters.go | 123 + .../project/head_project_responses.go | 192 + .../project/head_project_urlbuilder.go | 100 + .../operations/project/list_projects.go | 73 + .../project/list_projects_parameters.go | 361 + .../project/list_projects_responses.go | 238 + .../project/list_projects_urlbuilder.go | 168 + .../list_scanner_candidates_of_project.go | 73 + ...canner_candidates_of_project_parameters.go | 300 + ...scanner_candidates_of_project_responses.go | 370 + ...canner_candidates_of_project_urlbuilder.go | 142 + .../project/set_scanner_of_project.go | 73 + .../set_scanner_of_project_parameters.go | 186 + .../set_scanner_of_project_responses.go | 390 + .../set_scanner_of_project_urlbuilder.go | 99 + .../operations/project/update_project.go | 73 + .../project/update_project_parameters.go | 186 + .../project/update_project_responses.go | 390 + .../project/update_project_urlbuilder.go | 99 + .../project_metadata/add_project_metadatas.go | 73 + .../add_project_metadatas_parameters.go | 170 + .../add_project_metadatas_responses.go | 456 + .../add_project_metadatas_urlbuilder.go | 99 + .../delete_project_metadata.go | 73 + .../delete_project_metadata_parameters.go | 180 + .../delete_project_metadata_responses.go | 456 + .../delete_project_metadata_urlbuilder.go | 107 + .../project_metadata/get_project_metadata.go | 73 + .../get_project_metadata_parameters.go | 180 + .../get_project_metadata_responses.go | 391 + .../get_project_metadata_urlbuilder.go | 107 + .../list_project_metadatas.go | 73 + .../list_project_metadatas_parameters.go | 155 + .../list_project_metadatas_responses.go | 391 + .../list_project_metadatas_urlbuilder.go | 99 + .../update_project_metadata.go | 73 + .../update_project_metadata_parameters.go | 195 + .../update_project_metadata_responses.go | 456 + .../update_project_metadata_urlbuilder.go | 107 + .../operations/purge/create_purge_schedule.go | 74 + .../purge/create_purge_schedule_parameters.go | 124 + .../purge/create_purge_schedule_responses.go | 346 + .../purge/create_purge_schedule_urlbuilder.go | 87 + .../operations/purge/get_purge_history.go | 73 + .../purge/get_purge_history_parameters.go | 239 + .../purge/get_purge_history_responses.go | 304 + .../purge/get_purge_history_urlbuilder.go | 132 + .../restapi/operations/purge/get_purge_job.go | 73 + .../operations/purge/get_purge_job_log.go | 73 + .../purge/get_purge_job_log_parameters.go | 119 + .../purge/get_purge_job_log_responses.go | 386 + .../purge/get_purge_job_log_urlbuilder.go | 101 + .../purge/get_purge_job_parameters.go | 119 + .../purge/get_purge_job_responses.go | 322 + .../purge/get_purge_job_urlbuilder.go | 101 + .../operations/purge/get_purge_schedule.go | 73 + .../purge/get_purge_schedule_parameters.go | 89 + .../purge/get_purge_schedule_responses.go | 256 + .../purge/get_purge_schedule_urlbuilder.go | 87 + .../restapi/operations/purge/stop_purge.go | 73 + .../operations/purge/stop_purge_parameters.go | 119 + .../operations/purge/stop_purge_responses.go | 324 + .../operations/purge/stop_purge_urlbuilder.go | 101 + .../operations/purge/update_purge_schedule.go | 74 + .../purge/update_purge_schedule_parameters.go | 124 + .../purge/update_purge_schedule_responses.go | 302 + .../purge/update_purge_schedule_urlbuilder.go | 87 + .../restapi/operations/quota/get_quota.go | 73 + .../operations/quota/get_quota_parameters.go | 119 + .../operations/quota/get_quota_responses.go | 322 + .../operations/quota/get_quota_urlbuilder.go | 101 + .../restapi/operations/quota/list_quotas.go | 73 + .../quota/list_quotas_parameters.go | 269 + .../operations/quota/list_quotas_responses.go | 304 + .../quota/list_quotas_urlbuilder.go | 141 + .../restapi/operations/quota/update_quota.go | 73 + .../quota/update_quota_parameters.go | 150 + .../quota/update_quota_responses.go | 390 + .../quota/update_quota_urlbuilder.go | 101 + .../operations/registry/create_registry.go | 73 + .../registry/create_registry_parameters.go | 120 + .../registry/create_registry_responses.go | 412 + .../registry/create_registry_urlbuilder.go | 87 + .../operations/registry/delete_registry.go | 73 + .../registry/delete_registry_parameters.go | 119 + .../registry/delete_registry_responses.go | 390 + .../registry/delete_registry_urlbuilder.go | 101 + .../operations/registry/get_registry.go | 73 + .../operations/registry/get_registry_info.go | 73 + .../registry/get_registry_info_parameters.go | 119 + .../registry/get_registry_info_responses.go | 322 + .../registry/get_registry_info_urlbuilder.go | 101 + .../registry/get_registry_parameters.go | 119 + .../registry/get_registry_responses.go | 322 + .../registry/get_registry_urlbuilder.go | 101 + .../operations/registry/list_registries.go | 73 + .../registry/list_registries_parameters.go | 266 + .../registry/list_registries_responses.go | 304 + .../registry/list_registries_urlbuilder.go | 141 + .../registry/list_registry_provider_infos.go | 73 + ...list_registry_provider_infos_parameters.go | 89 + .../list_registry_provider_infos_responses.go | 259 + ...list_registry_provider_infos_urlbuilder.go | 87 + .../registry/list_registry_provider_types.go | 73 + ...list_registry_provider_types_parameters.go | 89 + .../list_registry_provider_types_responses.go | 259 + ...list_registry_provider_types_urlbuilder.go | 87 + .../operations/registry/ping_registry.go | 73 + .../registry/ping_registry_parameters.go | 120 + .../registry/ping_registry_responses.go | 390 + .../registry/ping_registry_urlbuilder.go | 87 + .../operations/registry/update_registry.go | 73 + .../registry/update_registry_parameters.go | 150 + .../registry/update_registry_responses.go | 390 + .../registry/update_registry_urlbuilder.go | 101 + .../replication/create_replication_policy.go | 73 + .../create_replication_policy_parameters.go | 120 + .../create_replication_policy_responses.go | 412 + .../create_replication_policy_urlbuilder.go | 87 + .../replication/delete_replication_policy.go | 73 + .../delete_replication_policy_parameters.go | 119 + .../delete_replication_policy_responses.go | 390 + .../delete_replication_policy_urlbuilder.go | 101 + .../replication/get_replication_execution.go | 73 + .../get_replication_execution_parameters.go | 119 + .../get_replication_execution_responses.go | 322 + .../get_replication_execution_urlbuilder.go | 101 + .../replication/get_replication_log.go | 73 + .../get_replication_log_parameters.go | 148 + .../get_replication_log_responses.go | 342 + .../get_replication_log_urlbuilder.go | 109 + .../replication/get_replication_policy.go | 73 + .../get_replication_policy_parameters.go | 119 + .../get_replication_policy_responses.go | 256 + .../get_replication_policy_urlbuilder.go | 101 + .../list_replication_executions.go | 73 + .../list_replication_executions_parameters.go | 297 + .../list_replication_executions_responses.go | 304 + .../list_replication_executions_urlbuilder.go | 150 + .../replication/list_replication_policies.go | 73 + .../list_replication_policies_parameters.go | 266 + .../list_replication_policies_responses.go | 304 + .../list_replication_policies_urlbuilder.go | 141 + .../replication/list_replication_tasks.go | 73 + .../list_replication_tasks_parameters.go | 295 + .../list_replication_tasks_responses.go | 304 + .../list_replication_tasks_urlbuilder.go | 151 + .../replication/start_replication.go | 73 + .../start_replication_parameters.go | 120 + .../start_replication_responses.go | 346 + .../start_replication_urlbuilder.go | 87 + .../replication/stop_replication.go | 73 + .../stop_replication_parameters.go | 119 + .../replication/stop_replication_responses.go | 324 + .../stop_replication_urlbuilder.go | 101 + .../replication/update_replication_policy.go | 73 + .../update_replication_policy_parameters.go | 150 + .../update_replication_policy_responses.go | 390 + .../update_replication_policy_urlbuilder.go | 101 + .../repository/delete_repository.go | 73 + .../delete_repository_parameters.go | 139 + .../repository/delete_repository_responses.go | 390 + .../delete_repository_urlbuilder.go | 107 + .../operations/repository/get_repository.go | 73 + .../repository/get_repository_parameters.go | 139 + .../repository/get_repository_responses.go | 388 + .../repository/get_repository_urlbuilder.go | 107 + .../repository/list_all_repositories.go | 73 + .../list_all_repositories_parameters.go | 239 + .../list_all_repositories_responses.go | 238 + .../list_all_repositories_urlbuilder.go | 132 + .../repository/list_repositories.go | 73 + .../list_repositories_parameters.go | 264 + .../repository/list_repositories_responses.go | 436 + .../list_repositories_urlbuilder.go | 142 + .../repository/update_repository.go | 73 + .../update_repository_parameters.go | 170 + .../repository/update_repository_responses.go | 390 + .../update_repository_urlbuilder.go | 107 + .../operations/retention/create_retention.go | 73 + .../retention/create_retention_parameters.go | 120 + .../retention/create_retention_responses.go | 346 + .../retention/create_retention_urlbuilder.go | 87 + .../operations/retention/delete_retention.go | 73 + .../retention/delete_retention_parameters.go | 119 + .../retention/delete_retention_responses.go | 236 + .../retention/delete_retention_urlbuilder.go | 101 + .../retention/get_rentenition_metadata.go | 73 + .../get_rentenition_metadata_parameters.go | 89 + .../get_rentenition_metadata_responses.go | 58 + .../get_rentenition_metadata_urlbuilder.go | 87 + .../operations/retention/get_retention.go | 73 + .../retention/get_retention_parameters.go | 119 + .../retention/get_retention_responses.go | 256 + .../retention/get_retention_task_log.go | 73 + .../get_retention_task_log_parameters.go | 177 + .../get_retention_task_log_responses.go | 254 + .../get_retention_task_log_urlbuilder.go | 117 + .../retention/get_retention_urlbuilder.go | 101 + .../retention/list_retention_executions.go | 73 + .../list_retention_executions_parameters.go | 184 + .../list_retention_executions_responses.go | 304 + .../list_retention_executions_urlbuilder.go | 124 + .../retention/list_retention_tasks.go | 73 + .../list_retention_tasks_parameters.go | 213 + .../list_retention_tasks_responses.go | 304 + .../list_retention_tasks_urlbuilder.go | 132 + .../retention/operate_retention_execution.go | 107 + .../operate_retention_execution_parameters.go | 177 + .../operate_retention_execution_responses.go | 236 + .../operate_retention_execution_urlbuilder.go | 109 + .../retention/trigger_retention_execution.go | 107 + .../trigger_retention_execution_parameters.go | 148 + .../trigger_retention_execution_responses.go | 304 + .../trigger_retention_execution_urlbuilder.go | 101 + .../operations/retention/update_retention.go | 73 + .../retention/update_retention_parameters.go | 150 + .../retention/update_retention_responses.go | 236 + .../retention/update_retention_urlbuilder.go | 101 + .../restapi/operations/robot/create_robot.go | 73 + .../robot/create_robot_parameters.go | 120 + .../robot/create_robot_responses.go | 432 + .../robot/create_robot_urlbuilder.go | 87 + .../restapi/operations/robot/delete_robot.go | 73 + .../robot/delete_robot_parameters.go | 119 + .../robot/delete_robot_responses.go | 390 + .../robot/delete_robot_urlbuilder.go | 101 + .../operations/robot/get_robot_by_id.go | 73 + .../robot/get_robot_by_id_parameters.go | 119 + .../robot/get_robot_by_id_responses.go | 322 + .../robot/get_robot_by_id_urlbuilder.go | 101 + .../restapi/operations/robot/list_robot.go | 73 + .../operations/robot/list_robot_parameters.go | 239 + .../operations/robot/list_robot_responses.go | 304 + .../operations/robot/list_robot_urlbuilder.go | 132 + .../restapi/operations/robot/refresh_sec.go | 73 + .../robot/refresh_sec_parameters.go | 150 + .../operations/robot/refresh_sec_responses.go | 388 + .../robot/refresh_sec_urlbuilder.go | 101 + .../restapi/operations/robot/update_robot.go | 73 + .../robot/update_robot_parameters.go | 150 + .../robot/update_robot_responses.go | 456 + .../robot/update_robot_urlbuilder.go | 101 + .../operations/robotv1/create_robot_v1.go | 73 + .../robotv1/create_robot_v1_parameters.go | 186 + .../robotv1/create_robot_v1_responses.go | 432 + .../robotv1/create_robot_v1_urlbuilder.go | 99 + .../operations/robotv1/delete_robot_v1.go | 73 + .../robotv1/delete_robot_v1_parameters.go | 184 + .../robotv1/delete_robot_v1_responses.go | 390 + .../robotv1/delete_robot_v1_urlbuilder.go | 109 + .../operations/robotv1/get_robot_by_id_v1.go | 73 + .../robotv1/get_robot_by_id_v1_parameters.go | 184 + .../robotv1/get_robot_by_id_v1_responses.go | 322 + .../robotv1/get_robot_by_id_v1_urlbuilder.go | 109 + .../operations/robotv1/list_robot_v1.go | 73 + .../robotv1/list_robot_v1_parameters.go | 300 + .../robotv1/list_robot_v1_responses.go | 304 + .../robotv1/list_robot_v1_urlbuilder.go | 142 + .../operations/robotv1/update_robot_v1.go | 73 + .../robotv1/update_robot_v1_parameters.go | 215 + .../robotv1/update_robot_v1_responses.go | 456 + .../robotv1/update_robot_v1_urlbuilder.go | 109 + .../restapi/operations/scan/get_report_log.go | 73 + .../scan/get_report_log_parameters.go | 189 + .../scan/get_report_log_responses.go | 320 + .../scan/get_report_log_urlbuilder.go | 123 + .../restapi/operations/scan/scan_artifact.go | 73 + .../scan/scan_artifact_parameters.go | 164 + .../scan/scan_artifact_responses.go | 390 + .../scan/scan_artifact_urlbuilder.go | 115 + .../operations/scan/stop_scan_artifact.go | 73 + .../scan/stop_scan_artifact_parameters.go | 164 + .../scan/stop_scan_artifact_responses.go | 390 + .../scan/stop_scan_artifact_urlbuilder.go | 115 + .../scan_all/create_scan_all_schedule.go | 73 + .../create_scan_all_schedule_parameters.go | 120 + .../create_scan_all_schedule_responses.go | 478 + .../create_scan_all_schedule_urlbuilder.go | 87 + .../scan_all/get_latest_scan_all_metrics.go | 73 + .../get_latest_scan_all_metrics_parameters.go | 89 + .../get_latest_scan_all_metrics_responses.go | 322 + .../get_latest_scan_all_metrics_urlbuilder.go | 87 + .../get_latest_scheduled_scan_all_metrics.go | 73 + ...t_scheduled_scan_all_metrics_parameters.go | 89 + ...st_scheduled_scan_all_metrics_responses.go | 322 + ...t_scheduled_scan_all_metrics_urlbuilder.go | 87 + .../scan_all/get_scan_all_schedule.go | 73 + .../get_scan_all_schedule_parameters.go | 89 + .../get_scan_all_schedule_responses.go | 322 + .../get_scan_all_schedule_urlbuilder.go | 87 + .../operations/scan_all/stop_scan_all.go | 73 + .../scan_all/stop_scan_all_parameters.go | 89 + .../scan_all/stop_scan_all_responses.go | 324 + .../scan_all/stop_scan_all_urlbuilder.go | 87 + .../scan_all/update_scan_all_schedule.go | 73 + .../update_scan_all_schedule_parameters.go | 120 + .../update_scan_all_schedule_responses.go | 390 + .../update_scan_all_schedule_urlbuilder.go | 87 + .../scan_data_export/download_scan_data.go | 73 + .../download_scan_data_parameters.go | 149 + .../download_scan_data_responses.go | 343 + .../download_scan_data_urlbuilder.go | 115 + .../scan_data_export/export_scan_data.go | 73 + .../export_scan_data_parameters.go | 150 + .../export_scan_data_responses.go | 520 + .../export_scan_data_urlbuilder.go | 87 + .../get_scan_data_export_execution.go | 73 + .../get_scan_data_export_execution_list.go | 73 + ...n_data_export_execution_list_parameters.go | 89 + ...an_data_export_execution_list_responses.go | 322 + ...n_data_export_execution_list_urlbuilder.go | 87 + ...t_scan_data_export_execution_parameters.go | 119 + ...et_scan_data_export_execution_responses.go | 322 + ...t_scan_data_export_execution_urlbuilder.go | 101 + .../operations/scanner/create_scanner.go | 74 + .../scanner/create_scanner_parameters.go | 120 + .../scanner/create_scanner_responses.go | 324 + .../scanner/create_scanner_urlbuilder.go | 87 + .../operations/scanner/delete_scanner.go | 74 + .../scanner/delete_scanner_parameters.go | 114 + .../scanner/delete_scanner_responses.go | 322 + .../scanner/delete_scanner_urlbuilder.go | 99 + .../restapi/operations/scanner/get_scanner.go | 74 + .../scanner/get_scanner_metadata.go | 74 + .../get_scanner_metadata_parameters.go | 114 + .../scanner/get_scanner_metadata_responses.go | 256 + .../get_scanner_metadata_urlbuilder.go | 99 + .../scanner/get_scanner_parameters.go | 114 + .../scanner/get_scanner_responses.go | 322 + .../scanner/get_scanner_urlbuilder.go | 99 + .../operations/scanner/list_scanners.go | 74 + .../scanner/list_scanners_parameters.go | 239 + .../scanner/list_scanners_responses.go | 370 + .../scanner/list_scanners_urlbuilder.go | 132 + .../operations/scanner/ping_scanner.go | 74 + .../scanner/ping_scanner_parameters.go | 120 + .../scanner/ping_scanner_responses.go | 324 + .../scanner/ping_scanner_urlbuilder.go | 87 + .../scanner/set_scanner_as_default.go | 74 + .../set_scanner_as_default_parameters.go | 145 + .../set_scanner_as_default_responses.go | 236 + .../set_scanner_as_default_urlbuilder.go | 99 + .../operations/scanner/update_scanner.go | 74 + .../scanner/update_scanner_parameters.go | 145 + .../scanner/update_scanner_responses.go | 324 + .../scanner/update_scanner_urlbuilder.go | 99 + .../schedule/get_schedule_paused.go | 71 + .../get_schedule_paused_parameters.go | 114 + .../schedule/get_schedule_paused_responses.go | 322 + .../get_schedule_paused_urlbuilder.go | 99 + .../operations/schedule/list_schedules.go | 71 + .../schedule/list_schedules_parameters.go | 185 + .../schedule/list_schedules_responses.go | 370 + .../schedule/list_schedules_urlbuilder.go | 114 + .../v2.0/restapi/operations/search/search.go | 73 + .../operations/search/search_parameters.go | 123 + .../operations/search/search_responses.go | 124 + .../operations/search/search_urlbuilder.go | 100 + .../operations/statistic/get_statistic.go | 73 + .../statistic/get_statistic_parameters.go | 89 + .../statistic/get_statistic_responses.go | 190 + .../statistic/get_statistic_urlbuilder.go | 87 + .../get_system_cve_allowlist.go | 73 + .../get_system_cve_allowlist_parameters.go | 89 + .../get_system_cve_allowlist_responses.go | 190 + .../get_system_cve_allowlist_urlbuilder.go | 87 + .../put_system_cve_allowlist.go | 73 + .../put_system_cve_allowlist_parameters.go | 112 + .../put_system_cve_allowlist_responses.go | 236 + .../put_system_cve_allowlist_urlbuilder.go | 87 + .../restapi/operations/systeminfo/get_cert.go | 74 + .../systeminfo/get_cert_parameters.go | 89 + .../systeminfo/get_cert_responses.go | 169 + .../systeminfo/get_cert_urlbuilder.go | 87 + .../operations/systeminfo/get_system_info.go | 74 + .../systeminfo/get_system_info_parameters.go | 89 + .../systeminfo/get_system_info_responses.go | 124 + .../systeminfo/get_system_info_urlbuilder.go | 87 + .../operations/systeminfo/get_volumes.go | 74 + .../systeminfo/get_volumes_parameters.go | 89 + .../systeminfo/get_volumes_responses.go | 322 + .../systeminfo/get_volumes_urlbuilder.go | 87 + .../restapi/operations/user/create_user.go | 73 + .../operations/user/create_user_parameters.go | 120 + .../operations/user/create_user_responses.go | 370 + .../operations/user/create_user_urlbuilder.go | 87 + .../restapi/operations/user/delete_user.go | 74 + .../operations/user/delete_user_parameters.go | 119 + .../operations/user/delete_user_responses.go | 324 + .../operations/user/delete_user_urlbuilder.go | 101 + .../operations/user/get_current_user_info.go | 71 + .../user/get_current_user_info_parameters.go | 89 + .../user/get_current_user_info_responses.go | 190 + .../user/get_current_user_info_urlbuilder.go | 87 + .../user/get_current_user_permissions.go | 71 + ...get_current_user_permissions_parameters.go | 153 + .../get_current_user_permissions_responses.go | 109 + ...get_current_user_permissions_urlbuilder.go | 114 + .../v2.0/restapi/operations/user/get_user.go | 71 + .../operations/user/get_user_parameters.go | 119 + .../operations/user/get_user_responses.go | 322 + .../operations/user/get_user_urlbuilder.go | 101 + .../restapi/operations/user/list_users.go | 71 + .../operations/user/list_users_parameters.go | 239 + .../operations/user/list_users_responses.go | 304 + .../operations/user/list_users_urlbuilder.go | 132 + .../restapi/operations/user/search_users.go | 74 + .../user/search_users_parameters.go | 216 + .../operations/user/search_users_responses.go | 238 + .../user/search_users_urlbuilder.go | 120 + .../restapi/operations/user/set_cli_secret.go | 73 + .../user/set_cli_secret_parameters.go | 150 + .../user/set_cli_secret_responses.go | 350 + .../user/set_cli_secret_urlbuilder.go | 101 + .../operations/user/set_user_sys_admin.go | 71 + .../user/set_user_sys_admin_parameters.go | 150 + .../user/set_user_sys_admin_responses.go | 282 + .../user/set_user_sys_admin_urlbuilder.go | 101 + .../operations/user/update_user_password.go | 74 + .../user/update_user_password_parameters.go | 150 + .../user/update_user_password_responses.go | 240 + .../user/update_user_password_urlbuilder.go | 101 + .../operations/user/update_user_profile.go | 71 + .../user/update_user_profile_parameters.go | 150 + .../user/update_user_profile_responses.go | 324 + .../user/update_user_profile_urlbuilder.go | 101 + .../operations/usergroup/create_user_group.go | 73 + .../usergroup/create_user_group_parameters.go | 112 + .../usergroup/create_user_group_responses.go | 390 + .../usergroup/create_user_group_urlbuilder.go | 87 + .../operations/usergroup/delete_user_group.go | 73 + .../usergroup/delete_user_group_parameters.go | 119 + .../usergroup/delete_user_group_responses.go | 324 + .../usergroup/delete_user_group_urlbuilder.go | 101 + .../operations/usergroup/get_user_group.go | 73 + .../usergroup/get_user_group_parameters.go | 119 + .../usergroup/get_user_group_responses.go | 388 + .../usergroup/get_user_group_urlbuilder.go | 101 + .../operations/usergroup/list_user_groups.go | 73 + .../usergroup/list_user_groups_parameters.go | 239 + .../usergroup/list_user_groups_responses.go | 304 + .../usergroup/list_user_groups_urlbuilder.go | 132 + .../usergroup/search_user_groups.go | 74 + .../search_user_groups_parameters.go | 216 + .../usergroup/search_user_groups_responses.go | 238 + .../search_user_groups_urlbuilder.go | 120 + .../operations/usergroup/update_user_group.go | 73 + .../usergroup/update_user_group_parameters.go | 142 + .../usergroup/update_user_group_responses.go | 390 + .../usergroup/update_user_group_urlbuilder.go | 101 + .../create_webhook_policy_of_project.go | 74 + ...te_webhook_policy_of_project_parameters.go | 186 + ...ate_webhook_policy_of_project_responses.go | 346 + ...te_webhook_policy_of_project_urlbuilder.go | 99 + .../delete_webhook_policy_of_project.go | 74 + ...te_webhook_policy_of_project_parameters.go | 184 + ...ete_webhook_policy_of_project_responses.go | 390 + ...te_webhook_policy_of_project_urlbuilder.go | 109 + .../webhook/get_supported_event_types.go | 73 + .../get_supported_event_types_parameters.go | 155 + .../get_supported_event_types_responses.go | 256 + .../get_supported_event_types_urlbuilder.go | 99 + .../webhook/get_webhook_policy_of_project.go | 74 + ...et_webhook_policy_of_project_parameters.go | 184 + ...get_webhook_policy_of_project_responses.go | 388 + ...et_webhook_policy_of_project_urlbuilder.go | 109 + .../operations/webhook/last_trigger.go | 74 + .../webhook/last_trigger_parameters.go | 155 + .../webhook/last_trigger_responses.go | 325 + .../webhook/last_trigger_urlbuilder.go | 99 + .../list_webhook_policies_of_project.go | 74 + ..._webhook_policies_of_project_parameters.go | 300 + ...t_webhook_policies_of_project_responses.go | 370 + ..._webhook_policies_of_project_urlbuilder.go | 142 + .../update_webhook_policy_of_project.go | 74 + ...te_webhook_policy_of_project_parameters.go | 215 + ...ate_webhook_policy_of_project_responses.go | 390 + ...te_webhook_policy_of_project_urlbuilder.go | 109 + .../webhookjob/list_webhook_jobs.go | 74 + .../list_webhook_jobs_parameters.go | 372 + .../webhookjob/list_webhook_jobs_responses.go | 370 + .../list_webhook_jobs_urlbuilder.go | 166 + src/server/v2.0/restapi/server.go | 5 + 937 files changed, 191271 insertions(+) create mode 100644 src/server/v2.0/models/access.go create mode 100644 src/server/v2.0/models/accessory.go create mode 100644 src/server/v2.0/models/action_request.go create mode 100644 src/server/v2.0/models/addition_link.go create mode 100644 src/server/v2.0/models/addition_links.go create mode 100644 src/server/v2.0/models/annotations.go create mode 100644 src/server/v2.0/models/artifact.go create mode 100644 src/server/v2.0/models/audit_log.go create mode 100644 src/server/v2.0/models/authproxy_setting.go create mode 100644 src/server/v2.0/models/bool_config_item.go create mode 100644 src/server/v2.0/models/chart_metadata.go create mode 100644 src/server/v2.0/models/chart_version.go create mode 100644 src/server/v2.0/models/component_health_status.go create mode 100644 src/server/v2.0/models/configurations.go create mode 100644 src/server/v2.0/models/configurations_response.go create mode 100644 src/server/v2.0/models/cve_allowlist.go create mode 100644 src/server/v2.0/models/cve_allowlist_item.go create mode 100644 src/server/v2.0/models/error.go create mode 100644 src/server/v2.0/models/errors.go create mode 100644 src/server/v2.0/models/event_type.go create mode 100644 src/server/v2.0/models/exec_history.go create mode 100644 src/server/v2.0/models/execution.go create mode 100644 src/server/v2.0/models/extra_attrs.go create mode 100644 src/server/v2.0/models/filter_style.go create mode 100644 src/server/v2.0/models/gc_history.go create mode 100644 src/server/v2.0/models/general_info.go create mode 100644 src/server/v2.0/models/icon.go create mode 100644 src/server/v2.0/models/immutable_rule.go create mode 100644 src/server/v2.0/models/immutable_selector.go create mode 100644 src/server/v2.0/models/instance.go create mode 100644 src/server/v2.0/models/integer_config_item.go create mode 100644 src/server/v2.0/models/internal_configuration_value.go create mode 100644 src/server/v2.0/models/internal_configurations_response.go create mode 100644 src/server/v2.0/models/is_default.go create mode 100644 src/server/v2.0/models/job_queue.go create mode 100644 src/server/v2.0/models/label.go create mode 100644 src/server/v2.0/models/ldap_conf.go create mode 100644 src/server/v2.0/models/ldap_failed_import_user.go create mode 100644 src/server/v2.0/models/ldap_import_users.go create mode 100644 src/server/v2.0/models/ldap_ping_result.go create mode 100644 src/server/v2.0/models/ldap_user.go create mode 100644 src/server/v2.0/models/metadata.go create mode 100644 src/server/v2.0/models/metrics.go create mode 100644 src/server/v2.0/models/native_report_summary.go create mode 100644 src/server/v2.0/models/notify_type.go create mode 100644 src/server/v2.0/models/oidc_cli_secret_req.go create mode 100644 src/server/v2.0/models/oidc_user_info.go create mode 100644 src/server/v2.0/models/overall_health_status.go create mode 100644 src/server/v2.0/models/password_req.go create mode 100644 src/server/v2.0/models/permission.go create mode 100644 src/server/v2.0/models/platform.go create mode 100644 src/server/v2.0/models/preheat_policy.go create mode 100644 src/server/v2.0/models/project.go create mode 100644 src/server/v2.0/models/project_deletable.go create mode 100644 src/server/v2.0/models/project_member.go create mode 100644 src/server/v2.0/models/project_member_entity.go create mode 100644 src/server/v2.0/models/project_metadata.go create mode 100644 src/server/v2.0/models/project_req.go create mode 100644 src/server/v2.0/models/project_scanner.go create mode 100644 src/server/v2.0/models/project_summary.go create mode 100644 src/server/v2.0/models/project_summary_quota.go create mode 100644 src/server/v2.0/models/provider_under_project.go create mode 100644 src/server/v2.0/models/quota.go create mode 100644 src/server/v2.0/models/quota_ref_object.go create mode 100644 src/server/v2.0/models/quota_update_req.go create mode 100644 src/server/v2.0/models/reference.go create mode 100644 src/server/v2.0/models/registry.go create mode 100644 src/server/v2.0/models/registry_credential.go create mode 100644 src/server/v2.0/models/registry_endpoint.go create mode 100644 src/server/v2.0/models/registry_info.go create mode 100644 src/server/v2.0/models/registry_ping.go create mode 100644 src/server/v2.0/models/registry_provider_credential_pattern.go create mode 100644 src/server/v2.0/models/registry_provider_endpoint_pattern.go create mode 100644 src/server/v2.0/models/registry_provider_info.go create mode 100644 src/server/v2.0/models/registry_update.go create mode 100644 src/server/v2.0/models/replication_execution.go create mode 100644 src/server/v2.0/models/replication_filter.go create mode 100644 src/server/v2.0/models/replication_policy.go create mode 100644 src/server/v2.0/models/replication_task.go create mode 100644 src/server/v2.0/models/replication_trigger.go create mode 100644 src/server/v2.0/models/replication_trigger_settings.go create mode 100644 src/server/v2.0/models/repository.go create mode 100644 src/server/v2.0/models/resource_list.go create mode 100644 src/server/v2.0/models/retention_execution.go create mode 100644 src/server/v2.0/models/retention_execution_task.go create mode 100644 src/server/v2.0/models/retention_metadata.go create mode 100644 src/server/v2.0/models/retention_policy.go create mode 100644 src/server/v2.0/models/retention_policy_scope.go create mode 100644 src/server/v2.0/models/retention_rule.go create mode 100644 src/server/v2.0/models/retention_rule_metadata.go create mode 100644 src/server/v2.0/models/retention_rule_param_metadata.go create mode 100644 src/server/v2.0/models/retention_rule_trigger.go create mode 100644 src/server/v2.0/models/retention_selector.go create mode 100644 src/server/v2.0/models/retention_selector_metadata.go create mode 100644 src/server/v2.0/models/robot.go create mode 100644 src/server/v2.0/models/robot_create.go create mode 100644 src/server/v2.0/models/robot_create_v1.go create mode 100644 src/server/v2.0/models/robot_created.go create mode 100644 src/server/v2.0/models/robot_permission.go create mode 100644 src/server/v2.0/models/robot_sec.go create mode 100644 src/server/v2.0/models/role_request.go create mode 100644 src/server/v2.0/models/scan_data_export_execution.go create mode 100644 src/server/v2.0/models/scan_data_export_execution_list.go create mode 100644 src/server/v2.0/models/scan_data_export_job.go create mode 100644 src/server/v2.0/models/scan_data_export_request.go create mode 100644 src/server/v2.0/models/scan_overview.go create mode 100644 src/server/v2.0/models/scanner.go create mode 100644 src/server/v2.0/models/scanner_adapter_metadata.go create mode 100644 src/server/v2.0/models/scanner_capability.go create mode 100644 src/server/v2.0/models/scanner_registration.go create mode 100644 src/server/v2.0/models/scanner_registration_req.go create mode 100644 src/server/v2.0/models/scanner_registration_settings.go create mode 100644 src/server/v2.0/models/schedule.go create mode 100644 src/server/v2.0/models/schedule_obj.go create mode 100644 src/server/v2.0/models/schedule_task.go create mode 100644 src/server/v2.0/models/scheduler_status.go create mode 100644 src/server/v2.0/models/search.go create mode 100644 src/server/v2.0/models/search_repository.go create mode 100644 src/server/v2.0/models/search_result.go create mode 100644 src/server/v2.0/models/start_replication_execution.go create mode 100644 src/server/v2.0/models/statistic.go create mode 100644 src/server/v2.0/models/stats.go create mode 100644 src/server/v2.0/models/storage.go create mode 100644 src/server/v2.0/models/string_config_item.go create mode 100644 src/server/v2.0/models/supported_webhook_event_types.go create mode 100644 src/server/v2.0/models/system_info.go create mode 100644 src/server/v2.0/models/tag.go create mode 100644 src/server/v2.0/models/task.go create mode 100644 src/server/v2.0/models/user_creation_req.go create mode 100644 src/server/v2.0/models/user_entity.go create mode 100644 src/server/v2.0/models/user_group.go create mode 100644 src/server/v2.0/models/user_group_search_item.go create mode 100644 src/server/v2.0/models/user_profile.go create mode 100644 src/server/v2.0/models/user_resp.go create mode 100644 src/server/v2.0/models/user_search.go create mode 100644 src/server/v2.0/models/user_search_resp_item.go create mode 100644 src/server/v2.0/models/user_sys_admin_flag.go create mode 100644 src/server/v2.0/models/vulnerability_summary.go create mode 100644 src/server/v2.0/models/webhook_job.go create mode 100644 src/server/v2.0/models/webhook_last_trigger.go create mode 100644 src/server/v2.0/models/webhook_policy.go create mode 100644 src/server/v2.0/models/webhook_target_object.go create mode 100644 src/server/v2.0/models/worker.go create mode 100644 src/server/v2.0/models/worker_pool.go create mode 100644 src/server/v2.0/restapi/configure_harbor.go create mode 100644 src/server/v2.0/restapi/doc.go create mode 100644 src/server/v2.0/restapi/embedded_spec.go create mode 100644 src/server/v2.0/restapi/operations/artifact/add_label.go create mode 100644 src/server/v2.0/restapi/operations/artifact/add_label_parameters.go create mode 100644 src/server/v2.0/restapi/operations/artifact/add_label_responses.go create mode 100644 src/server/v2.0/restapi/operations/artifact/add_label_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/artifact/copy_artifact.go create mode 100644 src/server/v2.0/restapi/operations/artifact/copy_artifact_parameters.go create mode 100644 src/server/v2.0/restapi/operations/artifact/copy_artifact_responses.go create mode 100644 src/server/v2.0/restapi/operations/artifact/copy_artifact_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/artifact/create_tag.go create mode 100644 src/server/v2.0/restapi/operations/artifact/create_tag_parameters.go create mode 100644 src/server/v2.0/restapi/operations/artifact/create_tag_responses.go create mode 100644 src/server/v2.0/restapi/operations/artifact/create_tag_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/artifact/delete_artifact.go create mode 100644 src/server/v2.0/restapi/operations/artifact/delete_artifact_parameters.go create mode 100644 src/server/v2.0/restapi/operations/artifact/delete_artifact_responses.go create mode 100644 src/server/v2.0/restapi/operations/artifact/delete_artifact_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/artifact/delete_tag.go create mode 100644 src/server/v2.0/restapi/operations/artifact/delete_tag_parameters.go create mode 100644 src/server/v2.0/restapi/operations/artifact/delete_tag_responses.go create mode 100644 src/server/v2.0/restapi/operations/artifact/delete_tag_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/artifact/get_addition.go create mode 100644 src/server/v2.0/restapi/operations/artifact/get_addition_parameters.go create mode 100644 src/server/v2.0/restapi/operations/artifact/get_addition_responses.go create mode 100644 src/server/v2.0/restapi/operations/artifact/get_addition_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/artifact/get_artifact.go create mode 100644 src/server/v2.0/restapi/operations/artifact/get_artifact_parameters.go create mode 100644 src/server/v2.0/restapi/operations/artifact/get_artifact_responses.go create mode 100644 src/server/v2.0/restapi/operations/artifact/get_artifact_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/artifact/get_vulnerabilities_addition.go create mode 100644 src/server/v2.0/restapi/operations/artifact/get_vulnerabilities_addition_parameters.go create mode 100644 src/server/v2.0/restapi/operations/artifact/get_vulnerabilities_addition_responses.go create mode 100644 src/server/v2.0/restapi/operations/artifact/get_vulnerabilities_addition_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/artifact/list_accessories.go create mode 100644 src/server/v2.0/restapi/operations/artifact/list_accessories_parameters.go create mode 100644 src/server/v2.0/restapi/operations/artifact/list_accessories_responses.go create mode 100644 src/server/v2.0/restapi/operations/artifact/list_accessories_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/artifact/list_artifacts.go create mode 100644 src/server/v2.0/restapi/operations/artifact/list_artifacts_parameters.go create mode 100644 src/server/v2.0/restapi/operations/artifact/list_artifacts_responses.go create mode 100644 src/server/v2.0/restapi/operations/artifact/list_artifacts_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/artifact/list_tags.go create mode 100644 src/server/v2.0/restapi/operations/artifact/list_tags_parameters.go create mode 100644 src/server/v2.0/restapi/operations/artifact/list_tags_responses.go create mode 100644 src/server/v2.0/restapi/operations/artifact/list_tags_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/artifact/remove_label.go create mode 100644 src/server/v2.0/restapi/operations/artifact/remove_label_parameters.go create mode 100644 src/server/v2.0/restapi/operations/artifact/remove_label_responses.go create mode 100644 src/server/v2.0/restapi/operations/artifact/remove_label_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/auditlog/list_audit_logs.go create mode 100644 src/server/v2.0/restapi/operations/auditlog/list_audit_logs_parameters.go create mode 100644 src/server/v2.0/restapi/operations/auditlog/list_audit_logs_responses.go create mode 100644 src/server/v2.0/restapi/operations/auditlog/list_audit_logs_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/configure/get_configurations.go create mode 100644 src/server/v2.0/restapi/operations/configure/get_configurations_parameters.go create mode 100644 src/server/v2.0/restapi/operations/configure/get_configurations_responses.go create mode 100644 src/server/v2.0/restapi/operations/configure/get_configurations_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/configure/get_internalconfig.go create mode 100644 src/server/v2.0/restapi/operations/configure/get_internalconfig_parameters.go create mode 100644 src/server/v2.0/restapi/operations/configure/get_internalconfig_responses.go create mode 100644 src/server/v2.0/restapi/operations/configure/get_internalconfig_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/configure/update_configurations.go create mode 100644 src/server/v2.0/restapi/operations/configure/update_configurations_parameters.go create mode 100644 src/server/v2.0/restapi/operations/configure/update_configurations_responses.go create mode 100644 src/server/v2.0/restapi/operations/configure/update_configurations_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/gc/create_gc_schedule.go create mode 100644 src/server/v2.0/restapi/operations/gc/create_gc_schedule_parameters.go create mode 100644 src/server/v2.0/restapi/operations/gc/create_gc_schedule_responses.go create mode 100644 src/server/v2.0/restapi/operations/gc/create_gc_schedule_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/gc/get_gc.go create mode 100644 src/server/v2.0/restapi/operations/gc/get_gc_history.go create mode 100644 src/server/v2.0/restapi/operations/gc/get_gc_history_parameters.go create mode 100644 src/server/v2.0/restapi/operations/gc/get_gc_history_responses.go create mode 100644 src/server/v2.0/restapi/operations/gc/get_gc_history_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/gc/get_gc_log.go create mode 100644 src/server/v2.0/restapi/operations/gc/get_gc_log_parameters.go create mode 100644 src/server/v2.0/restapi/operations/gc/get_gc_log_responses.go create mode 100644 src/server/v2.0/restapi/operations/gc/get_gc_log_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/gc/get_gc_parameters.go create mode 100644 src/server/v2.0/restapi/operations/gc/get_gc_responses.go create mode 100644 src/server/v2.0/restapi/operations/gc/get_gc_schedule.go create mode 100644 src/server/v2.0/restapi/operations/gc/get_gc_schedule_parameters.go create mode 100644 src/server/v2.0/restapi/operations/gc/get_gc_schedule_responses.go create mode 100644 src/server/v2.0/restapi/operations/gc/get_gc_schedule_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/gc/get_gc_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/gc/stop_gc.go create mode 100644 src/server/v2.0/restapi/operations/gc/stop_gc_parameters.go create mode 100644 src/server/v2.0/restapi/operations/gc/stop_gc_responses.go create mode 100644 src/server/v2.0/restapi/operations/gc/stop_gc_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/gc/update_gc_schedule.go create mode 100644 src/server/v2.0/restapi/operations/gc/update_gc_schedule_parameters.go create mode 100644 src/server/v2.0/restapi/operations/gc/update_gc_schedule_responses.go create mode 100644 src/server/v2.0/restapi/operations/gc/update_gc_schedule_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/harbor_api.go create mode 100644 src/server/v2.0/restapi/operations/health/get_health.go create mode 100644 src/server/v2.0/restapi/operations/health/get_health_parameters.go create mode 100644 src/server/v2.0/restapi/operations/health/get_health_responses.go create mode 100644 src/server/v2.0/restapi/operations/health/get_health_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/icon/get_icon.go create mode 100644 src/server/v2.0/restapi/operations/icon/get_icon_parameters.go create mode 100644 src/server/v2.0/restapi/operations/icon/get_icon_responses.go create mode 100644 src/server/v2.0/restapi/operations/icon/get_icon_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/immutable/create_immu_rule.go create mode 100644 src/server/v2.0/restapi/operations/immutable/create_immu_rule_parameters.go create mode 100644 src/server/v2.0/restapi/operations/immutable/create_immu_rule_responses.go create mode 100644 src/server/v2.0/restapi/operations/immutable/create_immu_rule_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/immutable/delete_immu_rule.go create mode 100644 src/server/v2.0/restapi/operations/immutable/delete_immu_rule_parameters.go create mode 100644 src/server/v2.0/restapi/operations/immutable/delete_immu_rule_responses.go create mode 100644 src/server/v2.0/restapi/operations/immutable/delete_immu_rule_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/immutable/list_immu_rules.go create mode 100644 src/server/v2.0/restapi/operations/immutable/list_immu_rules_parameters.go create mode 100644 src/server/v2.0/restapi/operations/immutable/list_immu_rules_responses.go create mode 100644 src/server/v2.0/restapi/operations/immutable/list_immu_rules_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/immutable/update_immu_rule.go create mode 100644 src/server/v2.0/restapi/operations/immutable/update_immu_rule_parameters.go create mode 100644 src/server/v2.0/restapi/operations/immutable/update_immu_rule_responses.go create mode 100644 src/server/v2.0/restapi/operations/immutable/update_immu_rule_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/jobservice/action_pending_jobs.go create mode 100644 src/server/v2.0/restapi/operations/jobservice/action_pending_jobs_parameters.go create mode 100644 src/server/v2.0/restapi/operations/jobservice/action_pending_jobs_responses.go create mode 100644 src/server/v2.0/restapi/operations/jobservice/action_pending_jobs_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/jobservice/get_worker_pools.go create mode 100644 src/server/v2.0/restapi/operations/jobservice/get_worker_pools_parameters.go create mode 100644 src/server/v2.0/restapi/operations/jobservice/get_worker_pools_responses.go create mode 100644 src/server/v2.0/restapi/operations/jobservice/get_worker_pools_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/jobservice/get_workers.go create mode 100644 src/server/v2.0/restapi/operations/jobservice/get_workers_parameters.go create mode 100644 src/server/v2.0/restapi/operations/jobservice/get_workers_responses.go create mode 100644 src/server/v2.0/restapi/operations/jobservice/get_workers_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/jobservice/list_job_queues.go create mode 100644 src/server/v2.0/restapi/operations/jobservice/list_job_queues_parameters.go create mode 100644 src/server/v2.0/restapi/operations/jobservice/list_job_queues_responses.go create mode 100644 src/server/v2.0/restapi/operations/jobservice/list_job_queues_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/jobservice/stop_running_job.go create mode 100644 src/server/v2.0/restapi/operations/jobservice/stop_running_job_parameters.go create mode 100644 src/server/v2.0/restapi/operations/jobservice/stop_running_job_responses.go create mode 100644 src/server/v2.0/restapi/operations/jobservice/stop_running_job_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/label/create_label.go create mode 100644 src/server/v2.0/restapi/operations/label/create_label_parameters.go create mode 100644 src/server/v2.0/restapi/operations/label/create_label_responses.go create mode 100644 src/server/v2.0/restapi/operations/label/create_label_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/label/delete_label.go create mode 100644 src/server/v2.0/restapi/operations/label/delete_label_parameters.go create mode 100644 src/server/v2.0/restapi/operations/label/delete_label_responses.go create mode 100644 src/server/v2.0/restapi/operations/label/delete_label_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/label/get_label_by_id.go create mode 100644 src/server/v2.0/restapi/operations/label/get_label_by_id_parameters.go create mode 100644 src/server/v2.0/restapi/operations/label/get_label_by_id_responses.go create mode 100644 src/server/v2.0/restapi/operations/label/get_label_by_id_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/label/list_labels.go create mode 100644 src/server/v2.0/restapi/operations/label/list_labels_parameters.go create mode 100644 src/server/v2.0/restapi/operations/label/list_labels_responses.go create mode 100644 src/server/v2.0/restapi/operations/label/list_labels_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/label/update_label.go create mode 100644 src/server/v2.0/restapi/operations/label/update_label_parameters.go create mode 100644 src/server/v2.0/restapi/operations/label/update_label_responses.go create mode 100644 src/server/v2.0/restapi/operations/label/update_label_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/ldap/import_ldap_user.go create mode 100644 src/server/v2.0/restapi/operations/ldap/import_ldap_user_parameters.go create mode 100644 src/server/v2.0/restapi/operations/ldap/import_ldap_user_responses.go create mode 100644 src/server/v2.0/restapi/operations/ldap/import_ldap_user_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/ldap/ping_ldap.go create mode 100644 src/server/v2.0/restapi/operations/ldap/ping_ldap_parameters.go create mode 100644 src/server/v2.0/restapi/operations/ldap/ping_ldap_responses.go create mode 100644 src/server/v2.0/restapi/operations/ldap/ping_ldap_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/ldap/search_ldap_group.go create mode 100644 src/server/v2.0/restapi/operations/ldap/search_ldap_group_parameters.go create mode 100644 src/server/v2.0/restapi/operations/ldap/search_ldap_group_responses.go create mode 100644 src/server/v2.0/restapi/operations/ldap/search_ldap_group_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/ldap/search_ldap_user.go create mode 100644 src/server/v2.0/restapi/operations/ldap/search_ldap_user_parameters.go create mode 100644 src/server/v2.0/restapi/operations/ldap/search_ldap_user_responses.go create mode 100644 src/server/v2.0/restapi/operations/ldap/search_ldap_user_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/member/create_project_member.go create mode 100644 src/server/v2.0/restapi/operations/member/create_project_member_parameters.go create mode 100644 src/server/v2.0/restapi/operations/member/create_project_member_responses.go create mode 100644 src/server/v2.0/restapi/operations/member/create_project_member_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/member/delete_project_member.go create mode 100644 src/server/v2.0/restapi/operations/member/delete_project_member_parameters.go create mode 100644 src/server/v2.0/restapi/operations/member/delete_project_member_responses.go create mode 100644 src/server/v2.0/restapi/operations/member/delete_project_member_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/member/get_project_member.go create mode 100644 src/server/v2.0/restapi/operations/member/get_project_member_parameters.go create mode 100644 src/server/v2.0/restapi/operations/member/get_project_member_responses.go create mode 100644 src/server/v2.0/restapi/operations/member/get_project_member_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/member/list_project_members.go create mode 100644 src/server/v2.0/restapi/operations/member/list_project_members_parameters.go create mode 100644 src/server/v2.0/restapi/operations/member/list_project_members_responses.go create mode 100644 src/server/v2.0/restapi/operations/member/list_project_members_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/member/update_project_member.go create mode 100644 src/server/v2.0/restapi/operations/member/update_project_member_parameters.go create mode 100644 src/server/v2.0/restapi/operations/member/update_project_member_responses.go create mode 100644 src/server/v2.0/restapi/operations/member/update_project_member_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/oidc/ping_oidc.go create mode 100644 src/server/v2.0/restapi/operations/oidc/ping_oidc_parameters.go create mode 100644 src/server/v2.0/restapi/operations/oidc/ping_oidc_responses.go create mode 100644 src/server/v2.0/restapi/operations/oidc/ping_oidc_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/ping/get_ping.go create mode 100644 src/server/v2.0/restapi/operations/ping/get_ping_parameters.go create mode 100644 src/server/v2.0/restapi/operations/ping/get_ping_responses.go create mode 100644 src/server/v2.0/restapi/operations/ping/get_ping_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/preheat/create_instance.go create mode 100644 src/server/v2.0/restapi/operations/preheat/create_instance_parameters.go create mode 100644 src/server/v2.0/restapi/operations/preheat/create_instance_responses.go create mode 100644 src/server/v2.0/restapi/operations/preheat/create_instance_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/preheat/create_policy.go create mode 100644 src/server/v2.0/restapi/operations/preheat/create_policy_parameters.go create mode 100644 src/server/v2.0/restapi/operations/preheat/create_policy_responses.go create mode 100644 src/server/v2.0/restapi/operations/preheat/create_policy_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/preheat/delete_instance.go create mode 100644 src/server/v2.0/restapi/operations/preheat/delete_instance_parameters.go create mode 100644 src/server/v2.0/restapi/operations/preheat/delete_instance_responses.go create mode 100644 src/server/v2.0/restapi/operations/preheat/delete_instance_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/preheat/delete_policy.go create mode 100644 src/server/v2.0/restapi/operations/preheat/delete_policy_parameters.go create mode 100644 src/server/v2.0/restapi/operations/preheat/delete_policy_responses.go create mode 100644 src/server/v2.0/restapi/operations/preheat/delete_policy_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/preheat/get_execution.go create mode 100644 src/server/v2.0/restapi/operations/preheat/get_execution_parameters.go create mode 100644 src/server/v2.0/restapi/operations/preheat/get_execution_responses.go create mode 100644 src/server/v2.0/restapi/operations/preheat/get_execution_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/preheat/get_instance.go create mode 100644 src/server/v2.0/restapi/operations/preheat/get_instance_parameters.go create mode 100644 src/server/v2.0/restapi/operations/preheat/get_instance_responses.go create mode 100644 src/server/v2.0/restapi/operations/preheat/get_instance_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/preheat/get_policy.go create mode 100644 src/server/v2.0/restapi/operations/preheat/get_policy_parameters.go create mode 100644 src/server/v2.0/restapi/operations/preheat/get_policy_responses.go create mode 100644 src/server/v2.0/restapi/operations/preheat/get_policy_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/preheat/get_preheat_log.go create mode 100644 src/server/v2.0/restapi/operations/preheat/get_preheat_log_parameters.go create mode 100644 src/server/v2.0/restapi/operations/preheat/get_preheat_log_responses.go create mode 100644 src/server/v2.0/restapi/operations/preheat/get_preheat_log_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/preheat/list_executions.go create mode 100644 src/server/v2.0/restapi/operations/preheat/list_executions_parameters.go create mode 100644 src/server/v2.0/restapi/operations/preheat/list_executions_responses.go create mode 100644 src/server/v2.0/restapi/operations/preheat/list_executions_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/preheat/list_instances.go create mode 100644 src/server/v2.0/restapi/operations/preheat/list_instances_parameters.go create mode 100644 src/server/v2.0/restapi/operations/preheat/list_instances_responses.go create mode 100644 src/server/v2.0/restapi/operations/preheat/list_instances_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/preheat/list_policies.go create mode 100644 src/server/v2.0/restapi/operations/preheat/list_policies_parameters.go create mode 100644 src/server/v2.0/restapi/operations/preheat/list_policies_responses.go create mode 100644 src/server/v2.0/restapi/operations/preheat/list_policies_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/preheat/list_providers.go create mode 100644 src/server/v2.0/restapi/operations/preheat/list_providers_parameters.go create mode 100644 src/server/v2.0/restapi/operations/preheat/list_providers_responses.go create mode 100644 src/server/v2.0/restapi/operations/preheat/list_providers_under_project.go create mode 100644 src/server/v2.0/restapi/operations/preheat/list_providers_under_project_parameters.go create mode 100644 src/server/v2.0/restapi/operations/preheat/list_providers_under_project_responses.go create mode 100644 src/server/v2.0/restapi/operations/preheat/list_providers_under_project_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/preheat/list_providers_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/preheat/list_tasks.go create mode 100644 src/server/v2.0/restapi/operations/preheat/list_tasks_parameters.go create mode 100644 src/server/v2.0/restapi/operations/preheat/list_tasks_responses.go create mode 100644 src/server/v2.0/restapi/operations/preheat/list_tasks_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/preheat/manual_preheat.go create mode 100644 src/server/v2.0/restapi/operations/preheat/manual_preheat_parameters.go create mode 100644 src/server/v2.0/restapi/operations/preheat/manual_preheat_responses.go create mode 100644 src/server/v2.0/restapi/operations/preheat/manual_preheat_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/preheat/ping_instances.go create mode 100644 src/server/v2.0/restapi/operations/preheat/ping_instances_parameters.go create mode 100644 src/server/v2.0/restapi/operations/preheat/ping_instances_responses.go create mode 100644 src/server/v2.0/restapi/operations/preheat/ping_instances_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/preheat/stop_execution.go create mode 100644 src/server/v2.0/restapi/operations/preheat/stop_execution_parameters.go create mode 100644 src/server/v2.0/restapi/operations/preheat/stop_execution_responses.go create mode 100644 src/server/v2.0/restapi/operations/preheat/stop_execution_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/preheat/update_instance.go create mode 100644 src/server/v2.0/restapi/operations/preheat/update_instance_parameters.go create mode 100644 src/server/v2.0/restapi/operations/preheat/update_instance_responses.go create mode 100644 src/server/v2.0/restapi/operations/preheat/update_instance_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/preheat/update_policy.go create mode 100644 src/server/v2.0/restapi/operations/preheat/update_policy_parameters.go create mode 100644 src/server/v2.0/restapi/operations/preheat/update_policy_responses.go create mode 100644 src/server/v2.0/restapi/operations/preheat/update_policy_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/project/create_project.go create mode 100644 src/server/v2.0/restapi/operations/project/create_project_parameters.go create mode 100644 src/server/v2.0/restapi/operations/project/create_project_responses.go create mode 100644 src/server/v2.0/restapi/operations/project/create_project_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/project/delete_project.go create mode 100644 src/server/v2.0/restapi/operations/project/delete_project_parameters.go create mode 100644 src/server/v2.0/restapi/operations/project/delete_project_responses.go create mode 100644 src/server/v2.0/restapi/operations/project/delete_project_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/project/get_logs.go create mode 100644 src/server/v2.0/restapi/operations/project/get_logs_parameters.go create mode 100644 src/server/v2.0/restapi/operations/project/get_logs_responses.go create mode 100644 src/server/v2.0/restapi/operations/project/get_logs_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/project/get_project.go create mode 100644 src/server/v2.0/restapi/operations/project/get_project_deletable.go create mode 100644 src/server/v2.0/restapi/operations/project/get_project_deletable_parameters.go create mode 100644 src/server/v2.0/restapi/operations/project/get_project_deletable_responses.go create mode 100644 src/server/v2.0/restapi/operations/project/get_project_deletable_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/project/get_project_parameters.go create mode 100644 src/server/v2.0/restapi/operations/project/get_project_responses.go create mode 100644 src/server/v2.0/restapi/operations/project/get_project_summary.go create mode 100644 src/server/v2.0/restapi/operations/project/get_project_summary_parameters.go create mode 100644 src/server/v2.0/restapi/operations/project/get_project_summary_responses.go create mode 100644 src/server/v2.0/restapi/operations/project/get_project_summary_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/project/get_project_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/project/get_scanner_of_project.go create mode 100644 src/server/v2.0/restapi/operations/project/get_scanner_of_project_parameters.go create mode 100644 src/server/v2.0/restapi/operations/project/get_scanner_of_project_responses.go create mode 100644 src/server/v2.0/restapi/operations/project/get_scanner_of_project_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/project/head_project.go create mode 100644 src/server/v2.0/restapi/operations/project/head_project_parameters.go create mode 100644 src/server/v2.0/restapi/operations/project/head_project_responses.go create mode 100644 src/server/v2.0/restapi/operations/project/head_project_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/project/list_projects.go create mode 100644 src/server/v2.0/restapi/operations/project/list_projects_parameters.go create mode 100644 src/server/v2.0/restapi/operations/project/list_projects_responses.go create mode 100644 src/server/v2.0/restapi/operations/project/list_projects_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/project/list_scanner_candidates_of_project.go create mode 100644 src/server/v2.0/restapi/operations/project/list_scanner_candidates_of_project_parameters.go create mode 100644 src/server/v2.0/restapi/operations/project/list_scanner_candidates_of_project_responses.go create mode 100644 src/server/v2.0/restapi/operations/project/list_scanner_candidates_of_project_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/project/set_scanner_of_project.go create mode 100644 src/server/v2.0/restapi/operations/project/set_scanner_of_project_parameters.go create mode 100644 src/server/v2.0/restapi/operations/project/set_scanner_of_project_responses.go create mode 100644 src/server/v2.0/restapi/operations/project/set_scanner_of_project_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/project/update_project.go create mode 100644 src/server/v2.0/restapi/operations/project/update_project_parameters.go create mode 100644 src/server/v2.0/restapi/operations/project/update_project_responses.go create mode 100644 src/server/v2.0/restapi/operations/project/update_project_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/project_metadata/add_project_metadatas.go create mode 100644 src/server/v2.0/restapi/operations/project_metadata/add_project_metadatas_parameters.go create mode 100644 src/server/v2.0/restapi/operations/project_metadata/add_project_metadatas_responses.go create mode 100644 src/server/v2.0/restapi/operations/project_metadata/add_project_metadatas_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/project_metadata/delete_project_metadata.go create mode 100644 src/server/v2.0/restapi/operations/project_metadata/delete_project_metadata_parameters.go create mode 100644 src/server/v2.0/restapi/operations/project_metadata/delete_project_metadata_responses.go create mode 100644 src/server/v2.0/restapi/operations/project_metadata/delete_project_metadata_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/project_metadata/get_project_metadata.go create mode 100644 src/server/v2.0/restapi/operations/project_metadata/get_project_metadata_parameters.go create mode 100644 src/server/v2.0/restapi/operations/project_metadata/get_project_metadata_responses.go create mode 100644 src/server/v2.0/restapi/operations/project_metadata/get_project_metadata_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/project_metadata/list_project_metadatas.go create mode 100644 src/server/v2.0/restapi/operations/project_metadata/list_project_metadatas_parameters.go create mode 100644 src/server/v2.0/restapi/operations/project_metadata/list_project_metadatas_responses.go create mode 100644 src/server/v2.0/restapi/operations/project_metadata/list_project_metadatas_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/project_metadata/update_project_metadata.go create mode 100644 src/server/v2.0/restapi/operations/project_metadata/update_project_metadata_parameters.go create mode 100644 src/server/v2.0/restapi/operations/project_metadata/update_project_metadata_responses.go create mode 100644 src/server/v2.0/restapi/operations/project_metadata/update_project_metadata_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/purge/create_purge_schedule.go create mode 100644 src/server/v2.0/restapi/operations/purge/create_purge_schedule_parameters.go create mode 100644 src/server/v2.0/restapi/operations/purge/create_purge_schedule_responses.go create mode 100644 src/server/v2.0/restapi/operations/purge/create_purge_schedule_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/purge/get_purge_history.go create mode 100644 src/server/v2.0/restapi/operations/purge/get_purge_history_parameters.go create mode 100644 src/server/v2.0/restapi/operations/purge/get_purge_history_responses.go create mode 100644 src/server/v2.0/restapi/operations/purge/get_purge_history_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/purge/get_purge_job.go create mode 100644 src/server/v2.0/restapi/operations/purge/get_purge_job_log.go create mode 100644 src/server/v2.0/restapi/operations/purge/get_purge_job_log_parameters.go create mode 100644 src/server/v2.0/restapi/operations/purge/get_purge_job_log_responses.go create mode 100644 src/server/v2.0/restapi/operations/purge/get_purge_job_log_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/purge/get_purge_job_parameters.go create mode 100644 src/server/v2.0/restapi/operations/purge/get_purge_job_responses.go create mode 100644 src/server/v2.0/restapi/operations/purge/get_purge_job_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/purge/get_purge_schedule.go create mode 100644 src/server/v2.0/restapi/operations/purge/get_purge_schedule_parameters.go create mode 100644 src/server/v2.0/restapi/operations/purge/get_purge_schedule_responses.go create mode 100644 src/server/v2.0/restapi/operations/purge/get_purge_schedule_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/purge/stop_purge.go create mode 100644 src/server/v2.0/restapi/operations/purge/stop_purge_parameters.go create mode 100644 src/server/v2.0/restapi/operations/purge/stop_purge_responses.go create mode 100644 src/server/v2.0/restapi/operations/purge/stop_purge_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/purge/update_purge_schedule.go create mode 100644 src/server/v2.0/restapi/operations/purge/update_purge_schedule_parameters.go create mode 100644 src/server/v2.0/restapi/operations/purge/update_purge_schedule_responses.go create mode 100644 src/server/v2.0/restapi/operations/purge/update_purge_schedule_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/quota/get_quota.go create mode 100644 src/server/v2.0/restapi/operations/quota/get_quota_parameters.go create mode 100644 src/server/v2.0/restapi/operations/quota/get_quota_responses.go create mode 100644 src/server/v2.0/restapi/operations/quota/get_quota_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/quota/list_quotas.go create mode 100644 src/server/v2.0/restapi/operations/quota/list_quotas_parameters.go create mode 100644 src/server/v2.0/restapi/operations/quota/list_quotas_responses.go create mode 100644 src/server/v2.0/restapi/operations/quota/list_quotas_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/quota/update_quota.go create mode 100644 src/server/v2.0/restapi/operations/quota/update_quota_parameters.go create mode 100644 src/server/v2.0/restapi/operations/quota/update_quota_responses.go create mode 100644 src/server/v2.0/restapi/operations/quota/update_quota_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/registry/create_registry.go create mode 100644 src/server/v2.0/restapi/operations/registry/create_registry_parameters.go create mode 100644 src/server/v2.0/restapi/operations/registry/create_registry_responses.go create mode 100644 src/server/v2.0/restapi/operations/registry/create_registry_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/registry/delete_registry.go create mode 100644 src/server/v2.0/restapi/operations/registry/delete_registry_parameters.go create mode 100644 src/server/v2.0/restapi/operations/registry/delete_registry_responses.go create mode 100644 src/server/v2.0/restapi/operations/registry/delete_registry_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/registry/get_registry.go create mode 100644 src/server/v2.0/restapi/operations/registry/get_registry_info.go create mode 100644 src/server/v2.0/restapi/operations/registry/get_registry_info_parameters.go create mode 100644 src/server/v2.0/restapi/operations/registry/get_registry_info_responses.go create mode 100644 src/server/v2.0/restapi/operations/registry/get_registry_info_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/registry/get_registry_parameters.go create mode 100644 src/server/v2.0/restapi/operations/registry/get_registry_responses.go create mode 100644 src/server/v2.0/restapi/operations/registry/get_registry_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/registry/list_registries.go create mode 100644 src/server/v2.0/restapi/operations/registry/list_registries_parameters.go create mode 100644 src/server/v2.0/restapi/operations/registry/list_registries_responses.go create mode 100644 src/server/v2.0/restapi/operations/registry/list_registries_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/registry/list_registry_provider_infos.go create mode 100644 src/server/v2.0/restapi/operations/registry/list_registry_provider_infos_parameters.go create mode 100644 src/server/v2.0/restapi/operations/registry/list_registry_provider_infos_responses.go create mode 100644 src/server/v2.0/restapi/operations/registry/list_registry_provider_infos_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/registry/list_registry_provider_types.go create mode 100644 src/server/v2.0/restapi/operations/registry/list_registry_provider_types_parameters.go create mode 100644 src/server/v2.0/restapi/operations/registry/list_registry_provider_types_responses.go create mode 100644 src/server/v2.0/restapi/operations/registry/list_registry_provider_types_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/registry/ping_registry.go create mode 100644 src/server/v2.0/restapi/operations/registry/ping_registry_parameters.go create mode 100644 src/server/v2.0/restapi/operations/registry/ping_registry_responses.go create mode 100644 src/server/v2.0/restapi/operations/registry/ping_registry_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/registry/update_registry.go create mode 100644 src/server/v2.0/restapi/operations/registry/update_registry_parameters.go create mode 100644 src/server/v2.0/restapi/operations/registry/update_registry_responses.go create mode 100644 src/server/v2.0/restapi/operations/registry/update_registry_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/replication/create_replication_policy.go create mode 100644 src/server/v2.0/restapi/operations/replication/create_replication_policy_parameters.go create mode 100644 src/server/v2.0/restapi/operations/replication/create_replication_policy_responses.go create mode 100644 src/server/v2.0/restapi/operations/replication/create_replication_policy_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/replication/delete_replication_policy.go create mode 100644 src/server/v2.0/restapi/operations/replication/delete_replication_policy_parameters.go create mode 100644 src/server/v2.0/restapi/operations/replication/delete_replication_policy_responses.go create mode 100644 src/server/v2.0/restapi/operations/replication/delete_replication_policy_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/replication/get_replication_execution.go create mode 100644 src/server/v2.0/restapi/operations/replication/get_replication_execution_parameters.go create mode 100644 src/server/v2.0/restapi/operations/replication/get_replication_execution_responses.go create mode 100644 src/server/v2.0/restapi/operations/replication/get_replication_execution_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/replication/get_replication_log.go create mode 100644 src/server/v2.0/restapi/operations/replication/get_replication_log_parameters.go create mode 100644 src/server/v2.0/restapi/operations/replication/get_replication_log_responses.go create mode 100644 src/server/v2.0/restapi/operations/replication/get_replication_log_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/replication/get_replication_policy.go create mode 100644 src/server/v2.0/restapi/operations/replication/get_replication_policy_parameters.go create mode 100644 src/server/v2.0/restapi/operations/replication/get_replication_policy_responses.go create mode 100644 src/server/v2.0/restapi/operations/replication/get_replication_policy_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/replication/list_replication_executions.go create mode 100644 src/server/v2.0/restapi/operations/replication/list_replication_executions_parameters.go create mode 100644 src/server/v2.0/restapi/operations/replication/list_replication_executions_responses.go create mode 100644 src/server/v2.0/restapi/operations/replication/list_replication_executions_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/replication/list_replication_policies.go create mode 100644 src/server/v2.0/restapi/operations/replication/list_replication_policies_parameters.go create mode 100644 src/server/v2.0/restapi/operations/replication/list_replication_policies_responses.go create mode 100644 src/server/v2.0/restapi/operations/replication/list_replication_policies_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/replication/list_replication_tasks.go create mode 100644 src/server/v2.0/restapi/operations/replication/list_replication_tasks_parameters.go create mode 100644 src/server/v2.0/restapi/operations/replication/list_replication_tasks_responses.go create mode 100644 src/server/v2.0/restapi/operations/replication/list_replication_tasks_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/replication/start_replication.go create mode 100644 src/server/v2.0/restapi/operations/replication/start_replication_parameters.go create mode 100644 src/server/v2.0/restapi/operations/replication/start_replication_responses.go create mode 100644 src/server/v2.0/restapi/operations/replication/start_replication_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/replication/stop_replication.go create mode 100644 src/server/v2.0/restapi/operations/replication/stop_replication_parameters.go create mode 100644 src/server/v2.0/restapi/operations/replication/stop_replication_responses.go create mode 100644 src/server/v2.0/restapi/operations/replication/stop_replication_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/replication/update_replication_policy.go create mode 100644 src/server/v2.0/restapi/operations/replication/update_replication_policy_parameters.go create mode 100644 src/server/v2.0/restapi/operations/replication/update_replication_policy_responses.go create mode 100644 src/server/v2.0/restapi/operations/replication/update_replication_policy_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/repository/delete_repository.go create mode 100644 src/server/v2.0/restapi/operations/repository/delete_repository_parameters.go create mode 100644 src/server/v2.0/restapi/operations/repository/delete_repository_responses.go create mode 100644 src/server/v2.0/restapi/operations/repository/delete_repository_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/repository/get_repository.go create mode 100644 src/server/v2.0/restapi/operations/repository/get_repository_parameters.go create mode 100644 src/server/v2.0/restapi/operations/repository/get_repository_responses.go create mode 100644 src/server/v2.0/restapi/operations/repository/get_repository_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/repository/list_all_repositories.go create mode 100644 src/server/v2.0/restapi/operations/repository/list_all_repositories_parameters.go create mode 100644 src/server/v2.0/restapi/operations/repository/list_all_repositories_responses.go create mode 100644 src/server/v2.0/restapi/operations/repository/list_all_repositories_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/repository/list_repositories.go create mode 100644 src/server/v2.0/restapi/operations/repository/list_repositories_parameters.go create mode 100644 src/server/v2.0/restapi/operations/repository/list_repositories_responses.go create mode 100644 src/server/v2.0/restapi/operations/repository/list_repositories_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/repository/update_repository.go create mode 100644 src/server/v2.0/restapi/operations/repository/update_repository_parameters.go create mode 100644 src/server/v2.0/restapi/operations/repository/update_repository_responses.go create mode 100644 src/server/v2.0/restapi/operations/repository/update_repository_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/retention/create_retention.go create mode 100644 src/server/v2.0/restapi/operations/retention/create_retention_parameters.go create mode 100644 src/server/v2.0/restapi/operations/retention/create_retention_responses.go create mode 100644 src/server/v2.0/restapi/operations/retention/create_retention_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/retention/delete_retention.go create mode 100644 src/server/v2.0/restapi/operations/retention/delete_retention_parameters.go create mode 100644 src/server/v2.0/restapi/operations/retention/delete_retention_responses.go create mode 100644 src/server/v2.0/restapi/operations/retention/delete_retention_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/retention/get_rentenition_metadata.go create mode 100644 src/server/v2.0/restapi/operations/retention/get_rentenition_metadata_parameters.go create mode 100644 src/server/v2.0/restapi/operations/retention/get_rentenition_metadata_responses.go create mode 100644 src/server/v2.0/restapi/operations/retention/get_rentenition_metadata_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/retention/get_retention.go create mode 100644 src/server/v2.0/restapi/operations/retention/get_retention_parameters.go create mode 100644 src/server/v2.0/restapi/operations/retention/get_retention_responses.go create mode 100644 src/server/v2.0/restapi/operations/retention/get_retention_task_log.go create mode 100644 src/server/v2.0/restapi/operations/retention/get_retention_task_log_parameters.go create mode 100644 src/server/v2.0/restapi/operations/retention/get_retention_task_log_responses.go create mode 100644 src/server/v2.0/restapi/operations/retention/get_retention_task_log_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/retention/get_retention_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/retention/list_retention_executions.go create mode 100644 src/server/v2.0/restapi/operations/retention/list_retention_executions_parameters.go create mode 100644 src/server/v2.0/restapi/operations/retention/list_retention_executions_responses.go create mode 100644 src/server/v2.0/restapi/operations/retention/list_retention_executions_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/retention/list_retention_tasks.go create mode 100644 src/server/v2.0/restapi/operations/retention/list_retention_tasks_parameters.go create mode 100644 src/server/v2.0/restapi/operations/retention/list_retention_tasks_responses.go create mode 100644 src/server/v2.0/restapi/operations/retention/list_retention_tasks_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/retention/operate_retention_execution.go create mode 100644 src/server/v2.0/restapi/operations/retention/operate_retention_execution_parameters.go create mode 100644 src/server/v2.0/restapi/operations/retention/operate_retention_execution_responses.go create mode 100644 src/server/v2.0/restapi/operations/retention/operate_retention_execution_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/retention/trigger_retention_execution.go create mode 100644 src/server/v2.0/restapi/operations/retention/trigger_retention_execution_parameters.go create mode 100644 src/server/v2.0/restapi/operations/retention/trigger_retention_execution_responses.go create mode 100644 src/server/v2.0/restapi/operations/retention/trigger_retention_execution_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/retention/update_retention.go create mode 100644 src/server/v2.0/restapi/operations/retention/update_retention_parameters.go create mode 100644 src/server/v2.0/restapi/operations/retention/update_retention_responses.go create mode 100644 src/server/v2.0/restapi/operations/retention/update_retention_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/robot/create_robot.go create mode 100644 src/server/v2.0/restapi/operations/robot/create_robot_parameters.go create mode 100644 src/server/v2.0/restapi/operations/robot/create_robot_responses.go create mode 100644 src/server/v2.0/restapi/operations/robot/create_robot_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/robot/delete_robot.go create mode 100644 src/server/v2.0/restapi/operations/robot/delete_robot_parameters.go create mode 100644 src/server/v2.0/restapi/operations/robot/delete_robot_responses.go create mode 100644 src/server/v2.0/restapi/operations/robot/delete_robot_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/robot/get_robot_by_id.go create mode 100644 src/server/v2.0/restapi/operations/robot/get_robot_by_id_parameters.go create mode 100644 src/server/v2.0/restapi/operations/robot/get_robot_by_id_responses.go create mode 100644 src/server/v2.0/restapi/operations/robot/get_robot_by_id_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/robot/list_robot.go create mode 100644 src/server/v2.0/restapi/operations/robot/list_robot_parameters.go create mode 100644 src/server/v2.0/restapi/operations/robot/list_robot_responses.go create mode 100644 src/server/v2.0/restapi/operations/robot/list_robot_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/robot/refresh_sec.go create mode 100644 src/server/v2.0/restapi/operations/robot/refresh_sec_parameters.go create mode 100644 src/server/v2.0/restapi/operations/robot/refresh_sec_responses.go create mode 100644 src/server/v2.0/restapi/operations/robot/refresh_sec_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/robot/update_robot.go create mode 100644 src/server/v2.0/restapi/operations/robot/update_robot_parameters.go create mode 100644 src/server/v2.0/restapi/operations/robot/update_robot_responses.go create mode 100644 src/server/v2.0/restapi/operations/robot/update_robot_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/robotv1/create_robot_v1.go create mode 100644 src/server/v2.0/restapi/operations/robotv1/create_robot_v1_parameters.go create mode 100644 src/server/v2.0/restapi/operations/robotv1/create_robot_v1_responses.go create mode 100644 src/server/v2.0/restapi/operations/robotv1/create_robot_v1_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/robotv1/delete_robot_v1.go create mode 100644 src/server/v2.0/restapi/operations/robotv1/delete_robot_v1_parameters.go create mode 100644 src/server/v2.0/restapi/operations/robotv1/delete_robot_v1_responses.go create mode 100644 src/server/v2.0/restapi/operations/robotv1/delete_robot_v1_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/robotv1/get_robot_by_id_v1.go create mode 100644 src/server/v2.0/restapi/operations/robotv1/get_robot_by_id_v1_parameters.go create mode 100644 src/server/v2.0/restapi/operations/robotv1/get_robot_by_id_v1_responses.go create mode 100644 src/server/v2.0/restapi/operations/robotv1/get_robot_by_id_v1_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/robotv1/list_robot_v1.go create mode 100644 src/server/v2.0/restapi/operations/robotv1/list_robot_v1_parameters.go create mode 100644 src/server/v2.0/restapi/operations/robotv1/list_robot_v1_responses.go create mode 100644 src/server/v2.0/restapi/operations/robotv1/list_robot_v1_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/robotv1/update_robot_v1.go create mode 100644 src/server/v2.0/restapi/operations/robotv1/update_robot_v1_parameters.go create mode 100644 src/server/v2.0/restapi/operations/robotv1/update_robot_v1_responses.go create mode 100644 src/server/v2.0/restapi/operations/robotv1/update_robot_v1_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/scan/get_report_log.go create mode 100644 src/server/v2.0/restapi/operations/scan/get_report_log_parameters.go create mode 100644 src/server/v2.0/restapi/operations/scan/get_report_log_responses.go create mode 100644 src/server/v2.0/restapi/operations/scan/get_report_log_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/scan/scan_artifact.go create mode 100644 src/server/v2.0/restapi/operations/scan/scan_artifact_parameters.go create mode 100644 src/server/v2.0/restapi/operations/scan/scan_artifact_responses.go create mode 100644 src/server/v2.0/restapi/operations/scan/scan_artifact_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/scan/stop_scan_artifact.go create mode 100644 src/server/v2.0/restapi/operations/scan/stop_scan_artifact_parameters.go create mode 100644 src/server/v2.0/restapi/operations/scan/stop_scan_artifact_responses.go create mode 100644 src/server/v2.0/restapi/operations/scan/stop_scan_artifact_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/scan_all/create_scan_all_schedule.go create mode 100644 src/server/v2.0/restapi/operations/scan_all/create_scan_all_schedule_parameters.go create mode 100644 src/server/v2.0/restapi/operations/scan_all/create_scan_all_schedule_responses.go create mode 100644 src/server/v2.0/restapi/operations/scan_all/create_scan_all_schedule_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/scan_all/get_latest_scan_all_metrics.go create mode 100644 src/server/v2.0/restapi/operations/scan_all/get_latest_scan_all_metrics_parameters.go create mode 100644 src/server/v2.0/restapi/operations/scan_all/get_latest_scan_all_metrics_responses.go create mode 100644 src/server/v2.0/restapi/operations/scan_all/get_latest_scan_all_metrics_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/scan_all/get_latest_scheduled_scan_all_metrics.go create mode 100644 src/server/v2.0/restapi/operations/scan_all/get_latest_scheduled_scan_all_metrics_parameters.go create mode 100644 src/server/v2.0/restapi/operations/scan_all/get_latest_scheduled_scan_all_metrics_responses.go create mode 100644 src/server/v2.0/restapi/operations/scan_all/get_latest_scheduled_scan_all_metrics_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/scan_all/get_scan_all_schedule.go create mode 100644 src/server/v2.0/restapi/operations/scan_all/get_scan_all_schedule_parameters.go create mode 100644 src/server/v2.0/restapi/operations/scan_all/get_scan_all_schedule_responses.go create mode 100644 src/server/v2.0/restapi/operations/scan_all/get_scan_all_schedule_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/scan_all/stop_scan_all.go create mode 100644 src/server/v2.0/restapi/operations/scan_all/stop_scan_all_parameters.go create mode 100644 src/server/v2.0/restapi/operations/scan_all/stop_scan_all_responses.go create mode 100644 src/server/v2.0/restapi/operations/scan_all/stop_scan_all_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/scan_all/update_scan_all_schedule.go create mode 100644 src/server/v2.0/restapi/operations/scan_all/update_scan_all_schedule_parameters.go create mode 100644 src/server/v2.0/restapi/operations/scan_all/update_scan_all_schedule_responses.go create mode 100644 src/server/v2.0/restapi/operations/scan_all/update_scan_all_schedule_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/scan_data_export/download_scan_data.go create mode 100644 src/server/v2.0/restapi/operations/scan_data_export/download_scan_data_parameters.go create mode 100644 src/server/v2.0/restapi/operations/scan_data_export/download_scan_data_responses.go create mode 100644 src/server/v2.0/restapi/operations/scan_data_export/download_scan_data_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/scan_data_export/export_scan_data.go create mode 100644 src/server/v2.0/restapi/operations/scan_data_export/export_scan_data_parameters.go create mode 100644 src/server/v2.0/restapi/operations/scan_data_export/export_scan_data_responses.go create mode 100644 src/server/v2.0/restapi/operations/scan_data_export/export_scan_data_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/scan_data_export/get_scan_data_export_execution.go create mode 100644 src/server/v2.0/restapi/operations/scan_data_export/get_scan_data_export_execution_list.go create mode 100644 src/server/v2.0/restapi/operations/scan_data_export/get_scan_data_export_execution_list_parameters.go create mode 100644 src/server/v2.0/restapi/operations/scan_data_export/get_scan_data_export_execution_list_responses.go create mode 100644 src/server/v2.0/restapi/operations/scan_data_export/get_scan_data_export_execution_list_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/scan_data_export/get_scan_data_export_execution_parameters.go create mode 100644 src/server/v2.0/restapi/operations/scan_data_export/get_scan_data_export_execution_responses.go create mode 100644 src/server/v2.0/restapi/operations/scan_data_export/get_scan_data_export_execution_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/scanner/create_scanner.go create mode 100644 src/server/v2.0/restapi/operations/scanner/create_scanner_parameters.go create mode 100644 src/server/v2.0/restapi/operations/scanner/create_scanner_responses.go create mode 100644 src/server/v2.0/restapi/operations/scanner/create_scanner_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/scanner/delete_scanner.go create mode 100644 src/server/v2.0/restapi/operations/scanner/delete_scanner_parameters.go create mode 100644 src/server/v2.0/restapi/operations/scanner/delete_scanner_responses.go create mode 100644 src/server/v2.0/restapi/operations/scanner/delete_scanner_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/scanner/get_scanner.go create mode 100644 src/server/v2.0/restapi/operations/scanner/get_scanner_metadata.go create mode 100644 src/server/v2.0/restapi/operations/scanner/get_scanner_metadata_parameters.go create mode 100644 src/server/v2.0/restapi/operations/scanner/get_scanner_metadata_responses.go create mode 100644 src/server/v2.0/restapi/operations/scanner/get_scanner_metadata_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/scanner/get_scanner_parameters.go create mode 100644 src/server/v2.0/restapi/operations/scanner/get_scanner_responses.go create mode 100644 src/server/v2.0/restapi/operations/scanner/get_scanner_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/scanner/list_scanners.go create mode 100644 src/server/v2.0/restapi/operations/scanner/list_scanners_parameters.go create mode 100644 src/server/v2.0/restapi/operations/scanner/list_scanners_responses.go create mode 100644 src/server/v2.0/restapi/operations/scanner/list_scanners_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/scanner/ping_scanner.go create mode 100644 src/server/v2.0/restapi/operations/scanner/ping_scanner_parameters.go create mode 100644 src/server/v2.0/restapi/operations/scanner/ping_scanner_responses.go create mode 100644 src/server/v2.0/restapi/operations/scanner/ping_scanner_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/scanner/set_scanner_as_default.go create mode 100644 src/server/v2.0/restapi/operations/scanner/set_scanner_as_default_parameters.go create mode 100644 src/server/v2.0/restapi/operations/scanner/set_scanner_as_default_responses.go create mode 100644 src/server/v2.0/restapi/operations/scanner/set_scanner_as_default_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/scanner/update_scanner.go create mode 100644 src/server/v2.0/restapi/operations/scanner/update_scanner_parameters.go create mode 100644 src/server/v2.0/restapi/operations/scanner/update_scanner_responses.go create mode 100644 src/server/v2.0/restapi/operations/scanner/update_scanner_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/schedule/get_schedule_paused.go create mode 100644 src/server/v2.0/restapi/operations/schedule/get_schedule_paused_parameters.go create mode 100644 src/server/v2.0/restapi/operations/schedule/get_schedule_paused_responses.go create mode 100644 src/server/v2.0/restapi/operations/schedule/get_schedule_paused_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/schedule/list_schedules.go create mode 100644 src/server/v2.0/restapi/operations/schedule/list_schedules_parameters.go create mode 100644 src/server/v2.0/restapi/operations/schedule/list_schedules_responses.go create mode 100644 src/server/v2.0/restapi/operations/schedule/list_schedules_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/search/search.go create mode 100644 src/server/v2.0/restapi/operations/search/search_parameters.go create mode 100644 src/server/v2.0/restapi/operations/search/search_responses.go create mode 100644 src/server/v2.0/restapi/operations/search/search_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/statistic/get_statistic.go create mode 100644 src/server/v2.0/restapi/operations/statistic/get_statistic_parameters.go create mode 100644 src/server/v2.0/restapi/operations/statistic/get_statistic_responses.go create mode 100644 src/server/v2.0/restapi/operations/statistic/get_statistic_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/system_cve_allowlist/get_system_cve_allowlist.go create mode 100644 src/server/v2.0/restapi/operations/system_cve_allowlist/get_system_cve_allowlist_parameters.go create mode 100644 src/server/v2.0/restapi/operations/system_cve_allowlist/get_system_cve_allowlist_responses.go create mode 100644 src/server/v2.0/restapi/operations/system_cve_allowlist/get_system_cve_allowlist_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/system_cve_allowlist/put_system_cve_allowlist.go create mode 100644 src/server/v2.0/restapi/operations/system_cve_allowlist/put_system_cve_allowlist_parameters.go create mode 100644 src/server/v2.0/restapi/operations/system_cve_allowlist/put_system_cve_allowlist_responses.go create mode 100644 src/server/v2.0/restapi/operations/system_cve_allowlist/put_system_cve_allowlist_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/systeminfo/get_cert.go create mode 100644 src/server/v2.0/restapi/operations/systeminfo/get_cert_parameters.go create mode 100644 src/server/v2.0/restapi/operations/systeminfo/get_cert_responses.go create mode 100644 src/server/v2.0/restapi/operations/systeminfo/get_cert_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/systeminfo/get_system_info.go create mode 100644 src/server/v2.0/restapi/operations/systeminfo/get_system_info_parameters.go create mode 100644 src/server/v2.0/restapi/operations/systeminfo/get_system_info_responses.go create mode 100644 src/server/v2.0/restapi/operations/systeminfo/get_system_info_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/systeminfo/get_volumes.go create mode 100644 src/server/v2.0/restapi/operations/systeminfo/get_volumes_parameters.go create mode 100644 src/server/v2.0/restapi/operations/systeminfo/get_volumes_responses.go create mode 100644 src/server/v2.0/restapi/operations/systeminfo/get_volumes_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/user/create_user.go create mode 100644 src/server/v2.0/restapi/operations/user/create_user_parameters.go create mode 100644 src/server/v2.0/restapi/operations/user/create_user_responses.go create mode 100644 src/server/v2.0/restapi/operations/user/create_user_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/user/delete_user.go create mode 100644 src/server/v2.0/restapi/operations/user/delete_user_parameters.go create mode 100644 src/server/v2.0/restapi/operations/user/delete_user_responses.go create mode 100644 src/server/v2.0/restapi/operations/user/delete_user_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/user/get_current_user_info.go create mode 100644 src/server/v2.0/restapi/operations/user/get_current_user_info_parameters.go create mode 100644 src/server/v2.0/restapi/operations/user/get_current_user_info_responses.go create mode 100644 src/server/v2.0/restapi/operations/user/get_current_user_info_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/user/get_current_user_permissions.go create mode 100644 src/server/v2.0/restapi/operations/user/get_current_user_permissions_parameters.go create mode 100644 src/server/v2.0/restapi/operations/user/get_current_user_permissions_responses.go create mode 100644 src/server/v2.0/restapi/operations/user/get_current_user_permissions_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/user/get_user.go create mode 100644 src/server/v2.0/restapi/operations/user/get_user_parameters.go create mode 100644 src/server/v2.0/restapi/operations/user/get_user_responses.go create mode 100644 src/server/v2.0/restapi/operations/user/get_user_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/user/list_users.go create mode 100644 src/server/v2.0/restapi/operations/user/list_users_parameters.go create mode 100644 src/server/v2.0/restapi/operations/user/list_users_responses.go create mode 100644 src/server/v2.0/restapi/operations/user/list_users_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/user/search_users.go create mode 100644 src/server/v2.0/restapi/operations/user/search_users_parameters.go create mode 100644 src/server/v2.0/restapi/operations/user/search_users_responses.go create mode 100644 src/server/v2.0/restapi/operations/user/search_users_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/user/set_cli_secret.go create mode 100644 src/server/v2.0/restapi/operations/user/set_cli_secret_parameters.go create mode 100644 src/server/v2.0/restapi/operations/user/set_cli_secret_responses.go create mode 100644 src/server/v2.0/restapi/operations/user/set_cli_secret_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/user/set_user_sys_admin.go create mode 100644 src/server/v2.0/restapi/operations/user/set_user_sys_admin_parameters.go create mode 100644 src/server/v2.0/restapi/operations/user/set_user_sys_admin_responses.go create mode 100644 src/server/v2.0/restapi/operations/user/set_user_sys_admin_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/user/update_user_password.go create mode 100644 src/server/v2.0/restapi/operations/user/update_user_password_parameters.go create mode 100644 src/server/v2.0/restapi/operations/user/update_user_password_responses.go create mode 100644 src/server/v2.0/restapi/operations/user/update_user_password_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/user/update_user_profile.go create mode 100644 src/server/v2.0/restapi/operations/user/update_user_profile_parameters.go create mode 100644 src/server/v2.0/restapi/operations/user/update_user_profile_responses.go create mode 100644 src/server/v2.0/restapi/operations/user/update_user_profile_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/usergroup/create_user_group.go create mode 100644 src/server/v2.0/restapi/operations/usergroup/create_user_group_parameters.go create mode 100644 src/server/v2.0/restapi/operations/usergroup/create_user_group_responses.go create mode 100644 src/server/v2.0/restapi/operations/usergroup/create_user_group_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/usergroup/delete_user_group.go create mode 100644 src/server/v2.0/restapi/operations/usergroup/delete_user_group_parameters.go create mode 100644 src/server/v2.0/restapi/operations/usergroup/delete_user_group_responses.go create mode 100644 src/server/v2.0/restapi/operations/usergroup/delete_user_group_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/usergroup/get_user_group.go create mode 100644 src/server/v2.0/restapi/operations/usergroup/get_user_group_parameters.go create mode 100644 src/server/v2.0/restapi/operations/usergroup/get_user_group_responses.go create mode 100644 src/server/v2.0/restapi/operations/usergroup/get_user_group_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/usergroup/list_user_groups.go create mode 100644 src/server/v2.0/restapi/operations/usergroup/list_user_groups_parameters.go create mode 100644 src/server/v2.0/restapi/operations/usergroup/list_user_groups_responses.go create mode 100644 src/server/v2.0/restapi/operations/usergroup/list_user_groups_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/usergroup/search_user_groups.go create mode 100644 src/server/v2.0/restapi/operations/usergroup/search_user_groups_parameters.go create mode 100644 src/server/v2.0/restapi/operations/usergroup/search_user_groups_responses.go create mode 100644 src/server/v2.0/restapi/operations/usergroup/search_user_groups_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/usergroup/update_user_group.go create mode 100644 src/server/v2.0/restapi/operations/usergroup/update_user_group_parameters.go create mode 100644 src/server/v2.0/restapi/operations/usergroup/update_user_group_responses.go create mode 100644 src/server/v2.0/restapi/operations/usergroup/update_user_group_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/webhook/create_webhook_policy_of_project.go create mode 100644 src/server/v2.0/restapi/operations/webhook/create_webhook_policy_of_project_parameters.go create mode 100644 src/server/v2.0/restapi/operations/webhook/create_webhook_policy_of_project_responses.go create mode 100644 src/server/v2.0/restapi/operations/webhook/create_webhook_policy_of_project_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/webhook/delete_webhook_policy_of_project.go create mode 100644 src/server/v2.0/restapi/operations/webhook/delete_webhook_policy_of_project_parameters.go create mode 100644 src/server/v2.0/restapi/operations/webhook/delete_webhook_policy_of_project_responses.go create mode 100644 src/server/v2.0/restapi/operations/webhook/delete_webhook_policy_of_project_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/webhook/get_supported_event_types.go create mode 100644 src/server/v2.0/restapi/operations/webhook/get_supported_event_types_parameters.go create mode 100644 src/server/v2.0/restapi/operations/webhook/get_supported_event_types_responses.go create mode 100644 src/server/v2.0/restapi/operations/webhook/get_supported_event_types_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/webhook/get_webhook_policy_of_project.go create mode 100644 src/server/v2.0/restapi/operations/webhook/get_webhook_policy_of_project_parameters.go create mode 100644 src/server/v2.0/restapi/operations/webhook/get_webhook_policy_of_project_responses.go create mode 100644 src/server/v2.0/restapi/operations/webhook/get_webhook_policy_of_project_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/webhook/last_trigger.go create mode 100644 src/server/v2.0/restapi/operations/webhook/last_trigger_parameters.go create mode 100644 src/server/v2.0/restapi/operations/webhook/last_trigger_responses.go create mode 100644 src/server/v2.0/restapi/operations/webhook/last_trigger_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/webhook/list_webhook_policies_of_project.go create mode 100644 src/server/v2.0/restapi/operations/webhook/list_webhook_policies_of_project_parameters.go create mode 100644 src/server/v2.0/restapi/operations/webhook/list_webhook_policies_of_project_responses.go create mode 100644 src/server/v2.0/restapi/operations/webhook/list_webhook_policies_of_project_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/webhook/update_webhook_policy_of_project.go create mode 100644 src/server/v2.0/restapi/operations/webhook/update_webhook_policy_of_project_parameters.go create mode 100644 src/server/v2.0/restapi/operations/webhook/update_webhook_policy_of_project_responses.go create mode 100644 src/server/v2.0/restapi/operations/webhook/update_webhook_policy_of_project_urlbuilder.go create mode 100644 src/server/v2.0/restapi/operations/webhookjob/list_webhook_jobs.go create mode 100644 src/server/v2.0/restapi/operations/webhookjob/list_webhook_jobs_parameters.go create mode 100644 src/server/v2.0/restapi/operations/webhookjob/list_webhook_jobs_responses.go create mode 100644 src/server/v2.0/restapi/operations/webhookjob/list_webhook_jobs_urlbuilder.go create mode 100644 src/server/v2.0/restapi/server.go diff --git a/src/server/v2.0/models/access.go b/src/server/v2.0/models/access.go new file mode 100644 index 000000000..8009da80b --- /dev/null +++ b/src/server/v2.0/models/access.go @@ -0,0 +1,49 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// Access access +// +// swagger:model Access +type Access struct { + + // The action of the access + Action string `json:"action,omitempty"` + + // The effect of the access + Effect string `json:"effect,omitempty"` + + // The resource of the access + Resource string `json:"resource,omitempty"` +} + +// Validate validates this access +func (m *Access) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *Access) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Access) UnmarshalBinary(b []byte) error { + var res Access + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/accessory.go b/src/server/v2.0/models/accessory.go new file mode 100644 index 000000000..5be00d7e7 --- /dev/null +++ b/src/server/v2.0/models/accessory.go @@ -0,0 +1,89 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// Accessory The accessory of the artifact +// +// swagger:model Accessory +type Accessory struct { + + // The artifact id of the accessory + ArtifactID int64 `json:"artifact_id"` + + // The creation time of the accessory + // Format: date-time + CreationTime strfmt.DateTime `json:"creation_time,omitempty"` + + // The artifact digest of the accessory + Digest string `json:"digest"` + + // The icon of the accessory + Icon string `json:"icon"` + + // The ID of the accessory + ID int64 `json:"id,omitempty"` + + // The artifact size of the accessory + Size int64 `json:"size"` + + // The subject artifact id of the accessory + SubjectArtifactID int64 `json:"subject_artifact_id"` + + // The artifact size of the accessory + Type string `json:"type"` +} + +// Validate validates this accessory +func (m *Accessory) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCreationTime(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Accessory) validateCreationTime(formats strfmt.Registry) error { + + if swag.IsZero(m.CreationTime) { // not required + return nil + } + + if err := validate.FormatOf("creation_time", "body", "date-time", m.CreationTime.String(), formats); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Accessory) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Accessory) UnmarshalBinary(b []byte) error { + var res Accessory + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/action_request.go b/src/server/v2.0/models/action_request.go new file mode 100644 index 000000000..83e916355 --- /dev/null +++ b/src/server/v2.0/models/action_request.go @@ -0,0 +1,103 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ActionRequest The request to stop, pause or resume +// +// swagger:model ActionRequest +type ActionRequest struct { + + // The action of the request, should be stop, pause or resume + // Enum: [stop pause resume] + Action string `json:"action,omitempty"` +} + +// Validate validates this action request +func (m *ActionRequest) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAction(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +var actionRequestTypeActionPropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["stop","pause","resume"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + actionRequestTypeActionPropEnum = append(actionRequestTypeActionPropEnum, v) + } +} + +const ( + + // ActionRequestActionStop captures enum value "stop" + ActionRequestActionStop string = "stop" + + // ActionRequestActionPause captures enum value "pause" + ActionRequestActionPause string = "pause" + + // ActionRequestActionResume captures enum value "resume" + ActionRequestActionResume string = "resume" +) + +// prop value enum +func (m *ActionRequest) validateActionEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, actionRequestTypeActionPropEnum, true); err != nil { + return err + } + return nil +} + +func (m *ActionRequest) validateAction(formats strfmt.Registry) error { + + if swag.IsZero(m.Action) { // not required + return nil + } + + // value enum + if err := m.validateActionEnum("action", "body", m.Action); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ActionRequest) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ActionRequest) UnmarshalBinary(b []byte) error { + var res ActionRequest + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/addition_link.go b/src/server/v2.0/models/addition_link.go new file mode 100644 index 000000000..db6ff18f2 --- /dev/null +++ b/src/server/v2.0/models/addition_link.go @@ -0,0 +1,46 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// AdditionLink addition link +// +// swagger:model AdditionLink +type AdditionLink struct { + + // Determine whether the link is an absolute URL or not + Absolute bool `json:"absolute"` + + // The link of the addition + Href string `json:"href,omitempty"` +} + +// Validate validates this addition link +func (m *AdditionLink) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *AdditionLink) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *AdditionLink) UnmarshalBinary(b []byte) error { + var res AdditionLink + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/addition_links.go b/src/server/v2.0/models/addition_links.go new file mode 100644 index 000000000..d5f50aab3 --- /dev/null +++ b/src/server/v2.0/models/addition_links.go @@ -0,0 +1,40 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// AdditionLinks addition links +// +// swagger:model AdditionLinks +type AdditionLinks map[string]AdditionLink + +// Validate validates this addition links +func (m AdditionLinks) Validate(formats strfmt.Registry) error { + var res []error + + for k := range m { + + if err := validate.Required(k, "body", m[k]); err != nil { + return err + } + if val, ok := m[k]; ok { + if err := val.Validate(formats); err != nil { + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/src/server/v2.0/models/annotations.go b/src/server/v2.0/models/annotations.go new file mode 100644 index 000000000..8e5adf28e --- /dev/null +++ b/src/server/v2.0/models/annotations.go @@ -0,0 +1,20 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" +) + +// Annotations annotations +// +// swagger:model Annotations +type Annotations map[string]string + +// Validate validates this annotations +func (m Annotations) Validate(formats strfmt.Registry) error { + return nil +} diff --git a/src/server/v2.0/models/artifact.go b/src/server/v2.0/models/artifact.go new file mode 100644 index 000000000..8144740e0 --- /dev/null +++ b/src/server/v2.0/models/artifact.go @@ -0,0 +1,338 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// Artifact artifact +// +// swagger:model Artifact +type Artifact struct { + + // accessories + Accessories []*Accessory `json:"accessories"` + + // addition links + AdditionLinks AdditionLinks `json:"addition_links,omitempty"` + + // annotations + Annotations Annotations `json:"annotations,omitempty"` + + // The digest of the artifact + Digest string `json:"digest,omitempty"` + + // extra attrs + ExtraAttrs ExtraAttrs `json:"extra_attrs,omitempty"` + + // The digest of the icon + Icon string `json:"icon,omitempty"` + + // The ID of the artifact + ID int64 `json:"id,omitempty"` + + // labels + Labels []*Label `json:"labels"` + + // The manifest media type of the artifact + ManifestMediaType string `json:"manifest_media_type,omitempty"` + + // The media type of the artifact + MediaType string `json:"media_type,omitempty"` + + // The ID of the project that the artifact belongs to + ProjectID int64 `json:"project_id,omitempty"` + + // The latest pull time of the artifact + // Format: date-time + PullTime strfmt.DateTime `json:"pull_time,omitempty"` + + // The push time of the artifact + // Format: date-time + PushTime strfmt.DateTime `json:"push_time,omitempty"` + + // references + References []*Reference `json:"references"` + + // The ID of the repository that the artifact belongs to + RepositoryID int64 `json:"repository_id,omitempty"` + + // The overview of the scan result. + ScanOverview ScanOverview `json:"scan_overview,omitempty"` + + // The size of the artifact + Size int64 `json:"size,omitempty"` + + // tags + Tags []*Tag `json:"tags"` + + // The type of the artifact, e.g. image, chart, etc + Type string `json:"type,omitempty"` +} + +// Validate validates this artifact +func (m *Artifact) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAccessories(formats); err != nil { + res = append(res, err) + } + + if err := m.validateAdditionLinks(formats); err != nil { + res = append(res, err) + } + + if err := m.validateAnnotations(formats); err != nil { + res = append(res, err) + } + + if err := m.validateExtraAttrs(formats); err != nil { + res = append(res, err) + } + + if err := m.validateLabels(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePullTime(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePushTime(formats); err != nil { + res = append(res, err) + } + + if err := m.validateReferences(formats); err != nil { + res = append(res, err) + } + + if err := m.validateScanOverview(formats); err != nil { + res = append(res, err) + } + + if err := m.validateTags(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Artifact) validateAccessories(formats strfmt.Registry) error { + + if swag.IsZero(m.Accessories) { // not required + return nil + } + + for i := 0; i < len(m.Accessories); i++ { + if swag.IsZero(m.Accessories[i]) { // not required + continue + } + + if m.Accessories[i] != nil { + if err := m.Accessories[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("accessories" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *Artifact) validateAdditionLinks(formats strfmt.Registry) error { + + if swag.IsZero(m.AdditionLinks) { // not required + return nil + } + + if err := m.AdditionLinks.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("addition_links") + } + return err + } + + return nil +} + +func (m *Artifact) validateAnnotations(formats strfmt.Registry) error { + + if swag.IsZero(m.Annotations) { // not required + return nil + } + + if err := m.Annotations.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("annotations") + } + return err + } + + return nil +} + +func (m *Artifact) validateExtraAttrs(formats strfmt.Registry) error { + + if swag.IsZero(m.ExtraAttrs) { // not required + return nil + } + + if err := m.ExtraAttrs.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("extra_attrs") + } + return err + } + + return nil +} + +func (m *Artifact) validateLabels(formats strfmt.Registry) error { + + if swag.IsZero(m.Labels) { // not required + return nil + } + + for i := 0; i < len(m.Labels); i++ { + if swag.IsZero(m.Labels[i]) { // not required + continue + } + + if m.Labels[i] != nil { + if err := m.Labels[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("labels" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *Artifact) validatePullTime(formats strfmt.Registry) error { + + if swag.IsZero(m.PullTime) { // not required + return nil + } + + if err := validate.FormatOf("pull_time", "body", "date-time", m.PullTime.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *Artifact) validatePushTime(formats strfmt.Registry) error { + + if swag.IsZero(m.PushTime) { // not required + return nil + } + + if err := validate.FormatOf("push_time", "body", "date-time", m.PushTime.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *Artifact) validateReferences(formats strfmt.Registry) error { + + if swag.IsZero(m.References) { // not required + return nil + } + + for i := 0; i < len(m.References); i++ { + if swag.IsZero(m.References[i]) { // not required + continue + } + + if m.References[i] != nil { + if err := m.References[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("references" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *Artifact) validateScanOverview(formats strfmt.Registry) error { + + if swag.IsZero(m.ScanOverview) { // not required + return nil + } + + if err := m.ScanOverview.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("scan_overview") + } + return err + } + + return nil +} + +func (m *Artifact) validateTags(formats strfmt.Registry) error { + + if swag.IsZero(m.Tags) { // not required + return nil + } + + for i := 0; i < len(m.Tags); i++ { + if swag.IsZero(m.Tags[i]) { // not required + continue + } + + if m.Tags[i] != nil { + if err := m.Tags[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("tags" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Artifact) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Artifact) UnmarshalBinary(b []byte) error { + var res Artifact + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/audit_log.go b/src/server/v2.0/models/audit_log.go new file mode 100644 index 000000000..ce8754d17 --- /dev/null +++ b/src/server/v2.0/models/audit_log.go @@ -0,0 +1,83 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// AuditLog audit log +// +// swagger:model AuditLog +type AuditLog struct { + + // The ID of the audit log entry. + ID int64 `json:"id,omitempty"` + + // The time when this operation is triggered. + // Format: date-time + OpTime strfmt.DateTime `json:"op_time,omitempty"` + + // The operation against the repository in this log entry. + Operation string `json:"operation,omitempty"` + + // Name of the repository in this log entry. + Resource string `json:"resource,omitempty"` + + // Tag of the repository in this log entry. + ResourceType string `json:"resource_type,omitempty"` + + // Username of the user in this log entry. + Username string `json:"username,omitempty"` +} + +// Validate validates this audit log +func (m *AuditLog) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateOpTime(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *AuditLog) validateOpTime(formats strfmt.Registry) error { + + if swag.IsZero(m.OpTime) { // not required + return nil + } + + if err := validate.FormatOf("op_time", "body", "date-time", m.OpTime.String(), formats); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *AuditLog) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *AuditLog) UnmarshalBinary(b []byte) error { + var res AuditLog + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/authproxy_setting.go b/src/server/v2.0/models/authproxy_setting.go new file mode 100644 index 000000000..28aa5f20f --- /dev/null +++ b/src/server/v2.0/models/authproxy_setting.go @@ -0,0 +1,55 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// AuthproxySetting authproxy setting +// +// swagger:model AuthproxySetting +type AuthproxySetting struct { + + // The fully qualified URI of login endpoint of authproxy, such as 'https://192.168.1.2:8443/login' + Endpoint string `json:"endpoint,omitempty"` + + // The certificate to be pinned when connecting auth proxy. + ServerCertificate string `json:"server_certificate,omitempty"` + + // The flag to determine whether Harbor can skip search the user/group when adding him as a member. + SkipSearch bool `json:"skip_search,omitempty"` + + // The fully qualified URI of token review endpoint of authproxy, such as 'https://192.168.1.2:8443/tokenreview' + TokenreivewEndpoint string `json:"tokenreivew_endpoint,omitempty"` + + // The flag to determine whether Harbor should verify the certificate when connecting to the auth proxy. + VerifyCert bool `json:"verify_cert,omitempty"` +} + +// Validate validates this authproxy setting +func (m *AuthproxySetting) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *AuthproxySetting) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *AuthproxySetting) UnmarshalBinary(b []byte) error { + var res AuthproxySetting + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/bool_config_item.go b/src/server/v2.0/models/bool_config_item.go new file mode 100644 index 000000000..1d5a92cc1 --- /dev/null +++ b/src/server/v2.0/models/bool_config_item.go @@ -0,0 +1,46 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// BoolConfigItem bool config item +// +// swagger:model BoolConfigItem +type BoolConfigItem struct { + + // The configure item can be updated or not + Editable bool `json:"editable"` + + // The boolean value of current config item + Value bool `json:"value"` +} + +// Validate validates this bool config item +func (m *BoolConfigItem) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *BoolConfigItem) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *BoolConfigItem) UnmarshalBinary(b []byte) error { + var res BoolConfigItem + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/chart_metadata.go b/src/server/v2.0/models/chart_metadata.go new file mode 100644 index 000000000..ff3a351ad --- /dev/null +++ b/src/server/v2.0/models/chart_metadata.go @@ -0,0 +1,164 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ChartMetadata The metadata of chart version +// +// swagger:model ChartMetadata +type ChartMetadata struct { + + // The API version of this chart + // Required: true + APIVersion *string `json:"apiVersion"` + + // The version of the application enclosed in the chart + // Required: true + AppVersion *string `json:"appVersion"` + + // Whether or not this chart is deprecated + Deprecated bool `json:"deprecated,omitempty"` + + // A one-sentence description of chart + Description string `json:"description,omitempty"` + + // The name of template engine + // Required: true + Engine *string `json:"engine"` + + // The URL to the relevant project page + Home string `json:"home,omitempty"` + + // The URL to an icon file + // Required: true + Icon *string `json:"icon"` + + // A list of string keywords + Keywords []string `json:"keywords"` + + // The name of the chart + // Required: true + Name *string `json:"name"` + + // The URL to the source code of chart + Sources []string `json:"sources"` + + // A SemVer 2 version of chart + // Required: true + Version *string `json:"version"` +} + +// Validate validates this chart metadata +func (m *ChartMetadata) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAPIVersion(formats); err != nil { + res = append(res, err) + } + + if err := m.validateAppVersion(formats); err != nil { + res = append(res, err) + } + + if err := m.validateEngine(formats); err != nil { + res = append(res, err) + } + + if err := m.validateIcon(formats); err != nil { + res = append(res, err) + } + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateVersion(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ChartMetadata) validateAPIVersion(formats strfmt.Registry) error { + + if err := validate.Required("apiVersion", "body", m.APIVersion); err != nil { + return err + } + + return nil +} + +func (m *ChartMetadata) validateAppVersion(formats strfmt.Registry) error { + + if err := validate.Required("appVersion", "body", m.AppVersion); err != nil { + return err + } + + return nil +} + +func (m *ChartMetadata) validateEngine(formats strfmt.Registry) error { + + if err := validate.Required("engine", "body", m.Engine); err != nil { + return err + } + + return nil +} + +func (m *ChartMetadata) validateIcon(formats strfmt.Registry) error { + + if err := validate.Required("icon", "body", m.Icon); err != nil { + return err + } + + return nil +} + +func (m *ChartMetadata) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + return nil +} + +func (m *ChartMetadata) validateVersion(formats strfmt.Registry) error { + + if err := validate.Required("version", "body", m.Version); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ChartMetadata) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ChartMetadata) UnmarshalBinary(b []byte) error { + var res ChartMetadata + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/chart_version.go b/src/server/v2.0/models/chart_version.go new file mode 100644 index 000000000..46642c0fb --- /dev/null +++ b/src/server/v2.0/models/chart_version.go @@ -0,0 +1,188 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// ChartVersion A specified chart entry +// +// swagger:model ChartVersion +type ChartVersion struct { + ChartMetadata + + // The created time of the chart entry + Created string `json:"created,omitempty"` + + // The digest value of the chart entry + Digest string `json:"digest,omitempty"` + + // A flag to indicate if the chart entry is removed + Removed bool `json:"removed,omitempty"` + + // The urls of the chart entry + Urls []string `json:"urls"` + + // A list of label + Labels []*Label `json:"labels"` +} + +// UnmarshalJSON unmarshals this object from a JSON structure +func (m *ChartVersion) UnmarshalJSON(raw []byte) error { + // AO0 + var aO0 ChartMetadata + if err := swag.ReadJSON(raw, &aO0); err != nil { + return err + } + m.ChartMetadata = aO0 + + // AO1 + var dataAO1 struct { + Created string `json:"created,omitempty"` + + Digest string `json:"digest,omitempty"` + + Removed bool `json:"removed,omitempty"` + + Urls []string `json:"urls"` + } + if err := swag.ReadJSON(raw, &dataAO1); err != nil { + return err + } + + m.Created = dataAO1.Created + + m.Digest = dataAO1.Digest + + m.Removed = dataAO1.Removed + + m.Urls = dataAO1.Urls + + // now for regular properties + var propsChartVersion struct { + Labels []*Label `json:"labels"` + } + if err := swag.ReadJSON(raw, &propsChartVersion); err != nil { + return err + } + m.Labels = propsChartVersion.Labels + + return nil +} + +// MarshalJSON marshals this object to a JSON structure +func (m ChartVersion) MarshalJSON() ([]byte, error) { + _parts := make([][]byte, 0, 2) + + aO0, err := swag.WriteJSON(m.ChartMetadata) + if err != nil { + return nil, err + } + _parts = append(_parts, aO0) + var dataAO1 struct { + Created string `json:"created,omitempty"` + + Digest string `json:"digest,omitempty"` + + Removed bool `json:"removed,omitempty"` + + Urls []string `json:"urls"` + } + + dataAO1.Created = m.Created + + dataAO1.Digest = m.Digest + + dataAO1.Removed = m.Removed + + dataAO1.Urls = m.Urls + + jsonDataAO1, errAO1 := swag.WriteJSON(dataAO1) + if errAO1 != nil { + return nil, errAO1 + } + _parts = append(_parts, jsonDataAO1) + + // now for regular properties + var propsChartVersion struct { + Labels []*Label `json:"labels"` + } + propsChartVersion.Labels = m.Labels + + jsonDataPropsChartVersion, errChartVersion := swag.WriteJSON(propsChartVersion) + if errChartVersion != nil { + return nil, errChartVersion + } + _parts = append(_parts, jsonDataPropsChartVersion) + return swag.ConcatJSON(_parts...), nil +} + +// Validate validates this chart version +func (m *ChartVersion) Validate(formats strfmt.Registry) error { + var res []error + + // validation for a type composition with ChartMetadata + if err := m.ChartMetadata.Validate(formats); err != nil { + res = append(res, err) + } + + if err := m.validateLabels(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ChartVersion) validateLabels(formats strfmt.Registry) error { + + if swag.IsZero(m.Labels) { // not required + return nil + } + + for i := 0; i < len(m.Labels); i++ { + if swag.IsZero(m.Labels[i]) { // not required + continue + } + + if m.Labels[i] != nil { + if err := m.Labels[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("labels" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ChartVersion) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ChartVersion) UnmarshalBinary(b []byte) error { + var res ChartVersion + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/component_health_status.go b/src/server/v2.0/models/component_health_status.go new file mode 100644 index 000000000..127bf3864 --- /dev/null +++ b/src/server/v2.0/models/component_health_status.go @@ -0,0 +1,49 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// ComponentHealthStatus The health status of component +// +// swagger:model ComponentHealthStatus +type ComponentHealthStatus struct { + + // (optional) The error message when the status is "unhealthy" + Error string `json:"error,omitempty"` + + // The component name + Name string `json:"name,omitempty"` + + // The health status of component + Status string `json:"status,omitempty"` +} + +// Validate validates this component health status +func (m *ComponentHealthStatus) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ComponentHealthStatus) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ComponentHealthStatus) UnmarshalBinary(b []byte) error { + var res ComponentHealthStatus + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/configurations.go b/src/server/v2.0/models/configurations.go new file mode 100644 index 000000000..10f82a244 --- /dev/null +++ b/src/server/v2.0/models/configurations.go @@ -0,0 +1,193 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// Configurations configurations +// +// swagger:model Configurations +type Configurations struct { + + // The audit log forward endpoint + AuditLogForwardEndpoint *string `json:"audit_log_forward_endpoint,omitempty"` + + // The auth mode of current system, such as "db_auth", "ldap_auth", "oidc_auth" + AuthMode *string `json:"auth_mode,omitempty"` + + // The group which has the harbor admin privileges + HTTPAuthproxyAdminGroups *string `json:"http_authproxy_admin_groups,omitempty"` + + // The username which has the harbor admin privileges + HTTPAuthproxyAdminUsernames *string `json:"http_authproxy_admin_usernames,omitempty"` + + // The endpoint of the HTTP auth + HTTPAuthproxyEndpoint *string `json:"http_authproxy_endpoint,omitempty"` + + // The certificate of the HTTP auth provider + HTTPAuthproxyServerCertificate *string `json:"http_authproxy_server_certificate,omitempty"` + + // Search user before onboard + HTTPAuthproxySkipSearch *bool `json:"http_authproxy_skip_search,omitempty"` + + // The token review endpoint + HTTPAuthproxyTokenreviewEndpoint *string `json:"http_authproxy_tokenreview_endpoint,omitempty"` + + // Verify the HTTP auth provider's certificate + HTTPAuthproxyVerifyCert *bool `json:"http_authproxy_verify_cert,omitempty"` + + // The Base DN for LDAP binding. + LdapBaseDn *string `json:"ldap_base_dn,omitempty"` + + // The filter for LDAP search + LdapFilter *string `json:"ldap_filter,omitempty"` + + // Specify the ldap group which have the same privilege with Harbor admin + LdapGroupAdminDn *string `json:"ldap_group_admin_dn,omitempty"` + + // The attribute which is used as identity of the LDAP group, default is cn.' + LdapGroupAttributeName *string `json:"ldap_group_attribute_name,omitempty"` + + // The base DN to search LDAP group. + LdapGroupBaseDn *string `json:"ldap_group_base_dn,omitempty"` + + // The user attribute to identify the group membership + LdapGroupMembershipAttribute *string `json:"ldap_group_membership_attribute,omitempty"` + + // The filter to search the ldap group + LdapGroupSearchFilter *string `json:"ldap_group_search_filter,omitempty"` + + // The scope to search ldap group. ''0-LDAP_SCOPE_BASE, 1-LDAP_SCOPE_ONELEVEL, 2-LDAP_SCOPE_SUBTREE'' + LdapGroupSearchScope *int64 `json:"ldap_group_search_scope,omitempty"` + + // The scope to search ldap users,'0-LDAP_SCOPE_BASE, 1-LDAP_SCOPE_ONELEVEL, 2-LDAP_SCOPE_SUBTREE' + LdapScope *int64 `json:"ldap_scope,omitempty"` + + // The DN of the user to do the search. + LdapSearchDn *string `json:"ldap_search_dn,omitempty"` + + // The password of the ldap search dn + LdapSearchPassword *string `json:"ldap_search_password,omitempty"` + + // Timeout in seconds for connection to LDAP server + LdapTimeout *int64 `json:"ldap_timeout,omitempty"` + + // The attribute which is used as identity for the LDAP binding, such as "CN" or "SAMAccountname" + LdapUID *string `json:"ldap_uid,omitempty"` + + // The URL of LDAP server + LdapURL *string `json:"ldap_url,omitempty"` + + // Whether verify your OIDC server certificate, disable it if your OIDC server is hosted via self-hosted certificate. + LdapVerifyCert *bool `json:"ldap_verify_cert,omitempty"` + + // Enable notification + NotificationEnable *bool `json:"notification_enable,omitempty"` + + // The OIDC group which has the harbor admin privileges + OIDCAdminGroup *string `json:"oidc_admin_group,omitempty"` + + // Auto onboard the OIDC user + OIDCAutoOnboard *bool `json:"oidc_auto_onboard,omitempty"` + + // The client ID of the OIDC provider + OIDCClientID *string `json:"oidc_client_id,omitempty"` + + // The OIDC provider secret + OIDCClientSecret *string `json:"oidc_client_secret,omitempty"` + + // The endpoint of the OIDC provider + OIDCEndpoint *string `json:"oidc_endpoint,omitempty"` + + // Extra parameters to add when redirect request to OIDC provider + OIDCExtraRedirectParms *string `json:"oidc_extra_redirect_parms,omitempty"` + + // The OIDC group filter which filters out the group name doesn't match the regular expression + OIDCGroupFilter *string `json:"oidc_group_filter,omitempty"` + + // The attribute claims the group name + OIDCGroupsClaim *string `json:"oidc_groups_claim,omitempty"` + + // The OIDC provider name + OIDCName *string `json:"oidc_name,omitempty"` + + // The scope of the OIDC provider + OIDCScope *string `json:"oidc_scope,omitempty"` + + // The attribute claims the username + OIDCUserClaim *string `json:"oidc_user_claim,omitempty"` + + // Verify the OIDC provider's certificate' + OIDCVerifyCert *bool `json:"oidc_verify_cert,omitempty"` + + // Indicate who can create projects, it could be ''adminonly'' or ''everyone''. + ProjectCreationRestriction *string `json:"project_creation_restriction,omitempty"` + + // Enable quota per project + QuotaPerProjectEnable *bool `json:"quota_per_project_enable,omitempty"` + + // The flag to indicate whether Harbor is in readonly mode. + ReadOnly *bool `json:"read_only,omitempty"` + + // The rebot account name prefix + RobotNamePrefix *string `json:"robot_name_prefix,omitempty"` + + // The robot account token duration in days + RobotTokenDuration *int64 `json:"robot_token_duration,omitempty"` + + // Whether the Harbor instance supports self-registration. If it''s set to false, admin need to add user to the instance. + SelfRegistration *bool `json:"self_registration,omitempty"` + + // The session timeout for harbor, in minutes. + SessionTimeout *int64 `json:"session_timeout,omitempty"` + + // Skip audit log database + SkipAuditLogDatabase *bool `json:"skip_audit_log_database,omitempty"` + + // The storage quota per project + StoragePerProject *int64 `json:"storage_per_project,omitempty"` + + // The expiration time of the token for internal Registry, in minutes. + TokenExpiration *int64 `json:"token_expiration,omitempty"` + + // The client id of UAA + UaaClientID *string `json:"uaa_client_id,omitempty"` + + // The client secret of the UAA + UaaClientSecret *string `json:"uaa_client_secret,omitempty"` + + // The endpoint of the UAA + UaaEndpoint *string `json:"uaa_endpoint,omitempty"` + + // Verify the certificate in UAA server + UaaVerifyCert *bool `json:"uaa_verify_cert,omitempty"` +} + +// Validate validates this configurations +func (m *Configurations) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *Configurations) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Configurations) UnmarshalBinary(b []byte) error { + var res Configurations + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/configurations_response.go b/src/server/v2.0/models/configurations_response.go new file mode 100644 index 000000000..3fe39477d --- /dev/null +++ b/src/server/v2.0/models/configurations_response.go @@ -0,0 +1,1390 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// ConfigurationsResponse configurations response +// +// swagger:model ConfigurationsResponse +type ConfigurationsResponse struct { + + // The endpoint of the audit log forwarder + AuditLogForwardEndpoint *StringConfigItem `json:"audit_log_forward_endpoint,omitempty"` + + // The auth mode of current system, such as "db_auth", "ldap_auth", "oidc_auth" + AuthMode *StringConfigItem `json:"auth_mode,omitempty"` + + // The group which has the harbor admin privileges + HTTPAuthproxyAdminGroups *StringConfigItem `json:"http_authproxy_admin_groups,omitempty"` + + // The usernames which has the harbor admin privileges + HTTPAuthproxyAdminUsernames *StringConfigItem `json:"http_authproxy_admin_usernames,omitempty"` + + // The endpoint of the HTTP auth + HTTPAuthproxyEndpoint *StringConfigItem `json:"http_authproxy_endpoint,omitempty"` + + // The certificate of the HTTP auth provider + HTTPAuthproxyServerCertificate *StringConfigItem `json:"http_authproxy_server_certificate,omitempty"` + + // Search user before onboard + HTTPAuthproxySkipSearch *BoolConfigItem `json:"http_authproxy_skip_search,omitempty"` + + // The token review endpoint + HTTPAuthproxyTokenreviewEndpoint *StringConfigItem `json:"http_authproxy_tokenreview_endpoint,omitempty"` + + // Verify the HTTP auth provider's certificate + HTTPAuthproxyVerifyCert *BoolConfigItem `json:"http_authproxy_verify_cert,omitempty"` + + // The Base DN for LDAP binding. + LdapBaseDn *StringConfigItem `json:"ldap_base_dn,omitempty"` + + // The filter for LDAP search + LdapFilter *StringConfigItem `json:"ldap_filter,omitempty"` + + // Specify the ldap group which have the same privilege with Harbor admin + LdapGroupAdminDn *StringConfigItem `json:"ldap_group_admin_dn,omitempty"` + + // The attribute which is used as identity of the LDAP group, default is cn.' + LdapGroupAttributeName *StringConfigItem `json:"ldap_group_attribute_name,omitempty"` + + // The base DN to search LDAP group. + LdapGroupBaseDn *StringConfigItem `json:"ldap_group_base_dn,omitempty"` + + // The user attribute to identify the group membership + LdapGroupMembershipAttribute *StringConfigItem `json:"ldap_group_membership_attribute,omitempty"` + + // The filter to search the ldap group + LdapGroupSearchFilter *StringConfigItem `json:"ldap_group_search_filter,omitempty"` + + // The scope to search ldap group. ''0-LDAP_SCOPE_BASE, 1-LDAP_SCOPE_ONELEVEL, 2-LDAP_SCOPE_SUBTREE'' + LdapGroupSearchScope *IntegerConfigItem `json:"ldap_group_search_scope,omitempty"` + + // The scope to search ldap users,'0-LDAP_SCOPE_BASE, 1-LDAP_SCOPE_ONELEVEL, 2-LDAP_SCOPE_SUBTREE' + LdapScope *IntegerConfigItem `json:"ldap_scope,omitempty"` + + // The DN of the user to do the search. + LdapSearchDn *StringConfigItem `json:"ldap_search_dn,omitempty"` + + // Timeout in seconds for connection to LDAP server + LdapTimeout *IntegerConfigItem `json:"ldap_timeout,omitempty"` + + // The attribute which is used as identity for the LDAP binding, such as "CN" or "SAMAccountname" + LdapUID *StringConfigItem `json:"ldap_uid,omitempty"` + + // The URL of LDAP server + LdapURL *StringConfigItem `json:"ldap_url,omitempty"` + + // Whether verify your OIDC server certificate, disable it if your OIDC server is hosted via self-hosted certificate. + LdapVerifyCert *BoolConfigItem `json:"ldap_verify_cert,omitempty"` + + // Enable notification + NotificationEnable *BoolConfigItem `json:"notification_enable,omitempty"` + + // The OIDC group which has the harbor admin privileges + OIDCAdminGroup *StringConfigItem `json:"oidc_admin_group,omitempty"` + + // Auto onboard the OIDC user + OIDCAutoOnboard *BoolConfigItem `json:"oidc_auto_onboard,omitempty"` + + // The client ID of the OIDC provider + OIDCClientID *StringConfigItem `json:"oidc_client_id,omitempty"` + + // The endpoint of the OIDC provider + OIDCEndpoint *StringConfigItem `json:"oidc_endpoint,omitempty"` + + // Extra parameters to add when redirect request to OIDC provider + OIDCExtraRedirectParms *StringConfigItem `json:"oidc_extra_redirect_parms,omitempty"` + + // The OIDC group filter which filters out the group doesn't match the regular expression + OIDCGroupFilter *StringConfigItem `json:"oidc_group_filter,omitempty"` + + // The attribute claims the group name + OIDCGroupsClaim *StringConfigItem `json:"oidc_groups_claim,omitempty"` + + // The OIDC provider name + OIDCName *StringConfigItem `json:"oidc_name,omitempty"` + + // The scope of the OIDC provider + OIDCScope *StringConfigItem `json:"oidc_scope,omitempty"` + + // The attribute claims the username + OIDCUserClaim *StringConfigItem `json:"oidc_user_claim,omitempty"` + + // Verify the OIDC provider's certificate' + OIDCVerifyCert *BoolConfigItem `json:"oidc_verify_cert,omitempty"` + + // Indicate who can create projects, it could be ''adminonly'' or ''everyone''. + ProjectCreationRestriction *StringConfigItem `json:"project_creation_restriction,omitempty"` + + // Enable quota per project + QuotaPerProjectEnable *BoolConfigItem `json:"quota_per_project_enable,omitempty"` + + // The flag to indicate whether Harbor is in readonly mode. + ReadOnly *BoolConfigItem `json:"read_only,omitempty"` + + // The rebot account name prefix + RobotNamePrefix *StringConfigItem `json:"robot_name_prefix,omitempty"` + + // The robot account token duration in days + RobotTokenDuration *IntegerConfigItem `json:"robot_token_duration,omitempty"` + + // scan all policy + ScanAllPolicy *ConfigurationsResponseScanAllPolicy `json:"scan_all_policy,omitempty"` + + // Whether the Harbor instance supports self-registration. If it''s set to false, admin need to add user to the instance. + SelfRegistration *BoolConfigItem `json:"self_registration,omitempty"` + + // The session timeout in minutes + SessionTimeout *IntegerConfigItem `json:"session_timeout,omitempty"` + + // Whether skip the audit log in database + SkipAuditLogDatabase *BoolConfigItem `json:"skip_audit_log_database,omitempty"` + + // The storage quota per project + StoragePerProject *IntegerConfigItem `json:"storage_per_project,omitempty"` + + // The expiration time of the token for internal Registry, in minutes. + TokenExpiration *IntegerConfigItem `json:"token_expiration,omitempty"` + + // The client id of UAA + UaaClientID *StringConfigItem `json:"uaa_client_id,omitempty"` + + // The client secret of the UAA + UaaClientSecret *StringConfigItem `json:"uaa_client_secret,omitempty"` + + // The endpoint of the UAA + UaaEndpoint *StringConfigItem `json:"uaa_endpoint,omitempty"` + + // Verify the certificate in UAA server + UaaVerifyCert *BoolConfigItem `json:"uaa_verify_cert,omitempty"` +} + +// Validate validates this configurations response +func (m *ConfigurationsResponse) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAuditLogForwardEndpoint(formats); err != nil { + res = append(res, err) + } + + if err := m.validateAuthMode(formats); err != nil { + res = append(res, err) + } + + if err := m.validateHTTPAuthproxyAdminGroups(formats); err != nil { + res = append(res, err) + } + + if err := m.validateHTTPAuthproxyAdminUsernames(formats); err != nil { + res = append(res, err) + } + + if err := m.validateHTTPAuthproxyEndpoint(formats); err != nil { + res = append(res, err) + } + + if err := m.validateHTTPAuthproxyServerCertificate(formats); err != nil { + res = append(res, err) + } + + if err := m.validateHTTPAuthproxySkipSearch(formats); err != nil { + res = append(res, err) + } + + if err := m.validateHTTPAuthproxyTokenreviewEndpoint(formats); err != nil { + res = append(res, err) + } + + if err := m.validateHTTPAuthproxyVerifyCert(formats); err != nil { + res = append(res, err) + } + + if err := m.validateLdapBaseDn(formats); err != nil { + res = append(res, err) + } + + if err := m.validateLdapFilter(formats); err != nil { + res = append(res, err) + } + + if err := m.validateLdapGroupAdminDn(formats); err != nil { + res = append(res, err) + } + + if err := m.validateLdapGroupAttributeName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateLdapGroupBaseDn(formats); err != nil { + res = append(res, err) + } + + if err := m.validateLdapGroupMembershipAttribute(formats); err != nil { + res = append(res, err) + } + + if err := m.validateLdapGroupSearchFilter(formats); err != nil { + res = append(res, err) + } + + if err := m.validateLdapGroupSearchScope(formats); err != nil { + res = append(res, err) + } + + if err := m.validateLdapScope(formats); err != nil { + res = append(res, err) + } + + if err := m.validateLdapSearchDn(formats); err != nil { + res = append(res, err) + } + + if err := m.validateLdapTimeout(formats); err != nil { + res = append(res, err) + } + + if err := m.validateLdapUID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateLdapURL(formats); err != nil { + res = append(res, err) + } + + if err := m.validateLdapVerifyCert(formats); err != nil { + res = append(res, err) + } + + if err := m.validateNotificationEnable(formats); err != nil { + res = append(res, err) + } + + if err := m.validateOIDCAdminGroup(formats); err != nil { + res = append(res, err) + } + + if err := m.validateOIDCAutoOnboard(formats); err != nil { + res = append(res, err) + } + + if err := m.validateOIDCClientID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateOIDCEndpoint(formats); err != nil { + res = append(res, err) + } + + if err := m.validateOIDCExtraRedirectParms(formats); err != nil { + res = append(res, err) + } + + if err := m.validateOIDCGroupFilter(formats); err != nil { + res = append(res, err) + } + + if err := m.validateOIDCGroupsClaim(formats); err != nil { + res = append(res, err) + } + + if err := m.validateOIDCName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateOIDCScope(formats); err != nil { + res = append(res, err) + } + + if err := m.validateOIDCUserClaim(formats); err != nil { + res = append(res, err) + } + + if err := m.validateOIDCVerifyCert(formats); err != nil { + res = append(res, err) + } + + if err := m.validateProjectCreationRestriction(formats); err != nil { + res = append(res, err) + } + + if err := m.validateQuotaPerProjectEnable(formats); err != nil { + res = append(res, err) + } + + if err := m.validateReadOnly(formats); err != nil { + res = append(res, err) + } + + if err := m.validateRobotNamePrefix(formats); err != nil { + res = append(res, err) + } + + if err := m.validateRobotTokenDuration(formats); err != nil { + res = append(res, err) + } + + if err := m.validateScanAllPolicy(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSelfRegistration(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSessionTimeout(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSkipAuditLogDatabase(formats); err != nil { + res = append(res, err) + } + + if err := m.validateStoragePerProject(formats); err != nil { + res = append(res, err) + } + + if err := m.validateTokenExpiration(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUaaClientID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUaaClientSecret(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUaaEndpoint(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUaaVerifyCert(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ConfigurationsResponse) validateAuditLogForwardEndpoint(formats strfmt.Registry) error { + + if swag.IsZero(m.AuditLogForwardEndpoint) { // not required + return nil + } + + if m.AuditLogForwardEndpoint != nil { + if err := m.AuditLogForwardEndpoint.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("audit_log_forward_endpoint") + } + return err + } + } + + return nil +} + +func (m *ConfigurationsResponse) validateAuthMode(formats strfmt.Registry) error { + + if swag.IsZero(m.AuthMode) { // not required + return nil + } + + if m.AuthMode != nil { + if err := m.AuthMode.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("auth_mode") + } + return err + } + } + + return nil +} + +func (m *ConfigurationsResponse) validateHTTPAuthproxyAdminGroups(formats strfmt.Registry) error { + + if swag.IsZero(m.HTTPAuthproxyAdminGroups) { // not required + return nil + } + + if m.HTTPAuthproxyAdminGroups != nil { + if err := m.HTTPAuthproxyAdminGroups.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("http_authproxy_admin_groups") + } + return err + } + } + + return nil +} + +func (m *ConfigurationsResponse) validateHTTPAuthproxyAdminUsernames(formats strfmt.Registry) error { + + if swag.IsZero(m.HTTPAuthproxyAdminUsernames) { // not required + return nil + } + + if m.HTTPAuthproxyAdminUsernames != nil { + if err := m.HTTPAuthproxyAdminUsernames.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("http_authproxy_admin_usernames") + } + return err + } + } + + return nil +} + +func (m *ConfigurationsResponse) validateHTTPAuthproxyEndpoint(formats strfmt.Registry) error { + + if swag.IsZero(m.HTTPAuthproxyEndpoint) { // not required + return nil + } + + if m.HTTPAuthproxyEndpoint != nil { + if err := m.HTTPAuthproxyEndpoint.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("http_authproxy_endpoint") + } + return err + } + } + + return nil +} + +func (m *ConfigurationsResponse) validateHTTPAuthproxyServerCertificate(formats strfmt.Registry) error { + + if swag.IsZero(m.HTTPAuthproxyServerCertificate) { // not required + return nil + } + + if m.HTTPAuthproxyServerCertificate != nil { + if err := m.HTTPAuthproxyServerCertificate.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("http_authproxy_server_certificate") + } + return err + } + } + + return nil +} + +func (m *ConfigurationsResponse) validateHTTPAuthproxySkipSearch(formats strfmt.Registry) error { + + if swag.IsZero(m.HTTPAuthproxySkipSearch) { // not required + return nil + } + + if m.HTTPAuthproxySkipSearch != nil { + if err := m.HTTPAuthproxySkipSearch.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("http_authproxy_skip_search") + } + return err + } + } + + return nil +} + +func (m *ConfigurationsResponse) validateHTTPAuthproxyTokenreviewEndpoint(formats strfmt.Registry) error { + + if swag.IsZero(m.HTTPAuthproxyTokenreviewEndpoint) { // not required + return nil + } + + if m.HTTPAuthproxyTokenreviewEndpoint != nil { + if err := m.HTTPAuthproxyTokenreviewEndpoint.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("http_authproxy_tokenreview_endpoint") + } + return err + } + } + + return nil +} + +func (m *ConfigurationsResponse) validateHTTPAuthproxyVerifyCert(formats strfmt.Registry) error { + + if swag.IsZero(m.HTTPAuthproxyVerifyCert) { // not required + return nil + } + + if m.HTTPAuthproxyVerifyCert != nil { + if err := m.HTTPAuthproxyVerifyCert.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("http_authproxy_verify_cert") + } + return err + } + } + + return nil +} + +func (m *ConfigurationsResponse) validateLdapBaseDn(formats strfmt.Registry) error { + + if swag.IsZero(m.LdapBaseDn) { // not required + return nil + } + + if m.LdapBaseDn != nil { + if err := m.LdapBaseDn.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ldap_base_dn") + } + return err + } + } + + return nil +} + +func (m *ConfigurationsResponse) validateLdapFilter(formats strfmt.Registry) error { + + if swag.IsZero(m.LdapFilter) { // not required + return nil + } + + if m.LdapFilter != nil { + if err := m.LdapFilter.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ldap_filter") + } + return err + } + } + + return nil +} + +func (m *ConfigurationsResponse) validateLdapGroupAdminDn(formats strfmt.Registry) error { + + if swag.IsZero(m.LdapGroupAdminDn) { // not required + return nil + } + + if m.LdapGroupAdminDn != nil { + if err := m.LdapGroupAdminDn.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ldap_group_admin_dn") + } + return err + } + } + + return nil +} + +func (m *ConfigurationsResponse) validateLdapGroupAttributeName(formats strfmt.Registry) error { + + if swag.IsZero(m.LdapGroupAttributeName) { // not required + return nil + } + + if m.LdapGroupAttributeName != nil { + if err := m.LdapGroupAttributeName.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ldap_group_attribute_name") + } + return err + } + } + + return nil +} + +func (m *ConfigurationsResponse) validateLdapGroupBaseDn(formats strfmt.Registry) error { + + if swag.IsZero(m.LdapGroupBaseDn) { // not required + return nil + } + + if m.LdapGroupBaseDn != nil { + if err := m.LdapGroupBaseDn.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ldap_group_base_dn") + } + return err + } + } + + return nil +} + +func (m *ConfigurationsResponse) validateLdapGroupMembershipAttribute(formats strfmt.Registry) error { + + if swag.IsZero(m.LdapGroupMembershipAttribute) { // not required + return nil + } + + if m.LdapGroupMembershipAttribute != nil { + if err := m.LdapGroupMembershipAttribute.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ldap_group_membership_attribute") + } + return err + } + } + + return nil +} + +func (m *ConfigurationsResponse) validateLdapGroupSearchFilter(formats strfmt.Registry) error { + + if swag.IsZero(m.LdapGroupSearchFilter) { // not required + return nil + } + + if m.LdapGroupSearchFilter != nil { + if err := m.LdapGroupSearchFilter.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ldap_group_search_filter") + } + return err + } + } + + return nil +} + +func (m *ConfigurationsResponse) validateLdapGroupSearchScope(formats strfmt.Registry) error { + + if swag.IsZero(m.LdapGroupSearchScope) { // not required + return nil + } + + if m.LdapGroupSearchScope != nil { + if err := m.LdapGroupSearchScope.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ldap_group_search_scope") + } + return err + } + } + + return nil +} + +func (m *ConfigurationsResponse) validateLdapScope(formats strfmt.Registry) error { + + if swag.IsZero(m.LdapScope) { // not required + return nil + } + + if m.LdapScope != nil { + if err := m.LdapScope.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ldap_scope") + } + return err + } + } + + return nil +} + +func (m *ConfigurationsResponse) validateLdapSearchDn(formats strfmt.Registry) error { + + if swag.IsZero(m.LdapSearchDn) { // not required + return nil + } + + if m.LdapSearchDn != nil { + if err := m.LdapSearchDn.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ldap_search_dn") + } + return err + } + } + + return nil +} + +func (m *ConfigurationsResponse) validateLdapTimeout(formats strfmt.Registry) error { + + if swag.IsZero(m.LdapTimeout) { // not required + return nil + } + + if m.LdapTimeout != nil { + if err := m.LdapTimeout.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ldap_timeout") + } + return err + } + } + + return nil +} + +func (m *ConfigurationsResponse) validateLdapUID(formats strfmt.Registry) error { + + if swag.IsZero(m.LdapUID) { // not required + return nil + } + + if m.LdapUID != nil { + if err := m.LdapUID.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ldap_uid") + } + return err + } + } + + return nil +} + +func (m *ConfigurationsResponse) validateLdapURL(formats strfmt.Registry) error { + + if swag.IsZero(m.LdapURL) { // not required + return nil + } + + if m.LdapURL != nil { + if err := m.LdapURL.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ldap_url") + } + return err + } + } + + return nil +} + +func (m *ConfigurationsResponse) validateLdapVerifyCert(formats strfmt.Registry) error { + + if swag.IsZero(m.LdapVerifyCert) { // not required + return nil + } + + if m.LdapVerifyCert != nil { + if err := m.LdapVerifyCert.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ldap_verify_cert") + } + return err + } + } + + return nil +} + +func (m *ConfigurationsResponse) validateNotificationEnable(formats strfmt.Registry) error { + + if swag.IsZero(m.NotificationEnable) { // not required + return nil + } + + if m.NotificationEnable != nil { + if err := m.NotificationEnable.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("notification_enable") + } + return err + } + } + + return nil +} + +func (m *ConfigurationsResponse) validateOIDCAdminGroup(formats strfmt.Registry) error { + + if swag.IsZero(m.OIDCAdminGroup) { // not required + return nil + } + + if m.OIDCAdminGroup != nil { + if err := m.OIDCAdminGroup.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("oidc_admin_group") + } + return err + } + } + + return nil +} + +func (m *ConfigurationsResponse) validateOIDCAutoOnboard(formats strfmt.Registry) error { + + if swag.IsZero(m.OIDCAutoOnboard) { // not required + return nil + } + + if m.OIDCAutoOnboard != nil { + if err := m.OIDCAutoOnboard.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("oidc_auto_onboard") + } + return err + } + } + + return nil +} + +func (m *ConfigurationsResponse) validateOIDCClientID(formats strfmt.Registry) error { + + if swag.IsZero(m.OIDCClientID) { // not required + return nil + } + + if m.OIDCClientID != nil { + if err := m.OIDCClientID.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("oidc_client_id") + } + return err + } + } + + return nil +} + +func (m *ConfigurationsResponse) validateOIDCEndpoint(formats strfmt.Registry) error { + + if swag.IsZero(m.OIDCEndpoint) { // not required + return nil + } + + if m.OIDCEndpoint != nil { + if err := m.OIDCEndpoint.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("oidc_endpoint") + } + return err + } + } + + return nil +} + +func (m *ConfigurationsResponse) validateOIDCExtraRedirectParms(formats strfmt.Registry) error { + + if swag.IsZero(m.OIDCExtraRedirectParms) { // not required + return nil + } + + if m.OIDCExtraRedirectParms != nil { + if err := m.OIDCExtraRedirectParms.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("oidc_extra_redirect_parms") + } + return err + } + } + + return nil +} + +func (m *ConfigurationsResponse) validateOIDCGroupFilter(formats strfmt.Registry) error { + + if swag.IsZero(m.OIDCGroupFilter) { // not required + return nil + } + + if m.OIDCGroupFilter != nil { + if err := m.OIDCGroupFilter.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("oidc_group_filter") + } + return err + } + } + + return nil +} + +func (m *ConfigurationsResponse) validateOIDCGroupsClaim(formats strfmt.Registry) error { + + if swag.IsZero(m.OIDCGroupsClaim) { // not required + return nil + } + + if m.OIDCGroupsClaim != nil { + if err := m.OIDCGroupsClaim.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("oidc_groups_claim") + } + return err + } + } + + return nil +} + +func (m *ConfigurationsResponse) validateOIDCName(formats strfmt.Registry) error { + + if swag.IsZero(m.OIDCName) { // not required + return nil + } + + if m.OIDCName != nil { + if err := m.OIDCName.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("oidc_name") + } + return err + } + } + + return nil +} + +func (m *ConfigurationsResponse) validateOIDCScope(formats strfmt.Registry) error { + + if swag.IsZero(m.OIDCScope) { // not required + return nil + } + + if m.OIDCScope != nil { + if err := m.OIDCScope.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("oidc_scope") + } + return err + } + } + + return nil +} + +func (m *ConfigurationsResponse) validateOIDCUserClaim(formats strfmt.Registry) error { + + if swag.IsZero(m.OIDCUserClaim) { // not required + return nil + } + + if m.OIDCUserClaim != nil { + if err := m.OIDCUserClaim.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("oidc_user_claim") + } + return err + } + } + + return nil +} + +func (m *ConfigurationsResponse) validateOIDCVerifyCert(formats strfmt.Registry) error { + + if swag.IsZero(m.OIDCVerifyCert) { // not required + return nil + } + + if m.OIDCVerifyCert != nil { + if err := m.OIDCVerifyCert.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("oidc_verify_cert") + } + return err + } + } + + return nil +} + +func (m *ConfigurationsResponse) validateProjectCreationRestriction(formats strfmt.Registry) error { + + if swag.IsZero(m.ProjectCreationRestriction) { // not required + return nil + } + + if m.ProjectCreationRestriction != nil { + if err := m.ProjectCreationRestriction.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("project_creation_restriction") + } + return err + } + } + + return nil +} + +func (m *ConfigurationsResponse) validateQuotaPerProjectEnable(formats strfmt.Registry) error { + + if swag.IsZero(m.QuotaPerProjectEnable) { // not required + return nil + } + + if m.QuotaPerProjectEnable != nil { + if err := m.QuotaPerProjectEnable.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("quota_per_project_enable") + } + return err + } + } + + return nil +} + +func (m *ConfigurationsResponse) validateReadOnly(formats strfmt.Registry) error { + + if swag.IsZero(m.ReadOnly) { // not required + return nil + } + + if m.ReadOnly != nil { + if err := m.ReadOnly.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("read_only") + } + return err + } + } + + return nil +} + +func (m *ConfigurationsResponse) validateRobotNamePrefix(formats strfmt.Registry) error { + + if swag.IsZero(m.RobotNamePrefix) { // not required + return nil + } + + if m.RobotNamePrefix != nil { + if err := m.RobotNamePrefix.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("robot_name_prefix") + } + return err + } + } + + return nil +} + +func (m *ConfigurationsResponse) validateRobotTokenDuration(formats strfmt.Registry) error { + + if swag.IsZero(m.RobotTokenDuration) { // not required + return nil + } + + if m.RobotTokenDuration != nil { + if err := m.RobotTokenDuration.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("robot_token_duration") + } + return err + } + } + + return nil +} + +func (m *ConfigurationsResponse) validateScanAllPolicy(formats strfmt.Registry) error { + + if swag.IsZero(m.ScanAllPolicy) { // not required + return nil + } + + if m.ScanAllPolicy != nil { + if err := m.ScanAllPolicy.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("scan_all_policy") + } + return err + } + } + + return nil +} + +func (m *ConfigurationsResponse) validateSelfRegistration(formats strfmt.Registry) error { + + if swag.IsZero(m.SelfRegistration) { // not required + return nil + } + + if m.SelfRegistration != nil { + if err := m.SelfRegistration.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("self_registration") + } + return err + } + } + + return nil +} + +func (m *ConfigurationsResponse) validateSessionTimeout(formats strfmt.Registry) error { + + if swag.IsZero(m.SessionTimeout) { // not required + return nil + } + + if m.SessionTimeout != nil { + if err := m.SessionTimeout.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("session_timeout") + } + return err + } + } + + return nil +} + +func (m *ConfigurationsResponse) validateSkipAuditLogDatabase(formats strfmt.Registry) error { + + if swag.IsZero(m.SkipAuditLogDatabase) { // not required + return nil + } + + if m.SkipAuditLogDatabase != nil { + if err := m.SkipAuditLogDatabase.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("skip_audit_log_database") + } + return err + } + } + + return nil +} + +func (m *ConfigurationsResponse) validateStoragePerProject(formats strfmt.Registry) error { + + if swag.IsZero(m.StoragePerProject) { // not required + return nil + } + + if m.StoragePerProject != nil { + if err := m.StoragePerProject.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("storage_per_project") + } + return err + } + } + + return nil +} + +func (m *ConfigurationsResponse) validateTokenExpiration(formats strfmt.Registry) error { + + if swag.IsZero(m.TokenExpiration) { // not required + return nil + } + + if m.TokenExpiration != nil { + if err := m.TokenExpiration.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("token_expiration") + } + return err + } + } + + return nil +} + +func (m *ConfigurationsResponse) validateUaaClientID(formats strfmt.Registry) error { + + if swag.IsZero(m.UaaClientID) { // not required + return nil + } + + if m.UaaClientID != nil { + if err := m.UaaClientID.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("uaa_client_id") + } + return err + } + } + + return nil +} + +func (m *ConfigurationsResponse) validateUaaClientSecret(formats strfmt.Registry) error { + + if swag.IsZero(m.UaaClientSecret) { // not required + return nil + } + + if m.UaaClientSecret != nil { + if err := m.UaaClientSecret.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("uaa_client_secret") + } + return err + } + } + + return nil +} + +func (m *ConfigurationsResponse) validateUaaEndpoint(formats strfmt.Registry) error { + + if swag.IsZero(m.UaaEndpoint) { // not required + return nil + } + + if m.UaaEndpoint != nil { + if err := m.UaaEndpoint.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("uaa_endpoint") + } + return err + } + } + + return nil +} + +func (m *ConfigurationsResponse) validateUaaVerifyCert(formats strfmt.Registry) error { + + if swag.IsZero(m.UaaVerifyCert) { // not required + return nil + } + + if m.UaaVerifyCert != nil { + if err := m.UaaVerifyCert.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("uaa_verify_cert") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ConfigurationsResponse) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ConfigurationsResponse) UnmarshalBinary(b []byte) error { + var res ConfigurationsResponse + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} + +// ConfigurationsResponseScanAllPolicy configurations response scan all policy +// +// swagger:model ConfigurationsResponseScanAllPolicy +type ConfigurationsResponseScanAllPolicy struct { + + // parameter + Parameter *ConfigurationsResponseScanAllPolicyParameter `json:"parameter,omitempty"` + + // The type of scan all policy, currently the valid values are "none" and "daily" + Type string `json:"type,omitempty"` +} + +// Validate validates this configurations response scan all policy +func (m *ConfigurationsResponseScanAllPolicy) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateParameter(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ConfigurationsResponseScanAllPolicy) validateParameter(formats strfmt.Registry) error { + + if swag.IsZero(m.Parameter) { // not required + return nil + } + + if m.Parameter != nil { + if err := m.Parameter.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("scan_all_policy" + "." + "parameter") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ConfigurationsResponseScanAllPolicy) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ConfigurationsResponseScanAllPolicy) UnmarshalBinary(b []byte) error { + var res ConfigurationsResponseScanAllPolicy + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} + +// ConfigurationsResponseScanAllPolicyParameter The parameters of the policy, the values are dependent on the type of the policy. +// +// swagger:model ConfigurationsResponseScanAllPolicyParameter +type ConfigurationsResponseScanAllPolicyParameter struct { + + // The offset in seconds of UTC 0 o'clock, only valid when the policy type is "daily" + DailyTime int64 `json:"daily_time,omitempty"` +} + +// Validate validates this configurations response scan all policy parameter +func (m *ConfigurationsResponseScanAllPolicyParameter) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ConfigurationsResponseScanAllPolicyParameter) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ConfigurationsResponseScanAllPolicyParameter) UnmarshalBinary(b []byte) error { + var res ConfigurationsResponseScanAllPolicyParameter + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/cve_allowlist.go b/src/server/v2.0/models/cve_allowlist.go new file mode 100644 index 000000000..6dbffcae6 --- /dev/null +++ b/src/server/v2.0/models/cve_allowlist.go @@ -0,0 +1,132 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// CVEAllowlist The CVE Allowlist for system or project +// +// swagger:model CVEAllowlist +type CVEAllowlist struct { + + // The creation time of the allowlist. + // Format: date-time + CreationTime strfmt.DateTime `json:"creation_time,omitempty"` + + // the time for expiration of the allowlist, in the form of seconds since epoch. This is an optional attribute, if it's not set the CVE allowlist does not expire. + ExpiresAt *int64 `json:"expires_at,omitempty"` + + // ID of the allowlist + ID int64 `json:"id,omitempty"` + + // items + Items []*CVEAllowlistItem `json:"items"` + + // ID of the project which the allowlist belongs to. For system level allowlist this attribute is zero. + ProjectID int64 `json:"project_id,omitempty"` + + // The update time of the allowlist. + // Format: date-time + UpdateTime strfmt.DateTime `json:"update_time,omitempty"` +} + +// Validate validates this CVE allowlist +func (m *CVEAllowlist) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCreationTime(formats); err != nil { + res = append(res, err) + } + + if err := m.validateItems(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUpdateTime(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CVEAllowlist) validateCreationTime(formats strfmt.Registry) error { + + if swag.IsZero(m.CreationTime) { // not required + return nil + } + + if err := validate.FormatOf("creation_time", "body", "date-time", m.CreationTime.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *CVEAllowlist) validateItems(formats strfmt.Registry) error { + + if swag.IsZero(m.Items) { // not required + return nil + } + + for i := 0; i < len(m.Items); i++ { + if swag.IsZero(m.Items[i]) { // not required + continue + } + + if m.Items[i] != nil { + if err := m.Items[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("items" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *CVEAllowlist) validateUpdateTime(formats strfmt.Registry) error { + + if swag.IsZero(m.UpdateTime) { // not required + return nil + } + + if err := validate.FormatOf("update_time", "body", "date-time", m.UpdateTime.String(), formats); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *CVEAllowlist) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *CVEAllowlist) UnmarshalBinary(b []byte) error { + var res CVEAllowlist + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/cve_allowlist_item.go b/src/server/v2.0/models/cve_allowlist_item.go new file mode 100644 index 000000000..6ae3ce5ee --- /dev/null +++ b/src/server/v2.0/models/cve_allowlist_item.go @@ -0,0 +1,43 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// CVEAllowlistItem The item in CVE allowlist +// +// swagger:model CVEAllowlistItem +type CVEAllowlistItem struct { + + // The ID of the CVE, such as "CVE-2019-10164" + CVEID string `json:"cve_id,omitempty"` +} + +// Validate validates this CVE allowlist item +func (m *CVEAllowlistItem) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *CVEAllowlistItem) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *CVEAllowlistItem) UnmarshalBinary(b []byte) error { + var res CVEAllowlistItem + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/error.go b/src/server/v2.0/models/error.go new file mode 100644 index 000000000..3527c63cb --- /dev/null +++ b/src/server/v2.0/models/error.go @@ -0,0 +1,46 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// Error a model for all the error response coming from harbor +// +// swagger:model Error +type Error struct { + + // The error code + Code string `json:"code,omitempty"` + + // The error message + Message string `json:"message,omitempty"` +} + +// Validate validates this error +func (m *Error) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *Error) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Error) UnmarshalBinary(b []byte) error { + var res Error + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/errors.go b/src/server/v2.0/models/errors.go new file mode 100644 index 000000000..0ef34646b --- /dev/null +++ b/src/server/v2.0/models/errors.go @@ -0,0 +1,80 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// Errors The error array that describe the errors got during the handling of request +// +// swagger:model Errors +type Errors struct { + + // errors + Errors []*Error `json:"errors"` +} + +// Validate validates this errors +func (m *Errors) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateErrors(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Errors) validateErrors(formats strfmt.Registry) error { + + if swag.IsZero(m.Errors) { // not required + return nil + } + + for i := 0; i < len(m.Errors); i++ { + if swag.IsZero(m.Errors[i]) { // not required + continue + } + + if m.Errors[i] != nil { + if err := m.Errors[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("errors" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Errors) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Errors) UnmarshalBinary(b []byte) error { + var res Errors + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/event_type.go b/src/server/v2.0/models/event_type.go new file mode 100644 index 000000000..0a110b24d --- /dev/null +++ b/src/server/v2.0/models/event_type.go @@ -0,0 +1,20 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" +) + +// EventType Webhook supportted event type. +// +// swagger:model EventType +type EventType string + +// Validate validates this event type +func (m EventType) Validate(formats strfmt.Registry) error { + return nil +} diff --git a/src/server/v2.0/models/exec_history.go b/src/server/v2.0/models/exec_history.go new file mode 100644 index 000000000..330fa70f3 --- /dev/null +++ b/src/server/v2.0/models/exec_history.go @@ -0,0 +1,132 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ExecHistory exec history +// +// swagger:model ExecHistory +type ExecHistory struct { + + // the creation time of purge job. + // Format: date-time + CreationTime strfmt.DateTime `json:"creation_time,omitempty"` + + // if purge job was deleted. + Deleted bool `json:"deleted,omitempty"` + + // the id of purge job. + ID int64 `json:"id,omitempty"` + + // the job kind of purge job. + JobKind string `json:"job_kind,omitempty"` + + // the job name of purge job. + JobName string `json:"job_name,omitempty"` + + // the job parameters of purge job. + JobParameters string `json:"job_parameters,omitempty"` + + // the status of purge job. + JobStatus string `json:"job_status,omitempty"` + + // schedule + Schedule *ScheduleObj `json:"schedule,omitempty"` + + // the update time of purge job. + // Format: date-time + UpdateTime strfmt.DateTime `json:"update_time,omitempty"` +} + +// Validate validates this exec history +func (m *ExecHistory) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCreationTime(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSchedule(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUpdateTime(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ExecHistory) validateCreationTime(formats strfmt.Registry) error { + + if swag.IsZero(m.CreationTime) { // not required + return nil + } + + if err := validate.FormatOf("creation_time", "body", "date-time", m.CreationTime.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *ExecHistory) validateSchedule(formats strfmt.Registry) error { + + if swag.IsZero(m.Schedule) { // not required + return nil + } + + if m.Schedule != nil { + if err := m.Schedule.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("schedule") + } + return err + } + } + + return nil +} + +func (m *ExecHistory) validateUpdateTime(formats strfmt.Registry) error { + + if swag.IsZero(m.UpdateTime) { // not required + return nil + } + + if err := validate.FormatOf("update_time", "body", "date-time", m.UpdateTime.String(), formats); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ExecHistory) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ExecHistory) UnmarshalBinary(b []byte) error { + var res ExecHistory + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/execution.go b/src/server/v2.0/models/execution.go new file mode 100644 index 000000000..7103d0078 --- /dev/null +++ b/src/server/v2.0/models/execution.go @@ -0,0 +1,118 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// Execution execution +// +// swagger:model Execution +type Execution struct { + + // The end time of execution + EndTime string `json:"end_time,omitempty"` + + // extra attrs + ExtraAttrs ExtraAttrs `json:"extra_attrs,omitempty"` + + // The ID of execution + ID int64 `json:"id,omitempty"` + + // metrics + Metrics *Metrics `json:"metrics,omitempty"` + + // The start time of execution + StartTime string `json:"start_time,omitempty"` + + // The status of execution + Status string `json:"status,omitempty"` + + // The status message of execution + StatusMessage string `json:"status_message,omitempty"` + + // The trigger of execution + Trigger string `json:"trigger,omitempty"` + + // The vendor id of execution + VendorID int64 `json:"vendor_id,omitempty"` + + // The vendor type of execution + VendorType string `json:"vendor_type,omitempty"` +} + +// Validate validates this execution +func (m *Execution) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateExtraAttrs(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMetrics(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Execution) validateExtraAttrs(formats strfmt.Registry) error { + + if swag.IsZero(m.ExtraAttrs) { // not required + return nil + } + + if err := m.ExtraAttrs.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("extra_attrs") + } + return err + } + + return nil +} + +func (m *Execution) validateMetrics(formats strfmt.Registry) error { + + if swag.IsZero(m.Metrics) { // not required + return nil + } + + if m.Metrics != nil { + if err := m.Metrics.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("metrics") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Execution) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Execution) UnmarshalBinary(b []byte) error { + var res Execution + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/extra_attrs.go b/src/server/v2.0/models/extra_attrs.go new file mode 100644 index 000000000..45c9227fa --- /dev/null +++ b/src/server/v2.0/models/extra_attrs.go @@ -0,0 +1,20 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" +) + +// ExtraAttrs extra attrs +// +// swagger:model ExtraAttrs +type ExtraAttrs map[string]interface{} + +// Validate validates this extra attrs +func (m ExtraAttrs) Validate(formats strfmt.Registry) error { + return nil +} diff --git a/src/server/v2.0/models/filter_style.go b/src/server/v2.0/models/filter_style.go new file mode 100644 index 000000000..32ef39589 --- /dev/null +++ b/src/server/v2.0/models/filter_style.go @@ -0,0 +1,49 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// FilterStyle The style of the resource filter +// +// swagger:model FilterStyle +type FilterStyle struct { + + // The filter style + Style string `json:"style,omitempty"` + + // The filter type + Type string `json:"type,omitempty"` + + // The filter values + Values []string `json:"values"` +} + +// Validate validates this filter style +func (m *FilterStyle) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *FilterStyle) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *FilterStyle) UnmarshalBinary(b []byte) error { + var res FilterStyle + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/gc_history.go b/src/server/v2.0/models/gc_history.go new file mode 100644 index 000000000..1acf2c561 --- /dev/null +++ b/src/server/v2.0/models/gc_history.go @@ -0,0 +1,132 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// GCHistory GC history +// +// swagger:model GCHistory +type GCHistory struct { + + // the creation time of gc job. + // Format: date-time + CreationTime strfmt.DateTime `json:"creation_time,omitempty"` + + // if gc job was deleted. + Deleted bool `json:"deleted,omitempty"` + + // the id of gc job. + ID int64 `json:"id,omitempty"` + + // the job kind of gc job. + JobKind string `json:"job_kind,omitempty"` + + // the job name of gc job. + JobName string `json:"job_name,omitempty"` + + // the job parameters of gc job. + JobParameters string `json:"job_parameters,omitempty"` + + // the status of gc job. + JobStatus string `json:"job_status,omitempty"` + + // schedule + Schedule *ScheduleObj `json:"schedule,omitempty"` + + // the update time of gc job. + // Format: date-time + UpdateTime strfmt.DateTime `json:"update_time,omitempty"` +} + +// Validate validates this GC history +func (m *GCHistory) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCreationTime(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSchedule(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUpdateTime(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *GCHistory) validateCreationTime(formats strfmt.Registry) error { + + if swag.IsZero(m.CreationTime) { // not required + return nil + } + + if err := validate.FormatOf("creation_time", "body", "date-time", m.CreationTime.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *GCHistory) validateSchedule(formats strfmt.Registry) error { + + if swag.IsZero(m.Schedule) { // not required + return nil + } + + if m.Schedule != nil { + if err := m.Schedule.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("schedule") + } + return err + } + } + + return nil +} + +func (m *GCHistory) validateUpdateTime(formats strfmt.Registry) error { + + if swag.IsZero(m.UpdateTime) { // not required + return nil + } + + if err := validate.FormatOf("update_time", "body", "date-time", m.UpdateTime.String(), formats); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *GCHistory) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *GCHistory) UnmarshalBinary(b []byte) error { + var res GCHistory + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/general_info.go b/src/server/v2.0/models/general_info.go new file mode 100644 index 000000000..e269a2d83 --- /dev/null +++ b/src/server/v2.0/models/general_info.go @@ -0,0 +1,129 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// GeneralInfo general info +// +// swagger:model GeneralInfo +type GeneralInfo struct { + + // The auth mode of current Harbor instance. + AuthMode *string `json:"auth_mode,omitempty"` + + // The setting of auth proxy this is only available when Harbor relies on authproxy for authentication. + AuthproxySettings *AuthproxySetting `json:"authproxy_settings,omitempty"` + + // The current time of the server. + // Format: date-time + CurrentTime *strfmt.DateTime `json:"current_time,omitempty"` + + // The external URL of Harbor, with protocol. + ExternalURL *string `json:"external_url,omitempty"` + + // The build version of Harbor. + HarborVersion *string `json:"harbor_version,omitempty"` + + // Indicate whether there is a ca root cert file ready for download in the file system. + HasCaRoot *bool `json:"has_ca_root,omitempty"` + + // The flag to indicate whether notification mechanism is enabled on Harbor instance. + NotificationEnable *bool `json:"notification_enable,omitempty"` + + // Indicate who can create projects, it could be 'adminonly' or 'everyone'. + ProjectCreationRestriction *string `json:"project_creation_restriction,omitempty"` + + // The flag to indicate whether Harbor is in readonly mode. + ReadOnly *bool `json:"read_only,omitempty"` + + // The storage provider's name of Harbor registry + RegistryStorageProviderName *string `json:"registry_storage_provider_name,omitempty"` + + // The url of registry against which the docker command should be issued. + RegistryURL *string `json:"registry_url,omitempty"` + + // Indicate whether the Harbor instance enable user to register himself. + SelfRegistration *bool `json:"self_registration,omitempty"` + + // If the Harbor instance is deployed with nested chartmuseum. + WithChartmuseum *bool `json:"with_chartmuseum,omitempty"` + + // If the Harbor instance is deployed with nested notary. + WithNotary *bool `json:"with_notary,omitempty"` +} + +// Validate validates this general info +func (m *GeneralInfo) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAuthproxySettings(formats); err != nil { + res = append(res, err) + } + + if err := m.validateCurrentTime(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *GeneralInfo) validateAuthproxySettings(formats strfmt.Registry) error { + + if swag.IsZero(m.AuthproxySettings) { // not required + return nil + } + + if m.AuthproxySettings != nil { + if err := m.AuthproxySettings.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("authproxy_settings") + } + return err + } + } + + return nil +} + +func (m *GeneralInfo) validateCurrentTime(formats strfmt.Registry) error { + + if swag.IsZero(m.CurrentTime) { // not required + return nil + } + + if err := validate.FormatOf("current_time", "body", "date-time", m.CurrentTime.String(), formats); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *GeneralInfo) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *GeneralInfo) UnmarshalBinary(b []byte) error { + var res GeneralInfo + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/icon.go b/src/server/v2.0/models/icon.go new file mode 100644 index 000000000..02975ebec --- /dev/null +++ b/src/server/v2.0/models/icon.go @@ -0,0 +1,46 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// Icon icon +// +// swagger:model Icon +type Icon struct { + + // The base64 encoded content of the icon + Content string `json:"content,omitempty"` + + // The content type of the icon + ContentType string `json:"content-type,omitempty"` +} + +// Validate validates this icon +func (m *Icon) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *Icon) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Icon) UnmarshalBinary(b []byte) error { + var res Icon + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/immutable_rule.go b/src/server/v2.0/models/immutable_rule.go new file mode 100644 index 000000000..cb715bf74 --- /dev/null +++ b/src/server/v2.0/models/immutable_rule.go @@ -0,0 +1,134 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ImmutableRule immutable rule +// +// swagger:model ImmutableRule +type ImmutableRule struct { + + // action + Action string `json:"action,omitempty"` + + // disabled + Disabled bool `json:"disabled,omitempty"` + + // id + ID int64 `json:"id,omitempty"` + + // params + Params map[string]interface{} `json:"params,omitempty"` + + // priority + Priority int64 `json:"priority,omitempty"` + + // scope selectors + ScopeSelectors map[string][]ImmutableSelector `json:"scope_selectors,omitempty"` + + // tag selectors + TagSelectors []*ImmutableSelector `json:"tag_selectors"` + + // template + Template string `json:"template,omitempty"` +} + +// Validate validates this immutable rule +func (m *ImmutableRule) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateScopeSelectors(formats); err != nil { + res = append(res, err) + } + + if err := m.validateTagSelectors(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ImmutableRule) validateScopeSelectors(formats strfmt.Registry) error { + + if swag.IsZero(m.ScopeSelectors) { // not required + return nil + } + + for k := range m.ScopeSelectors { + + if err := validate.Required("scope_selectors"+"."+k, "body", m.ScopeSelectors[k]); err != nil { + return err + } + + for i := 0; i < len(m.ScopeSelectors[k]); i++ { + + if err := m.ScopeSelectors[k][i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("scope_selectors" + "." + k + "." + strconv.Itoa(i)) + } + return err + } + + } + + } + + return nil +} + +func (m *ImmutableRule) validateTagSelectors(formats strfmt.Registry) error { + + if swag.IsZero(m.TagSelectors) { // not required + return nil + } + + for i := 0; i < len(m.TagSelectors); i++ { + if swag.IsZero(m.TagSelectors[i]) { // not required + continue + } + + if m.TagSelectors[i] != nil { + if err := m.TagSelectors[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("tag_selectors" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ImmutableRule) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ImmutableRule) UnmarshalBinary(b []byte) error { + var res ImmutableRule + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/immutable_selector.go b/src/server/v2.0/models/immutable_selector.go new file mode 100644 index 000000000..d28eb4b34 --- /dev/null +++ b/src/server/v2.0/models/immutable_selector.go @@ -0,0 +1,52 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// ImmutableSelector immutable selector +// +// swagger:model ImmutableSelector +type ImmutableSelector struct { + + // decoration + Decoration string `json:"decoration,omitempty"` + + // extras + Extras string `json:"extras,omitempty"` + + // kind + Kind string `json:"kind,omitempty"` + + // pattern + Pattern string `json:"pattern,omitempty"` +} + +// Validate validates this immutable selector +func (m *ImmutableSelector) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ImmutableSelector) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ImmutableSelector) UnmarshalBinary(b []byte) error { + var res ImmutableSelector + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/instance.go b/src/server/v2.0/models/instance.go new file mode 100644 index 000000000..b388edc75 --- /dev/null +++ b/src/server/v2.0/models/instance.go @@ -0,0 +1,76 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// Instance instance +// +// swagger:model Instance +type Instance struct { + + // The auth credential data if exists + AuthInfo map[string]string `json:"auth_info,omitempty"` + + // The authentication way supported + AuthMode string `json:"auth_mode,omitempty"` + + // Whether the instance is default or not + Default bool `json:"default"` + + // Description of instance + Description string `json:"description,omitempty"` + + // Whether the instance is activated or not + Enabled bool `json:"enabled"` + + // The service endpoint of this instance + Endpoint string `json:"endpoint,omitempty"` + + // Unique ID + ID int64 `json:"id,omitempty"` + + // Whether the instance endpoint is insecure or not + Insecure bool `json:"insecure"` + + // Instance name + Name string `json:"name,omitempty"` + + // The timestamp of instance setting up + SetupTimestamp int64 `json:"setup_timestamp,omitempty"` + + // The health status + Status string `json:"status,omitempty"` + + // Based on which driver, identified by ID + Vendor string `json:"vendor,omitempty"` +} + +// Validate validates this instance +func (m *Instance) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *Instance) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Instance) UnmarshalBinary(b []byte) error { + var res Instance + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/integer_config_item.go b/src/server/v2.0/models/integer_config_item.go new file mode 100644 index 000000000..1b5dda3fb --- /dev/null +++ b/src/server/v2.0/models/integer_config_item.go @@ -0,0 +1,46 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// IntegerConfigItem integer config item +// +// swagger:model IntegerConfigItem +type IntegerConfigItem struct { + + // The configure item can be updated or not + Editable bool `json:"editable"` + + // The integer value of current config item + Value int64 `json:"value"` +} + +// Validate validates this integer config item +func (m *IntegerConfigItem) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *IntegerConfigItem) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *IntegerConfigItem) UnmarshalBinary(b []byte) error { + var res IntegerConfigItem + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/internal_configuration_value.go b/src/server/v2.0/models/internal_configuration_value.go new file mode 100644 index 000000000..8c790b83b --- /dev/null +++ b/src/server/v2.0/models/internal_configuration_value.go @@ -0,0 +1,46 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// InternalConfigurationValue internal configuration value +// +// swagger:model InternalConfigurationValue +type InternalConfigurationValue struct { + + // The configure item can be updated or not + Editable bool `json:"editable"` + + // The value of current config item + Value interface{} `json:"value,omitempty"` +} + +// Validate validates this internal configuration value +func (m *InternalConfigurationValue) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *InternalConfigurationValue) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *InternalConfigurationValue) UnmarshalBinary(b []byte) error { + var res InternalConfigurationValue + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/internal_configurations_response.go b/src/server/v2.0/models/internal_configurations_response.go new file mode 100644 index 000000000..87ab7e7cb --- /dev/null +++ b/src/server/v2.0/models/internal_configurations_response.go @@ -0,0 +1,40 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// InternalConfigurationsResponse internal configurations response +// +// swagger:model InternalConfigurationsResponse +type InternalConfigurationsResponse map[string]InternalConfigurationValue + +// Validate validates this internal configurations response +func (m InternalConfigurationsResponse) Validate(formats strfmt.Registry) error { + var res []error + + for k := range m { + + if err := validate.Required(k, "body", m[k]); err != nil { + return err + } + if val, ok := m[k]; ok { + if err := val.Validate(formats); err != nil { + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/src/server/v2.0/models/is_default.go b/src/server/v2.0/models/is_default.go new file mode 100644 index 000000000..187e62c2f --- /dev/null +++ b/src/server/v2.0/models/is_default.go @@ -0,0 +1,43 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// IsDefault is default +// +// swagger:model IsDefault +type IsDefault struct { + + // A flag indicating whether a scanner registration is default. + IsDefault bool `json:"is_default,omitempty"` +} + +// Validate validates this is default +func (m *IsDefault) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *IsDefault) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *IsDefault) UnmarshalBinary(b []byte) error { + var res IsDefault + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/job_queue.go b/src/server/v2.0/models/job_queue.go new file mode 100644 index 000000000..417340b6d --- /dev/null +++ b/src/server/v2.0/models/job_queue.go @@ -0,0 +1,52 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// JobQueue the job queue info +// +// swagger:model JobQueue +type JobQueue struct { + + // The count of jobs in the job queue + Count int64 `json:"count,omitempty"` + + // The type of the job queue + JobType string `json:"job_type,omitempty"` + + // The latency the job queue (seconds) + Latency int64 `json:"latency,omitempty"` + + // The paused status of the job queue + Paused bool `json:"paused"` +} + +// Validate validates this job queue +func (m *JobQueue) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *JobQueue) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *JobQueue) UnmarshalBinary(b []byte) error { + var res JobQueue + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/label.go b/src/server/v2.0/models/label.go new file mode 100644 index 000000000..f9a9fbbac --- /dev/null +++ b/src/server/v2.0/models/label.go @@ -0,0 +1,107 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// Label label +// +// swagger:model Label +type Label struct { + + // The color the label + Color string `json:"color,omitempty"` + + // The creation time the label + // Format: date-time + CreationTime strfmt.DateTime `json:"creation_time,omitempty"` + + // The description the label + Description string `json:"description,omitempty"` + + // The ID of the label + ID int64 `json:"id,omitempty"` + + // The name the label + Name string `json:"name,omitempty"` + + // The ID of project that the label belongs to + ProjectID int64 `json:"project_id,omitempty"` + + // The scope the label + Scope string `json:"scope,omitempty"` + + // The update time of the label + // Format: date-time + UpdateTime strfmt.DateTime `json:"update_time,omitempty"` +} + +// Validate validates this label +func (m *Label) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCreationTime(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUpdateTime(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Label) validateCreationTime(formats strfmt.Registry) error { + + if swag.IsZero(m.CreationTime) { // not required + return nil + } + + if err := validate.FormatOf("creation_time", "body", "date-time", m.CreationTime.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *Label) validateUpdateTime(formats strfmt.Registry) error { + + if swag.IsZero(m.UpdateTime) { // not required + return nil + } + + if err := validate.FormatOf("update_time", "body", "date-time", m.UpdateTime.String(), formats); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Label) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Label) UnmarshalBinary(b []byte) error { + var res Label + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/ldap_conf.go b/src/server/v2.0/models/ldap_conf.go new file mode 100644 index 000000000..24cf4c432 --- /dev/null +++ b/src/server/v2.0/models/ldap_conf.go @@ -0,0 +1,67 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// LdapConf The ldap configure properties +// +// swagger:model LdapConf +type LdapConf struct { + + // The base dn of ldap service. + LdapBaseDn string `json:"ldap_base_dn,omitempty"` + + // The connect timeout of ldap service(second). + LdapConnectionTimeout int64 `json:"ldap_connection_timeout,omitempty"` + + // The serach filter of ldap service. + LdapFilter string `json:"ldap_filter,omitempty"` + + // The serach scope of ldap service. + LdapScope int64 `json:"ldap_scope,omitempty"` + + // The search dn of ldap service. + LdapSearchDn string `json:"ldap_search_dn,omitempty"` + + // The search password of ldap service. + LdapSearchPassword string `json:"ldap_search_password,omitempty"` + + // The serach uid from ldap service attributes. + LdapUID string `json:"ldap_uid,omitempty"` + + // The url of ldap service. + LdapURL string `json:"ldap_url,omitempty"` + + // Verify Ldap server certificate. + LdapVerifyCert bool `json:"ldap_verify_cert,omitempty"` +} + +// Validate validates this ldap conf +func (m *LdapConf) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *LdapConf) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *LdapConf) UnmarshalBinary(b []byte) error { + var res LdapConf + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/ldap_failed_import_user.go b/src/server/v2.0/models/ldap_failed_import_user.go new file mode 100644 index 000000000..4174a5039 --- /dev/null +++ b/src/server/v2.0/models/ldap_failed_import_user.go @@ -0,0 +1,46 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// LdapFailedImportUser ldap failed import user +// +// swagger:model LdapFailedImportUser +type LdapFailedImportUser struct { + + // fail reason. + Error string `json:"error,omitempty"` + + // the uid can't add to system. + UID string `json:"uid,omitempty"` +} + +// Validate validates this ldap failed import user +func (m *LdapFailedImportUser) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *LdapFailedImportUser) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *LdapFailedImportUser) UnmarshalBinary(b []byte) error { + var res LdapFailedImportUser + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/ldap_import_users.go b/src/server/v2.0/models/ldap_import_users.go new file mode 100644 index 000000000..d05966f2a --- /dev/null +++ b/src/server/v2.0/models/ldap_import_users.go @@ -0,0 +1,43 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// LdapImportUsers ldap import users +// +// swagger:model LdapImportUsers +type LdapImportUsers struct { + + // selected uid list + LdapUIDList []string `json:"ldap_uid_list"` +} + +// Validate validates this ldap import users +func (m *LdapImportUsers) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *LdapImportUsers) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *LdapImportUsers) UnmarshalBinary(b []byte) error { + var res LdapImportUsers + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/ldap_ping_result.go b/src/server/v2.0/models/ldap_ping_result.go new file mode 100644 index 000000000..ab88f63ef --- /dev/null +++ b/src/server/v2.0/models/ldap_ping_result.go @@ -0,0 +1,46 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// LdapPingResult The ldap ping result +// +// swagger:model LdapPingResult +type LdapPingResult struct { + + // The ping operation output message. + Message string `json:"message,omitempty"` + + // Test success + Success bool `json:"success,omitempty"` +} + +// Validate validates this ldap ping result +func (m *LdapPingResult) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *LdapPingResult) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *LdapPingResult) UnmarshalBinary(b []byte) error { + var res LdapPingResult + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/ldap_user.go b/src/server/v2.0/models/ldap_user.go new file mode 100644 index 000000000..6be9f5900 --- /dev/null +++ b/src/server/v2.0/models/ldap_user.go @@ -0,0 +1,49 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// LdapUser ldap user +// +// swagger:model LdapUser +type LdapUser struct { + + // The user email address from "mail" or "email" attribute. + Email string `json:"email,omitempty"` + + // The user realname from "uid" or "cn" attribute. + Realname string `json:"realname,omitempty"` + + // ldap username. + Username string `json:"username,omitempty"` +} + +// Validate validates this ldap user +func (m *LdapUser) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *LdapUser) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *LdapUser) UnmarshalBinary(b []byte) error { + var res LdapUser + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/metadata.go b/src/server/v2.0/models/metadata.go new file mode 100644 index 000000000..232d3678c --- /dev/null +++ b/src/server/v2.0/models/metadata.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// Metadata metadata +// +// swagger:model Metadata +type Metadata struct { + + // icon + Icon string `json:"icon,omitempty"` + + // id + ID string `json:"id,omitempty"` + + // maintainers + Maintainers []string `json:"maintainers"` + + // name + Name string `json:"name,omitempty"` + + // source + Source string `json:"source,omitempty"` + + // version + Version string `json:"version,omitempty"` +} + +// Validate validates this metadata +func (m *Metadata) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *Metadata) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Metadata) UnmarshalBinary(b []byte) error { + var res Metadata + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/metrics.go b/src/server/v2.0/models/metrics.go new file mode 100644 index 000000000..da6486d24 --- /dev/null +++ b/src/server/v2.0/models/metrics.go @@ -0,0 +1,61 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// Metrics metrics +// +// swagger:model Metrics +type Metrics struct { + + // The count of error task + ErrorTaskCount int64 `json:"error_task_count,omitempty"` + + // The count of pending task + PendingTaskCount int64 `json:"pending_task_count,omitempty"` + + // The count of running task + RunningTaskCount int64 `json:"running_task_count,omitempty"` + + // The count of scheduled task + ScheduledTaskCount int64 `json:"scheduled_task_count,omitempty"` + + // The count of stopped task + StoppedTaskCount int64 `json:"stopped_task_count,omitempty"` + + // The count of success task + SuccessTaskCount int64 `json:"success_task_count,omitempty"` + + // The count of task + TaskCount int64 `json:"task_count,omitempty"` +} + +// Validate validates this metrics +func (m *Metrics) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *Metrics) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Metrics) UnmarshalBinary(b []byte) error { + var res Metrics + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/native_report_summary.go b/src/server/v2.0/models/native_report_summary.go new file mode 100644 index 000000000..6aafc4edf --- /dev/null +++ b/src/server/v2.0/models/native_report_summary.go @@ -0,0 +1,154 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NativeReportSummary The summary for the native report +// +// swagger:model NativeReportSummary +type NativeReportSummary struct { + + // The complete percent of the scanning which value is between 0 and 100 + CompletePercent int64 `json:"complete_percent,omitempty"` + + // The seconds spent for generating the report + Duration int64 `json:"duration,omitempty"` + + // The end time of the scan process that generating report + // Format: date-time + EndTime strfmt.DateTime `json:"end_time,omitempty"` + + // id of the native scan report + ReportID string `json:"report_id,omitempty"` + + // The status of the report generating process + ScanStatus string `json:"scan_status,omitempty"` + + // scanner + Scanner *Scanner `json:"scanner,omitempty"` + + // The overall severity + Severity string `json:"severity,omitempty"` + + // The start time of the scan process that generating report + // Format: date-time + StartTime strfmt.DateTime `json:"start_time,omitempty"` + + // summary + Summary *VulnerabilitySummary `json:"summary,omitempty"` +} + +// Validate validates this native report summary +func (m *NativeReportSummary) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateEndTime(formats); err != nil { + res = append(res, err) + } + + if err := m.validateScanner(formats); err != nil { + res = append(res, err) + } + + if err := m.validateStartTime(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSummary(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *NativeReportSummary) validateEndTime(formats strfmt.Registry) error { + + if swag.IsZero(m.EndTime) { // not required + return nil + } + + if err := validate.FormatOf("end_time", "body", "date-time", m.EndTime.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *NativeReportSummary) validateScanner(formats strfmt.Registry) error { + + if swag.IsZero(m.Scanner) { // not required + return nil + } + + if m.Scanner != nil { + if err := m.Scanner.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("scanner") + } + return err + } + } + + return nil +} + +func (m *NativeReportSummary) validateStartTime(formats strfmt.Registry) error { + + if swag.IsZero(m.StartTime) { // not required + return nil + } + + if err := validate.FormatOf("start_time", "body", "date-time", m.StartTime.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *NativeReportSummary) validateSummary(formats strfmt.Registry) error { + + if swag.IsZero(m.Summary) { // not required + return nil + } + + if m.Summary != nil { + if err := m.Summary.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("summary") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *NativeReportSummary) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *NativeReportSummary) UnmarshalBinary(b []byte) error { + var res NativeReportSummary + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/notify_type.go b/src/server/v2.0/models/notify_type.go new file mode 100644 index 000000000..616289780 --- /dev/null +++ b/src/server/v2.0/models/notify_type.go @@ -0,0 +1,20 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" +) + +// NotifyType Webhook supportted notify type. +// +// swagger:model NotifyType +type NotifyType string + +// Validate validates this notify type +func (m NotifyType) Validate(formats strfmt.Registry) error { + return nil +} diff --git a/src/server/v2.0/models/oidc_cli_secret_req.go b/src/server/v2.0/models/oidc_cli_secret_req.go new file mode 100644 index 000000000..86d5c7a4e --- /dev/null +++ b/src/server/v2.0/models/oidc_cli_secret_req.go @@ -0,0 +1,43 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// OIDCCliSecretReq OIDC cli secret req +// +// swagger:model OIDCCliSecretReq +type OIDCCliSecretReq struct { + + // The new secret + Secret string `json:"secret,omitempty"` +} + +// Validate validates this OIDC cli secret req +func (m *OIDCCliSecretReq) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *OIDCCliSecretReq) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *OIDCCliSecretReq) UnmarshalBinary(b []byte) error { + var res OIDCCliSecretReq + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/oidc_user_info.go b/src/server/v2.0/models/oidc_user_info.go new file mode 100644 index 000000000..19886f3e8 --- /dev/null +++ b/src/server/v2.0/models/oidc_user_info.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// OIDCUserInfo OIDC user info +// +// swagger:model OIDCUserInfo +type OIDCUserInfo struct { + + // The creation time of the OIDC user info record. + // Format: date-time + CreationTime strfmt.DateTime `json:"creation_time,omitempty"` + + // the ID of the OIDC info record + ID int64 `json:"id,omitempty"` + + // the secret of the OIDC user that can be used for CLI to push/pull artifacts + Secret string `json:"secret,omitempty"` + + // the concatenation of sub and issuer in the ID token + Subiss string `json:"subiss,omitempty"` + + // The update time of the OIDC user info record. + // Format: date-time + UpdateTime strfmt.DateTime `json:"update_time,omitempty"` + + // the ID of the user + UserID int64 `json:"user_id,omitempty"` +} + +// Validate validates this OIDC user info +func (m *OIDCUserInfo) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCreationTime(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUpdateTime(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *OIDCUserInfo) validateCreationTime(formats strfmt.Registry) error { + + if swag.IsZero(m.CreationTime) { // not required + return nil + } + + if err := validate.FormatOf("creation_time", "body", "date-time", m.CreationTime.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *OIDCUserInfo) validateUpdateTime(formats strfmt.Registry) error { + + if swag.IsZero(m.UpdateTime) { // not required + return nil + } + + if err := validate.FormatOf("update_time", "body", "date-time", m.UpdateTime.String(), formats); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *OIDCUserInfo) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *OIDCUserInfo) UnmarshalBinary(b []byte) error { + var res OIDCUserInfo + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/overall_health_status.go b/src/server/v2.0/models/overall_health_status.go new file mode 100644 index 000000000..205fefd1c --- /dev/null +++ b/src/server/v2.0/models/overall_health_status.go @@ -0,0 +1,83 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// OverallHealthStatus The system health status +// +// swagger:model OverallHealthStatus +type OverallHealthStatus struct { + + // components + Components []*ComponentHealthStatus `json:"components"` + + // The overall health status. It is "healthy" only when all the components' status are "healthy" + Status string `json:"status,omitempty"` +} + +// Validate validates this overall health status +func (m *OverallHealthStatus) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateComponents(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *OverallHealthStatus) validateComponents(formats strfmt.Registry) error { + + if swag.IsZero(m.Components) { // not required + return nil + } + + for i := 0; i < len(m.Components); i++ { + if swag.IsZero(m.Components[i]) { // not required + continue + } + + if m.Components[i] != nil { + if err := m.Components[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("components" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *OverallHealthStatus) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *OverallHealthStatus) UnmarshalBinary(b []byte) error { + var res OverallHealthStatus + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/password_req.go b/src/server/v2.0/models/password_req.go new file mode 100644 index 000000000..8f8fd218e --- /dev/null +++ b/src/server/v2.0/models/password_req.go @@ -0,0 +1,46 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// PasswordReq password req +// +// swagger:model PasswordReq +type PasswordReq struct { + + // New password for marking as to be updated. + NewPassword string `json:"new_password,omitempty"` + + // The user's existing password. + OldPassword string `json:"old_password,omitempty"` +} + +// Validate validates this password req +func (m *PasswordReq) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *PasswordReq) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *PasswordReq) UnmarshalBinary(b []byte) error { + var res PasswordReq + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/permission.go b/src/server/v2.0/models/permission.go new file mode 100644 index 000000000..ab6b6b2f4 --- /dev/null +++ b/src/server/v2.0/models/permission.go @@ -0,0 +1,46 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// Permission permission +// +// swagger:model Permission +type Permission struct { + + // The permission action + Action string `json:"action,omitempty"` + + // The permission resoruce + Resource string `json:"resource,omitempty"` +} + +// Validate validates this permission +func (m *Permission) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *Permission) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Permission) UnmarshalBinary(b []byte) error { + var res Permission + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/platform.go b/src/server/v2.0/models/platform.go new file mode 100644 index 000000000..13a4fb0ca --- /dev/null +++ b/src/server/v2.0/models/platform.go @@ -0,0 +1,55 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// Platform platform +// +// swagger:model Platform +type Platform struct { + + // The features of the OS that the artifact applys to + OsFeatures []string `json:"'os.features'"` + + // The version of the OS that the artifact applys to + OsVersion string `json:"'os.version',omitempty"` + + // The architecture that the artifact applys to + Architecture string `json:"architecture,omitempty"` + + // The OS that the artifact applys to + Os string `json:"os,omitempty"` + + // The variant of the CPU + Variant string `json:"variant,omitempty"` +} + +// Validate validates this platform +func (m *Platform) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *Platform) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Platform) UnmarshalBinary(b []byte) error { + var res Platform + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/preheat_policy.go b/src/server/v2.0/models/preheat_policy.go new file mode 100644 index 000000000..9cd2d0539 --- /dev/null +++ b/src/server/v2.0/models/preheat_policy.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// PreheatPolicy preheat policy +// +// swagger:model PreheatPolicy +type PreheatPolicy struct { + + // The Create Time of preheat policy + // Format: date-time + CreationTime strfmt.DateTime `json:"creation_time,omitempty"` + + // The Description of preheat policy + Description string `json:"description,omitempty"` + + // Whether the preheat policy enabled + Enabled bool `json:"enabled"` + + // The Filters of preheat policy + Filters string `json:"filters,omitempty"` + + // The ID of preheat policy + ID int64 `json:"id,omitempty"` + + // The Name of preheat policy + Name string `json:"name,omitempty"` + + // The ID of preheat policy project + ProjectID int64 `json:"project_id,omitempty"` + + // The ID of preheat policy provider + ProviderID int64 `json:"provider_id,omitempty"` + + // The Name of preheat policy provider + ProviderName string `json:"provider_name,omitempty"` + + // The Trigger of preheat policy + Trigger string `json:"trigger,omitempty"` + + // The Update Time of preheat policy + // Format: date-time + UpdateTime strfmt.DateTime `json:"update_time,omitempty"` +} + +// Validate validates this preheat policy +func (m *PreheatPolicy) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCreationTime(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUpdateTime(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *PreheatPolicy) validateCreationTime(formats strfmt.Registry) error { + + if swag.IsZero(m.CreationTime) { // not required + return nil + } + + if err := validate.FormatOf("creation_time", "body", "date-time", m.CreationTime.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *PreheatPolicy) validateUpdateTime(formats strfmt.Registry) error { + + if swag.IsZero(m.UpdateTime) { // not required + return nil + } + + if err := validate.FormatOf("update_time", "body", "date-time", m.UpdateTime.String(), formats); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *PreheatPolicy) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *PreheatPolicy) UnmarshalBinary(b []byte) error { + var res PreheatPolicy + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/project.go b/src/server/v2.0/models/project.go new file mode 100644 index 000000000..b076285b8 --- /dev/null +++ b/src/server/v2.0/models/project.go @@ -0,0 +1,172 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// Project project +// +// swagger:model Project +type Project struct { + + // The total number of charts under this project. + ChartCount int64 `json:"chart_count"` + + // The creation time of the project. + // Format: date-time + CreationTime strfmt.DateTime `json:"creation_time,omitempty"` + + // The role ID with highest permission of the current user who triggered the API (for UI). This attribute is deprecated and will be removed in future versions. + CurrentUserRoleID int64 `json:"current_user_role_id,omitempty"` + + // The list of role ID of the current user who triggered the API (for UI) + CurrentUserRoleIds []int32 `json:"current_user_role_ids"` + + // The CVE allowlist of this project. + CVEAllowlist *CVEAllowlist `json:"cve_allowlist,omitempty"` + + // A deletion mark of the project. + Deleted bool `json:"deleted,omitempty"` + + // The metadata of the project. + Metadata *ProjectMetadata `json:"metadata,omitempty"` + + // The name of the project. + Name string `json:"name,omitempty"` + + // The owner ID of the project always means the creator of the project. + OwnerID int32 `json:"owner_id,omitempty"` + + // The owner name of the project. + OwnerName string `json:"owner_name,omitempty"` + + // Project ID + ProjectID int32 `json:"project_id,omitempty"` + + // The ID of referenced registry when the project is a proxy cache project. + RegistryID int64 `json:"registry_id,omitempty"` + + // The number of the repositories under this project. + RepoCount int64 `json:"repo_count"` + + // Correspond to the UI about whether the project's publicity is updatable (for UI) + Togglable bool `json:"togglable,omitempty"` + + // The update time of the project. + // Format: date-time + UpdateTime strfmt.DateTime `json:"update_time,omitempty"` +} + +// Validate validates this project +func (m *Project) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCreationTime(formats); err != nil { + res = append(res, err) + } + + if err := m.validateCVEAllowlist(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMetadata(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUpdateTime(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Project) validateCreationTime(formats strfmt.Registry) error { + + if swag.IsZero(m.CreationTime) { // not required + return nil + } + + if err := validate.FormatOf("creation_time", "body", "date-time", m.CreationTime.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *Project) validateCVEAllowlist(formats strfmt.Registry) error { + + if swag.IsZero(m.CVEAllowlist) { // not required + return nil + } + + if m.CVEAllowlist != nil { + if err := m.CVEAllowlist.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("cve_allowlist") + } + return err + } + } + + return nil +} + +func (m *Project) validateMetadata(formats strfmt.Registry) error { + + if swag.IsZero(m.Metadata) { // not required + return nil + } + + if m.Metadata != nil { + if err := m.Metadata.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("metadata") + } + return err + } + } + + return nil +} + +func (m *Project) validateUpdateTime(formats strfmt.Registry) error { + + if swag.IsZero(m.UpdateTime) { // not required + return nil + } + + if err := validate.FormatOf("update_time", "body", "date-time", m.UpdateTime.String(), formats); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Project) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Project) UnmarshalBinary(b []byte) error { + var res Project + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/project_deletable.go b/src/server/v2.0/models/project_deletable.go new file mode 100644 index 000000000..9be7db434 --- /dev/null +++ b/src/server/v2.0/models/project_deletable.go @@ -0,0 +1,46 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// ProjectDeletable project deletable +// +// swagger:model ProjectDeletable +type ProjectDeletable struct { + + // Whether the project can be deleted. + Deletable bool `json:"deletable,omitempty"` + + // The detail message when the project can not be deleted. + Message string `json:"message,omitempty"` +} + +// Validate validates this project deletable +func (m *ProjectDeletable) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ProjectDeletable) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ProjectDeletable) UnmarshalBinary(b []byte) error { + var res ProjectDeletable + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/project_member.go b/src/server/v2.0/models/project_member.go new file mode 100644 index 000000000..8433d5bde --- /dev/null +++ b/src/server/v2.0/models/project_member.go @@ -0,0 +1,99 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// ProjectMember project member +// +// swagger:model ProjectMember +type ProjectMember struct { + + // member group + MemberGroup *UserGroup `json:"member_group,omitempty"` + + // member user + MemberUser *UserEntity `json:"member_user,omitempty"` + + // The role id 1 for projectAdmin, 2 for developer, 3 for guest, 4 for maintainer + RoleID int64 `json:"role_id,omitempty"` +} + +// Validate validates this project member +func (m *ProjectMember) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateMemberGroup(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMemberUser(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ProjectMember) validateMemberGroup(formats strfmt.Registry) error { + + if swag.IsZero(m.MemberGroup) { // not required + return nil + } + + if m.MemberGroup != nil { + if err := m.MemberGroup.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("member_group") + } + return err + } + } + + return nil +} + +func (m *ProjectMember) validateMemberUser(formats strfmt.Registry) error { + + if swag.IsZero(m.MemberUser) { // not required + return nil + } + + if m.MemberUser != nil { + if err := m.MemberUser.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("member_user") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ProjectMember) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ProjectMember) UnmarshalBinary(b []byte) error { + var res ProjectMember + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/project_member_entity.go b/src/server/v2.0/models/project_member_entity.go new file mode 100644 index 000000000..31d84b4a3 --- /dev/null +++ b/src/server/v2.0/models/project_member_entity.go @@ -0,0 +1,61 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// ProjectMemberEntity project member entity +// +// swagger:model ProjectMemberEntity +type ProjectMemberEntity struct { + + // the id of entity, if the member is a user, it is user_id in user table. if the member is a user group, it is the user group's ID in user_group table. + EntityID int64 `json:"entity_id,omitempty"` + + // the name of the group member. + EntityName string `json:"entity_name,omitempty"` + + // the entity's type, u for user entity, g for group entity. + EntityType string `json:"entity_type,omitempty"` + + // the project member id + ID int64 `json:"id,omitempty"` + + // the project id + ProjectID int64 `json:"project_id,omitempty"` + + // the role id + RoleID int64 `json:"role_id,omitempty"` + + // the name of the role + RoleName string `json:"role_name,omitempty"` +} + +// Validate validates this project member entity +func (m *ProjectMemberEntity) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ProjectMemberEntity) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ProjectMemberEntity) UnmarshalBinary(b []byte) error { + var res ProjectMemberEntity + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/project_metadata.go b/src/server/v2.0/models/project_metadata.go new file mode 100644 index 000000000..edde380c5 --- /dev/null +++ b/src/server/v2.0/models/project_metadata.go @@ -0,0 +1,64 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// ProjectMetadata project metadata +// +// swagger:model ProjectMetadata +type ProjectMetadata struct { + + // Whether scan images automatically when pushing. The valid values are "true", "false". + AutoScan *string `json:"auto_scan,omitempty"` + + // Whether content trust is enabled or not. If it is enabled, user can't pull unsigned images from this project. The valid values are "true", "false". + EnableContentTrust *string `json:"enable_content_trust,omitempty"` + + // Whether cosign content trust is enabled or not. If it is enabled, user can't pull images without cosign signature from this project. The valid values are "true", "false". + EnableContentTrustCosign *string `json:"enable_content_trust_cosign,omitempty"` + + // Whether prevent the vulnerable images from running. The valid values are "true", "false". + PreventVul *string `json:"prevent_vul,omitempty"` + + // The public status of the project. The valid values are "true", "false". + Public string `json:"public,omitempty"` + + // The ID of the tag retention policy for the project + RetentionID *string `json:"retention_id,omitempty"` + + // Whether this project reuse the system level CVE allowlist as the allowlist of its own. The valid values are "true", "false". If it is set to "true" the actual allowlist associate with this project, if any, will be ignored. + ReuseSysCVEAllowlist *string `json:"reuse_sys_cve_allowlist,omitempty"` + + // If the vulnerability is high than severity defined here, the images can't be pulled. The valid values are "none", "low", "medium", "high", "critical". + Severity *string `json:"severity,omitempty"` +} + +// Validate validates this project metadata +func (m *ProjectMetadata) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ProjectMetadata) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ProjectMetadata) UnmarshalBinary(b []byte) error { + var res ProjectMetadata + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/project_req.go b/src/server/v2.0/models/project_req.go new file mode 100644 index 000000000..e8e9f37e3 --- /dev/null +++ b/src/server/v2.0/models/project_req.go @@ -0,0 +1,127 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ProjectReq project req +// +// swagger:model ProjectReq +type ProjectReq struct { + + // The CVE allowlist of the project. + CVEAllowlist *CVEAllowlist `json:"cve_allowlist,omitempty"` + + // The metadata of the project. + Metadata *ProjectMetadata `json:"metadata,omitempty"` + + // The name of the project. + // Max Length: 255 + ProjectName string `json:"project_name,omitempty"` + + // deprecated, reserved for project creation in replication + Public *bool `json:"public,omitempty"` + + // The ID of referenced registry when creating the proxy cache project + RegistryID *int64 `json:"registry_id,omitempty"` + + // The storage quota of the project. + StorageLimit *int64 `json:"storage_limit,omitempty"` +} + +// Validate validates this project req +func (m *ProjectReq) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCVEAllowlist(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMetadata(formats); err != nil { + res = append(res, err) + } + + if err := m.validateProjectName(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ProjectReq) validateCVEAllowlist(formats strfmt.Registry) error { + + if swag.IsZero(m.CVEAllowlist) { // not required + return nil + } + + if m.CVEAllowlist != nil { + if err := m.CVEAllowlist.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("cve_allowlist") + } + return err + } + } + + return nil +} + +func (m *ProjectReq) validateMetadata(formats strfmt.Registry) error { + + if swag.IsZero(m.Metadata) { // not required + return nil + } + + if m.Metadata != nil { + if err := m.Metadata.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("metadata") + } + return err + } + } + + return nil +} + +func (m *ProjectReq) validateProjectName(formats strfmt.Registry) error { + + if swag.IsZero(m.ProjectName) { // not required + return nil + } + + if err := validate.MaxLength("project_name", "body", string(m.ProjectName), 255); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ProjectReq) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ProjectReq) UnmarshalBinary(b []byte) error { + var res ProjectReq + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/project_scanner.go b/src/server/v2.0/models/project_scanner.go new file mode 100644 index 000000000..574fb1c3a --- /dev/null +++ b/src/server/v2.0/models/project_scanner.go @@ -0,0 +1,64 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ProjectScanner project scanner +// +// swagger:model ProjectScanner +type ProjectScanner struct { + + // The identifier of the scanner registration + // Required: true + UUID *string `json:"uuid"` +} + +// Validate validates this project scanner +func (m *ProjectScanner) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateUUID(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ProjectScanner) validateUUID(formats strfmt.Registry) error { + + if err := validate.Required("uuid", "body", m.UUID); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ProjectScanner) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ProjectScanner) UnmarshalBinary(b []byte) error { + var res ProjectScanner + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/project_summary.go b/src/server/v2.0/models/project_summary.go new file mode 100644 index 000000000..3552d4fe3 --- /dev/null +++ b/src/server/v2.0/models/project_summary.go @@ -0,0 +1,117 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// ProjectSummary project summary +// +// swagger:model ProjectSummary +type ProjectSummary struct { + + // The total number of charts under this project. + ChartCount int64 `json:"chart_count"` + + // The total number of developer members. + DeveloperCount int64 `json:"developer_count,omitempty"` + + // The total number of guest members. + GuestCount int64 `json:"guest_count,omitempty"` + + // The total number of limited guest members. + LimitedGuestCount int64 `json:"limited_guest_count,omitempty"` + + // The total number of maintainer members. + MaintainerCount int64 `json:"maintainer_count,omitempty"` + + // The total number of project admin members. + ProjectAdminCount int64 `json:"project_admin_count,omitempty"` + + // quota + Quota *ProjectSummaryQuota `json:"quota,omitempty"` + + // registry + Registry *Registry `json:"registry,omitempty"` + + // The number of the repositories under this project. + RepoCount int64 `json:"repo_count"` +} + +// Validate validates this project summary +func (m *ProjectSummary) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateQuota(formats); err != nil { + res = append(res, err) + } + + if err := m.validateRegistry(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ProjectSummary) validateQuota(formats strfmt.Registry) error { + + if swag.IsZero(m.Quota) { // not required + return nil + } + + if m.Quota != nil { + if err := m.Quota.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("quota") + } + return err + } + } + + return nil +} + +func (m *ProjectSummary) validateRegistry(formats strfmt.Registry) error { + + if swag.IsZero(m.Registry) { // not required + return nil + } + + if m.Registry != nil { + if err := m.Registry.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("registry") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ProjectSummary) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ProjectSummary) UnmarshalBinary(b []byte) error { + var res ProjectSummary + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/project_summary_quota.go b/src/server/v2.0/models/project_summary_quota.go new file mode 100644 index 000000000..221e67b4f --- /dev/null +++ b/src/server/v2.0/models/project_summary_quota.go @@ -0,0 +1,92 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// ProjectSummaryQuota project summary quota +// +// swagger:model ProjectSummaryQuota +type ProjectSummaryQuota struct { + + // The hard limits of the quota + Hard ResourceList `json:"hard,omitempty"` + + // The used status of the quota + Used ResourceList `json:"used,omitempty"` +} + +// Validate validates this project summary quota +func (m *ProjectSummaryQuota) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateHard(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUsed(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ProjectSummaryQuota) validateHard(formats strfmt.Registry) error { + + if swag.IsZero(m.Hard) { // not required + return nil + } + + if err := m.Hard.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("hard") + } + return err + } + + return nil +} + +func (m *ProjectSummaryQuota) validateUsed(formats strfmt.Registry) error { + + if swag.IsZero(m.Used) { // not required + return nil + } + + if err := m.Used.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("used") + } + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ProjectSummaryQuota) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ProjectSummaryQuota) UnmarshalBinary(b []byte) error { + var res ProjectSummaryQuota + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/provider_under_project.go b/src/server/v2.0/models/provider_under_project.go new file mode 100644 index 000000000..c07392657 --- /dev/null +++ b/src/server/v2.0/models/provider_under_project.go @@ -0,0 +1,52 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// ProviderUnderProject provider under project +// +// swagger:model ProviderUnderProject +type ProviderUnderProject struct { + + // default + Default bool `json:"default,omitempty"` + + // enabled + Enabled bool `json:"enabled,omitempty"` + + // id + ID int64 `json:"id,omitempty"` + + // provider + Provider string `json:"provider,omitempty"` +} + +// Validate validates this provider under project +func (m *ProviderUnderProject) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ProviderUnderProject) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ProviderUnderProject) UnmarshalBinary(b []byte) error { + var res ProviderUnderProject + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/quota.go b/src/server/v2.0/models/quota.go new file mode 100644 index 000000000..47c9f7bc7 --- /dev/null +++ b/src/server/v2.0/models/quota.go @@ -0,0 +1,141 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// Quota The quota object +// +// swagger:model Quota +type Quota struct { + + // the creation time of the quota + // Format: date-time + CreationTime strfmt.DateTime `json:"creation_time,omitempty"` + + // The hard limits of the quota + Hard ResourceList `json:"hard,omitempty"` + + // ID of the quota + ID int64 `json:"id,omitempty"` + + // The reference object of the quota + Ref QuotaRefObject `json:"ref,omitempty"` + + // the update time of the quota + // Format: date-time + UpdateTime strfmt.DateTime `json:"update_time,omitempty"` + + // The used status of the quota + Used ResourceList `json:"used,omitempty"` +} + +// Validate validates this quota +func (m *Quota) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCreationTime(formats); err != nil { + res = append(res, err) + } + + if err := m.validateHard(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUpdateTime(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUsed(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Quota) validateCreationTime(formats strfmt.Registry) error { + + if swag.IsZero(m.CreationTime) { // not required + return nil + } + + if err := validate.FormatOf("creation_time", "body", "date-time", m.CreationTime.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *Quota) validateHard(formats strfmt.Registry) error { + + if swag.IsZero(m.Hard) { // not required + return nil + } + + if err := m.Hard.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("hard") + } + return err + } + + return nil +} + +func (m *Quota) validateUpdateTime(formats strfmt.Registry) error { + + if swag.IsZero(m.UpdateTime) { // not required + return nil + } + + if err := validate.FormatOf("update_time", "body", "date-time", m.UpdateTime.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *Quota) validateUsed(formats strfmt.Registry) error { + + if swag.IsZero(m.Used) { // not required + return nil + } + + if err := m.Used.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("used") + } + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Quota) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Quota) UnmarshalBinary(b []byte) error { + var res Quota + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/quota_ref_object.go b/src/server/v2.0/models/quota_ref_object.go new file mode 100644 index 000000000..604323528 --- /dev/null +++ b/src/server/v2.0/models/quota_ref_object.go @@ -0,0 +1,11 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +// QuotaRefObject quota ref object +// +// swagger:model QuotaRefObject +type QuotaRefObject interface{} diff --git a/src/server/v2.0/models/quota_update_req.go b/src/server/v2.0/models/quota_update_req.go new file mode 100644 index 000000000..b063f1c9c --- /dev/null +++ b/src/server/v2.0/models/quota_update_req.go @@ -0,0 +1,69 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// QuotaUpdateReq quota update req +// +// swagger:model QuotaUpdateReq +type QuotaUpdateReq struct { + + // The new hard limits for the quota + Hard ResourceList `json:"hard,omitempty"` +} + +// Validate validates this quota update req +func (m *QuotaUpdateReq) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateHard(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *QuotaUpdateReq) validateHard(formats strfmt.Registry) error { + + if swag.IsZero(m.Hard) { // not required + return nil + } + + if err := m.Hard.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("hard") + } + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *QuotaUpdateReq) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *QuotaUpdateReq) UnmarshalBinary(b []byte) error { + var res QuotaUpdateReq + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/reference.go b/src/server/v2.0/models/reference.go new file mode 100644 index 000000000..3dd55d275 --- /dev/null +++ b/src/server/v2.0/models/reference.go @@ -0,0 +1,106 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// Reference reference +// +// swagger:model Reference +type Reference struct { + + // annotations + Annotations Annotations `json:"annotations,omitempty"` + + // The digest of the child artifact + ChildDigest string `json:"child_digest,omitempty"` + + // The child ID of the reference + ChildID int64 `json:"child_id,omitempty"` + + // The parent ID of the reference + ParentID int64 `json:"parent_id,omitempty"` + + // platform + Platform *Platform `json:"platform,omitempty"` + + // The download URLs + Urls []string `json:"urls"` +} + +// Validate validates this reference +func (m *Reference) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAnnotations(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePlatform(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Reference) validateAnnotations(formats strfmt.Registry) error { + + if swag.IsZero(m.Annotations) { // not required + return nil + } + + if err := m.Annotations.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("annotations") + } + return err + } + + return nil +} + +func (m *Reference) validatePlatform(formats strfmt.Registry) error { + + if swag.IsZero(m.Platform) { // not required + return nil + } + + if m.Platform != nil { + if err := m.Platform.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("platform") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Reference) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Reference) UnmarshalBinary(b []byte) error { + var res Reference + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/registry.go b/src/server/v2.0/models/registry.go new file mode 100644 index 000000000..49b33da7d --- /dev/null +++ b/src/server/v2.0/models/registry.go @@ -0,0 +1,135 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// Registry registry +// +// swagger:model Registry +type Registry struct { + + // The create time of the policy. + // Format: date-time + CreationTime strfmt.DateTime `json:"creation_time,omitempty"` + + // credential + Credential *RegistryCredential `json:"credential,omitempty"` + + // Description of the registry. + Description string `json:"description,omitempty"` + + // The registry ID. + ID int64 `json:"id"` + + // Whether or not the certificate will be verified when Harbor tries to access the server. + Insecure bool `json:"insecure,omitempty"` + + // The registry name. + Name string `json:"name,omitempty"` + + // Health status of the registry. + Status string `json:"status,omitempty"` + + // Type of the registry, e.g. 'harbor'. + Type string `json:"type,omitempty"` + + // The update time of the policy. + // Format: date-time + UpdateTime strfmt.DateTime `json:"update_time,omitempty"` + + // The registry URL string. + URL string `json:"url,omitempty"` +} + +// Validate validates this registry +func (m *Registry) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCreationTime(formats); err != nil { + res = append(res, err) + } + + if err := m.validateCredential(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUpdateTime(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Registry) validateCreationTime(formats strfmt.Registry) error { + + if swag.IsZero(m.CreationTime) { // not required + return nil + } + + if err := validate.FormatOf("creation_time", "body", "date-time", m.CreationTime.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *Registry) validateCredential(formats strfmt.Registry) error { + + if swag.IsZero(m.Credential) { // not required + return nil + } + + if m.Credential != nil { + if err := m.Credential.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("credential") + } + return err + } + } + + return nil +} + +func (m *Registry) validateUpdateTime(formats strfmt.Registry) error { + + if swag.IsZero(m.UpdateTime) { // not required + return nil + } + + if err := validate.FormatOf("update_time", "body", "date-time", m.UpdateTime.String(), formats); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Registry) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Registry) UnmarshalBinary(b []byte) error { + var res Registry + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/registry_credential.go b/src/server/v2.0/models/registry_credential.go new file mode 100644 index 000000000..38827c44c --- /dev/null +++ b/src/server/v2.0/models/registry_credential.go @@ -0,0 +1,49 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// RegistryCredential registry credential +// +// swagger:model RegistryCredential +type RegistryCredential struct { + + // Access key, e.g. user name when credential type is 'basic'. + AccessKey string `json:"access_key,omitempty"` + + // Access secret, e.g. password when credential type is 'basic'. + AccessSecret string `json:"access_secret,omitempty"` + + // Credential type, such as 'basic', 'oauth'. + Type string `json:"type,omitempty"` +} + +// Validate validates this registry credential +func (m *RegistryCredential) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *RegistryCredential) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *RegistryCredential) UnmarshalBinary(b []byte) error { + var res RegistryCredential + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/registry_endpoint.go b/src/server/v2.0/models/registry_endpoint.go new file mode 100644 index 000000000..cd15f8c36 --- /dev/null +++ b/src/server/v2.0/models/registry_endpoint.go @@ -0,0 +1,46 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// RegistryEndpoint The style of the resource filter +// +// swagger:model RegistryEndpoint +type RegistryEndpoint struct { + + // The endpoint key + Key string `json:"key,omitempty"` + + // The endpoint value + Value string `json:"value,omitempty"` +} + +// Validate validates this registry endpoint +func (m *RegistryEndpoint) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *RegistryEndpoint) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *RegistryEndpoint) UnmarshalBinary(b []byte) error { + var res RegistryEndpoint + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/registry_info.go b/src/server/v2.0/models/registry_info.go new file mode 100644 index 000000000..619fb092a --- /dev/null +++ b/src/server/v2.0/models/registry_info.go @@ -0,0 +1,92 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// RegistryInfo The registry info contains the base info and capability declarations of the registry +// +// swagger:model RegistryInfo +type RegistryInfo struct { + + // The description + Description string `json:"description,omitempty"` + + // The registry whether support copy by chunk. + SupportedCopyByChunk *bool `json:"supported_copy_by_chunk,omitempty"` + + // The filters that the registry supports + SupportedResourceFilters []*FilterStyle `json:"supported_resource_filters"` + + // The triggers that the registry supports + SupportedTriggers []string `json:"supported_triggers"` + + // The registry type + Type string `json:"type,omitempty"` +} + +// Validate validates this registry info +func (m *RegistryInfo) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateSupportedResourceFilters(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *RegistryInfo) validateSupportedResourceFilters(formats strfmt.Registry) error { + + if swag.IsZero(m.SupportedResourceFilters) { // not required + return nil + } + + for i := 0; i < len(m.SupportedResourceFilters); i++ { + if swag.IsZero(m.SupportedResourceFilters[i]) { // not required + continue + } + + if m.SupportedResourceFilters[i] != nil { + if err := m.SupportedResourceFilters[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("supported_resource_filters" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *RegistryInfo) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *RegistryInfo) UnmarshalBinary(b []byte) error { + var res RegistryInfo + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/registry_ping.go b/src/server/v2.0/models/registry_ping.go new file mode 100644 index 000000000..3ff52de42 --- /dev/null +++ b/src/server/v2.0/models/registry_ping.go @@ -0,0 +1,61 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// RegistryPing registry ping +// +// swagger:model RegistryPing +type RegistryPing struct { + + // The registry access key. + AccessKey *string `json:"access_key,omitempty"` + + // The registry access secret. + AccessSecret *string `json:"access_secret,omitempty"` + + // Credential type of the registry, e.g. 'basic'. + CredentialType *string `json:"credential_type,omitempty"` + + // The registry ID. + ID *int64 `json:"id,omitempty"` + + // Whether or not the certificate will be verified when Harbor tries to access the server. + Insecure *bool `json:"insecure,omitempty"` + + // Type of the registry, e.g. 'harbor'. + Type *string `json:"type,omitempty"` + + // The registry URL. + URL *string `json:"url,omitempty"` +} + +// Validate validates this registry ping +func (m *RegistryPing) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *RegistryPing) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *RegistryPing) UnmarshalBinary(b []byte) error { + var res RegistryPing + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/registry_provider_credential_pattern.go b/src/server/v2.0/models/registry_provider_credential_pattern.go new file mode 100644 index 000000000..8c2f0e0cd --- /dev/null +++ b/src/server/v2.0/models/registry_provider_credential_pattern.go @@ -0,0 +1,52 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// RegistryProviderCredentialPattern The registry credential pattern +// +// swagger:model RegistryProviderCredentialPattern +type RegistryProviderCredentialPattern struct { + + // The access key data + AccessKeyData string `json:"access_key_data,omitempty"` + + // The access key type + AccessKeyType string `json:"access_key_type,omitempty"` + + // The access secret data + AccessSecretData string `json:"access_secret_data,omitempty"` + + // The access secret type + AccessSecretType string `json:"access_secret_type,omitempty"` +} + +// Validate validates this registry provider credential pattern +func (m *RegistryProviderCredentialPattern) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *RegistryProviderCredentialPattern) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *RegistryProviderCredentialPattern) UnmarshalBinary(b []byte) error { + var res RegistryProviderCredentialPattern + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/registry_provider_endpoint_pattern.go b/src/server/v2.0/models/registry_provider_endpoint_pattern.go new file mode 100644 index 000000000..6f5f188be --- /dev/null +++ b/src/server/v2.0/models/registry_provider_endpoint_pattern.go @@ -0,0 +1,83 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// RegistryProviderEndpointPattern The registry endpoint pattern +// +// swagger:model RegistryProviderEndpointPattern +type RegistryProviderEndpointPattern struct { + + // The endpoint type + EndpointType string `json:"endpoint_type,omitempty"` + + // The endpoint list + Endpoints []*RegistryEndpoint `json:"endpoints"` +} + +// Validate validates this registry provider endpoint pattern +func (m *RegistryProviderEndpointPattern) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateEndpoints(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *RegistryProviderEndpointPattern) validateEndpoints(formats strfmt.Registry) error { + + if swag.IsZero(m.Endpoints) { // not required + return nil + } + + for i := 0; i < len(m.Endpoints); i++ { + if swag.IsZero(m.Endpoints[i]) { // not required + continue + } + + if m.Endpoints[i] != nil { + if err := m.Endpoints[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("endpoints" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *RegistryProviderEndpointPattern) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *RegistryProviderEndpointPattern) UnmarshalBinary(b []byte) error { + var res RegistryProviderEndpointPattern + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/registry_provider_info.go b/src/server/v2.0/models/registry_provider_info.go new file mode 100644 index 000000000..7c5eea9f0 --- /dev/null +++ b/src/server/v2.0/models/registry_provider_info.go @@ -0,0 +1,96 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// RegistryProviderInfo The registry provider info contains the base info and capability declarations of the registry provider +// +// swagger:model RegistryProviderInfo +type RegistryProviderInfo struct { + + // The credential pattern + CredentialPattern *RegistryProviderCredentialPattern `json:"credential_pattern,omitempty"` + + // The endpoint pattern + EndpointPattern *RegistryProviderEndpointPattern `json:"endpoint_pattern,omitempty"` +} + +// Validate validates this registry provider info +func (m *RegistryProviderInfo) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCredentialPattern(formats); err != nil { + res = append(res, err) + } + + if err := m.validateEndpointPattern(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *RegistryProviderInfo) validateCredentialPattern(formats strfmt.Registry) error { + + if swag.IsZero(m.CredentialPattern) { // not required + return nil + } + + if m.CredentialPattern != nil { + if err := m.CredentialPattern.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("credential_pattern") + } + return err + } + } + + return nil +} + +func (m *RegistryProviderInfo) validateEndpointPattern(formats strfmt.Registry) error { + + if swag.IsZero(m.EndpointPattern) { // not required + return nil + } + + if m.EndpointPattern != nil { + if err := m.EndpointPattern.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("endpoint_pattern") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *RegistryProviderInfo) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *RegistryProviderInfo) UnmarshalBinary(b []byte) error { + var res RegistryProviderInfo + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/registry_update.go b/src/server/v2.0/models/registry_update.go new file mode 100644 index 000000000..650a481be --- /dev/null +++ b/src/server/v2.0/models/registry_update.go @@ -0,0 +1,61 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// RegistryUpdate registry update +// +// swagger:model RegistryUpdate +type RegistryUpdate struct { + + // The registry access key. + AccessKey *string `json:"access_key,omitempty"` + + // The registry access secret. + AccessSecret *string `json:"access_secret,omitempty"` + + // Credential type of the registry, e.g. 'basic'. + CredentialType *string `json:"credential_type,omitempty"` + + // Description of the registry. + Description *string `json:"description,omitempty"` + + // Whether or not the certificate will be verified when Harbor tries to access the server. + Insecure *bool `json:"insecure,omitempty"` + + // The registry name. + Name *string `json:"name,omitempty"` + + // The registry URL. + URL *string `json:"url,omitempty"` +} + +// Validate validates this registry update +func (m *RegistryUpdate) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *RegistryUpdate) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *RegistryUpdate) UnmarshalBinary(b []byte) error { + var res RegistryUpdate + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/replication_execution.go b/src/server/v2.0/models/replication_execution.go new file mode 100644 index 000000000..d44316d46 --- /dev/null +++ b/src/server/v2.0/models/replication_execution.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ReplicationExecution The replication execution +// +// swagger:model ReplicationExecution +type ReplicationExecution struct { + + // The end time + // Format: date-time + EndTime strfmt.DateTime `json:"end_time,omitempty"` + + // The count of failed executions + Failed int64 `json:"failed"` + + // The ID of the execution + ID int64 `json:"id,omitempty"` + + // The count of in_progress executions + InProgress int64 `json:"in_progress"` + + // The ID if the policy that the execution belongs to + PolicyID int64 `json:"policy_id,omitempty"` + + // The start time + // Format: date-time + StartTime strfmt.DateTime `json:"start_time,omitempty"` + + // The status of the execution + Status string `json:"status,omitempty"` + + // The status text + StatusText string `json:"status_text"` + + // The count of stopped executions + Stopped int64 `json:"stopped"` + + // The count of succeed executions + Succeed int64 `json:"succeed"` + + // The total count of all executions + Total int64 `json:"total"` + + // The trigger mode + Trigger string `json:"trigger,omitempty"` +} + +// Validate validates this replication execution +func (m *ReplicationExecution) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateEndTime(formats); err != nil { + res = append(res, err) + } + + if err := m.validateStartTime(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ReplicationExecution) validateEndTime(formats strfmt.Registry) error { + + if swag.IsZero(m.EndTime) { // not required + return nil + } + + if err := validate.FormatOf("end_time", "body", "date-time", m.EndTime.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *ReplicationExecution) validateStartTime(formats strfmt.Registry) error { + + if swag.IsZero(m.StartTime) { // not required + return nil + } + + if err := validate.FormatOf("start_time", "body", "date-time", m.StartTime.String(), formats); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ReplicationExecution) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ReplicationExecution) UnmarshalBinary(b []byte) error { + var res ReplicationExecution + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/replication_filter.go b/src/server/v2.0/models/replication_filter.go new file mode 100644 index 000000000..ce345e6d6 --- /dev/null +++ b/src/server/v2.0/models/replication_filter.go @@ -0,0 +1,49 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// ReplicationFilter replication filter +// +// swagger:model ReplicationFilter +type ReplicationFilter struct { + + // matches or excludes the result + Decoration string `json:"decoration,omitempty"` + + // The replication policy filter type. + Type string `json:"type,omitempty"` + + // The value of replication policy filter. + Value interface{} `json:"value,omitempty"` +} + +// Validate validates this replication filter +func (m *ReplicationFilter) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ReplicationFilter) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ReplicationFilter) UnmarshalBinary(b []byte) error { + var res ReplicationFilter + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/replication_policy.go b/src/server/v2.0/models/replication_policy.go new file mode 100644 index 000000000..63a29363c --- /dev/null +++ b/src/server/v2.0/models/replication_policy.go @@ -0,0 +1,232 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ReplicationPolicy replication policy +// +// swagger:model ReplicationPolicy +type ReplicationPolicy struct { + + // Whether to enable copy by chunk. + CopyByChunk *bool `json:"copy_by_chunk,omitempty"` + + // The create time of the policy. + // Format: date-time + CreationTime strfmt.DateTime `json:"creation_time,omitempty"` + + // Deprecated, use "replicate_deletion" instead. Whether to replicate the deletion operation. + Deletion bool `json:"deletion,omitempty"` + + // The description of the policy. + Description string `json:"description,omitempty"` + + // The destination namespace. + DestNamespace string `json:"dest_namespace,omitempty"` + + // Specify how many path components will be replaced by the provided destination namespace. + // The default value is -1 in which case the legacy mode will be applied. + DestNamespaceReplaceCount *int8 `json:"dest_namespace_replace_count,omitempty"` + + // The destination registry. + DestRegistry *Registry `json:"dest_registry,omitempty"` + + // Whether the policy is enabled or not. + Enabled bool `json:"enabled,omitempty"` + + // The replication policy filter array. + Filters []*ReplicationFilter `json:"filters"` + + // The policy ID. + ID int64 `json:"id,omitempty"` + + // The policy name. + Name string `json:"name,omitempty"` + + // Whether to override the resources on the destination registry. + Override bool `json:"override,omitempty"` + + // Whether to replicate the deletion operation. + ReplicateDeletion bool `json:"replicate_deletion,omitempty"` + + // speed limit for each task + Speed *int32 `json:"speed,omitempty"` + + // The source registry. + SrcRegistry *Registry `json:"src_registry,omitempty"` + + // trigger + Trigger *ReplicationTrigger `json:"trigger,omitempty"` + + // The update time of the policy. + // Format: date-time + UpdateTime strfmt.DateTime `json:"update_time,omitempty"` +} + +// Validate validates this replication policy +func (m *ReplicationPolicy) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCreationTime(formats); err != nil { + res = append(res, err) + } + + if err := m.validateDestRegistry(formats); err != nil { + res = append(res, err) + } + + if err := m.validateFilters(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSrcRegistry(formats); err != nil { + res = append(res, err) + } + + if err := m.validateTrigger(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUpdateTime(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ReplicationPolicy) validateCreationTime(formats strfmt.Registry) error { + + if swag.IsZero(m.CreationTime) { // not required + return nil + } + + if err := validate.FormatOf("creation_time", "body", "date-time", m.CreationTime.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *ReplicationPolicy) validateDestRegistry(formats strfmt.Registry) error { + + if swag.IsZero(m.DestRegistry) { // not required + return nil + } + + if m.DestRegistry != nil { + if err := m.DestRegistry.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("dest_registry") + } + return err + } + } + + return nil +} + +func (m *ReplicationPolicy) validateFilters(formats strfmt.Registry) error { + + if swag.IsZero(m.Filters) { // not required + return nil + } + + for i := 0; i < len(m.Filters); i++ { + if swag.IsZero(m.Filters[i]) { // not required + continue + } + + if m.Filters[i] != nil { + if err := m.Filters[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("filters" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *ReplicationPolicy) validateSrcRegistry(formats strfmt.Registry) error { + + if swag.IsZero(m.SrcRegistry) { // not required + return nil + } + + if m.SrcRegistry != nil { + if err := m.SrcRegistry.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("src_registry") + } + return err + } + } + + return nil +} + +func (m *ReplicationPolicy) validateTrigger(formats strfmt.Registry) error { + + if swag.IsZero(m.Trigger) { // not required + return nil + } + + if m.Trigger != nil { + if err := m.Trigger.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("trigger") + } + return err + } + } + + return nil +} + +func (m *ReplicationPolicy) validateUpdateTime(formats strfmt.Registry) error { + + if swag.IsZero(m.UpdateTime) { // not required + return nil + } + + if err := validate.FormatOf("update_time", "body", "date-time", m.UpdateTime.String(), formats); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ReplicationPolicy) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ReplicationPolicy) UnmarshalBinary(b []byte) error { + var res ReplicationPolicy + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/replication_task.go b/src/server/v2.0/models/replication_task.go new file mode 100644 index 000000000..146e665a7 --- /dev/null +++ b/src/server/v2.0/models/replication_task.go @@ -0,0 +1,113 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ReplicationTask The replication task +// +// swagger:model ReplicationTask +type ReplicationTask struct { + + // The destination resource that the task operates + DstResource string `json:"dst_resource,omitempty"` + + // The end time of the task + // Format: date-time + EndTime strfmt.DateTime `json:"end_time,omitempty"` + + // The ID of the execution that the task belongs to + ExecutionID int64 `json:"execution_id,omitempty"` + + // The ID of the task + ID int64 `json:"id,omitempty"` + + // The ID of the underlying job that the task related to + JobID string `json:"job_id,omitempty"` + + // The operation of the task + Operation string `json:"operation,omitempty"` + + // The type of the resource that the task operates + ResourceType string `json:"resource_type,omitempty"` + + // The source resource that the task operates + SrcResource string `json:"src_resource,omitempty"` + + // The start time of the task + // Format: date-time + StartTime strfmt.DateTime `json:"start_time,omitempty"` + + // The status of the task + Status string `json:"status,omitempty"` +} + +// Validate validates this replication task +func (m *ReplicationTask) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateEndTime(formats); err != nil { + res = append(res, err) + } + + if err := m.validateStartTime(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ReplicationTask) validateEndTime(formats strfmt.Registry) error { + + if swag.IsZero(m.EndTime) { // not required + return nil + } + + if err := validate.FormatOf("end_time", "body", "date-time", m.EndTime.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *ReplicationTask) validateStartTime(formats strfmt.Registry) error { + + if swag.IsZero(m.StartTime) { // not required + return nil + } + + if err := validate.FormatOf("start_time", "body", "date-time", m.StartTime.String(), formats); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ReplicationTask) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ReplicationTask) UnmarshalBinary(b []byte) error { + var res ReplicationTask + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/replication_trigger.go b/src/server/v2.0/models/replication_trigger.go new file mode 100644 index 000000000..3febbe9aa --- /dev/null +++ b/src/server/v2.0/models/replication_trigger.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// ReplicationTrigger replication trigger +// +// swagger:model ReplicationTrigger +type ReplicationTrigger struct { + + // trigger settings + TriggerSettings *ReplicationTriggerSettings `json:"trigger_settings,omitempty"` + + // The replication policy trigger type. The valid values are manual, event_based and scheduled. + Type string `json:"type,omitempty"` +} + +// Validate validates this replication trigger +func (m *ReplicationTrigger) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateTriggerSettings(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ReplicationTrigger) validateTriggerSettings(formats strfmt.Registry) error { + + if swag.IsZero(m.TriggerSettings) { // not required + return nil + } + + if m.TriggerSettings != nil { + if err := m.TriggerSettings.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("trigger_settings") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ReplicationTrigger) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ReplicationTrigger) UnmarshalBinary(b []byte) error { + var res ReplicationTrigger + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/replication_trigger_settings.go b/src/server/v2.0/models/replication_trigger_settings.go new file mode 100644 index 000000000..d90f3a3c6 --- /dev/null +++ b/src/server/v2.0/models/replication_trigger_settings.go @@ -0,0 +1,43 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// ReplicationTriggerSettings replication trigger settings +// +// swagger:model ReplicationTriggerSettings +type ReplicationTriggerSettings struct { + + // The cron string for scheduled trigger + Cron string `json:"cron,omitempty"` +} + +// Validate validates this replication trigger settings +func (m *ReplicationTriggerSettings) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ReplicationTriggerSettings) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ReplicationTriggerSettings) UnmarshalBinary(b []byte) error { + var res ReplicationTriggerSettings + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/repository.go b/src/server/v2.0/models/repository.go new file mode 100644 index 000000000..20fc72941 --- /dev/null +++ b/src/server/v2.0/models/repository.go @@ -0,0 +1,107 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// Repository repository +// +// swagger:model Repository +type Repository struct { + + // The count of the artifacts inside the repository + ArtifactCount int64 `json:"artifact_count"` + + // The creation time of the repository + // Format: date-time + CreationTime *strfmt.DateTime `json:"creation_time,omitempty"` + + // The description of the repository + Description string `json:"description,omitempty"` + + // The ID of the repository + ID int64 `json:"id,omitempty"` + + // The name of the repository + Name string `json:"name,omitempty"` + + // The ID of the project that the repository belongs to + ProjectID int64 `json:"project_id,omitempty"` + + // The count that the artifact inside the repository pulled + PullCount int64 `json:"pull_count"` + + // The update time of the repository + // Format: date-time + UpdateTime strfmt.DateTime `json:"update_time,omitempty"` +} + +// Validate validates this repository +func (m *Repository) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCreationTime(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUpdateTime(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Repository) validateCreationTime(formats strfmt.Registry) error { + + if swag.IsZero(m.CreationTime) { // not required + return nil + } + + if err := validate.FormatOf("creation_time", "body", "date-time", m.CreationTime.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *Repository) validateUpdateTime(formats strfmt.Registry) error { + + if swag.IsZero(m.UpdateTime) { // not required + return nil + } + + if err := validate.FormatOf("update_time", "body", "date-time", m.UpdateTime.String(), formats); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Repository) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Repository) UnmarshalBinary(b []byte) error { + var res Repository + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/resource_list.go b/src/server/v2.0/models/resource_list.go new file mode 100644 index 000000000..9f26bfa6c --- /dev/null +++ b/src/server/v2.0/models/resource_list.go @@ -0,0 +1,20 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" +) + +// ResourceList resource list +// +// swagger:model ResourceList +type ResourceList map[string]int64 + +// Validate validates this resource list +func (m ResourceList) Validate(formats strfmt.Registry) error { + return nil +} diff --git a/src/server/v2.0/models/retention_execution.go b/src/server/v2.0/models/retention_execution.go new file mode 100644 index 000000000..c5e8041a1 --- /dev/null +++ b/src/server/v2.0/models/retention_execution.go @@ -0,0 +1,61 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// RetentionExecution retention execution +// +// swagger:model RetentionExecution +type RetentionExecution struct { + + // dry run + DryRun bool `json:"dry_run,omitempty"` + + // end time + EndTime string `json:"end_time,omitempty"` + + // id + ID int64 `json:"id,omitempty"` + + // policy id + PolicyID int64 `json:"policy_id,omitempty"` + + // start time + StartTime string `json:"start_time,omitempty"` + + // status + Status string `json:"status,omitempty"` + + // trigger + Trigger string `json:"trigger,omitempty"` +} + +// Validate validates this retention execution +func (m *RetentionExecution) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *RetentionExecution) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *RetentionExecution) UnmarshalBinary(b []byte) error { + var res RetentionExecution + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/retention_execution_task.go b/src/server/v2.0/models/retention_execution_task.go new file mode 100644 index 000000000..7a09b261b --- /dev/null +++ b/src/server/v2.0/models/retention_execution_task.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// RetentionExecutionTask retention execution task +// +// swagger:model RetentionExecutionTask +type RetentionExecutionTask struct { + + // end time + EndTime string `json:"end_time,omitempty"` + + // execution id + ExecutionID int64 `json:"execution_id,omitempty"` + + // id + ID int64 `json:"id,omitempty"` + + // job id + JobID string `json:"job_id,omitempty"` + + // repository + Repository string `json:"repository,omitempty"` + + // retained + Retained int64 `json:"retained"` + + // start time + StartTime string `json:"start_time,omitempty"` + + // status + Status string `json:"status,omitempty"` + + // status code + StatusCode int64 `json:"status_code"` + + // status revision + StatusRevision int64 `json:"status_revision,omitempty"` + + // total + Total int64 `json:"total"` +} + +// Validate validates this retention execution task +func (m *RetentionExecutionTask) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *RetentionExecutionTask) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *RetentionExecutionTask) UnmarshalBinary(b []byte) error { + var res RetentionExecutionTask + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/retention_metadata.go b/src/server/v2.0/models/retention_metadata.go new file mode 100644 index 000000000..990c69b0e --- /dev/null +++ b/src/server/v2.0/models/retention_metadata.go @@ -0,0 +1,144 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// RetentionMetadata the tag retention metadata +// +// swagger:model RetentionMetadata +type RetentionMetadata struct { + + // supported scope selectors + ScopeSelectors []*RetentionSelectorMetadata `json:"scope_selectors"` + + // supported tag selectors + TagSelectors []*RetentionSelectorMetadata `json:"tag_selectors"` + + // templates + Templates []*RetentionRuleMetadata `json:"templates"` +} + +// Validate validates this retention metadata +func (m *RetentionMetadata) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateScopeSelectors(formats); err != nil { + res = append(res, err) + } + + if err := m.validateTagSelectors(formats); err != nil { + res = append(res, err) + } + + if err := m.validateTemplates(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *RetentionMetadata) validateScopeSelectors(formats strfmt.Registry) error { + + if swag.IsZero(m.ScopeSelectors) { // not required + return nil + } + + for i := 0; i < len(m.ScopeSelectors); i++ { + if swag.IsZero(m.ScopeSelectors[i]) { // not required + continue + } + + if m.ScopeSelectors[i] != nil { + if err := m.ScopeSelectors[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("scope_selectors" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *RetentionMetadata) validateTagSelectors(formats strfmt.Registry) error { + + if swag.IsZero(m.TagSelectors) { // not required + return nil + } + + for i := 0; i < len(m.TagSelectors); i++ { + if swag.IsZero(m.TagSelectors[i]) { // not required + continue + } + + if m.TagSelectors[i] != nil { + if err := m.TagSelectors[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("tag_selectors" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *RetentionMetadata) validateTemplates(formats strfmt.Registry) error { + + if swag.IsZero(m.Templates) { // not required + return nil + } + + for i := 0; i < len(m.Templates); i++ { + if swag.IsZero(m.Templates[i]) { // not required + continue + } + + if m.Templates[i] != nil { + if err := m.Templates[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("templates" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *RetentionMetadata) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *RetentionMetadata) UnmarshalBinary(b []byte) error { + var res RetentionMetadata + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/retention_policy.go b/src/server/v2.0/models/retention_policy.go new file mode 100644 index 000000000..b755e8524 --- /dev/null +++ b/src/server/v2.0/models/retention_policy.go @@ -0,0 +1,136 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// RetentionPolicy retention policy +// +// swagger:model RetentionPolicy +type RetentionPolicy struct { + + // algorithm + Algorithm string `json:"algorithm,omitempty"` + + // id + ID int64 `json:"id,omitempty"` + + // rules + Rules []*RetentionRule `json:"rules"` + + // scope + Scope *RetentionPolicyScope `json:"scope,omitempty"` + + // trigger + Trigger *RetentionRuleTrigger `json:"trigger,omitempty"` +} + +// Validate validates this retention policy +func (m *RetentionPolicy) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateRules(formats); err != nil { + res = append(res, err) + } + + if err := m.validateScope(formats); err != nil { + res = append(res, err) + } + + if err := m.validateTrigger(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *RetentionPolicy) validateRules(formats strfmt.Registry) error { + + if swag.IsZero(m.Rules) { // not required + return nil + } + + for i := 0; i < len(m.Rules); i++ { + if swag.IsZero(m.Rules[i]) { // not required + continue + } + + if m.Rules[i] != nil { + if err := m.Rules[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("rules" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *RetentionPolicy) validateScope(formats strfmt.Registry) error { + + if swag.IsZero(m.Scope) { // not required + return nil + } + + if m.Scope != nil { + if err := m.Scope.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("scope") + } + return err + } + } + + return nil +} + +func (m *RetentionPolicy) validateTrigger(formats strfmt.Registry) error { + + if swag.IsZero(m.Trigger) { // not required + return nil + } + + if m.Trigger != nil { + if err := m.Trigger.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("trigger") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *RetentionPolicy) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *RetentionPolicy) UnmarshalBinary(b []byte) error { + var res RetentionPolicy + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/retention_policy_scope.go b/src/server/v2.0/models/retention_policy_scope.go new file mode 100644 index 000000000..923a66791 --- /dev/null +++ b/src/server/v2.0/models/retention_policy_scope.go @@ -0,0 +1,46 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// RetentionPolicyScope retention policy scope +// +// swagger:model RetentionPolicyScope +type RetentionPolicyScope struct { + + // level + Level string `json:"level,omitempty"` + + // ref + Ref int64 `json:"ref,omitempty"` +} + +// Validate validates this retention policy scope +func (m *RetentionPolicyScope) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *RetentionPolicyScope) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *RetentionPolicyScope) UnmarshalBinary(b []byte) error { + var res RetentionPolicyScope + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/retention_rule.go b/src/server/v2.0/models/retention_rule.go new file mode 100644 index 000000000..3f0d7d517 --- /dev/null +++ b/src/server/v2.0/models/retention_rule.go @@ -0,0 +1,134 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// RetentionRule retention rule +// +// swagger:model RetentionRule +type RetentionRule struct { + + // action + Action string `json:"action,omitempty"` + + // disabled + Disabled bool `json:"disabled,omitempty"` + + // id + ID int64 `json:"id,omitempty"` + + // params + Params map[string]interface{} `json:"params,omitempty"` + + // priority + Priority int64 `json:"priority,omitempty"` + + // scope selectors + ScopeSelectors map[string][]RetentionSelector `json:"scope_selectors,omitempty"` + + // tag selectors + TagSelectors []*RetentionSelector `json:"tag_selectors"` + + // template + Template string `json:"template,omitempty"` +} + +// Validate validates this retention rule +func (m *RetentionRule) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateScopeSelectors(formats); err != nil { + res = append(res, err) + } + + if err := m.validateTagSelectors(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *RetentionRule) validateScopeSelectors(formats strfmt.Registry) error { + + if swag.IsZero(m.ScopeSelectors) { // not required + return nil + } + + for k := range m.ScopeSelectors { + + if err := validate.Required("scope_selectors"+"."+k, "body", m.ScopeSelectors[k]); err != nil { + return err + } + + for i := 0; i < len(m.ScopeSelectors[k]); i++ { + + if err := m.ScopeSelectors[k][i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("scope_selectors" + "." + k + "." + strconv.Itoa(i)) + } + return err + } + + } + + } + + return nil +} + +func (m *RetentionRule) validateTagSelectors(formats strfmt.Registry) error { + + if swag.IsZero(m.TagSelectors) { // not required + return nil + } + + for i := 0; i < len(m.TagSelectors); i++ { + if swag.IsZero(m.TagSelectors[i]) { // not required + continue + } + + if m.TagSelectors[i] != nil { + if err := m.TagSelectors[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("tag_selectors" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *RetentionRule) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *RetentionRule) UnmarshalBinary(b []byte) error { + var res RetentionRule + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/retention_rule_metadata.go b/src/server/v2.0/models/retention_rule_metadata.go new file mode 100644 index 000000000..45fb726a0 --- /dev/null +++ b/src/server/v2.0/models/retention_rule_metadata.go @@ -0,0 +1,89 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// RetentionRuleMetadata the tag retention rule metadata +// +// swagger:model RetentionRuleMetadata +type RetentionRuleMetadata struct { + + // rule action + Action string `json:"action,omitempty"` + + // rule display text + DisplayText string `json:"display_text,omitempty"` + + // rule params + Params []*RetentionRuleParamMetadata `json:"params"` + + // rule id + RuleTemplate string `json:"rule_template,omitempty"` +} + +// Validate validates this retention rule metadata +func (m *RetentionRuleMetadata) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateParams(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *RetentionRuleMetadata) validateParams(formats strfmt.Registry) error { + + if swag.IsZero(m.Params) { // not required + return nil + } + + for i := 0; i < len(m.Params); i++ { + if swag.IsZero(m.Params[i]) { // not required + continue + } + + if m.Params[i] != nil { + if err := m.Params[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("params" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *RetentionRuleMetadata) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *RetentionRuleMetadata) UnmarshalBinary(b []byte) error { + var res RetentionRuleMetadata + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/retention_rule_param_metadata.go b/src/server/v2.0/models/retention_rule_param_metadata.go new file mode 100644 index 000000000..45582d2fc --- /dev/null +++ b/src/server/v2.0/models/retention_rule_param_metadata.go @@ -0,0 +1,49 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// RetentionRuleParamMetadata rule param +// +// swagger:model RetentionRuleParamMetadata +type RetentionRuleParamMetadata struct { + + // required + Required bool `json:"required,omitempty"` + + // type + Type string `json:"type,omitempty"` + + // unit + Unit string `json:"unit,omitempty"` +} + +// Validate validates this retention rule param metadata +func (m *RetentionRuleParamMetadata) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *RetentionRuleParamMetadata) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *RetentionRuleParamMetadata) UnmarshalBinary(b []byte) error { + var res RetentionRuleParamMetadata + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/retention_rule_trigger.go b/src/server/v2.0/models/retention_rule_trigger.go new file mode 100644 index 000000000..a39b55cfc --- /dev/null +++ b/src/server/v2.0/models/retention_rule_trigger.go @@ -0,0 +1,49 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// RetentionRuleTrigger retention rule trigger +// +// swagger:model RetentionRuleTrigger +type RetentionRuleTrigger struct { + + // kind + Kind string `json:"kind,omitempty"` + + // references + References interface{} `json:"references,omitempty"` + + // settings + Settings interface{} `json:"settings,omitempty"` +} + +// Validate validates this retention rule trigger +func (m *RetentionRuleTrigger) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *RetentionRuleTrigger) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *RetentionRuleTrigger) UnmarshalBinary(b []byte) error { + var res RetentionRuleTrigger + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/retention_selector.go b/src/server/v2.0/models/retention_selector.go new file mode 100644 index 000000000..f67e1c3de --- /dev/null +++ b/src/server/v2.0/models/retention_selector.go @@ -0,0 +1,52 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// RetentionSelector retention selector +// +// swagger:model RetentionSelector +type RetentionSelector struct { + + // decoration + Decoration string `json:"decoration,omitempty"` + + // extras + Extras string `json:"extras,omitempty"` + + // kind + Kind string `json:"kind,omitempty"` + + // pattern + Pattern string `json:"pattern,omitempty"` +} + +// Validate validates this retention selector +func (m *RetentionSelector) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *RetentionSelector) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *RetentionSelector) UnmarshalBinary(b []byte) error { + var res RetentionSelector + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/retention_selector_metadata.go b/src/server/v2.0/models/retention_selector_metadata.go new file mode 100644 index 000000000..92e20acc2 --- /dev/null +++ b/src/server/v2.0/models/retention_selector_metadata.go @@ -0,0 +1,49 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// RetentionSelectorMetadata retention selector +// +// swagger:model RetentionSelectorMetadata +type RetentionSelectorMetadata struct { + + // decorations + Decorations []string `json:"decorations"` + + // display text + DisplayText string `json:"display_text,omitempty"` + + // kind + Kind string `json:"kind,omitempty"` +} + +// Validate validates this retention selector metadata +func (m *RetentionSelectorMetadata) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *RetentionSelectorMetadata) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *RetentionSelectorMetadata) UnmarshalBinary(b []byte) error { + var res RetentionSelectorMetadata + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/robot.go b/src/server/v2.0/models/robot.go new file mode 100644 index 000000000..666b48325 --- /dev/null +++ b/src/server/v2.0/models/robot.go @@ -0,0 +1,150 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// Robot robot +// +// swagger:model Robot +type Robot struct { + + // The creation time of the robot. + // Format: date-time + CreationTime strfmt.DateTime `json:"creation_time,omitempty"` + + // The description of the robot + Description string `json:"description,omitempty"` + + // The disable status of the robot + Disable bool `json:"disable"` + + // The duration of the robot in days + Duration int64 `json:"duration,omitempty"` + + // The editable status of the robot + Editable bool `json:"editable"` + + // The expiration data of the robot + ExpiresAt int64 `json:"expires_at,omitempty"` + + // The ID of the robot + ID int64 `json:"id,omitempty"` + + // The level of the robot, project or system + Level string `json:"level,omitempty"` + + // The name of the tag + Name string `json:"name,omitempty"` + + // permissions + Permissions []*RobotPermission `json:"permissions"` + + // The secret of the robot + Secret string `json:"secret,omitempty"` + + // The update time of the robot. + // Format: date-time + UpdateTime strfmt.DateTime `json:"update_time,omitempty"` +} + +// Validate validates this robot +func (m *Robot) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCreationTime(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePermissions(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUpdateTime(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Robot) validateCreationTime(formats strfmt.Registry) error { + + if swag.IsZero(m.CreationTime) { // not required + return nil + } + + if err := validate.FormatOf("creation_time", "body", "date-time", m.CreationTime.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *Robot) validatePermissions(formats strfmt.Registry) error { + + if swag.IsZero(m.Permissions) { // not required + return nil + } + + for i := 0; i < len(m.Permissions); i++ { + if swag.IsZero(m.Permissions[i]) { // not required + continue + } + + if m.Permissions[i] != nil { + if err := m.Permissions[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("permissions" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *Robot) validateUpdateTime(formats strfmt.Registry) error { + + if swag.IsZero(m.UpdateTime) { // not required + return nil + } + + if err := validate.FormatOf("update_time", "body", "date-time", m.UpdateTime.String(), formats); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Robot) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Robot) UnmarshalBinary(b []byte) error { + var res Robot + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/robot_create.go b/src/server/v2.0/models/robot_create.go new file mode 100644 index 000000000..88acc0b99 --- /dev/null +++ b/src/server/v2.0/models/robot_create.go @@ -0,0 +1,98 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// RobotCreate The request for robot account creation. +// +// swagger:model RobotCreate +type RobotCreate struct { + + // The description of the robot + Description string `json:"description,omitempty"` + + // The disable status of the robot + Disable bool `json:"disable,omitempty"` + + // The duration of the robot in days + Duration int64 `json:"duration,omitempty"` + + // The level of the robot, project or system + Level string `json:"level,omitempty"` + + // The name of the tag + Name string `json:"name,omitempty"` + + // permissions + Permissions []*RobotPermission `json:"permissions"` + + // The secret of the robot + Secret string `json:"secret,omitempty"` +} + +// Validate validates this robot create +func (m *RobotCreate) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validatePermissions(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *RobotCreate) validatePermissions(formats strfmt.Registry) error { + + if swag.IsZero(m.Permissions) { // not required + return nil + } + + for i := 0; i < len(m.Permissions); i++ { + if swag.IsZero(m.Permissions[i]) { // not required + continue + } + + if m.Permissions[i] != nil { + if err := m.Permissions[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("permissions" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *RobotCreate) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *RobotCreate) UnmarshalBinary(b []byte) error { + var res RobotCreate + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/robot_create_v1.go b/src/server/v2.0/models/robot_create_v1.go new file mode 100644 index 000000000..807776fb6 --- /dev/null +++ b/src/server/v2.0/models/robot_create_v1.go @@ -0,0 +1,89 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// RobotCreateV1 robot create v1 +// +// swagger:model RobotCreateV1 +type RobotCreateV1 struct { + + // The permission of robot account + Access []*Access `json:"access"` + + // The description of robot account + Description string `json:"description,omitempty"` + + // The expiration time on or after which the JWT MUST NOT be accepted for processing. + ExpiresAt int64 `json:"expires_at,omitempty"` + + // The name of robot account + Name string `json:"name,omitempty"` +} + +// Validate validates this robot create v1 +func (m *RobotCreateV1) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAccess(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *RobotCreateV1) validateAccess(formats strfmt.Registry) error { + + if swag.IsZero(m.Access) { // not required + return nil + } + + for i := 0; i < len(m.Access); i++ { + if swag.IsZero(m.Access[i]) { // not required + continue + } + + if m.Access[i] != nil { + if err := m.Access[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("access" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *RobotCreateV1) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *RobotCreateV1) UnmarshalBinary(b []byte) error { + var res RobotCreateV1 + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/robot_created.go b/src/server/v2.0/models/robot_created.go new file mode 100644 index 000000000..bed44d200 --- /dev/null +++ b/src/server/v2.0/models/robot_created.go @@ -0,0 +1,80 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// RobotCreated The response for robot account creation. +// +// swagger:model RobotCreated +type RobotCreated struct { + + // The creation time of the robot. + // Format: date-time + CreationTime strfmt.DateTime `json:"creation_time,omitempty"` + + // The expiration data of the robot + ExpiresAt int64 `json:"expires_at,omitempty"` + + // The ID of the robot + ID int64 `json:"id,omitempty"` + + // The name of the tag + Name string `json:"name,omitempty"` + + // The secret of the robot + Secret string `json:"secret,omitempty"` +} + +// Validate validates this robot created +func (m *RobotCreated) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCreationTime(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *RobotCreated) validateCreationTime(formats strfmt.Registry) error { + + if swag.IsZero(m.CreationTime) { // not required + return nil + } + + if err := validate.FormatOf("creation_time", "body", "date-time", m.CreationTime.String(), formats); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *RobotCreated) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *RobotCreated) UnmarshalBinary(b []byte) error { + var res RobotCreated + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/robot_permission.go b/src/server/v2.0/models/robot_permission.go new file mode 100644 index 000000000..c17eb1ee1 --- /dev/null +++ b/src/server/v2.0/models/robot_permission.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// RobotPermission robot permission +// +// swagger:model RobotPermission +type RobotPermission struct { + + // access + Access []*Access `json:"access"` + + // The kind of the permission + Kind string `json:"kind,omitempty"` + + // The namespace of the permission + Namespace string `json:"namespace,omitempty"` +} + +// Validate validates this robot permission +func (m *RobotPermission) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAccess(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *RobotPermission) validateAccess(formats strfmt.Registry) error { + + if swag.IsZero(m.Access) { // not required + return nil + } + + for i := 0; i < len(m.Access); i++ { + if swag.IsZero(m.Access[i]) { // not required + continue + } + + if m.Access[i] != nil { + if err := m.Access[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("access" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *RobotPermission) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *RobotPermission) UnmarshalBinary(b []byte) error { + var res RobotPermission + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/robot_sec.go b/src/server/v2.0/models/robot_sec.go new file mode 100644 index 000000000..36fc1877e --- /dev/null +++ b/src/server/v2.0/models/robot_sec.go @@ -0,0 +1,43 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// RobotSec The response for refresh/update robot account secret. +// +// swagger:model RobotSec +type RobotSec struct { + + // The secret of the robot + Secret string `json:"secret,omitempty"` +} + +// Validate validates this robot sec +func (m *RobotSec) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *RobotSec) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *RobotSec) UnmarshalBinary(b []byte) error { + var res RobotSec + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/role_request.go b/src/server/v2.0/models/role_request.go new file mode 100644 index 000000000..eb3301900 --- /dev/null +++ b/src/server/v2.0/models/role_request.go @@ -0,0 +1,43 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// RoleRequest role request +// +// swagger:model RoleRequest +type RoleRequest struct { + + // The role id 1 for projectAdmin, 2 for developer, 3 for guest, 4 for maintainer + RoleID int64 `json:"role_id,omitempty"` +} + +// Validate validates this role request +func (m *RoleRequest) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *RoleRequest) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *RoleRequest) UnmarshalBinary(b []byte) error { + var res RoleRequest + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/scan_data_export_execution.go b/src/server/v2.0/models/scan_data_export_execution.go new file mode 100644 index 000000000..af5b96896 --- /dev/null +++ b/src/server/v2.0/models/scan_data_export_execution.go @@ -0,0 +1,110 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ScanDataExportExecution The replication execution +// +// swagger:model ScanDataExportExecution +type ScanDataExportExecution struct { + + // The end time + // Format: date-time + EndTime strfmt.DateTime `json:"end_time,omitempty"` + + // Indicates whether the export artifact is present in registry + FilePresent bool `json:"file_present"` + + // The ID of the execution + ID int64 `json:"id,omitempty"` + + // The start time + // Format: date-time + StartTime strfmt.DateTime `json:"start_time,omitempty"` + + // The status of the execution + Status string `json:"status,omitempty"` + + // The status text + StatusText string `json:"status_text"` + + // The trigger mode + Trigger string `json:"trigger,omitempty"` + + // The ID if the user triggering the export job + UserID int64 `json:"user_id,omitempty"` + + // The name of the user triggering the job + UserName string `json:"user_name"` +} + +// Validate validates this scan data export execution +func (m *ScanDataExportExecution) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateEndTime(formats); err != nil { + res = append(res, err) + } + + if err := m.validateStartTime(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ScanDataExportExecution) validateEndTime(formats strfmt.Registry) error { + + if swag.IsZero(m.EndTime) { // not required + return nil + } + + if err := validate.FormatOf("end_time", "body", "date-time", m.EndTime.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *ScanDataExportExecution) validateStartTime(formats strfmt.Registry) error { + + if swag.IsZero(m.StartTime) { // not required + return nil + } + + if err := validate.FormatOf("start_time", "body", "date-time", m.StartTime.String(), formats); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ScanDataExportExecution) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ScanDataExportExecution) UnmarshalBinary(b []byte) error { + var res ScanDataExportExecution + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/scan_data_export_execution_list.go b/src/server/v2.0/models/scan_data_export_execution_list.go new file mode 100644 index 000000000..602a18b3f --- /dev/null +++ b/src/server/v2.0/models/scan_data_export_execution_list.go @@ -0,0 +1,80 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// ScanDataExportExecutionList The list of scan data export executions +// +// swagger:model ScanDataExportExecutionList +type ScanDataExportExecutionList struct { + + // The list of scan data export executions + Items []*ScanDataExportExecution `json:"items"` +} + +// Validate validates this scan data export execution list +func (m *ScanDataExportExecutionList) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateItems(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ScanDataExportExecutionList) validateItems(formats strfmt.Registry) error { + + if swag.IsZero(m.Items) { // not required + return nil + } + + for i := 0; i < len(m.Items); i++ { + if swag.IsZero(m.Items[i]) { // not required + continue + } + + if m.Items[i] != nil { + if err := m.Items[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("items" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ScanDataExportExecutionList) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ScanDataExportExecutionList) UnmarshalBinary(b []byte) error { + var res ScanDataExportExecutionList + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/scan_data_export_job.go b/src/server/v2.0/models/scan_data_export_job.go new file mode 100644 index 000000000..e9cc327fb --- /dev/null +++ b/src/server/v2.0/models/scan_data_export_job.go @@ -0,0 +1,43 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// ScanDataExportJob The metadata associated with the scan data export job +// +// swagger:model ScanDataExportJob +type ScanDataExportJob struct { + + // The id of the scan data export job + ID int64 `json:"id,omitempty"` +} + +// Validate validates this scan data export job +func (m *ScanDataExportJob) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ScanDataExportJob) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ScanDataExportJob) UnmarshalBinary(b []byte) error { + var res ScanDataExportJob + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/scan_data_export_request.go b/src/server/v2.0/models/scan_data_export_request.go new file mode 100644 index 000000000..e69ada80b --- /dev/null +++ b/src/server/v2.0/models/scan_data_export_request.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// ScanDataExportRequest The criteria to select the scan data to export. +// +// swagger:model ScanDataExportRequest +type ScanDataExportRequest struct { + + // CVE-IDs for which to export data. Multiple CVE-IDs can be specified by separating using ',' and enclosed between '{}'. Defaults to all if empty + CVEIds string `json:"cveIds,omitempty"` + + // Name of the scan data export job + JobName string `json:"job_name,omitempty"` + + // A list of one or more labels for which to export the scan data, defaults to all if empty + Labels []int64 `json:"labels"` + + // A list of one or more projects for which to export the scan data, currently only one project is supported due to performance concerns, but define as array for extension in the future. + Projects []int64 `json:"projects"` + + // A list of repositories for which to export the scan data, defaults to all if empty + Repositories string `json:"repositories,omitempty"` + + // A list of tags enclosed within '{}'. Defaults to all if empty + Tags string `json:"tags,omitempty"` +} + +// Validate validates this scan data export request +func (m *ScanDataExportRequest) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ScanDataExportRequest) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ScanDataExportRequest) UnmarshalBinary(b []byte) error { + var res ScanDataExportRequest + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/scan_overview.go b/src/server/v2.0/models/scan_overview.go new file mode 100644 index 000000000..17951d73f --- /dev/null +++ b/src/server/v2.0/models/scan_overview.go @@ -0,0 +1,40 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// ScanOverview The scan overview attached in the metadata of tag +// +// swagger:model ScanOverview +type ScanOverview map[string]NativeReportSummary + +// Validate validates this scan overview +func (m ScanOverview) Validate(formats strfmt.Registry) error { + var res []error + + for k := range m { + + if err := validate.Required(k, "body", m[k]); err != nil { + return err + } + if val, ok := m[k]; ok { + if err := val.Validate(formats); err != nil { + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/src/server/v2.0/models/scanner.go b/src/server/v2.0/models/scanner.go new file mode 100644 index 000000000..33c8dcbb1 --- /dev/null +++ b/src/server/v2.0/models/scanner.go @@ -0,0 +1,49 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// Scanner scanner +// +// swagger:model Scanner +type Scanner struct { + + // Name of the scanner + Name string `json:"name,omitempty"` + + // Name of the scanner provider + Vendor string `json:"vendor,omitempty"` + + // Version of the scanner adapter + Version string `json:"version,omitempty"` +} + +// Validate validates this scanner +func (m *Scanner) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *Scanner) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Scanner) UnmarshalBinary(b []byte) error { + var res Scanner + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/scanner_adapter_metadata.go b/src/server/v2.0/models/scanner_adapter_metadata.go new file mode 100644 index 000000000..c870a5e0b --- /dev/null +++ b/src/server/v2.0/models/scanner_adapter_metadata.go @@ -0,0 +1,108 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// ScannerAdapterMetadata The metadata info of the scanner adapter +// +// swagger:model ScannerAdapterMetadata +type ScannerAdapterMetadata struct { + + // capabilities + Capabilities []*ScannerCapability `json:"capabilities"` + + // properties + Properties map[string]string `json:"properties,omitempty"` + + // scanner + Scanner *Scanner `json:"scanner,omitempty"` +} + +// Validate validates this scanner adapter metadata +func (m *ScannerAdapterMetadata) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCapabilities(formats); err != nil { + res = append(res, err) + } + + if err := m.validateScanner(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ScannerAdapterMetadata) validateCapabilities(formats strfmt.Registry) error { + + if swag.IsZero(m.Capabilities) { // not required + return nil + } + + for i := 0; i < len(m.Capabilities); i++ { + if swag.IsZero(m.Capabilities[i]) { // not required + continue + } + + if m.Capabilities[i] != nil { + if err := m.Capabilities[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("capabilities" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *ScannerAdapterMetadata) validateScanner(formats strfmt.Registry) error { + + if swag.IsZero(m.Scanner) { // not required + return nil + } + + if m.Scanner != nil { + if err := m.Scanner.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("scanner") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ScannerAdapterMetadata) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ScannerAdapterMetadata) UnmarshalBinary(b []byte) error { + var res ScannerAdapterMetadata + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/scanner_capability.go b/src/server/v2.0/models/scanner_capability.go new file mode 100644 index 000000000..adb01cad6 --- /dev/null +++ b/src/server/v2.0/models/scanner_capability.go @@ -0,0 +1,46 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// ScannerCapability scanner capability +// +// swagger:model ScannerCapability +type ScannerCapability struct { + + // consumes mime types + ConsumesMimeTypes []string `json:"consumes_mime_types"` + + // produces mime types + ProducesMimeTypes []string `json:"produces_mime_types"` +} + +// Validate validates this scanner capability +func (m *ScannerCapability) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ScannerCapability) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ScannerCapability) UnmarshalBinary(b []byte) error { + var res ScannerCapability + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/scanner_registration.go b/src/server/v2.0/models/scanner_registration.go new file mode 100644 index 000000000..9d31b453a --- /dev/null +++ b/src/server/v2.0/models/scanner_registration.go @@ -0,0 +1,135 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ScannerRegistration Registration represents a named configuration for invoking a scanner via its adapter. +// +// +// swagger:model ScannerRegistration +type ScannerRegistration struct { + + // An optional value of the HTTP Authorization header sent with each request to the Scanner Adapter API. + // + AccessCredential string `json:"access_credential"` + + // Optional property to describe the name of the scanner registration + Adapter string `json:"adapter,omitempty"` + + // Specify what authentication approach is adopted for the HTTP communications. + // Supported types Basic", "Bearer" and api key header "X-ScannerAdapter-API-Key" + // + Auth string `json:"auth"` + + // The creation time of this registration + // Format: date-time + CreateTime strfmt.DateTime `json:"create_time,omitempty"` + + // An optional description of this registration. + Description string `json:"description"` + + // Indicate whether the registration is enabled or not + Disabled *bool `json:"disabled"` + + // Indicate the healthy of the registration + Health string `json:"health,omitempty"` + + // Indicate if the registration is set as the system default one + IsDefault *bool `json:"is_default"` + + // The name of this registration. + Name string `json:"name,omitempty"` + + // Indicate if skip the certificate verification when sending HTTP requests + SkipCertVerify *bool `json:"skip_certVerify"` + + // The update time of this registration + // Format: date-time + UpdateTime strfmt.DateTime `json:"update_time,omitempty"` + + // A base URL of the scanner adapter + URL string `json:"url,omitempty"` + + // Indicate whether use internal registry addr for the scanner to pull content or not + UseInternalAddr *bool `json:"use_internal_addr"` + + // The unique identifier of this registration. + UUID string `json:"uuid,omitempty"` + + // Optional property to describe the vendor of the scanner registration + Vendor string `json:"vendor,omitempty"` + + // Optional property to describe the version of the scanner registration + Version string `json:"version,omitempty"` +} + +// Validate validates this scanner registration +func (m *ScannerRegistration) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCreateTime(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUpdateTime(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ScannerRegistration) validateCreateTime(formats strfmt.Registry) error { + + if swag.IsZero(m.CreateTime) { // not required + return nil + } + + if err := validate.FormatOf("create_time", "body", "date-time", m.CreateTime.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *ScannerRegistration) validateUpdateTime(formats strfmt.Registry) error { + + if swag.IsZero(m.UpdateTime) { // not required + return nil + } + + if err := validate.FormatOf("update_time", "body", "date-time", m.UpdateTime.String(), formats); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ScannerRegistration) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ScannerRegistration) UnmarshalBinary(b []byte) error { + var res ScannerRegistration + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/scanner_registration_req.go b/src/server/v2.0/models/scanner_registration_req.go new file mode 100644 index 000000000..a1ea349a9 --- /dev/null +++ b/src/server/v2.0/models/scanner_registration_req.go @@ -0,0 +1,107 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ScannerRegistrationReq scanner registration req +// +// swagger:model ScannerRegistrationReq +type ScannerRegistrationReq struct { + + // An optional value of the HTTP Authorization header sent with each request to the Scanner Adapter API. + // + AccessCredential string `json:"access_credential,omitempty"` + + // Specify what authentication approach is adopted for the HTTP communications. + // Supported types Basic", "Bearer" and api key header "X-ScannerAdapter-API-Key" + // + Auth string `json:"auth,omitempty"` + + // An optional description of this registration. + Description string `json:"description,omitempty"` + + // Indicate whether the registration is enabled or not + Disabled *bool `json:"disabled,omitempty"` + + // The name of this registration + // Required: true + Name *string `json:"name"` + + // Indicate if skip the certificate verification when sending HTTP requests + SkipCertVerify *bool `json:"skip_certVerify,omitempty"` + + // A base URL of the scanner adapter. + // Required: true + // Format: uri + URL *strfmt.URI `json:"url"` + + // Indicate whether use internal registry addr for the scanner to pull content or not + UseInternalAddr *bool `json:"use_internal_addr,omitempty"` +} + +// Validate validates this scanner registration req +func (m *ScannerRegistrationReq) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateURL(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ScannerRegistrationReq) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + return nil +} + +func (m *ScannerRegistrationReq) validateURL(formats strfmt.Registry) error { + + if err := validate.Required("url", "body", m.URL); err != nil { + return err + } + + if err := validate.FormatOf("url", "body", "uri", m.URL.String(), formats); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ScannerRegistrationReq) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ScannerRegistrationReq) UnmarshalBinary(b []byte) error { + var res ScannerRegistrationReq + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/scanner_registration_settings.go b/src/server/v2.0/models/scanner_registration_settings.go new file mode 100644 index 000000000..18a21f2f7 --- /dev/null +++ b/src/server/v2.0/models/scanner_registration_settings.go @@ -0,0 +1,95 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ScannerRegistrationSettings scanner registration settings +// +// swagger:model ScannerRegistrationSettings +type ScannerRegistrationSettings struct { + + // An optional value of the HTTP Authorization header sent with each request to the Scanner Adapter API. + // + AccessCredential string `json:"access_credential,omitempty"` + + // Specify what authentication approach is adopted for the HTTP communications. + // Supported types Basic", "Bearer" and api key header "X-ScannerAdapter-API-Key" + // + Auth string `json:"auth,omitempty"` + + // The name of this registration + // Required: true + Name *string `json:"name"` + + // A base URL of the scanner adapter. + // Required: true + // Format: uri + URL *strfmt.URI `json:"url"` +} + +// Validate validates this scanner registration settings +func (m *ScannerRegistrationSettings) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateURL(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ScannerRegistrationSettings) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + return nil +} + +func (m *ScannerRegistrationSettings) validateURL(formats strfmt.Registry) error { + + if err := validate.Required("url", "body", m.URL); err != nil { + return err + } + + if err := validate.FormatOf("url", "body", "uri", m.URL.String(), formats); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ScannerRegistrationSettings) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ScannerRegistrationSettings) UnmarshalBinary(b []byte) error { + var res ScannerRegistrationSettings + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/schedule.go b/src/server/v2.0/models/schedule.go new file mode 100644 index 000000000..51a537bd6 --- /dev/null +++ b/src/server/v2.0/models/schedule.go @@ -0,0 +1,127 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// Schedule schedule +// +// swagger:model Schedule +type Schedule struct { + + // the creation time of the schedule. + // Read Only: true + // Format: date-time + CreationTime strfmt.DateTime `json:"creation_time,omitempty"` + + // The id of the schedule. + // Read Only: true + ID int64 `json:"id,omitempty"` + + // The parameters of schedule job + Parameters map[string]interface{} `json:"parameters,omitempty"` + + // schedule + Schedule *ScheduleObj `json:"schedule,omitempty"` + + // The status of the schedule. + // Read Only: true + Status string `json:"status,omitempty"` + + // the update time of the schedule. + // Read Only: true + // Format: date-time + UpdateTime strfmt.DateTime `json:"update_time,omitempty"` +} + +// Validate validates this schedule +func (m *Schedule) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCreationTime(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSchedule(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUpdateTime(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Schedule) validateCreationTime(formats strfmt.Registry) error { + + if swag.IsZero(m.CreationTime) { // not required + return nil + } + + if err := validate.FormatOf("creation_time", "body", "date-time", m.CreationTime.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *Schedule) validateSchedule(formats strfmt.Registry) error { + + if swag.IsZero(m.Schedule) { // not required + return nil + } + + if m.Schedule != nil { + if err := m.Schedule.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("schedule") + } + return err + } + } + + return nil +} + +func (m *Schedule) validateUpdateTime(formats strfmt.Registry) error { + + if swag.IsZero(m.UpdateTime) { // not required + return nil + } + + if err := validate.FormatOf("update_time", "body", "date-time", m.UpdateTime.String(), formats); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Schedule) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Schedule) UnmarshalBinary(b []byte) error { + var res Schedule + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/schedule_obj.go b/src/server/v2.0/models/schedule_obj.go new file mode 100644 index 000000000..2cdfca24e --- /dev/null +++ b/src/server/v2.0/models/schedule_obj.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ScheduleObj schedule obj +// +// swagger:model ScheduleObj +type ScheduleObj struct { + + // A cron expression, a time-based job scheduler. + Cron string `json:"cron,omitempty"` + + // The next time to schedule to run the job. + // Format: date-time + NextScheduledTime strfmt.DateTime `json:"next_scheduled_time,omitempty"` + + // The schedule type. The valid values are 'Hourly', 'Daily', 'Weekly', 'Custom', 'Manual' and 'None'. + // 'Manual' means to trigger it right away and 'None' means to cancel the schedule. + // + // Enum: [Hourly Daily Weekly Custom Manual None] + Type string `json:"type,omitempty"` +} + +// Validate validates this schedule obj +func (m *ScheduleObj) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateNextScheduledTime(formats); err != nil { + res = append(res, err) + } + + if err := m.validateType(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ScheduleObj) validateNextScheduledTime(formats strfmt.Registry) error { + + if swag.IsZero(m.NextScheduledTime) { // not required + return nil + } + + if err := validate.FormatOf("next_scheduled_time", "body", "date-time", m.NextScheduledTime.String(), formats); err != nil { + return err + } + + return nil +} + +var scheduleObjTypeTypePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["Hourly","Daily","Weekly","Custom","Manual","None"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + scheduleObjTypeTypePropEnum = append(scheduleObjTypeTypePropEnum, v) + } +} + +const ( + + // ScheduleObjTypeHourly captures enum value "Hourly" + ScheduleObjTypeHourly string = "Hourly" + + // ScheduleObjTypeDaily captures enum value "Daily" + ScheduleObjTypeDaily string = "Daily" + + // ScheduleObjTypeWeekly captures enum value "Weekly" + ScheduleObjTypeWeekly string = "Weekly" + + // ScheduleObjTypeCustom captures enum value "Custom" + ScheduleObjTypeCustom string = "Custom" + + // ScheduleObjTypeManual captures enum value "Manual" + ScheduleObjTypeManual string = "Manual" + + // ScheduleObjTypeNone captures enum value "None" + ScheduleObjTypeNone string = "None" +) + +// prop value enum +func (m *ScheduleObj) validateTypeEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, scheduleObjTypeTypePropEnum, true); err != nil { + return err + } + return nil +} + +func (m *ScheduleObj) validateType(formats strfmt.Registry) error { + + if swag.IsZero(m.Type) { // not required + return nil + } + + // value enum + if err := m.validateTypeEnum("type", "body", m.Type); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ScheduleObj) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ScheduleObj) UnmarshalBinary(b []byte) error { + var res ScheduleObj + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/schedule_task.go b/src/server/v2.0/models/schedule_task.go new file mode 100644 index 000000000..3b41cce88 --- /dev/null +++ b/src/server/v2.0/models/schedule_task.go @@ -0,0 +1,80 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ScheduleTask the schedule task info +// +// swagger:model ScheduleTask +type ScheduleTask struct { + + // the cron of the current schedule task + Cron string `json:"cron,omitempty"` + + // the id of the Schedule task + ID int64 `json:"id,omitempty"` + + // the update time of the schedule task + // Format: date-time + UpdateTime strfmt.DateTime `json:"update_time,omitempty"` + + // the vendor id of the current task + VendorID int64 `json:"vendor_id,omitempty"` + + // the vendor type of the current schedule task + VendorType string `json:"vendor_type,omitempty"` +} + +// Validate validates this schedule task +func (m *ScheduleTask) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateUpdateTime(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ScheduleTask) validateUpdateTime(formats strfmt.Registry) error { + + if swag.IsZero(m.UpdateTime) { // not required + return nil + } + + if err := validate.FormatOf("update_time", "body", "date-time", m.UpdateTime.String(), formats); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ScheduleTask) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ScheduleTask) UnmarshalBinary(b []byte) error { + var res ScheduleTask + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/scheduler_status.go b/src/server/v2.0/models/scheduler_status.go new file mode 100644 index 000000000..b5f5fd144 --- /dev/null +++ b/src/server/v2.0/models/scheduler_status.go @@ -0,0 +1,43 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// SchedulerStatus the scheduler status +// +// swagger:model SchedulerStatus +type SchedulerStatus struct { + + // if the scheduler is paused + Paused bool `json:"paused"` +} + +// Validate validates this scheduler status +func (m *SchedulerStatus) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *SchedulerStatus) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *SchedulerStatus) UnmarshalBinary(b []byte) error { + var res SchedulerStatus + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/search.go b/src/server/v2.0/models/search.go new file mode 100644 index 000000000..85312de17 --- /dev/null +++ b/src/server/v2.0/models/search.go @@ -0,0 +1,144 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// Search search +// +// swagger:model Search +type Search struct { + + // Search results of the charts that macthed the filter keywords. + Chart []*SearchResult `json:"chart,omitempty"` + + // Search results of the projects that matched the filter keywords. + Project []*Project `json:"project"` + + // Search results of the repositories that matched the filter keywords. + Repository []*SearchRepository `json:"repository"` +} + +// Validate validates this search +func (m *Search) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateChart(formats); err != nil { + res = append(res, err) + } + + if err := m.validateProject(formats); err != nil { + res = append(res, err) + } + + if err := m.validateRepository(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Search) validateChart(formats strfmt.Registry) error { + + if swag.IsZero(m.Chart) { // not required + return nil + } + + for i := 0; i < len(m.Chart); i++ { + if swag.IsZero(m.Chart[i]) { // not required + continue + } + + if m.Chart[i] != nil { + if err := m.Chart[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("chart" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *Search) validateProject(formats strfmt.Registry) error { + + if swag.IsZero(m.Project) { // not required + return nil + } + + for i := 0; i < len(m.Project); i++ { + if swag.IsZero(m.Project[i]) { // not required + continue + } + + if m.Project[i] != nil { + if err := m.Project[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("project" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *Search) validateRepository(formats strfmt.Registry) error { + + if swag.IsZero(m.Repository) { // not required + return nil + } + + for i := 0; i < len(m.Repository); i++ { + if swag.IsZero(m.Repository[i]) { // not required + continue + } + + if m.Repository[i] != nil { + if err := m.Repository[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("repository" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Search) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Search) UnmarshalBinary(b []byte) error { + var res Search + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/search_repository.go b/src/server/v2.0/models/search_repository.go new file mode 100644 index 000000000..0ec1efac6 --- /dev/null +++ b/src/server/v2.0/models/search_repository.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// SearchRepository search repository +// +// swagger:model SearchRepository +type SearchRepository struct { + + // The count of artifacts in the repository + ArtifactCount int64 `json:"artifact_count,omitempty"` + + // The ID of the project that the repository belongs to + ProjectID int64 `json:"project_id,omitempty"` + + // The name of the project that the repository belongs to + ProjectName string `json:"project_name,omitempty"` + + // The flag to indicate the publicity of the project that the repository belongs to (1 is public, 0 is not) + ProjectPublic bool `json:"project_public,omitempty"` + + // The count how many times the repository is pulled + PullCount int64 `json:"pull_count,omitempty"` + + // The name of the repository + RepositoryName string `json:"repository_name,omitempty"` +} + +// Validate validates this search repository +func (m *SearchRepository) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *SearchRepository) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *SearchRepository) UnmarshalBinary(b []byte) error { + var res SearchRepository + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/search_result.go b/src/server/v2.0/models/search_result.go new file mode 100644 index 000000000..0e3824d49 --- /dev/null +++ b/src/server/v2.0/models/search_result.go @@ -0,0 +1,77 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// SearchResult The chart search result item +// +// swagger:model SearchResult +type SearchResult struct { + + // chart + Chart *ChartVersion `json:"Chart,omitempty"` + + // The chart name with repo name + Name string `json:"Name,omitempty"` + + // The matched level + Score int64 `json:"Score,omitempty"` +} + +// Validate validates this search result +func (m *SearchResult) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateChart(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *SearchResult) validateChart(formats strfmt.Registry) error { + + if swag.IsZero(m.Chart) { // not required + return nil + } + + if m.Chart != nil { + if err := m.Chart.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("Chart") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *SearchResult) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *SearchResult) UnmarshalBinary(b []byte) error { + var res SearchResult + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/start_replication_execution.go b/src/server/v2.0/models/start_replication_execution.go new file mode 100644 index 000000000..122b2ac66 --- /dev/null +++ b/src/server/v2.0/models/start_replication_execution.go @@ -0,0 +1,43 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// StartReplicationExecution start replication execution +// +// swagger:model StartReplicationExecution +type StartReplicationExecution struct { + + // The ID of policy that the execution belongs to. + PolicyID int64 `json:"policy_id,omitempty"` +} + +// Validate validates this start replication execution +func (m *StartReplicationExecution) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *StartReplicationExecution) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *StartReplicationExecution) UnmarshalBinary(b []byte) error { + var res StartReplicationExecution + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/statistic.go b/src/server/v2.0/models/statistic.go new file mode 100644 index 000000000..d4994602f --- /dev/null +++ b/src/server/v2.0/models/statistic.go @@ -0,0 +1,61 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// Statistic statistic +// +// swagger:model Statistic +type Statistic struct { + + // The count of the private projects + PrivateProjectCount int64 `json:"private_project_count"` + + // The count of the private repositories + PrivateRepoCount int64 `json:"private_repo_count"` + + // The count of the public projects + PublicProjectCount int64 `json:"public_project_count"` + + // The count of the public repositories + PublicRepoCount int64 `json:"public_repo_count"` + + // The count of the total projects, only be seen by the system admin + TotalProjectCount int64 `json:"total_project_count"` + + // The count of the total repositories, only be seen by the system admin + TotalRepoCount int64 `json:"total_repo_count"` + + // The total storage consumption of blobs, only be seen by the system admin + TotalStorageConsumption int64 `json:"total_storage_consumption"` +} + +// Validate validates this statistic +func (m *Statistic) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *Statistic) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Statistic) UnmarshalBinary(b []byte) error { + var res Statistic + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/stats.go b/src/server/v2.0/models/stats.go new file mode 100644 index 000000000..6d1fdaab3 --- /dev/null +++ b/src/server/v2.0/models/stats.go @@ -0,0 +1,115 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// Stats Stats provides the overall progress of the scan all process. +// +// swagger:model Stats +type Stats struct { + + // The number of the finished scan processes triggered by the scan all action + Completed int64 `json:"completed"` + + // The metrics data for the each status + Metrics map[string]int64 `json:"metrics,omitempty"` + + // A flag indicating job status of scan all. + Ongoing bool `json:"ongoing"` + + // The total number of scan processes triggered by the scan all action + Total int64 `json:"total"` + + // The trigger of the scan all job. + // Enum: [Manual Schedule Event] + Trigger string `json:"trigger,omitempty"` +} + +// Validate validates this stats +func (m *Stats) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateTrigger(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +var statsTypeTriggerPropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["Manual","Schedule","Event"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + statsTypeTriggerPropEnum = append(statsTypeTriggerPropEnum, v) + } +} + +const ( + + // StatsTriggerManual captures enum value "Manual" + StatsTriggerManual string = "Manual" + + // StatsTriggerSchedule captures enum value "Schedule" + StatsTriggerSchedule string = "Schedule" + + // StatsTriggerEvent captures enum value "Event" + StatsTriggerEvent string = "Event" +) + +// prop value enum +func (m *Stats) validateTriggerEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, statsTypeTriggerPropEnum, true); err != nil { + return err + } + return nil +} + +func (m *Stats) validateTrigger(formats strfmt.Registry) error { + + if swag.IsZero(m.Trigger) { // not required + return nil + } + + // value enum + if err := m.validateTriggerEnum("trigger", "body", m.Trigger); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Stats) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Stats) UnmarshalBinary(b []byte) error { + var res Stats + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/storage.go b/src/server/v2.0/models/storage.go new file mode 100644 index 000000000..03e9e328d --- /dev/null +++ b/src/server/v2.0/models/storage.go @@ -0,0 +1,46 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// Storage storage +// +// swagger:model Storage +type Storage struct { + + // Free volume size. + Free uint64 `json:"free,omitempty"` + + // Total volume size. + Total uint64 `json:"total,omitempty"` +} + +// Validate validates this storage +func (m *Storage) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *Storage) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Storage) UnmarshalBinary(b []byte) error { + var res Storage + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/string_config_item.go b/src/server/v2.0/models/string_config_item.go new file mode 100644 index 000000000..ef233cd58 --- /dev/null +++ b/src/server/v2.0/models/string_config_item.go @@ -0,0 +1,46 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// StringConfigItem string config item +// +// swagger:model StringConfigItem +type StringConfigItem struct { + + // The configure item can be updated or not + Editable bool `json:"editable"` + + // The string value of current config item + Value string `json:"value"` +} + +// Validate validates this string config item +func (m *StringConfigItem) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *StringConfigItem) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *StringConfigItem) UnmarshalBinary(b []byte) error { + var res StringConfigItem + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/supported_webhook_event_types.go b/src/server/v2.0/models/supported_webhook_event_types.go new file mode 100644 index 000000000..dcc4d7255 --- /dev/null +++ b/src/server/v2.0/models/supported_webhook_event_types.go @@ -0,0 +1,102 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// SupportedWebhookEventTypes Supportted webhook event types and notify types. +// +// swagger:model SupportedWebhookEventTypes +type SupportedWebhookEventTypes struct { + + // event type + EventType []EventType `json:"event_type"` + + // notify type + NotifyType []NotifyType `json:"notify_type"` +} + +// Validate validates this supported webhook event types +func (m *SupportedWebhookEventTypes) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateEventType(formats); err != nil { + res = append(res, err) + } + + if err := m.validateNotifyType(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *SupportedWebhookEventTypes) validateEventType(formats strfmt.Registry) error { + + if swag.IsZero(m.EventType) { // not required + return nil + } + + for i := 0; i < len(m.EventType); i++ { + + if err := m.EventType[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("event_type" + "." + strconv.Itoa(i)) + } + return err + } + + } + + return nil +} + +func (m *SupportedWebhookEventTypes) validateNotifyType(formats strfmt.Registry) error { + + if swag.IsZero(m.NotifyType) { // not required + return nil + } + + for i := 0; i < len(m.NotifyType); i++ { + + if err := m.NotifyType[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("notify_type" + "." + strconv.Itoa(i)) + } + return err + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *SupportedWebhookEventTypes) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *SupportedWebhookEventTypes) UnmarshalBinary(b []byte) error { + var res SupportedWebhookEventTypes + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/system_info.go b/src/server/v2.0/models/system_info.go new file mode 100644 index 000000000..7534b9726 --- /dev/null +++ b/src/server/v2.0/models/system_info.go @@ -0,0 +1,80 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// SystemInfo system info +// +// swagger:model SystemInfo +type SystemInfo struct { + + // The storage of system. + Storage []*Storage `json:"storage"` +} + +// Validate validates this system info +func (m *SystemInfo) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateStorage(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *SystemInfo) validateStorage(formats strfmt.Registry) error { + + if swag.IsZero(m.Storage) { // not required + return nil + } + + for i := 0; i < len(m.Storage); i++ { + if swag.IsZero(m.Storage[i]) { // not required + continue + } + + if m.Storage[i] != nil { + if err := m.Storage[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("storage" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *SystemInfo) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *SystemInfo) UnmarshalBinary(b []byte) error { + var res SystemInfo + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/tag.go b/src/server/v2.0/models/tag.go new file mode 100644 index 000000000..0b9896baf --- /dev/null +++ b/src/server/v2.0/models/tag.go @@ -0,0 +1,107 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// Tag tag +// +// swagger:model Tag +type Tag struct { + + // The ID of the artifact that the tag attached to + ArtifactID int64 `json:"artifact_id,omitempty"` + + // The ID of the tag + ID int64 `json:"id,omitempty"` + + // The immutable status of the tag + Immutable bool `json:"immutable"` + + // The name of the tag + Name string `json:"name,omitempty"` + + // The latest pull time of the tag + // Format: date-time + PullTime strfmt.DateTime `json:"pull_time,omitempty"` + + // The push time of the tag + // Format: date-time + PushTime strfmt.DateTime `json:"push_time,omitempty"` + + // The ID of the repository that the tag belongs to + RepositoryID int64 `json:"repository_id,omitempty"` + + // The attribute indicates whether the tag is signed or not + Signed bool `json:"signed"` +} + +// Validate validates this tag +func (m *Tag) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validatePullTime(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePushTime(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Tag) validatePullTime(formats strfmt.Registry) error { + + if swag.IsZero(m.PullTime) { // not required + return nil + } + + if err := validate.FormatOf("pull_time", "body", "date-time", m.PullTime.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *Tag) validatePushTime(formats strfmt.Registry) error { + + if swag.IsZero(m.PushTime) { // not required + return nil + } + + if err := validate.FormatOf("push_time", "body", "date-time", m.PushTime.String(), formats); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Tag) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Tag) UnmarshalBinary(b []byte) error { + var res Tag + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/task.go b/src/server/v2.0/models/task.go new file mode 100644 index 000000000..509ba7d6a --- /dev/null +++ b/src/server/v2.0/models/task.go @@ -0,0 +1,96 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// Task task +// +// swagger:model Task +type Task struct { + + // The creation time of task + CreationTime string `json:"creation_time,omitempty"` + + // The end time of task + EndTime string `json:"end_time,omitempty"` + + // The ID of task execution + ExecutionID int64 `json:"execution_id,omitempty"` + + // extra attrs + ExtraAttrs ExtraAttrs `json:"extra_attrs,omitempty"` + + // The ID of task + ID int64 `json:"id,omitempty"` + + // The count of task run + RunCount int32 `json:"run_count,omitempty"` + + // The start time of task + StartTime string `json:"start_time,omitempty"` + + // The status of task + Status string `json:"status,omitempty"` + + // The status message of task + StatusMessage string `json:"status_message,omitempty"` + + // The update time of task + UpdateTime string `json:"update_time,omitempty"` +} + +// Validate validates this task +func (m *Task) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateExtraAttrs(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Task) validateExtraAttrs(formats strfmt.Registry) error { + + if swag.IsZero(m.ExtraAttrs) { // not required + return nil + } + + if err := m.ExtraAttrs.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("extra_attrs") + } + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Task) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Task) UnmarshalBinary(b []byte) error { + var res Task + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/user_creation_req.go b/src/server/v2.0/models/user_creation_req.go new file mode 100644 index 000000000..6fce1a336 --- /dev/null +++ b/src/server/v2.0/models/user_creation_req.go @@ -0,0 +1,98 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// UserCreationReq user creation req +// +// swagger:model UserCreationReq +type UserCreationReq struct { + + // comment + Comment string `json:"comment,omitempty"` + + // email + // Max Length: 255 + Email string `json:"email,omitempty"` + + // password + Password string `json:"password,omitempty"` + + // realname + Realname string `json:"realname,omitempty"` + + // username + // Max Length: 255 + Username string `json:"username,omitempty"` +} + +// Validate validates this user creation req +func (m *UserCreationReq) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateEmail(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUsername(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *UserCreationReq) validateEmail(formats strfmt.Registry) error { + + if swag.IsZero(m.Email) { // not required + return nil + } + + if err := validate.MaxLength("email", "body", string(m.Email), 255); err != nil { + return err + } + + return nil +} + +func (m *UserCreationReq) validateUsername(formats strfmt.Registry) error { + + if swag.IsZero(m.Username) { // not required + return nil + } + + if err := validate.MaxLength("username", "body", string(m.Username), 255); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *UserCreationReq) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *UserCreationReq) UnmarshalBinary(b []byte) error { + var res UserCreationReq + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/user_entity.go b/src/server/v2.0/models/user_entity.go new file mode 100644 index 000000000..b792f63e1 --- /dev/null +++ b/src/server/v2.0/models/user_entity.go @@ -0,0 +1,46 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// UserEntity user entity +// +// swagger:model UserEntity +type UserEntity struct { + + // The ID of the user. + UserID int64 `json:"user_id,omitempty"` + + // The name of the user. + Username string `json:"username,omitempty"` +} + +// Validate validates this user entity +func (m *UserEntity) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *UserEntity) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *UserEntity) UnmarshalBinary(b []byte) error { + var res UserEntity + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/user_group.go b/src/server/v2.0/models/user_group.go new file mode 100644 index 000000000..bae68231d --- /dev/null +++ b/src/server/v2.0/models/user_group.go @@ -0,0 +1,52 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// UserGroup user group +// +// swagger:model UserGroup +type UserGroup struct { + + // The name of the user group + GroupName string `json:"group_name,omitempty"` + + // The group type, 1 for LDAP group, 2 for HTTP group, 3 for OIDC group. + GroupType int64 `json:"group_type,omitempty"` + + // The ID of the user group + ID int64 `json:"id,omitempty"` + + // The DN of the LDAP group if group type is 1 (LDAP group). + LdapGroupDn string `json:"ldap_group_dn,omitempty"` +} + +// Validate validates this user group +func (m *UserGroup) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *UserGroup) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *UserGroup) UnmarshalBinary(b []byte) error { + var res UserGroup + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/user_group_search_item.go b/src/server/v2.0/models/user_group_search_item.go new file mode 100644 index 000000000..11e028c66 --- /dev/null +++ b/src/server/v2.0/models/user_group_search_item.go @@ -0,0 +1,49 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// UserGroupSearchItem user group search item +// +// swagger:model UserGroupSearchItem +type UserGroupSearchItem struct { + + // The name of the user group + GroupName string `json:"group_name,omitempty"` + + // The group type, 1 for LDAP group, 2 for HTTP group, 3 for OIDC group. + GroupType int64 `json:"group_type,omitempty"` + + // The ID of the user group + ID int64 `json:"id,omitempty"` +} + +// Validate validates this user group search item +func (m *UserGroupSearchItem) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *UserGroupSearchItem) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *UserGroupSearchItem) UnmarshalBinary(b []byte) error { + var res UserGroupSearchItem + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/user_profile.go b/src/server/v2.0/models/user_profile.go new file mode 100644 index 000000000..873f9255d --- /dev/null +++ b/src/server/v2.0/models/user_profile.go @@ -0,0 +1,49 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// UserProfile user profile +// +// swagger:model UserProfile +type UserProfile struct { + + // comment + Comment string `json:"comment,omitempty"` + + // email + Email string `json:"email,omitempty"` + + // realname + Realname string `json:"realname,omitempty"` +} + +// Validate validates this user profile +func (m *UserProfile) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *UserProfile) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *UserProfile) UnmarshalBinary(b []byte) error { + var res UserProfile + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/user_resp.go b/src/server/v2.0/models/user_resp.go new file mode 100644 index 000000000..882e0ec35 --- /dev/null +++ b/src/server/v2.0/models/user_resp.go @@ -0,0 +1,135 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// UserResp user resp +// +// swagger:model UserResp +type UserResp struct { + + // indicate the admin privilege is grant by authenticator (LDAP), is always false unless it is the current login user + AdminRoleInAuth bool `json:"admin_role_in_auth"` + + // comment + Comment string `json:"comment,omitempty"` + + // The creation time of the user. + // Format: date-time + CreationTime strfmt.DateTime `json:"creation_time,omitempty"` + + // email + Email string `json:"email,omitempty"` + + // oidc user meta + OIDCUserMeta *OIDCUserInfo `json:"oidc_user_meta,omitempty"` + + // realname + Realname string `json:"realname,omitempty"` + + // sysadmin flag + SysadminFlag bool `json:"sysadmin_flag"` + + // The update time of the user. + // Format: date-time + UpdateTime strfmt.DateTime `json:"update_time,omitempty"` + + // user id + UserID int64 `json:"user_id,omitempty"` + + // username + Username string `json:"username,omitempty"` +} + +// Validate validates this user resp +func (m *UserResp) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCreationTime(formats); err != nil { + res = append(res, err) + } + + if err := m.validateOIDCUserMeta(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUpdateTime(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *UserResp) validateCreationTime(formats strfmt.Registry) error { + + if swag.IsZero(m.CreationTime) { // not required + return nil + } + + if err := validate.FormatOf("creation_time", "body", "date-time", m.CreationTime.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *UserResp) validateOIDCUserMeta(formats strfmt.Registry) error { + + if swag.IsZero(m.OIDCUserMeta) { // not required + return nil + } + + if m.OIDCUserMeta != nil { + if err := m.OIDCUserMeta.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("oidc_user_meta") + } + return err + } + } + + return nil +} + +func (m *UserResp) validateUpdateTime(formats strfmt.Registry) error { + + if swag.IsZero(m.UpdateTime) { // not required + return nil + } + + if err := validate.FormatOf("update_time", "body", "date-time", m.UpdateTime.String(), formats); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *UserResp) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *UserResp) UnmarshalBinary(b []byte) error { + var res UserResp + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/user_search.go b/src/server/v2.0/models/user_search.go new file mode 100644 index 000000000..4c65d4da4 --- /dev/null +++ b/src/server/v2.0/models/user_search.go @@ -0,0 +1,46 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// UserSearch user search +// +// swagger:model UserSearch +type UserSearch struct { + + // The ID of the user. + UserID int64 `json:"user_id,omitempty"` + + // username + Username string `json:"username,omitempty"` +} + +// Validate validates this user search +func (m *UserSearch) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *UserSearch) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *UserSearch) UnmarshalBinary(b []byte) error { + var res UserSearch + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/user_search_resp_item.go b/src/server/v2.0/models/user_search_resp_item.go new file mode 100644 index 000000000..9c342b743 --- /dev/null +++ b/src/server/v2.0/models/user_search_resp_item.go @@ -0,0 +1,46 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// UserSearchRespItem user search resp item +// +// swagger:model UserSearchRespItem +type UserSearchRespItem struct { + + // The ID of the user. + UserID int64 `json:"user_id,omitempty"` + + // username + Username string `json:"username,omitempty"` +} + +// Validate validates this user search resp item +func (m *UserSearchRespItem) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *UserSearchRespItem) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *UserSearchRespItem) UnmarshalBinary(b []byte) error { + var res UserSearchRespItem + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/user_sys_admin_flag.go b/src/server/v2.0/models/user_sys_admin_flag.go new file mode 100644 index 000000000..bf824a8fb --- /dev/null +++ b/src/server/v2.0/models/user_sys_admin_flag.go @@ -0,0 +1,43 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// UserSysAdminFlag user sys admin flag +// +// swagger:model UserSysAdminFlag +type UserSysAdminFlag struct { + + // true-admin, false-not admin. + SysadminFlag bool `json:"sysadmin_flag,omitempty"` +} + +// Validate validates this user sys admin flag +func (m *UserSysAdminFlag) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *UserSysAdminFlag) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *UserSysAdminFlag) UnmarshalBinary(b []byte) error { + var res UserSysAdminFlag + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/vulnerability_summary.go b/src/server/v2.0/models/vulnerability_summary.go new file mode 100644 index 000000000..c0d8d69c5 --- /dev/null +++ b/src/server/v2.0/models/vulnerability_summary.go @@ -0,0 +1,50 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// VulnerabilitySummary VulnerabilitySummary contains the total number of the foun d vulnerabilities number and numbers of each severity level. +// +// +// swagger:model VulnerabilitySummary +type VulnerabilitySummary struct { + + // The number of the fixable vulnerabilities + Fixable int64 `json:"fixable"` + + // Numbers of the vulnerabilities with different severity + Summary map[string]int64 `json:"summary"` + + // The total number of the found vulnerabilities + Total int64 `json:"total"` +} + +// Validate validates this vulnerability summary +func (m *VulnerabilitySummary) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *VulnerabilitySummary) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *VulnerabilitySummary) UnmarshalBinary(b []byte) error { + var res VulnerabilitySummary + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/webhook_job.go b/src/server/v2.0/models/webhook_job.go new file mode 100644 index 000000000..d9a6fcb1f --- /dev/null +++ b/src/server/v2.0/models/webhook_job.go @@ -0,0 +1,107 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// WebhookJob The webhook job. +// +// swagger:model WebhookJob +type WebhookJob struct { + + // The webhook job creation time. + // Format: date-time + CreationTime strfmt.DateTime `json:"creation_time,omitempty"` + + // The webhook job event type. + EventType string `json:"event_type,omitempty"` + + // The webhook job ID. + ID int64 `json:"id,omitempty"` + + // The webhook job notify detailed data. + JobDetail string `json:"job_detail,omitempty"` + + // The webhook job notify type. + NotifyType string `json:"notify_type,omitempty"` + + // The webhook policy ID. + PolicyID int64 `json:"policy_id,omitempty"` + + // The webhook job status. + Status string `json:"status,omitempty"` + + // The webhook job update time. + // Format: date-time + UpdateTime strfmt.DateTime `json:"update_time,omitempty"` +} + +// Validate validates this webhook job +func (m *WebhookJob) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCreationTime(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUpdateTime(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *WebhookJob) validateCreationTime(formats strfmt.Registry) error { + + if swag.IsZero(m.CreationTime) { // not required + return nil + } + + if err := validate.FormatOf("creation_time", "body", "date-time", m.CreationTime.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *WebhookJob) validateUpdateTime(formats strfmt.Registry) error { + + if swag.IsZero(m.UpdateTime) { // not required + return nil + } + + if err := validate.FormatOf("update_time", "body", "date-time", m.UpdateTime.String(), formats); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *WebhookJob) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *WebhookJob) UnmarshalBinary(b []byte) error { + var res WebhookJob + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/webhook_last_trigger.go b/src/server/v2.0/models/webhook_last_trigger.go new file mode 100644 index 000000000..c77c17a8f --- /dev/null +++ b/src/server/v2.0/models/webhook_last_trigger.go @@ -0,0 +1,98 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// WebhookLastTrigger The webhook policy and last trigger time group by event type. +// +// swagger:model WebhookLastTrigger +type WebhookLastTrigger struct { + + // The creation time of webhook policy. + // Format: date-time + CreationTime strfmt.DateTime `json:"creation_time,omitempty"` + + // Whether or not the webhook policy enabled. + Enabled bool `json:"enabled,omitempty"` + + // The webhook event type. + EventType string `json:"event_type,omitempty"` + + // The last trigger time of webhook policy. + // Format: date-time + LastTriggerTime strfmt.DateTime `json:"last_trigger_time,omitempty"` + + // The webhook policy name. + PolicyName string `json:"policy_name,omitempty"` +} + +// Validate validates this webhook last trigger +func (m *WebhookLastTrigger) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCreationTime(formats); err != nil { + res = append(res, err) + } + + if err := m.validateLastTriggerTime(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *WebhookLastTrigger) validateCreationTime(formats strfmt.Registry) error { + + if swag.IsZero(m.CreationTime) { // not required + return nil + } + + if err := validate.FormatOf("creation_time", "body", "date-time", m.CreationTime.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *WebhookLastTrigger) validateLastTriggerTime(formats strfmt.Registry) error { + + if swag.IsZero(m.LastTriggerTime) { // not required + return nil + } + + if err := validate.FormatOf("last_trigger_time", "body", "date-time", m.LastTriggerTime.String(), formats); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *WebhookLastTrigger) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *WebhookLastTrigger) UnmarshalBinary(b []byte) error { + var res WebhookLastTrigger + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/webhook_policy.go b/src/server/v2.0/models/webhook_policy.go new file mode 100644 index 000000000..284ac5ba6 --- /dev/null +++ b/src/server/v2.0/models/webhook_policy.go @@ -0,0 +1,144 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// WebhookPolicy The webhook policy object +// +// swagger:model WebhookPolicy +type WebhookPolicy struct { + + // The create time of the webhook policy. + // Format: date-time + CreationTime strfmt.DateTime `json:"creation_time,omitempty"` + + // The creator of the webhook policy. + Creator string `json:"creator,omitempty"` + + // The description of webhook policy. + Description string `json:"description,omitempty"` + + // Whether the webhook policy is enabled or not. + Enabled bool `json:"enabled"` + + // event types + EventTypes []string `json:"event_types"` + + // The webhook policy ID. + ID int64 `json:"id,omitempty"` + + // The name of webhook policy. + Name string `json:"name,omitempty"` + + // The project ID of webhook policy. + ProjectID int64 `json:"project_id,omitempty"` + + // targets + Targets []*WebhookTargetObject `json:"targets"` + + // The update time of the webhook policy. + // Format: date-time + UpdateTime strfmt.DateTime `json:"update_time,omitempty"` +} + +// Validate validates this webhook policy +func (m *WebhookPolicy) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCreationTime(formats); err != nil { + res = append(res, err) + } + + if err := m.validateTargets(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUpdateTime(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *WebhookPolicy) validateCreationTime(formats strfmt.Registry) error { + + if swag.IsZero(m.CreationTime) { // not required + return nil + } + + if err := validate.FormatOf("creation_time", "body", "date-time", m.CreationTime.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *WebhookPolicy) validateTargets(formats strfmt.Registry) error { + + if swag.IsZero(m.Targets) { // not required + return nil + } + + for i := 0; i < len(m.Targets); i++ { + if swag.IsZero(m.Targets[i]) { // not required + continue + } + + if m.Targets[i] != nil { + if err := m.Targets[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("targets" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *WebhookPolicy) validateUpdateTime(formats strfmt.Registry) error { + + if swag.IsZero(m.UpdateTime) { // not required + return nil + } + + if err := validate.FormatOf("update_time", "body", "date-time", m.UpdateTime.String(), formats); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *WebhookPolicy) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *WebhookPolicy) UnmarshalBinary(b []byte) error { + var res WebhookPolicy + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/webhook_target_object.go b/src/server/v2.0/models/webhook_target_object.go new file mode 100644 index 000000000..faf067ca2 --- /dev/null +++ b/src/server/v2.0/models/webhook_target_object.go @@ -0,0 +1,52 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// WebhookTargetObject The webhook policy target object. +// +// swagger:model WebhookTargetObject +type WebhookTargetObject struct { + + // The webhook target address. + Address string `json:"address,omitempty"` + + // The webhook auth header. + AuthHeader string `json:"auth_header,omitempty"` + + // Whether or not to skip cert verify. + SkipCertVerify bool `json:"skip_cert_verify,omitempty"` + + // The webhook target notify type. + Type string `json:"type,omitempty"` +} + +// Validate validates this webhook target object +func (m *WebhookTargetObject) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *WebhookTargetObject) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *WebhookTargetObject) UnmarshalBinary(b []byte) error { + var res WebhookTargetObject + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/worker.go b/src/server/v2.0/models/worker.go new file mode 100644 index 000000000..70b970d56 --- /dev/null +++ b/src/server/v2.0/models/worker.go @@ -0,0 +1,104 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// Worker worker in the pool +// +// swagger:model Worker +type Worker struct { + + // the checkin of the running job in the worker + CheckIn string `json:"check_in,omitempty"` + + // The checkin time of the worker + // Format: date-time + CheckinAt *strfmt.DateTime `json:"checkin_at,omitempty"` + + // the id of the worker + ID string `json:"id,omitempty"` + + // the id of the running job in the worker + JobID string `json:"job_id,omitempty"` + + // the name of the running job in the worker + JobName string `json:"job_name,omitempty"` + + // the id of the worker pool + PoolID string `json:"pool_id,omitempty"` + + // The start time of the worker + // Format: date-time + StartAt *strfmt.DateTime `json:"start_at,omitempty"` +} + +// Validate validates this worker +func (m *Worker) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCheckinAt(formats); err != nil { + res = append(res, err) + } + + if err := m.validateStartAt(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Worker) validateCheckinAt(formats strfmt.Registry) error { + + if swag.IsZero(m.CheckinAt) { // not required + return nil + } + + if err := validate.FormatOf("checkin_at", "body", "date-time", m.CheckinAt.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *Worker) validateStartAt(formats strfmt.Registry) error { + + if swag.IsZero(m.StartAt) { // not required + return nil + } + + if err := validate.FormatOf("start_at", "body", "date-time", m.StartAt.String(), formats); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Worker) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Worker) UnmarshalBinary(b []byte) error { + var res Worker + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/models/worker_pool.go b/src/server/v2.0/models/worker_pool.go new file mode 100644 index 000000000..c771f8a01 --- /dev/null +++ b/src/server/v2.0/models/worker_pool.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// WorkerPool the worker pool of job service +// +// swagger:model WorkerPool +type WorkerPool struct { + + // The concurrency of the work pool + Concurrency int64 `json:"concurrency,omitempty"` + + // The heartbeat time of the work pool + // Format: date-time + HeartbeatAt strfmt.DateTime `json:"heartbeat_at,omitempty"` + + // The host of the work pool + Host string `json:"host,omitempty"` + + // the process id of jobservice + Pid int64 `json:"pid,omitempty"` + + // The start time of the work pool + // Format: date-time + StartAt strfmt.DateTime `json:"start_at,omitempty"` + + // the id of the worker pool + WorkerPoolID string `json:"worker_pool_id,omitempty"` +} + +// Validate validates this worker pool +func (m *WorkerPool) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateHeartbeatAt(formats); err != nil { + res = append(res, err) + } + + if err := m.validateStartAt(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *WorkerPool) validateHeartbeatAt(formats strfmt.Registry) error { + + if swag.IsZero(m.HeartbeatAt) { // not required + return nil + } + + if err := validate.FormatOf("heartbeat_at", "body", "date-time", m.HeartbeatAt.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *WorkerPool) validateStartAt(formats strfmt.Registry) error { + + if swag.IsZero(m.StartAt) { // not required + return nil + } + + if err := validate.FormatOf("start_at", "body", "date-time", m.StartAt.String(), formats); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *WorkerPool) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *WorkerPool) UnmarshalBinary(b []byte) error { + var res WorkerPool + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/server/v2.0/restapi/configure_harbor.go b/src/server/v2.0/restapi/configure_harbor.go new file mode 100644 index 000000000..85452949b --- /dev/null +++ b/src/server/v2.0/restapi/configure_harbor.go @@ -0,0 +1,3637 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package restapi + +import ( + "context" + "encoding/json" + "fmt" + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/loads" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/runtime/security" + + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/artifact" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/auditlog" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/configure" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/gc" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/health" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/icon" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/immutable" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/jobservice" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/label" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/ldap" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/member" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/oidc" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/ping" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/preheat" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/project" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/project_metadata" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/purge" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/quota" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/registry" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/replication" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/repository" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/retention" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/robot" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/robotv1" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/scan" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/scan_all" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/scan_data_export" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/scanner" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/schedule" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/search" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/statistic" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/system_cve_allowlist" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/systeminfo" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/user" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/usergroup" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/webhook" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/webhookjob" +) + +type contextKey string + +const AuthKey contextKey = "Auth" + +// go:generate mockery -name ArtifactAPI -inpkg + +/* ArtifactAPI */ +type ArtifactAPI interface { + /* Prepare action before the operation */ + Prepare(ctx context.Context, operation string, params interface{}) middleware.Responder + + /* CopyArtifact Copy artifact */ + CopyArtifact(ctx context.Context, params artifact.CopyArtifactParams) middleware.Responder + + /* AddLabel Add label to artifact */ + AddLabel(ctx context.Context, params artifact.AddLabelParams) middleware.Responder + + /* CreateTag Create tag */ + CreateTag(ctx context.Context, params artifact.CreateTagParams) middleware.Responder + + /* DeleteArtifact Delete the specific artifact */ + DeleteArtifact(ctx context.Context, params artifact.DeleteArtifactParams) middleware.Responder + + /* DeleteTag Delete tag */ + DeleteTag(ctx context.Context, params artifact.DeleteTagParams) middleware.Responder + + /* GetAddition Get the addition of the specific artifact */ + GetAddition(ctx context.Context, params artifact.GetAdditionParams) middleware.Responder + + /* GetArtifact Get the specific artifact */ + GetArtifact(ctx context.Context, params artifact.GetArtifactParams) middleware.Responder + + /* GetVulnerabilitiesAddition Get the vulnerabilities addition of the specific artifact */ + GetVulnerabilitiesAddition(ctx context.Context, params artifact.GetVulnerabilitiesAdditionParams) middleware.Responder + + /* ListAccessories List accessories */ + ListAccessories(ctx context.Context, params artifact.ListAccessoriesParams) middleware.Responder + + /* ListArtifacts List artifacts */ + ListArtifacts(ctx context.Context, params artifact.ListArtifactsParams) middleware.Responder + + /* ListTags List tags */ + ListTags(ctx context.Context, params artifact.ListTagsParams) middleware.Responder + + /* RemoveLabel Remove label from artifact */ + RemoveLabel(ctx context.Context, params artifact.RemoveLabelParams) middleware.Responder +} + +// go:generate mockery -name AuditlogAPI -inpkg + +/* AuditlogAPI */ +type AuditlogAPI interface { + /* Prepare action before the operation */ + Prepare(ctx context.Context, operation string, params interface{}) middleware.Responder + + /* ListAuditLogs Get recent logs of the projects which the user is a member of */ + ListAuditLogs(ctx context.Context, params auditlog.ListAuditLogsParams) middleware.Responder +} + +// go:generate mockery -name ConfigureAPI -inpkg + +/* ConfigureAPI */ +type ConfigureAPI interface { + /* Prepare action before the operation */ + Prepare(ctx context.Context, operation string, params interface{}) middleware.Responder + + /* GetConfigurations Get system configurations. */ + GetConfigurations(ctx context.Context, params configure.GetConfigurationsParams) middleware.Responder + + /* GetInternalconfig Get internal configurations. */ + GetInternalconfig(ctx context.Context, params configure.GetInternalconfigParams) middleware.Responder + + /* UpdateConfigurations Modify system configurations. */ + UpdateConfigurations(ctx context.Context, params configure.UpdateConfigurationsParams) middleware.Responder +} + +// go:generate mockery -name GCAPI -inpkg + +/* GCAPI */ +type GCAPI interface { + /* Prepare action before the operation */ + Prepare(ctx context.Context, operation string, params interface{}) middleware.Responder + + /* CreateGCSchedule Create a gc schedule. */ + CreateGCSchedule(ctx context.Context, params gc.CreateGCScheduleParams) middleware.Responder + + /* GetGC Get gc status. */ + GetGC(ctx context.Context, params gc.GetGCParams) middleware.Responder + + /* GetGCHistory Get gc results. */ + GetGCHistory(ctx context.Context, params gc.GetGCHistoryParams) middleware.Responder + + /* GetGCLog Get gc job log. */ + GetGCLog(ctx context.Context, params gc.GetGCLogParams) middleware.Responder + + /* GetGCSchedule Get gc's schedule. */ + GetGCSchedule(ctx context.Context, params gc.GetGCScheduleParams) middleware.Responder + + /* StopGC Stop the specific GC execution */ + StopGC(ctx context.Context, params gc.StopGCParams) middleware.Responder + + /* UpdateGCSchedule Update gc's schedule. */ + UpdateGCSchedule(ctx context.Context, params gc.UpdateGCScheduleParams) middleware.Responder +} + +// go:generate mockery -name HealthAPI -inpkg + +/* HealthAPI */ +type HealthAPI interface { + /* Prepare action before the operation */ + Prepare(ctx context.Context, operation string, params interface{}) middleware.Responder + + /* GetHealth Check the status of Harbor components */ + GetHealth(ctx context.Context, params health.GetHealthParams) middleware.Responder +} + +// go:generate mockery -name IconAPI -inpkg + +/* IconAPI */ +type IconAPI interface { + /* Prepare action before the operation */ + Prepare(ctx context.Context, operation string, params interface{}) middleware.Responder + + /* GetIcon Get artifact icon */ + GetIcon(ctx context.Context, params icon.GetIconParams) middleware.Responder +} + +// go:generate mockery -name ImmutableAPI -inpkg + +/* ImmutableAPI */ +type ImmutableAPI interface { + /* Prepare action before the operation */ + Prepare(ctx context.Context, operation string, params interface{}) middleware.Responder + + /* CreateImmuRule Add an immutable tag rule to current project */ + CreateImmuRule(ctx context.Context, params immutable.CreateImmuRuleParams) middleware.Responder + + /* DeleteImmuRule Delete the immutable tag rule. */ + DeleteImmuRule(ctx context.Context, params immutable.DeleteImmuRuleParams) middleware.Responder + + /* ListImmuRules List all immutable tag rules of current project */ + ListImmuRules(ctx context.Context, params immutable.ListImmuRulesParams) middleware.Responder + + /* UpdateImmuRule Update the immutable tag rule or enable or disable the rule */ + UpdateImmuRule(ctx context.Context, params immutable.UpdateImmuRuleParams) middleware.Responder +} + +// go:generate mockery -name JobserviceAPI -inpkg + +/* JobserviceAPI */ +type JobserviceAPI interface { + /* Prepare action before the operation */ + Prepare(ctx context.Context, operation string, params interface{}) middleware.Responder + + /* ActionPendingJobs stop and clean, pause, resume pending jobs in the queue */ + ActionPendingJobs(ctx context.Context, params jobservice.ActionPendingJobsParams) middleware.Responder + + /* GetWorkerPools Get worker pools */ + GetWorkerPools(ctx context.Context, params jobservice.GetWorkerPoolsParams) middleware.Responder + + /* GetWorkers Get workers */ + GetWorkers(ctx context.Context, params jobservice.GetWorkersParams) middleware.Responder + + /* ListJobQueues list job queues */ + ListJobQueues(ctx context.Context, params jobservice.ListJobQueuesParams) middleware.Responder + + /* StopRunningJob Stop running job */ + StopRunningJob(ctx context.Context, params jobservice.StopRunningJobParams) middleware.Responder +} + +// go:generate mockery -name LabelAPI -inpkg + +/* LabelAPI */ +type LabelAPI interface { + /* Prepare action before the operation */ + Prepare(ctx context.Context, operation string, params interface{}) middleware.Responder + + /* CreateLabel Post creates a label */ + CreateLabel(ctx context.Context, params label.CreateLabelParams) middleware.Responder + + /* DeleteLabel Delete the label specified by ID. */ + DeleteLabel(ctx context.Context, params label.DeleteLabelParams) middleware.Responder + + /* GetLabelByID Get the label specified by ID. */ + GetLabelByID(ctx context.Context, params label.GetLabelByIDParams) middleware.Responder + + /* ListLabels List labels according to the query strings. */ + ListLabels(ctx context.Context, params label.ListLabelsParams) middleware.Responder + + /* UpdateLabel Update the label properties. */ + UpdateLabel(ctx context.Context, params label.UpdateLabelParams) middleware.Responder +} + +// go:generate mockery -name LdapAPI -inpkg + +/* LdapAPI */ +type LdapAPI interface { + /* Prepare action before the operation */ + Prepare(ctx context.Context, operation string, params interface{}) middleware.Responder + + /* ImportLdapUser Import selected available ldap users. */ + ImportLdapUser(ctx context.Context, params ldap.ImportLdapUserParams) middleware.Responder + + /* PingLdap Ping available ldap service. */ + PingLdap(ctx context.Context, params ldap.PingLdapParams) middleware.Responder + + /* SearchLdapGroup Search available ldap groups. */ + SearchLdapGroup(ctx context.Context, params ldap.SearchLdapGroupParams) middleware.Responder + + /* SearchLdapUser Search available ldap users. */ + SearchLdapUser(ctx context.Context, params ldap.SearchLdapUserParams) middleware.Responder +} + +// go:generate mockery -name MemberAPI -inpkg + +/* MemberAPI */ +type MemberAPI interface { + /* Prepare action before the operation */ + Prepare(ctx context.Context, operation string, params interface{}) middleware.Responder + + /* CreateProjectMember Create project member */ + CreateProjectMember(ctx context.Context, params member.CreateProjectMemberParams) middleware.Responder + + /* DeleteProjectMember Delete project member */ + DeleteProjectMember(ctx context.Context, params member.DeleteProjectMemberParams) middleware.Responder + + /* GetProjectMember Get the project member information */ + GetProjectMember(ctx context.Context, params member.GetProjectMemberParams) middleware.Responder + + /* ListProjectMembers Get all project member information */ + ListProjectMembers(ctx context.Context, params member.ListProjectMembersParams) middleware.Responder + + /* UpdateProjectMember Update project member */ + UpdateProjectMember(ctx context.Context, params member.UpdateProjectMemberParams) middleware.Responder +} + +// go:generate mockery -name OIDCAPI -inpkg + +/* OIDCAPI */ +type OIDCAPI interface { + /* Prepare action before the operation */ + Prepare(ctx context.Context, operation string, params interface{}) middleware.Responder + + /* PingOIDC Test the OIDC endpoint. */ + PingOIDC(ctx context.Context, params oidc.PingOIDCParams) middleware.Responder +} + +// go:generate mockery -name PingAPI -inpkg + +/* PingAPI */ +type PingAPI interface { + /* Prepare action before the operation */ + Prepare(ctx context.Context, operation string, params interface{}) middleware.Responder + + /* GetPing Ping Harbor to check if it's alive. */ + GetPing(ctx context.Context, params ping.GetPingParams) middleware.Responder +} + +// go:generate mockery -name PreheatAPI -inpkg + +/* PreheatAPI */ +type PreheatAPI interface { + /* Prepare action before the operation */ + Prepare(ctx context.Context, operation string, params interface{}) middleware.Responder + + /* CreateInstance Create p2p provider instances */ + CreateInstance(ctx context.Context, params preheat.CreateInstanceParams) middleware.Responder + + /* CreatePolicy Create a preheat policy under a project */ + CreatePolicy(ctx context.Context, params preheat.CreatePolicyParams) middleware.Responder + + /* DeleteInstance Delete the specified P2P provider instance */ + DeleteInstance(ctx context.Context, params preheat.DeleteInstanceParams) middleware.Responder + + /* DeletePolicy Delete a preheat policy */ + DeletePolicy(ctx context.Context, params preheat.DeletePolicyParams) middleware.Responder + + /* GetExecution Get a execution detail by id */ + GetExecution(ctx context.Context, params preheat.GetExecutionParams) middleware.Responder + + /* GetInstance Get a P2P provider instance */ + GetInstance(ctx context.Context, params preheat.GetInstanceParams) middleware.Responder + + /* GetPolicy Get a preheat policy */ + GetPolicy(ctx context.Context, params preheat.GetPolicyParams) middleware.Responder + + /* GetPreheatLog Get the log text stream of the specified task for the given execution */ + GetPreheatLog(ctx context.Context, params preheat.GetPreheatLogParams) middleware.Responder + + /* ListExecutions List executions for the given policy */ + ListExecutions(ctx context.Context, params preheat.ListExecutionsParams) middleware.Responder + + /* ListInstances List P2P provider instances */ + ListInstances(ctx context.Context, params preheat.ListInstancesParams) middleware.Responder + + /* ListPolicies List preheat policies */ + ListPolicies(ctx context.Context, params preheat.ListPoliciesParams) middleware.Responder + + /* ListProviders List P2P providers */ + ListProviders(ctx context.Context, params preheat.ListProvidersParams) middleware.Responder + + /* ListProvidersUnderProject Get all providers at project level */ + ListProvidersUnderProject(ctx context.Context, params preheat.ListProvidersUnderProjectParams) middleware.Responder + + /* ListTasks List all the related tasks for the given execution */ + ListTasks(ctx context.Context, params preheat.ListTasksParams) middleware.Responder + + /* ManualPreheat Manual preheat */ + ManualPreheat(ctx context.Context, params preheat.ManualPreheatParams) middleware.Responder + + /* PingInstances Ping status of a instance. */ + PingInstances(ctx context.Context, params preheat.PingInstancesParams) middleware.Responder + + /* StopExecution Stop a execution */ + StopExecution(ctx context.Context, params preheat.StopExecutionParams) middleware.Responder + + /* UpdateInstance Update the specified P2P provider instance */ + UpdateInstance(ctx context.Context, params preheat.UpdateInstanceParams) middleware.Responder + + /* UpdatePolicy Update preheat policy */ + UpdatePolicy(ctx context.Context, params preheat.UpdatePolicyParams) middleware.Responder +} + +// go:generate mockery -name ProjectAPI -inpkg + +/* ProjectAPI */ +type ProjectAPI interface { + /* Prepare action before the operation */ + Prepare(ctx context.Context, operation string, params interface{}) middleware.Responder + + /* CreateProject Create a new project. */ + CreateProject(ctx context.Context, params project.CreateProjectParams) middleware.Responder + + /* DeleteProject Delete project by projectID */ + DeleteProject(ctx context.Context, params project.DeleteProjectParams) middleware.Responder + + /* GetLogs Get recent logs of the projects */ + GetLogs(ctx context.Context, params project.GetLogsParams) middleware.Responder + + /* GetProject Return specific project detail information */ + GetProject(ctx context.Context, params project.GetProjectParams) middleware.Responder + + /* GetProjectDeletable Get the deletable status of the project */ + GetProjectDeletable(ctx context.Context, params project.GetProjectDeletableParams) middleware.Responder + + /* GetProjectSummary Get summary of the project. */ + GetProjectSummary(ctx context.Context, params project.GetProjectSummaryParams) middleware.Responder + + /* GetScannerOfProject Get project level scanner */ + GetScannerOfProject(ctx context.Context, params project.GetScannerOfProjectParams) middleware.Responder + + /* HeadProject Check if the project name user provided already exists. */ + HeadProject(ctx context.Context, params project.HeadProjectParams) middleware.Responder + + /* ListProjects List projects */ + ListProjects(ctx context.Context, params project.ListProjectsParams) middleware.Responder + + /* ListScannerCandidatesOfProject Get scanner registration candidates for configurating project level scanner */ + ListScannerCandidatesOfProject(ctx context.Context, params project.ListScannerCandidatesOfProjectParams) middleware.Responder + + /* SetScannerOfProject Configure scanner for the specified project */ + SetScannerOfProject(ctx context.Context, params project.SetScannerOfProjectParams) middleware.Responder + + /* UpdateProject Update properties for a selected project. */ + UpdateProject(ctx context.Context, params project.UpdateProjectParams) middleware.Responder +} + +// go:generate mockery -name ProjectMetadataAPI -inpkg + +/* ProjectMetadataAPI */ +type ProjectMetadataAPI interface { + /* Prepare action before the operation */ + Prepare(ctx context.Context, operation string, params interface{}) middleware.Responder + + /* AddProjectMetadatas Add metadata for the specific project */ + AddProjectMetadatas(ctx context.Context, params project_metadata.AddProjectMetadatasParams) middleware.Responder + + /* DeleteProjectMetadata Delete the specific metadata for the specific project */ + DeleteProjectMetadata(ctx context.Context, params project_metadata.DeleteProjectMetadataParams) middleware.Responder + + /* GetProjectMetadata Get the specific metadata of the specific project */ + GetProjectMetadata(ctx context.Context, params project_metadata.GetProjectMetadataParams) middleware.Responder + + /* ListProjectMetadatas Get the metadata of the specific project */ + ListProjectMetadatas(ctx context.Context, params project_metadata.ListProjectMetadatasParams) middleware.Responder + + /* UpdateProjectMetadata Update the specific metadata for the specific project */ + UpdateProjectMetadata(ctx context.Context, params project_metadata.UpdateProjectMetadataParams) middleware.Responder +} + +// go:generate mockery -name PurgeAPI -inpkg + +/* PurgeAPI */ +type PurgeAPI interface { + /* Prepare action before the operation */ + Prepare(ctx context.Context, operation string, params interface{}) middleware.Responder + + /* CreatePurgeSchedule Create a purge job schedule. */ + CreatePurgeSchedule(ctx context.Context, params purge.CreatePurgeScheduleParams) middleware.Responder + + /* GetPurgeHistory Get purge job results. */ + GetPurgeHistory(ctx context.Context, params purge.GetPurgeHistoryParams) middleware.Responder + + /* GetPurgeJob Get purge job status. */ + GetPurgeJob(ctx context.Context, params purge.GetPurgeJobParams) middleware.Responder + + /* GetPurgeJobLog Get purge job log. */ + GetPurgeJobLog(ctx context.Context, params purge.GetPurgeJobLogParams) middleware.Responder + + /* GetPurgeSchedule Get purge's schedule. */ + GetPurgeSchedule(ctx context.Context, params purge.GetPurgeScheduleParams) middleware.Responder + + /* StopPurge Stop the specific purge audit log execution */ + StopPurge(ctx context.Context, params purge.StopPurgeParams) middleware.Responder + + /* UpdatePurgeSchedule Update purge job's schedule. */ + UpdatePurgeSchedule(ctx context.Context, params purge.UpdatePurgeScheduleParams) middleware.Responder +} + +// go:generate mockery -name QuotaAPI -inpkg + +/* QuotaAPI */ +type QuotaAPI interface { + /* Prepare action before the operation */ + Prepare(ctx context.Context, operation string, params interface{}) middleware.Responder + + /* GetQuota Get the specified quota */ + GetQuota(ctx context.Context, params quota.GetQuotaParams) middleware.Responder + + /* ListQuotas List quotas */ + ListQuotas(ctx context.Context, params quota.ListQuotasParams) middleware.Responder + + /* UpdateQuota Update the specified quota */ + UpdateQuota(ctx context.Context, params quota.UpdateQuotaParams) middleware.Responder +} + +// go:generate mockery -name RegistryAPI -inpkg + +/* RegistryAPI */ +type RegistryAPI interface { + /* Prepare action before the operation */ + Prepare(ctx context.Context, operation string, params interface{}) middleware.Responder + + /* CreateRegistry Create a registry */ + CreateRegistry(ctx context.Context, params registry.CreateRegistryParams) middleware.Responder + + /* DeleteRegistry Delete the specific registry */ + DeleteRegistry(ctx context.Context, params registry.DeleteRegistryParams) middleware.Responder + + /* GetRegistry Get the specific registry */ + GetRegistry(ctx context.Context, params registry.GetRegistryParams) middleware.Responder + + /* GetRegistryInfo Get the registry info */ + GetRegistryInfo(ctx context.Context, params registry.GetRegistryInfoParams) middleware.Responder + + /* ListRegistries List the registries */ + ListRegistries(ctx context.Context, params registry.ListRegistriesParams) middleware.Responder + + /* ListRegistryProviderInfos List all registered registry provider information */ + ListRegistryProviderInfos(ctx context.Context, params registry.ListRegistryProviderInfosParams) middleware.Responder + + /* ListRegistryProviderTypes List registry adapters */ + ListRegistryProviderTypes(ctx context.Context, params registry.ListRegistryProviderTypesParams) middleware.Responder + + /* PingRegistry Check status of a registry */ + PingRegistry(ctx context.Context, params registry.PingRegistryParams) middleware.Responder + + /* UpdateRegistry Update the registry */ + UpdateRegistry(ctx context.Context, params registry.UpdateRegistryParams) middleware.Responder +} + +// go:generate mockery -name ReplicationAPI -inpkg + +/* ReplicationAPI */ +type ReplicationAPI interface { + /* Prepare action before the operation */ + Prepare(ctx context.Context, operation string, params interface{}) middleware.Responder + + /* CreateReplicationPolicy Create a replication policy */ + CreateReplicationPolicy(ctx context.Context, params replication.CreateReplicationPolicyParams) middleware.Responder + + /* DeleteReplicationPolicy Delete the specific replication policy */ + DeleteReplicationPolicy(ctx context.Context, params replication.DeleteReplicationPolicyParams) middleware.Responder + + /* GetReplicationExecution Get the specific replication execution */ + GetReplicationExecution(ctx context.Context, params replication.GetReplicationExecutionParams) middleware.Responder + + /* GetReplicationLog Get the log of the specific replication task */ + GetReplicationLog(ctx context.Context, params replication.GetReplicationLogParams) middleware.Responder + + /* GetReplicationPolicy Get the specific replication policy */ + GetReplicationPolicy(ctx context.Context, params replication.GetReplicationPolicyParams) middleware.Responder + + /* ListReplicationExecutions List replication executions */ + ListReplicationExecutions(ctx context.Context, params replication.ListReplicationExecutionsParams) middleware.Responder + + /* ListReplicationPolicies List replication policies */ + ListReplicationPolicies(ctx context.Context, params replication.ListReplicationPoliciesParams) middleware.Responder + + /* ListReplicationTasks List replication tasks for a specific execution */ + ListReplicationTasks(ctx context.Context, params replication.ListReplicationTasksParams) middleware.Responder + + /* StartReplication Start one replication execution */ + StartReplication(ctx context.Context, params replication.StartReplicationParams) middleware.Responder + + /* StopReplication Stop the specific replication execution */ + StopReplication(ctx context.Context, params replication.StopReplicationParams) middleware.Responder + + /* UpdateReplicationPolicy Update the replication policy */ + UpdateReplicationPolicy(ctx context.Context, params replication.UpdateReplicationPolicyParams) middleware.Responder +} + +// go:generate mockery -name RepositoryAPI -inpkg + +/* RepositoryAPI */ +type RepositoryAPI interface { + /* Prepare action before the operation */ + Prepare(ctx context.Context, operation string, params interface{}) middleware.Responder + + /* DeleteRepository Delete repository */ + DeleteRepository(ctx context.Context, params repository.DeleteRepositoryParams) middleware.Responder + + /* GetRepository Get repository */ + GetRepository(ctx context.Context, params repository.GetRepositoryParams) middleware.Responder + + /* ListAllRepositories List all authorized repositories */ + ListAllRepositories(ctx context.Context, params repository.ListAllRepositoriesParams) middleware.Responder + + /* ListRepositories List repositories */ + ListRepositories(ctx context.Context, params repository.ListRepositoriesParams) middleware.Responder + + /* UpdateRepository Update repository */ + UpdateRepository(ctx context.Context, params repository.UpdateRepositoryParams) middleware.Responder +} + +// go:generate mockery -name RetentionAPI -inpkg + +/* RetentionAPI */ +type RetentionAPI interface { + /* Prepare action before the operation */ + Prepare(ctx context.Context, operation string, params interface{}) middleware.Responder + + /* CreateRetention Create Retention Policy */ + CreateRetention(ctx context.Context, params retention.CreateRetentionParams) middleware.Responder + + /* DeleteRetention Delete Retention Policy */ + DeleteRetention(ctx context.Context, params retention.DeleteRetentionParams) middleware.Responder + + /* GetRentenitionMetadata Get Retention Metadatas */ + GetRentenitionMetadata(ctx context.Context, params retention.GetRentenitionMetadataParams) middleware.Responder + + /* GetRetention Get Retention Policy */ + GetRetention(ctx context.Context, params retention.GetRetentionParams) middleware.Responder + + /* GetRetentionTaskLog Get Retention job task log */ + GetRetentionTaskLog(ctx context.Context, params retention.GetRetentionTaskLogParams) middleware.Responder + + /* ListRetentionExecutions Get Retention executions */ + ListRetentionExecutions(ctx context.Context, params retention.ListRetentionExecutionsParams) middleware.Responder + + /* ListRetentionTasks Get Retention tasks */ + ListRetentionTasks(ctx context.Context, params retention.ListRetentionTasksParams) middleware.Responder + + /* OperateRetentionExecution Stop a Retention execution */ + OperateRetentionExecution(ctx context.Context, params retention.OperateRetentionExecutionParams) middleware.Responder + + /* TriggerRetentionExecution Trigger a Retention Execution */ + TriggerRetentionExecution(ctx context.Context, params retention.TriggerRetentionExecutionParams) middleware.Responder + + /* UpdateRetention Update Retention Policy */ + UpdateRetention(ctx context.Context, params retention.UpdateRetentionParams) middleware.Responder +} + +// go:generate mockery -name RobotAPI -inpkg + +/* RobotAPI */ +type RobotAPI interface { + /* Prepare action before the operation */ + Prepare(ctx context.Context, operation string, params interface{}) middleware.Responder + + /* CreateRobot Create a robot account */ + CreateRobot(ctx context.Context, params robot.CreateRobotParams) middleware.Responder + + /* DeleteRobot Delete a robot account */ + DeleteRobot(ctx context.Context, params robot.DeleteRobotParams) middleware.Responder + + /* GetRobotByID Get a robot account */ + GetRobotByID(ctx context.Context, params robot.GetRobotByIDParams) middleware.Responder + + /* ListRobot Get robot account */ + ListRobot(ctx context.Context, params robot.ListRobotParams) middleware.Responder + + /* RefreshSec Refresh the robot secret */ + RefreshSec(ctx context.Context, params robot.RefreshSecParams) middleware.Responder + + /* UpdateRobot Update a robot account */ + UpdateRobot(ctx context.Context, params robot.UpdateRobotParams) middleware.Responder +} + +// go:generate mockery -name Robotv1API -inpkg + +/* Robotv1API */ +type Robotv1API interface { + /* Prepare action before the operation */ + Prepare(ctx context.Context, operation string, params interface{}) middleware.Responder + + /* CreateRobotV1 Create a robot account */ + CreateRobotV1(ctx context.Context, params robotv1.CreateRobotV1Params) middleware.Responder + + /* DeleteRobotV1 Delete a robot account */ + DeleteRobotV1(ctx context.Context, params robotv1.DeleteRobotV1Params) middleware.Responder + + /* GetRobotByIDV1 Get a robot account */ + GetRobotByIDV1(ctx context.Context, params robotv1.GetRobotByIDV1Params) middleware.Responder + + /* ListRobotV1 Get all robot accounts of specified project */ + ListRobotV1(ctx context.Context, params robotv1.ListRobotV1Params) middleware.Responder + + /* UpdateRobotV1 Update status of robot account. */ + UpdateRobotV1(ctx context.Context, params robotv1.UpdateRobotV1Params) middleware.Responder +} + +// go:generate mockery -name ScanAPI -inpkg + +/* ScanAPI */ +type ScanAPI interface { + /* Prepare action before the operation */ + Prepare(ctx context.Context, operation string, params interface{}) middleware.Responder + + /* GetReportLog Get the log of the scan report */ + GetReportLog(ctx context.Context, params scan.GetReportLogParams) middleware.Responder + + /* ScanArtifact Scan the artifact */ + ScanArtifact(ctx context.Context, params scan.ScanArtifactParams) middleware.Responder + + /* StopScanArtifact Cancelling a scan job for a particular artifact */ + StopScanArtifact(ctx context.Context, params scan.StopScanArtifactParams) middleware.Responder +} + +// go:generate mockery -name ScanAllAPI -inpkg + +/* ScanAllAPI */ +type ScanAllAPI interface { + /* Prepare action before the operation */ + Prepare(ctx context.Context, operation string, params interface{}) middleware.Responder + + /* CreateScanAllSchedule Create a schedule or a manual trigger for the scan all job. */ + CreateScanAllSchedule(ctx context.Context, params scan_all.CreateScanAllScheduleParams) middleware.Responder + + /* GetLatestScanAllMetrics Get the metrics of the latest scan all process */ + GetLatestScanAllMetrics(ctx context.Context, params scan_all.GetLatestScanAllMetricsParams) middleware.Responder + + /* GetLatestScheduledScanAllMetrics Get the metrics of the latest scheduled scan all process */ + GetLatestScheduledScanAllMetrics(ctx context.Context, params scan_all.GetLatestScheduledScanAllMetricsParams) middleware.Responder + + /* GetScanAllSchedule Get scan all's schedule. */ + GetScanAllSchedule(ctx context.Context, params scan_all.GetScanAllScheduleParams) middleware.Responder + + /* StopScanAll Stop scanAll job execution */ + StopScanAll(ctx context.Context, params scan_all.StopScanAllParams) middleware.Responder + + /* UpdateScanAllSchedule Update scan all's schedule. */ + UpdateScanAllSchedule(ctx context.Context, params scan_all.UpdateScanAllScheduleParams) middleware.Responder +} + +// go:generate mockery -name ScanDataExportAPI -inpkg + +/* ScanDataExportAPI */ +type ScanDataExportAPI interface { + /* Prepare action before the operation */ + Prepare(ctx context.Context, operation string, params interface{}) middleware.Responder + + /* DownloadScanData Download the scan data export file */ + DownloadScanData(ctx context.Context, params scan_data_export.DownloadScanDataParams) middleware.Responder + + /* ExportScanData Export scan data for selected projects */ + ExportScanData(ctx context.Context, params scan_data_export.ExportScanDataParams) middleware.Responder + + /* GetScanDataExportExecution Get the specific scan data export execution */ + GetScanDataExportExecution(ctx context.Context, params scan_data_export.GetScanDataExportExecutionParams) middleware.Responder + + /* GetScanDataExportExecutionList Get a list of specific scan data export execution jobs for a specified user */ + GetScanDataExportExecutionList(ctx context.Context, params scan_data_export.GetScanDataExportExecutionListParams) middleware.Responder +} + +// go:generate mockery -name ScannerAPI -inpkg + +/* ScannerAPI */ +type ScannerAPI interface { + /* Prepare action before the operation */ + Prepare(ctx context.Context, operation string, params interface{}) middleware.Responder + + /* CreateScanner Create a scanner registration */ + CreateScanner(ctx context.Context, params scanner.CreateScannerParams) middleware.Responder + + /* DeleteScanner Delete a scanner registration */ + DeleteScanner(ctx context.Context, params scanner.DeleteScannerParams) middleware.Responder + + /* GetScanner Get a scanner registration details */ + GetScanner(ctx context.Context, params scanner.GetScannerParams) middleware.Responder + + /* GetScannerMetadata Get the metadata of the specified scanner registration */ + GetScannerMetadata(ctx context.Context, params scanner.GetScannerMetadataParams) middleware.Responder + + /* ListScanners List scanner registrations */ + ListScanners(ctx context.Context, params scanner.ListScannersParams) middleware.Responder + + /* PingScanner Tests scanner registration settings */ + PingScanner(ctx context.Context, params scanner.PingScannerParams) middleware.Responder + + /* SetScannerAsDefault Set system default scanner registration */ + SetScannerAsDefault(ctx context.Context, params scanner.SetScannerAsDefaultParams) middleware.Responder + + /* UpdateScanner Update a scanner registration */ + UpdateScanner(ctx context.Context, params scanner.UpdateScannerParams) middleware.Responder +} + +// go:generate mockery -name ScheduleAPI -inpkg + +/* ScheduleAPI */ +type ScheduleAPI interface { + /* Prepare action before the operation */ + Prepare(ctx context.Context, operation string, params interface{}) middleware.Responder + + /* GetSchedulePaused Get scheduler paused status */ + GetSchedulePaused(ctx context.Context, params schedule.GetSchedulePausedParams) middleware.Responder + + /* ListSchedules List schedules */ + ListSchedules(ctx context.Context, params schedule.ListSchedulesParams) middleware.Responder +} + +// go:generate mockery -name SearchAPI -inpkg + +/* SearchAPI */ +type SearchAPI interface { + /* Prepare action before the operation */ + Prepare(ctx context.Context, operation string, params interface{}) middleware.Responder + + /* Search Search for projects, repositories and helm charts */ + Search(ctx context.Context, params search.SearchParams) middleware.Responder +} + +// go:generate mockery -name StatisticAPI -inpkg + +/* StatisticAPI */ +type StatisticAPI interface { + /* Prepare action before the operation */ + Prepare(ctx context.Context, operation string, params interface{}) middleware.Responder + + /* GetStatistic Get the statistic information about the projects and repositories */ + GetStatistic(ctx context.Context, params statistic.GetStatisticParams) middleware.Responder +} + +// go:generate mockery -name SystemCVEAllowlistAPI -inpkg + +/* SystemCVEAllowlistAPI */ +type SystemCVEAllowlistAPI interface { + /* Prepare action before the operation */ + Prepare(ctx context.Context, operation string, params interface{}) middleware.Responder + + /* GetSystemCVEAllowlist Get the system level allowlist of CVE. */ + GetSystemCVEAllowlist(ctx context.Context, params system_cve_allowlist.GetSystemCVEAllowlistParams) middleware.Responder + + /* PutSystemCVEAllowlist Update the system level allowlist of CVE. */ + PutSystemCVEAllowlist(ctx context.Context, params system_cve_allowlist.PutSystemCVEAllowlistParams) middleware.Responder +} + +// go:generate mockery -name SysteminfoAPI -inpkg + +/* SysteminfoAPI */ +type SysteminfoAPI interface { + /* Prepare action before the operation */ + Prepare(ctx context.Context, operation string, params interface{}) middleware.Responder + + /* GetCert Get default root certificate. */ + GetCert(ctx context.Context, params systeminfo.GetCertParams) middleware.Responder + + /* GetSystemInfo Get general system info */ + GetSystemInfo(ctx context.Context, params systeminfo.GetSystemInfoParams) middleware.Responder + + /* GetVolumes Get system volume info (total/free size). */ + GetVolumes(ctx context.Context, params systeminfo.GetVolumesParams) middleware.Responder +} + +// go:generate mockery -name UserAPI -inpkg + +/* UserAPI */ +type UserAPI interface { + /* Prepare action before the operation */ + Prepare(ctx context.Context, operation string, params interface{}) middleware.Responder + + /* CreateUser Create a local user. */ + CreateUser(ctx context.Context, params user.CreateUserParams) middleware.Responder + + /* DeleteUser Mark a registered user as be removed. */ + DeleteUser(ctx context.Context, params user.DeleteUserParams) middleware.Responder + + /* GetCurrentUserInfo Get current user info. */ + GetCurrentUserInfo(ctx context.Context, params user.GetCurrentUserInfoParams) middleware.Responder + + /* GetCurrentUserPermissions Get current user permissions. */ + GetCurrentUserPermissions(ctx context.Context, params user.GetCurrentUserPermissionsParams) middleware.Responder + + /* GetUser Get a user's profile. */ + GetUser(ctx context.Context, params user.GetUserParams) middleware.Responder + + /* ListUsers List users */ + ListUsers(ctx context.Context, params user.ListUsersParams) middleware.Responder + + /* SearchUsers Search users by username */ + SearchUsers(ctx context.Context, params user.SearchUsersParams) middleware.Responder + + /* SetCliSecret Set CLI secret for a user. */ + SetCliSecret(ctx context.Context, params user.SetCliSecretParams) middleware.Responder + + /* SetUserSysAdmin Update a registered user to change to be an administrator of Harbor. */ + SetUserSysAdmin(ctx context.Context, params user.SetUserSysAdminParams) middleware.Responder + + /* UpdateUserPassword Change the password on a user that already exists. */ + UpdateUserPassword(ctx context.Context, params user.UpdateUserPasswordParams) middleware.Responder + + /* UpdateUserProfile Update user's profile. */ + UpdateUserProfile(ctx context.Context, params user.UpdateUserProfileParams) middleware.Responder +} + +// go:generate mockery -name UsergroupAPI -inpkg + +/* UsergroupAPI */ +type UsergroupAPI interface { + /* Prepare action before the operation */ + Prepare(ctx context.Context, operation string, params interface{}) middleware.Responder + + /* CreateUserGroup Create user group */ + CreateUserGroup(ctx context.Context, params usergroup.CreateUserGroupParams) middleware.Responder + + /* DeleteUserGroup Delete user group */ + DeleteUserGroup(ctx context.Context, params usergroup.DeleteUserGroupParams) middleware.Responder + + /* GetUserGroup Get user group information */ + GetUserGroup(ctx context.Context, params usergroup.GetUserGroupParams) middleware.Responder + + /* ListUserGroups Get all user groups information */ + ListUserGroups(ctx context.Context, params usergroup.ListUserGroupsParams) middleware.Responder + + /* SearchUserGroups Search groups by groupname */ + SearchUserGroups(ctx context.Context, params usergroup.SearchUserGroupsParams) middleware.Responder + + /* UpdateUserGroup Update group information */ + UpdateUserGroup(ctx context.Context, params usergroup.UpdateUserGroupParams) middleware.Responder +} + +// go:generate mockery -name WebhookAPI -inpkg + +/* WebhookAPI */ +type WebhookAPI interface { + /* Prepare action before the operation */ + Prepare(ctx context.Context, operation string, params interface{}) middleware.Responder + + /* CreateWebhookPolicyOfProject Create project webhook policy. */ + CreateWebhookPolicyOfProject(ctx context.Context, params webhook.CreateWebhookPolicyOfProjectParams) middleware.Responder + + /* DeleteWebhookPolicyOfProject Delete webhook policy of a project */ + DeleteWebhookPolicyOfProject(ctx context.Context, params webhook.DeleteWebhookPolicyOfProjectParams) middleware.Responder + + /* GetSupportedEventTypes Get supported event types and notify types. */ + GetSupportedEventTypes(ctx context.Context, params webhook.GetSupportedEventTypesParams) middleware.Responder + + /* GetWebhookPolicyOfProject Get project webhook policy */ + GetWebhookPolicyOfProject(ctx context.Context, params webhook.GetWebhookPolicyOfProjectParams) middleware.Responder + + /* LastTrigger Get project webhook policy last trigger info */ + LastTrigger(ctx context.Context, params webhook.LastTriggerParams) middleware.Responder + + /* ListWebhookPoliciesOfProject List project webhook policies. */ + ListWebhookPoliciesOfProject(ctx context.Context, params webhook.ListWebhookPoliciesOfProjectParams) middleware.Responder + + /* UpdateWebhookPolicyOfProject Update webhook policy of a project. */ + UpdateWebhookPolicyOfProject(ctx context.Context, params webhook.UpdateWebhookPolicyOfProjectParams) middleware.Responder +} + +// go:generate mockery -name WebhookjobAPI -inpkg + +/* WebhookjobAPI */ +type WebhookjobAPI interface { + /* Prepare action before the operation */ + Prepare(ctx context.Context, operation string, params interface{}) middleware.Responder + + /* ListWebhookJobs List project webhook jobs */ + ListWebhookJobs(ctx context.Context, params webhookjob.ListWebhookJobsParams) middleware.Responder +} + +// Config is configuration for Handler +type Config struct { + ArtifactAPI + AuditlogAPI + ConfigureAPI + GCAPI + HealthAPI + IconAPI + ImmutableAPI + JobserviceAPI + LabelAPI + LdapAPI + MemberAPI + OIDCAPI + PingAPI + PreheatAPI + ProjectAPI + ProjectMetadataAPI + PurgeAPI + QuotaAPI + RegistryAPI + ReplicationAPI + RepositoryAPI + RetentionAPI + RobotAPI + Robotv1API + ScanAPI + ScanAllAPI + ScanDataExportAPI + ScannerAPI + ScheduleAPI + SearchAPI + StatisticAPI + SystemCVEAllowlistAPI + SysteminfoAPI + UserAPI + UsergroupAPI + WebhookAPI + WebhookjobAPI + Logger func(string, ...interface{}) + // InnerMiddleware is for the handler executors. These do not apply to the swagger.json document. + // The middleware executes after routing but before authentication, binding and validation + InnerMiddleware func(http.Handler) http.Handler + + // Authorizer is used to authorize a request after the Auth function was called using the "Auth*" functions + // and the principal was stored in the context in the "AuthKey" context value. + Authorizer func(*http.Request) error + + // AuthBasic for basic authentication + AuthBasic func(user string, pass string) (interface{}, error) + + // Authenticator to use for all APIKey authentication + APIKeyAuthenticator func(string, string, security.TokenAuthentication) runtime.Authenticator + // Authenticator to use for all Bearer authentication + BasicAuthenticator func(security.UserPassAuthentication) runtime.Authenticator + // Authenticator to use for all Basic authentication + BearerAuthenticator func(string, security.ScopedTokenAuthentication) runtime.Authenticator +} + +// Handler returns an http.Handler given the handler configuration +// It mounts all the business logic implementers in the right routing. +func Handler(c Config) (http.Handler, error) { + h, _, err := HandlerAPI(c) + return h, err +} + +// HandlerAPI returns an http.Handler given the handler configuration +// and the corresponding *Harbor instance. +// It mounts all the business logic implementers in the right routing. +func HandlerAPI(c Config) (http.Handler, *operations.HarborAPI, error) { + spec, err := loads.Analyzed(swaggerCopy(SwaggerJSON), "") + if err != nil { + return nil, nil, fmt.Errorf("analyze swagger: %v", err) + } + api := operations.NewHarborAPI(spec) + api.ServeError = errors.ServeError + api.Logger = c.Logger + + if c.APIKeyAuthenticator != nil { + api.APIKeyAuthenticator = c.APIKeyAuthenticator + } + if c.BasicAuthenticator != nil { + api.BasicAuthenticator = c.BasicAuthenticator + } + if c.BearerAuthenticator != nil { + api.BearerAuthenticator = c.BearerAuthenticator + } + + api.JSONConsumer = runtime.JSONConsumer() + api.BinProducer = runtime.ByteStreamProducer() + api.CsvProducer = runtime.ProducerFunc(func(w io.Writer, data interface{}) error { + return errors.NotImplemented("csv producer has not yet been implemented") + }) + api.JSONProducer = runtime.JSONProducer() + api.TxtProducer = runtime.TextProducer() + api.BasicAuth = func(user string, pass string) (interface{}, error) { + if c.AuthBasic == nil { + return "", nil + } + return c.AuthBasic(user, pass) + } + + api.APIAuthorizer = authorizer(c.Authorizer) + api.ArtifactCopyArtifactHandler = artifact.CopyArtifactHandlerFunc(func(params artifact.CopyArtifactParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "CopyArtifact", ¶ms); res != nil { + return res + } + } + if res := c.ArtifactAPI.Prepare(ctx, "CopyArtifact", ¶ms); res != nil { + return res + } + return c.ArtifactAPI.CopyArtifact(ctx, params) + }) + api.ImmutableCreateImmuRuleHandler = immutable.CreateImmuRuleHandlerFunc(func(params immutable.CreateImmuRuleParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "CreateImmuRule", ¶ms); res != nil { + return res + } + } + if res := c.ImmutableAPI.Prepare(ctx, "CreateImmuRule", ¶ms); res != nil { + return res + } + return c.ImmutableAPI.CreateImmuRule(ctx, params) + }) + api.PreheatCreateInstanceHandler = preheat.CreateInstanceHandlerFunc(func(params preheat.CreateInstanceParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "CreateInstance", ¶ms); res != nil { + return res + } + } + if res := c.PreheatAPI.Prepare(ctx, "CreateInstance", ¶ms); res != nil { + return res + } + return c.PreheatAPI.CreateInstance(ctx, params) + }) + api.LabelCreateLabelHandler = label.CreateLabelHandlerFunc(func(params label.CreateLabelParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "CreateLabel", ¶ms); res != nil { + return res + } + } + if res := c.LabelAPI.Prepare(ctx, "CreateLabel", ¶ms); res != nil { + return res + } + return c.LabelAPI.CreateLabel(ctx, params) + }) + api.PreheatCreatePolicyHandler = preheat.CreatePolicyHandlerFunc(func(params preheat.CreatePolicyParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "CreatePolicy", ¶ms); res != nil { + return res + } + } + if res := c.PreheatAPI.Prepare(ctx, "CreatePolicy", ¶ms); res != nil { + return res + } + return c.PreheatAPI.CreatePolicy(ctx, params) + }) + api.RobotCreateRobotHandler = robot.CreateRobotHandlerFunc(func(params robot.CreateRobotParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "CreateRobot", ¶ms); res != nil { + return res + } + } + if res := c.RobotAPI.Prepare(ctx, "CreateRobot", ¶ms); res != nil { + return res + } + return c.RobotAPI.CreateRobot(ctx, params) + }) + api.Robotv1CreateRobotV1Handler = robotv1.CreateRobotV1HandlerFunc(func(params robotv1.CreateRobotV1Params, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "CreateRobotV1", ¶ms); res != nil { + return res + } + } + if res := c.Robotv1API.Prepare(ctx, "CreateRobotV1", ¶ms); res != nil { + return res + } + return c.Robotv1API.CreateRobotV1(ctx, params) + }) + api.WebhookCreateWebhookPolicyOfProjectHandler = webhook.CreateWebhookPolicyOfProjectHandlerFunc(func(params webhook.CreateWebhookPolicyOfProjectParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "CreateWebhookPolicyOfProject", ¶ms); res != nil { + return res + } + } + if res := c.WebhookAPI.Prepare(ctx, "CreateWebhookPolicyOfProject", ¶ms); res != nil { + return res + } + return c.WebhookAPI.CreateWebhookPolicyOfProject(ctx, params) + }) + api.ImmutableDeleteImmuRuleHandler = immutable.DeleteImmuRuleHandlerFunc(func(params immutable.DeleteImmuRuleParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "DeleteImmuRule", ¶ms); res != nil { + return res + } + } + if res := c.ImmutableAPI.Prepare(ctx, "DeleteImmuRule", ¶ms); res != nil { + return res + } + return c.ImmutableAPI.DeleteImmuRule(ctx, params) + }) + api.PreheatDeleteInstanceHandler = preheat.DeleteInstanceHandlerFunc(func(params preheat.DeleteInstanceParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "DeleteInstance", ¶ms); res != nil { + return res + } + } + if res := c.PreheatAPI.Prepare(ctx, "DeleteInstance", ¶ms); res != nil { + return res + } + return c.PreheatAPI.DeleteInstance(ctx, params) + }) + api.LabelDeleteLabelHandler = label.DeleteLabelHandlerFunc(func(params label.DeleteLabelParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "DeleteLabel", ¶ms); res != nil { + return res + } + } + if res := c.LabelAPI.Prepare(ctx, "DeleteLabel", ¶ms); res != nil { + return res + } + return c.LabelAPI.DeleteLabel(ctx, params) + }) + api.PreheatDeletePolicyHandler = preheat.DeletePolicyHandlerFunc(func(params preheat.DeletePolicyParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "DeletePolicy", ¶ms); res != nil { + return res + } + } + if res := c.PreheatAPI.Prepare(ctx, "DeletePolicy", ¶ms); res != nil { + return res + } + return c.PreheatAPI.DeletePolicy(ctx, params) + }) + api.RobotDeleteRobotHandler = robot.DeleteRobotHandlerFunc(func(params robot.DeleteRobotParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "DeleteRobot", ¶ms); res != nil { + return res + } + } + if res := c.RobotAPI.Prepare(ctx, "DeleteRobot", ¶ms); res != nil { + return res + } + return c.RobotAPI.DeleteRobot(ctx, params) + }) + api.Robotv1DeleteRobotV1Handler = robotv1.DeleteRobotV1HandlerFunc(func(params robotv1.DeleteRobotV1Params, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "DeleteRobotV1", ¶ms); res != nil { + return res + } + } + if res := c.Robotv1API.Prepare(ctx, "DeleteRobotV1", ¶ms); res != nil { + return res + } + return c.Robotv1API.DeleteRobotV1(ctx, params) + }) + api.WebhookDeleteWebhookPolicyOfProjectHandler = webhook.DeleteWebhookPolicyOfProjectHandlerFunc(func(params webhook.DeleteWebhookPolicyOfProjectParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "DeleteWebhookPolicyOfProject", ¶ms); res != nil { + return res + } + } + if res := c.WebhookAPI.Prepare(ctx, "DeleteWebhookPolicyOfProject", ¶ms); res != nil { + return res + } + return c.WebhookAPI.DeleteWebhookPolicyOfProject(ctx, params) + }) + api.PreheatGetExecutionHandler = preheat.GetExecutionHandlerFunc(func(params preheat.GetExecutionParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetExecution", ¶ms); res != nil { + return res + } + } + if res := c.PreheatAPI.Prepare(ctx, "GetExecution", ¶ms); res != nil { + return res + } + return c.PreheatAPI.GetExecution(ctx, params) + }) + api.PreheatGetInstanceHandler = preheat.GetInstanceHandlerFunc(func(params preheat.GetInstanceParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetInstance", ¶ms); res != nil { + return res + } + } + if res := c.PreheatAPI.Prepare(ctx, "GetInstance", ¶ms); res != nil { + return res + } + return c.PreheatAPI.GetInstance(ctx, params) + }) + api.LabelGetLabelByIDHandler = label.GetLabelByIDHandlerFunc(func(params label.GetLabelByIDParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetLabelByID", ¶ms); res != nil { + return res + } + } + if res := c.LabelAPI.Prepare(ctx, "GetLabelByID", ¶ms); res != nil { + return res + } + return c.LabelAPI.GetLabelByID(ctx, params) + }) + api.PreheatGetPolicyHandler = preheat.GetPolicyHandlerFunc(func(params preheat.GetPolicyParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetPolicy", ¶ms); res != nil { + return res + } + } + if res := c.PreheatAPI.Prepare(ctx, "GetPolicy", ¶ms); res != nil { + return res + } + return c.PreheatAPI.GetPolicy(ctx, params) + }) + api.PreheatGetPreheatLogHandler = preheat.GetPreheatLogHandlerFunc(func(params preheat.GetPreheatLogParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetPreheatLog", ¶ms); res != nil { + return res + } + } + if res := c.PreheatAPI.Prepare(ctx, "GetPreheatLog", ¶ms); res != nil { + return res + } + return c.PreheatAPI.GetPreheatLog(ctx, params) + }) + api.RobotGetRobotByIDHandler = robot.GetRobotByIDHandlerFunc(func(params robot.GetRobotByIDParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetRobotByID", ¶ms); res != nil { + return res + } + } + if res := c.RobotAPI.Prepare(ctx, "GetRobotByID", ¶ms); res != nil { + return res + } + return c.RobotAPI.GetRobotByID(ctx, params) + }) + api.Robotv1GetRobotByIDV1Handler = robotv1.GetRobotByIDV1HandlerFunc(func(params robotv1.GetRobotByIDV1Params, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetRobotByIDV1", ¶ms); res != nil { + return res + } + } + if res := c.Robotv1API.Prepare(ctx, "GetRobotByIDV1", ¶ms); res != nil { + return res + } + return c.Robotv1API.GetRobotByIDV1(ctx, params) + }) + api.WebhookGetSupportedEventTypesHandler = webhook.GetSupportedEventTypesHandlerFunc(func(params webhook.GetSupportedEventTypesParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetSupportedEventTypes", ¶ms); res != nil { + return res + } + } + if res := c.WebhookAPI.Prepare(ctx, "GetSupportedEventTypes", ¶ms); res != nil { + return res + } + return c.WebhookAPI.GetSupportedEventTypes(ctx, params) + }) + api.WebhookGetWebhookPolicyOfProjectHandler = webhook.GetWebhookPolicyOfProjectHandlerFunc(func(params webhook.GetWebhookPolicyOfProjectParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetWebhookPolicyOfProject", ¶ms); res != nil { + return res + } + } + if res := c.WebhookAPI.Prepare(ctx, "GetWebhookPolicyOfProject", ¶ms); res != nil { + return res + } + return c.WebhookAPI.GetWebhookPolicyOfProject(ctx, params) + }) + api.WebhookLastTriggerHandler = webhook.LastTriggerHandlerFunc(func(params webhook.LastTriggerParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "LastTrigger", ¶ms); res != nil { + return res + } + } + if res := c.WebhookAPI.Prepare(ctx, "LastTrigger", ¶ms); res != nil { + return res + } + return c.WebhookAPI.LastTrigger(ctx, params) + }) + api.PreheatListExecutionsHandler = preheat.ListExecutionsHandlerFunc(func(params preheat.ListExecutionsParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "ListExecutions", ¶ms); res != nil { + return res + } + } + if res := c.PreheatAPI.Prepare(ctx, "ListExecutions", ¶ms); res != nil { + return res + } + return c.PreheatAPI.ListExecutions(ctx, params) + }) + api.ImmutableListImmuRulesHandler = immutable.ListImmuRulesHandlerFunc(func(params immutable.ListImmuRulesParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "ListImmuRules", ¶ms); res != nil { + return res + } + } + if res := c.ImmutableAPI.Prepare(ctx, "ListImmuRules", ¶ms); res != nil { + return res + } + return c.ImmutableAPI.ListImmuRules(ctx, params) + }) + api.PreheatListInstancesHandler = preheat.ListInstancesHandlerFunc(func(params preheat.ListInstancesParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "ListInstances", ¶ms); res != nil { + return res + } + } + if res := c.PreheatAPI.Prepare(ctx, "ListInstances", ¶ms); res != nil { + return res + } + return c.PreheatAPI.ListInstances(ctx, params) + }) + api.LabelListLabelsHandler = label.ListLabelsHandlerFunc(func(params label.ListLabelsParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "ListLabels", ¶ms); res != nil { + return res + } + } + if res := c.LabelAPI.Prepare(ctx, "ListLabels", ¶ms); res != nil { + return res + } + return c.LabelAPI.ListLabels(ctx, params) + }) + api.PreheatListPoliciesHandler = preheat.ListPoliciesHandlerFunc(func(params preheat.ListPoliciesParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "ListPolicies", ¶ms); res != nil { + return res + } + } + if res := c.PreheatAPI.Prepare(ctx, "ListPolicies", ¶ms); res != nil { + return res + } + return c.PreheatAPI.ListPolicies(ctx, params) + }) + api.PreheatListProvidersHandler = preheat.ListProvidersHandlerFunc(func(params preheat.ListProvidersParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "ListProviders", ¶ms); res != nil { + return res + } + } + if res := c.PreheatAPI.Prepare(ctx, "ListProviders", ¶ms); res != nil { + return res + } + return c.PreheatAPI.ListProviders(ctx, params) + }) + api.PreheatListProvidersUnderProjectHandler = preheat.ListProvidersUnderProjectHandlerFunc(func(params preheat.ListProvidersUnderProjectParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "ListProvidersUnderProject", ¶ms); res != nil { + return res + } + } + if res := c.PreheatAPI.Prepare(ctx, "ListProvidersUnderProject", ¶ms); res != nil { + return res + } + return c.PreheatAPI.ListProvidersUnderProject(ctx, params) + }) + api.RobotListRobotHandler = robot.ListRobotHandlerFunc(func(params robot.ListRobotParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "ListRobot", ¶ms); res != nil { + return res + } + } + if res := c.RobotAPI.Prepare(ctx, "ListRobot", ¶ms); res != nil { + return res + } + return c.RobotAPI.ListRobot(ctx, params) + }) + api.Robotv1ListRobotV1Handler = robotv1.ListRobotV1HandlerFunc(func(params robotv1.ListRobotV1Params, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "ListRobotV1", ¶ms); res != nil { + return res + } + } + if res := c.Robotv1API.Prepare(ctx, "ListRobotV1", ¶ms); res != nil { + return res + } + return c.Robotv1API.ListRobotV1(ctx, params) + }) + api.PreheatListTasksHandler = preheat.ListTasksHandlerFunc(func(params preheat.ListTasksParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "ListTasks", ¶ms); res != nil { + return res + } + } + if res := c.PreheatAPI.Prepare(ctx, "ListTasks", ¶ms); res != nil { + return res + } + return c.PreheatAPI.ListTasks(ctx, params) + }) + api.WebhookjobListWebhookJobsHandler = webhookjob.ListWebhookJobsHandlerFunc(func(params webhookjob.ListWebhookJobsParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "ListWebhookJobs", ¶ms); res != nil { + return res + } + } + if res := c.WebhookjobAPI.Prepare(ctx, "ListWebhookJobs", ¶ms); res != nil { + return res + } + return c.WebhookjobAPI.ListWebhookJobs(ctx, params) + }) + api.WebhookListWebhookPoliciesOfProjectHandler = webhook.ListWebhookPoliciesOfProjectHandlerFunc(func(params webhook.ListWebhookPoliciesOfProjectParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "ListWebhookPoliciesOfProject", ¶ms); res != nil { + return res + } + } + if res := c.WebhookAPI.Prepare(ctx, "ListWebhookPoliciesOfProject", ¶ms); res != nil { + return res + } + return c.WebhookAPI.ListWebhookPoliciesOfProject(ctx, params) + }) + api.PreheatManualPreheatHandler = preheat.ManualPreheatHandlerFunc(func(params preheat.ManualPreheatParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "ManualPreheat", ¶ms); res != nil { + return res + } + } + if res := c.PreheatAPI.Prepare(ctx, "ManualPreheat", ¶ms); res != nil { + return res + } + return c.PreheatAPI.ManualPreheat(ctx, params) + }) + api.PreheatPingInstancesHandler = preheat.PingInstancesHandlerFunc(func(params preheat.PingInstancesParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "PingInstances", ¶ms); res != nil { + return res + } + } + if res := c.PreheatAPI.Prepare(ctx, "PingInstances", ¶ms); res != nil { + return res + } + return c.PreheatAPI.PingInstances(ctx, params) + }) + api.RobotRefreshSecHandler = robot.RefreshSecHandlerFunc(func(params robot.RefreshSecParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "RefreshSec", ¶ms); res != nil { + return res + } + } + if res := c.RobotAPI.Prepare(ctx, "RefreshSec", ¶ms); res != nil { + return res + } + return c.RobotAPI.RefreshSec(ctx, params) + }) + api.PreheatStopExecutionHandler = preheat.StopExecutionHandlerFunc(func(params preheat.StopExecutionParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "StopExecution", ¶ms); res != nil { + return res + } + } + if res := c.PreheatAPI.Prepare(ctx, "StopExecution", ¶ms); res != nil { + return res + } + return c.PreheatAPI.StopExecution(ctx, params) + }) + api.ImmutableUpdateImmuRuleHandler = immutable.UpdateImmuRuleHandlerFunc(func(params immutable.UpdateImmuRuleParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "UpdateImmuRule", ¶ms); res != nil { + return res + } + } + if res := c.ImmutableAPI.Prepare(ctx, "UpdateImmuRule", ¶ms); res != nil { + return res + } + return c.ImmutableAPI.UpdateImmuRule(ctx, params) + }) + api.PreheatUpdateInstanceHandler = preheat.UpdateInstanceHandlerFunc(func(params preheat.UpdateInstanceParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "UpdateInstance", ¶ms); res != nil { + return res + } + } + if res := c.PreheatAPI.Prepare(ctx, "UpdateInstance", ¶ms); res != nil { + return res + } + return c.PreheatAPI.UpdateInstance(ctx, params) + }) + api.LabelUpdateLabelHandler = label.UpdateLabelHandlerFunc(func(params label.UpdateLabelParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "UpdateLabel", ¶ms); res != nil { + return res + } + } + if res := c.LabelAPI.Prepare(ctx, "UpdateLabel", ¶ms); res != nil { + return res + } + return c.LabelAPI.UpdateLabel(ctx, params) + }) + api.PreheatUpdatePolicyHandler = preheat.UpdatePolicyHandlerFunc(func(params preheat.UpdatePolicyParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "UpdatePolicy", ¶ms); res != nil { + return res + } + } + if res := c.PreheatAPI.Prepare(ctx, "UpdatePolicy", ¶ms); res != nil { + return res + } + return c.PreheatAPI.UpdatePolicy(ctx, params) + }) + api.RobotUpdateRobotHandler = robot.UpdateRobotHandlerFunc(func(params robot.UpdateRobotParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "UpdateRobot", ¶ms); res != nil { + return res + } + } + if res := c.RobotAPI.Prepare(ctx, "UpdateRobot", ¶ms); res != nil { + return res + } + return c.RobotAPI.UpdateRobot(ctx, params) + }) + api.Robotv1UpdateRobotV1Handler = robotv1.UpdateRobotV1HandlerFunc(func(params robotv1.UpdateRobotV1Params, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "UpdateRobotV1", ¶ms); res != nil { + return res + } + } + if res := c.Robotv1API.Prepare(ctx, "UpdateRobotV1", ¶ms); res != nil { + return res + } + return c.Robotv1API.UpdateRobotV1(ctx, params) + }) + api.WebhookUpdateWebhookPolicyOfProjectHandler = webhook.UpdateWebhookPolicyOfProjectHandlerFunc(func(params webhook.UpdateWebhookPolicyOfProjectParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "UpdateWebhookPolicyOfProject", ¶ms); res != nil { + return res + } + } + if res := c.WebhookAPI.Prepare(ctx, "UpdateWebhookPolicyOfProject", ¶ms); res != nil { + return res + } + return c.WebhookAPI.UpdateWebhookPolicyOfProject(ctx, params) + }) + api.JobserviceActionPendingJobsHandler = jobservice.ActionPendingJobsHandlerFunc(func(params jobservice.ActionPendingJobsParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "ActionPendingJobs", ¶ms); res != nil { + return res + } + } + if res := c.JobserviceAPI.Prepare(ctx, "ActionPendingJobs", ¶ms); res != nil { + return res + } + return c.JobserviceAPI.ActionPendingJobs(ctx, params) + }) + api.ArtifactAddLabelHandler = artifact.AddLabelHandlerFunc(func(params artifact.AddLabelParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "AddLabel", ¶ms); res != nil { + return res + } + } + if res := c.ArtifactAPI.Prepare(ctx, "AddLabel", ¶ms); res != nil { + return res + } + return c.ArtifactAPI.AddLabel(ctx, params) + }) + api.ProjectMetadataAddProjectMetadatasHandler = project_metadata.AddProjectMetadatasHandlerFunc(func(params project_metadata.AddProjectMetadatasParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "AddProjectMetadatas", ¶ms); res != nil { + return res + } + } + if res := c.ProjectMetadataAPI.Prepare(ctx, "AddProjectMetadatas", ¶ms); res != nil { + return res + } + return c.ProjectMetadataAPI.AddProjectMetadatas(ctx, params) + }) + api.GCCreateGCScheduleHandler = gc.CreateGCScheduleHandlerFunc(func(params gc.CreateGCScheduleParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "CreateGCSchedule", ¶ms); res != nil { + return res + } + } + if res := c.GCAPI.Prepare(ctx, "CreateGCSchedule", ¶ms); res != nil { + return res + } + return c.GCAPI.CreateGCSchedule(ctx, params) + }) + api.ProjectCreateProjectHandler = project.CreateProjectHandlerFunc(func(params project.CreateProjectParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "CreateProject", ¶ms); res != nil { + return res + } + } + if res := c.ProjectAPI.Prepare(ctx, "CreateProject", ¶ms); res != nil { + return res + } + return c.ProjectAPI.CreateProject(ctx, params) + }) + api.MemberCreateProjectMemberHandler = member.CreateProjectMemberHandlerFunc(func(params member.CreateProjectMemberParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "CreateProjectMember", ¶ms); res != nil { + return res + } + } + if res := c.MemberAPI.Prepare(ctx, "CreateProjectMember", ¶ms); res != nil { + return res + } + return c.MemberAPI.CreateProjectMember(ctx, params) + }) + api.PurgeCreatePurgeScheduleHandler = purge.CreatePurgeScheduleHandlerFunc(func(params purge.CreatePurgeScheduleParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "CreatePurgeSchedule", ¶ms); res != nil { + return res + } + } + if res := c.PurgeAPI.Prepare(ctx, "CreatePurgeSchedule", ¶ms); res != nil { + return res + } + return c.PurgeAPI.CreatePurgeSchedule(ctx, params) + }) + api.RegistryCreateRegistryHandler = registry.CreateRegistryHandlerFunc(func(params registry.CreateRegistryParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "CreateRegistry", ¶ms); res != nil { + return res + } + } + if res := c.RegistryAPI.Prepare(ctx, "CreateRegistry", ¶ms); res != nil { + return res + } + return c.RegistryAPI.CreateRegistry(ctx, params) + }) + api.ReplicationCreateReplicationPolicyHandler = replication.CreateReplicationPolicyHandlerFunc(func(params replication.CreateReplicationPolicyParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "CreateReplicationPolicy", ¶ms); res != nil { + return res + } + } + if res := c.ReplicationAPI.Prepare(ctx, "CreateReplicationPolicy", ¶ms); res != nil { + return res + } + return c.ReplicationAPI.CreateReplicationPolicy(ctx, params) + }) + api.RetentionCreateRetentionHandler = retention.CreateRetentionHandlerFunc(func(params retention.CreateRetentionParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "CreateRetention", ¶ms); res != nil { + return res + } + } + if res := c.RetentionAPI.Prepare(ctx, "CreateRetention", ¶ms); res != nil { + return res + } + return c.RetentionAPI.CreateRetention(ctx, params) + }) + api.ScanAllCreateScanAllScheduleHandler = scan_all.CreateScanAllScheduleHandlerFunc(func(params scan_all.CreateScanAllScheduleParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "CreateScanAllSchedule", ¶ms); res != nil { + return res + } + } + if res := c.ScanAllAPI.Prepare(ctx, "CreateScanAllSchedule", ¶ms); res != nil { + return res + } + return c.ScanAllAPI.CreateScanAllSchedule(ctx, params) + }) + api.ScannerCreateScannerHandler = scanner.CreateScannerHandlerFunc(func(params scanner.CreateScannerParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "CreateScanner", ¶ms); res != nil { + return res + } + } + if res := c.ScannerAPI.Prepare(ctx, "CreateScanner", ¶ms); res != nil { + return res + } + return c.ScannerAPI.CreateScanner(ctx, params) + }) + api.ArtifactCreateTagHandler = artifact.CreateTagHandlerFunc(func(params artifact.CreateTagParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "CreateTag", ¶ms); res != nil { + return res + } + } + if res := c.ArtifactAPI.Prepare(ctx, "CreateTag", ¶ms); res != nil { + return res + } + return c.ArtifactAPI.CreateTag(ctx, params) + }) + api.UserCreateUserHandler = user.CreateUserHandlerFunc(func(params user.CreateUserParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "CreateUser", ¶ms); res != nil { + return res + } + } + if res := c.UserAPI.Prepare(ctx, "CreateUser", ¶ms); res != nil { + return res + } + return c.UserAPI.CreateUser(ctx, params) + }) + api.UsergroupCreateUserGroupHandler = usergroup.CreateUserGroupHandlerFunc(func(params usergroup.CreateUserGroupParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "CreateUserGroup", ¶ms); res != nil { + return res + } + } + if res := c.UsergroupAPI.Prepare(ctx, "CreateUserGroup", ¶ms); res != nil { + return res + } + return c.UsergroupAPI.CreateUserGroup(ctx, params) + }) + api.ArtifactDeleteArtifactHandler = artifact.DeleteArtifactHandlerFunc(func(params artifact.DeleteArtifactParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "DeleteArtifact", ¶ms); res != nil { + return res + } + } + if res := c.ArtifactAPI.Prepare(ctx, "DeleteArtifact", ¶ms); res != nil { + return res + } + return c.ArtifactAPI.DeleteArtifact(ctx, params) + }) + api.ProjectDeleteProjectHandler = project.DeleteProjectHandlerFunc(func(params project.DeleteProjectParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "DeleteProject", ¶ms); res != nil { + return res + } + } + if res := c.ProjectAPI.Prepare(ctx, "DeleteProject", ¶ms); res != nil { + return res + } + return c.ProjectAPI.DeleteProject(ctx, params) + }) + api.MemberDeleteProjectMemberHandler = member.DeleteProjectMemberHandlerFunc(func(params member.DeleteProjectMemberParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "DeleteProjectMember", ¶ms); res != nil { + return res + } + } + if res := c.MemberAPI.Prepare(ctx, "DeleteProjectMember", ¶ms); res != nil { + return res + } + return c.MemberAPI.DeleteProjectMember(ctx, params) + }) + api.ProjectMetadataDeleteProjectMetadataHandler = project_metadata.DeleteProjectMetadataHandlerFunc(func(params project_metadata.DeleteProjectMetadataParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "DeleteProjectMetadata", ¶ms); res != nil { + return res + } + } + if res := c.ProjectMetadataAPI.Prepare(ctx, "DeleteProjectMetadata", ¶ms); res != nil { + return res + } + return c.ProjectMetadataAPI.DeleteProjectMetadata(ctx, params) + }) + api.RegistryDeleteRegistryHandler = registry.DeleteRegistryHandlerFunc(func(params registry.DeleteRegistryParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "DeleteRegistry", ¶ms); res != nil { + return res + } + } + if res := c.RegistryAPI.Prepare(ctx, "DeleteRegistry", ¶ms); res != nil { + return res + } + return c.RegistryAPI.DeleteRegistry(ctx, params) + }) + api.ReplicationDeleteReplicationPolicyHandler = replication.DeleteReplicationPolicyHandlerFunc(func(params replication.DeleteReplicationPolicyParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "DeleteReplicationPolicy", ¶ms); res != nil { + return res + } + } + if res := c.ReplicationAPI.Prepare(ctx, "DeleteReplicationPolicy", ¶ms); res != nil { + return res + } + return c.ReplicationAPI.DeleteReplicationPolicy(ctx, params) + }) + api.RepositoryDeleteRepositoryHandler = repository.DeleteRepositoryHandlerFunc(func(params repository.DeleteRepositoryParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "DeleteRepository", ¶ms); res != nil { + return res + } + } + if res := c.RepositoryAPI.Prepare(ctx, "DeleteRepository", ¶ms); res != nil { + return res + } + return c.RepositoryAPI.DeleteRepository(ctx, params) + }) + api.RetentionDeleteRetentionHandler = retention.DeleteRetentionHandlerFunc(func(params retention.DeleteRetentionParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "DeleteRetention", ¶ms); res != nil { + return res + } + } + if res := c.RetentionAPI.Prepare(ctx, "DeleteRetention", ¶ms); res != nil { + return res + } + return c.RetentionAPI.DeleteRetention(ctx, params) + }) + api.ScannerDeleteScannerHandler = scanner.DeleteScannerHandlerFunc(func(params scanner.DeleteScannerParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "DeleteScanner", ¶ms); res != nil { + return res + } + } + if res := c.ScannerAPI.Prepare(ctx, "DeleteScanner", ¶ms); res != nil { + return res + } + return c.ScannerAPI.DeleteScanner(ctx, params) + }) + api.ArtifactDeleteTagHandler = artifact.DeleteTagHandlerFunc(func(params artifact.DeleteTagParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "DeleteTag", ¶ms); res != nil { + return res + } + } + if res := c.ArtifactAPI.Prepare(ctx, "DeleteTag", ¶ms); res != nil { + return res + } + return c.ArtifactAPI.DeleteTag(ctx, params) + }) + api.UserDeleteUserHandler = user.DeleteUserHandlerFunc(func(params user.DeleteUserParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "DeleteUser", ¶ms); res != nil { + return res + } + } + if res := c.UserAPI.Prepare(ctx, "DeleteUser", ¶ms); res != nil { + return res + } + return c.UserAPI.DeleteUser(ctx, params) + }) + api.UsergroupDeleteUserGroupHandler = usergroup.DeleteUserGroupHandlerFunc(func(params usergroup.DeleteUserGroupParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "DeleteUserGroup", ¶ms); res != nil { + return res + } + } + if res := c.UsergroupAPI.Prepare(ctx, "DeleteUserGroup", ¶ms); res != nil { + return res + } + return c.UsergroupAPI.DeleteUserGroup(ctx, params) + }) + api.ScanDataExportDownloadScanDataHandler = scan_data_export.DownloadScanDataHandlerFunc(func(params scan_data_export.DownloadScanDataParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "DownloadScanData", ¶ms); res != nil { + return res + } + } + if res := c.ScanDataExportAPI.Prepare(ctx, "DownloadScanData", ¶ms); res != nil { + return res + } + return c.ScanDataExportAPI.DownloadScanData(ctx, params) + }) + api.ScanDataExportExportScanDataHandler = scan_data_export.ExportScanDataHandlerFunc(func(params scan_data_export.ExportScanDataParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "ExportScanData", ¶ms); res != nil { + return res + } + } + if res := c.ScanDataExportAPI.Prepare(ctx, "ExportScanData", ¶ms); res != nil { + return res + } + return c.ScanDataExportAPI.ExportScanData(ctx, params) + }) + api.ArtifactGetAdditionHandler = artifact.GetAdditionHandlerFunc(func(params artifact.GetAdditionParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetAddition", ¶ms); res != nil { + return res + } + } + if res := c.ArtifactAPI.Prepare(ctx, "GetAddition", ¶ms); res != nil { + return res + } + return c.ArtifactAPI.GetAddition(ctx, params) + }) + api.ArtifactGetArtifactHandler = artifact.GetArtifactHandlerFunc(func(params artifact.GetArtifactParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetArtifact", ¶ms); res != nil { + return res + } + } + if res := c.ArtifactAPI.Prepare(ctx, "GetArtifact", ¶ms); res != nil { + return res + } + return c.ArtifactAPI.GetArtifact(ctx, params) + }) + api.SysteminfoGetCertHandler = systeminfo.GetCertHandlerFunc(func(params systeminfo.GetCertParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetCert", ¶ms); res != nil { + return res + } + } + if res := c.SysteminfoAPI.Prepare(ctx, "GetCert", ¶ms); res != nil { + return res + } + return c.SysteminfoAPI.GetCert(ctx, params) + }) + api.ConfigureGetConfigurationsHandler = configure.GetConfigurationsHandlerFunc(func(params configure.GetConfigurationsParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetConfigurations", ¶ms); res != nil { + return res + } + } + if res := c.ConfigureAPI.Prepare(ctx, "GetConfigurations", ¶ms); res != nil { + return res + } + return c.ConfigureAPI.GetConfigurations(ctx, params) + }) + api.UserGetCurrentUserInfoHandler = user.GetCurrentUserInfoHandlerFunc(func(params user.GetCurrentUserInfoParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetCurrentUserInfo", ¶ms); res != nil { + return res + } + } + if res := c.UserAPI.Prepare(ctx, "GetCurrentUserInfo", ¶ms); res != nil { + return res + } + return c.UserAPI.GetCurrentUserInfo(ctx, params) + }) + api.UserGetCurrentUserPermissionsHandler = user.GetCurrentUserPermissionsHandlerFunc(func(params user.GetCurrentUserPermissionsParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetCurrentUserPermissions", ¶ms); res != nil { + return res + } + } + if res := c.UserAPI.Prepare(ctx, "GetCurrentUserPermissions", ¶ms); res != nil { + return res + } + return c.UserAPI.GetCurrentUserPermissions(ctx, params) + }) + api.GCGetGCHandler = gc.GetGCHandlerFunc(func(params gc.GetGCParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetGC", ¶ms); res != nil { + return res + } + } + if res := c.GCAPI.Prepare(ctx, "GetGC", ¶ms); res != nil { + return res + } + return c.GCAPI.GetGC(ctx, params) + }) + api.GCGetGCHistoryHandler = gc.GetGCHistoryHandlerFunc(func(params gc.GetGCHistoryParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetGCHistory", ¶ms); res != nil { + return res + } + } + if res := c.GCAPI.Prepare(ctx, "GetGCHistory", ¶ms); res != nil { + return res + } + return c.GCAPI.GetGCHistory(ctx, params) + }) + api.GCGetGCLogHandler = gc.GetGCLogHandlerFunc(func(params gc.GetGCLogParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetGCLog", ¶ms); res != nil { + return res + } + } + if res := c.GCAPI.Prepare(ctx, "GetGCLog", ¶ms); res != nil { + return res + } + return c.GCAPI.GetGCLog(ctx, params) + }) + api.GCGetGCScheduleHandler = gc.GetGCScheduleHandlerFunc(func(params gc.GetGCScheduleParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetGCSchedule", ¶ms); res != nil { + return res + } + } + if res := c.GCAPI.Prepare(ctx, "GetGCSchedule", ¶ms); res != nil { + return res + } + return c.GCAPI.GetGCSchedule(ctx, params) + }) + api.HealthGetHealthHandler = health.GetHealthHandlerFunc(func(params health.GetHealthParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetHealth", ¶ms); res != nil { + return res + } + } + if res := c.HealthAPI.Prepare(ctx, "GetHealth", ¶ms); res != nil { + return res + } + return c.HealthAPI.GetHealth(ctx, params) + }) + api.IconGetIconHandler = icon.GetIconHandlerFunc(func(params icon.GetIconParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetIcon", ¶ms); res != nil { + return res + } + } + if res := c.IconAPI.Prepare(ctx, "GetIcon", ¶ms); res != nil { + return res + } + return c.IconAPI.GetIcon(ctx, params) + }) + api.ConfigureGetInternalconfigHandler = configure.GetInternalconfigHandlerFunc(func(params configure.GetInternalconfigParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetInternalconfig", ¶ms); res != nil { + return res + } + } + if res := c.ConfigureAPI.Prepare(ctx, "GetInternalconfig", ¶ms); res != nil { + return res + } + return c.ConfigureAPI.GetInternalconfig(ctx, params) + }) + api.ScanAllGetLatestScanAllMetricsHandler = scan_all.GetLatestScanAllMetricsHandlerFunc(func(params scan_all.GetLatestScanAllMetricsParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetLatestScanAllMetrics", ¶ms); res != nil { + return res + } + } + if res := c.ScanAllAPI.Prepare(ctx, "GetLatestScanAllMetrics", ¶ms); res != nil { + return res + } + return c.ScanAllAPI.GetLatestScanAllMetrics(ctx, params) + }) + api.ScanAllGetLatestScheduledScanAllMetricsHandler = scan_all.GetLatestScheduledScanAllMetricsHandlerFunc(func(params scan_all.GetLatestScheduledScanAllMetricsParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetLatestScheduledScanAllMetrics", ¶ms); res != nil { + return res + } + } + if res := c.ScanAllAPI.Prepare(ctx, "GetLatestScheduledScanAllMetrics", ¶ms); res != nil { + return res + } + return c.ScanAllAPI.GetLatestScheduledScanAllMetrics(ctx, params) + }) + api.ProjectGetLogsHandler = project.GetLogsHandlerFunc(func(params project.GetLogsParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetLogs", ¶ms); res != nil { + return res + } + } + if res := c.ProjectAPI.Prepare(ctx, "GetLogs", ¶ms); res != nil { + return res + } + return c.ProjectAPI.GetLogs(ctx, params) + }) + api.PingGetPingHandler = ping.GetPingHandlerFunc(func(params ping.GetPingParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetPing", ¶ms); res != nil { + return res + } + } + if res := c.PingAPI.Prepare(ctx, "GetPing", ¶ms); res != nil { + return res + } + return c.PingAPI.GetPing(ctx, params) + }) + api.ProjectGetProjectHandler = project.GetProjectHandlerFunc(func(params project.GetProjectParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetProject", ¶ms); res != nil { + return res + } + } + if res := c.ProjectAPI.Prepare(ctx, "GetProject", ¶ms); res != nil { + return res + } + return c.ProjectAPI.GetProject(ctx, params) + }) + api.ProjectGetProjectDeletableHandler = project.GetProjectDeletableHandlerFunc(func(params project.GetProjectDeletableParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetProjectDeletable", ¶ms); res != nil { + return res + } + } + if res := c.ProjectAPI.Prepare(ctx, "GetProjectDeletable", ¶ms); res != nil { + return res + } + return c.ProjectAPI.GetProjectDeletable(ctx, params) + }) + api.MemberGetProjectMemberHandler = member.GetProjectMemberHandlerFunc(func(params member.GetProjectMemberParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetProjectMember", ¶ms); res != nil { + return res + } + } + if res := c.MemberAPI.Prepare(ctx, "GetProjectMember", ¶ms); res != nil { + return res + } + return c.MemberAPI.GetProjectMember(ctx, params) + }) + api.ProjectMetadataGetProjectMetadataHandler = project_metadata.GetProjectMetadataHandlerFunc(func(params project_metadata.GetProjectMetadataParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetProjectMetadata", ¶ms); res != nil { + return res + } + } + if res := c.ProjectMetadataAPI.Prepare(ctx, "GetProjectMetadata", ¶ms); res != nil { + return res + } + return c.ProjectMetadataAPI.GetProjectMetadata(ctx, params) + }) + api.ProjectGetProjectSummaryHandler = project.GetProjectSummaryHandlerFunc(func(params project.GetProjectSummaryParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetProjectSummary", ¶ms); res != nil { + return res + } + } + if res := c.ProjectAPI.Prepare(ctx, "GetProjectSummary", ¶ms); res != nil { + return res + } + return c.ProjectAPI.GetProjectSummary(ctx, params) + }) + api.PurgeGetPurgeHistoryHandler = purge.GetPurgeHistoryHandlerFunc(func(params purge.GetPurgeHistoryParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetPurgeHistory", ¶ms); res != nil { + return res + } + } + if res := c.PurgeAPI.Prepare(ctx, "GetPurgeHistory", ¶ms); res != nil { + return res + } + return c.PurgeAPI.GetPurgeHistory(ctx, params) + }) + api.PurgeGetPurgeJobHandler = purge.GetPurgeJobHandlerFunc(func(params purge.GetPurgeJobParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetPurgeJob", ¶ms); res != nil { + return res + } + } + if res := c.PurgeAPI.Prepare(ctx, "GetPurgeJob", ¶ms); res != nil { + return res + } + return c.PurgeAPI.GetPurgeJob(ctx, params) + }) + api.PurgeGetPurgeJobLogHandler = purge.GetPurgeJobLogHandlerFunc(func(params purge.GetPurgeJobLogParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetPurgeJobLog", ¶ms); res != nil { + return res + } + } + if res := c.PurgeAPI.Prepare(ctx, "GetPurgeJobLog", ¶ms); res != nil { + return res + } + return c.PurgeAPI.GetPurgeJobLog(ctx, params) + }) + api.PurgeGetPurgeScheduleHandler = purge.GetPurgeScheduleHandlerFunc(func(params purge.GetPurgeScheduleParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetPurgeSchedule", ¶ms); res != nil { + return res + } + } + if res := c.PurgeAPI.Prepare(ctx, "GetPurgeSchedule", ¶ms); res != nil { + return res + } + return c.PurgeAPI.GetPurgeSchedule(ctx, params) + }) + api.QuotaGetQuotaHandler = quota.GetQuotaHandlerFunc(func(params quota.GetQuotaParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetQuota", ¶ms); res != nil { + return res + } + } + if res := c.QuotaAPI.Prepare(ctx, "GetQuota", ¶ms); res != nil { + return res + } + return c.QuotaAPI.GetQuota(ctx, params) + }) + api.RegistryGetRegistryHandler = registry.GetRegistryHandlerFunc(func(params registry.GetRegistryParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetRegistry", ¶ms); res != nil { + return res + } + } + if res := c.RegistryAPI.Prepare(ctx, "GetRegistry", ¶ms); res != nil { + return res + } + return c.RegistryAPI.GetRegistry(ctx, params) + }) + api.RegistryGetRegistryInfoHandler = registry.GetRegistryInfoHandlerFunc(func(params registry.GetRegistryInfoParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetRegistryInfo", ¶ms); res != nil { + return res + } + } + if res := c.RegistryAPI.Prepare(ctx, "GetRegistryInfo", ¶ms); res != nil { + return res + } + return c.RegistryAPI.GetRegistryInfo(ctx, params) + }) + api.RetentionGetRentenitionMetadataHandler = retention.GetRentenitionMetadataHandlerFunc(func(params retention.GetRentenitionMetadataParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetRentenitionMetadata", ¶ms); res != nil { + return res + } + } + if res := c.RetentionAPI.Prepare(ctx, "GetRentenitionMetadata", ¶ms); res != nil { + return res + } + return c.RetentionAPI.GetRentenitionMetadata(ctx, params) + }) + api.ReplicationGetReplicationExecutionHandler = replication.GetReplicationExecutionHandlerFunc(func(params replication.GetReplicationExecutionParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetReplicationExecution", ¶ms); res != nil { + return res + } + } + if res := c.ReplicationAPI.Prepare(ctx, "GetReplicationExecution", ¶ms); res != nil { + return res + } + return c.ReplicationAPI.GetReplicationExecution(ctx, params) + }) + api.ReplicationGetReplicationLogHandler = replication.GetReplicationLogHandlerFunc(func(params replication.GetReplicationLogParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetReplicationLog", ¶ms); res != nil { + return res + } + } + if res := c.ReplicationAPI.Prepare(ctx, "GetReplicationLog", ¶ms); res != nil { + return res + } + return c.ReplicationAPI.GetReplicationLog(ctx, params) + }) + api.ReplicationGetReplicationPolicyHandler = replication.GetReplicationPolicyHandlerFunc(func(params replication.GetReplicationPolicyParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetReplicationPolicy", ¶ms); res != nil { + return res + } + } + if res := c.ReplicationAPI.Prepare(ctx, "GetReplicationPolicy", ¶ms); res != nil { + return res + } + return c.ReplicationAPI.GetReplicationPolicy(ctx, params) + }) + api.ScanGetReportLogHandler = scan.GetReportLogHandlerFunc(func(params scan.GetReportLogParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetReportLog", ¶ms); res != nil { + return res + } + } + if res := c.ScanAPI.Prepare(ctx, "GetReportLog", ¶ms); res != nil { + return res + } + return c.ScanAPI.GetReportLog(ctx, params) + }) + api.RepositoryGetRepositoryHandler = repository.GetRepositoryHandlerFunc(func(params repository.GetRepositoryParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetRepository", ¶ms); res != nil { + return res + } + } + if res := c.RepositoryAPI.Prepare(ctx, "GetRepository", ¶ms); res != nil { + return res + } + return c.RepositoryAPI.GetRepository(ctx, params) + }) + api.RetentionGetRetentionHandler = retention.GetRetentionHandlerFunc(func(params retention.GetRetentionParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetRetention", ¶ms); res != nil { + return res + } + } + if res := c.RetentionAPI.Prepare(ctx, "GetRetention", ¶ms); res != nil { + return res + } + return c.RetentionAPI.GetRetention(ctx, params) + }) + api.RetentionGetRetentionTaskLogHandler = retention.GetRetentionTaskLogHandlerFunc(func(params retention.GetRetentionTaskLogParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetRetentionTaskLog", ¶ms); res != nil { + return res + } + } + if res := c.RetentionAPI.Prepare(ctx, "GetRetentionTaskLog", ¶ms); res != nil { + return res + } + return c.RetentionAPI.GetRetentionTaskLog(ctx, params) + }) + api.ScanAllGetScanAllScheduleHandler = scan_all.GetScanAllScheduleHandlerFunc(func(params scan_all.GetScanAllScheduleParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetScanAllSchedule", ¶ms); res != nil { + return res + } + } + if res := c.ScanAllAPI.Prepare(ctx, "GetScanAllSchedule", ¶ms); res != nil { + return res + } + return c.ScanAllAPI.GetScanAllSchedule(ctx, params) + }) + api.ScanDataExportGetScanDataExportExecutionHandler = scan_data_export.GetScanDataExportExecutionHandlerFunc(func(params scan_data_export.GetScanDataExportExecutionParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetScanDataExportExecution", ¶ms); res != nil { + return res + } + } + if res := c.ScanDataExportAPI.Prepare(ctx, "GetScanDataExportExecution", ¶ms); res != nil { + return res + } + return c.ScanDataExportAPI.GetScanDataExportExecution(ctx, params) + }) + api.ScanDataExportGetScanDataExportExecutionListHandler = scan_data_export.GetScanDataExportExecutionListHandlerFunc(func(params scan_data_export.GetScanDataExportExecutionListParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetScanDataExportExecutionList", ¶ms); res != nil { + return res + } + } + if res := c.ScanDataExportAPI.Prepare(ctx, "GetScanDataExportExecutionList", ¶ms); res != nil { + return res + } + return c.ScanDataExportAPI.GetScanDataExportExecutionList(ctx, params) + }) + api.ScannerGetScannerHandler = scanner.GetScannerHandlerFunc(func(params scanner.GetScannerParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetScanner", ¶ms); res != nil { + return res + } + } + if res := c.ScannerAPI.Prepare(ctx, "GetScanner", ¶ms); res != nil { + return res + } + return c.ScannerAPI.GetScanner(ctx, params) + }) + api.ScannerGetScannerMetadataHandler = scanner.GetScannerMetadataHandlerFunc(func(params scanner.GetScannerMetadataParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetScannerMetadata", ¶ms); res != nil { + return res + } + } + if res := c.ScannerAPI.Prepare(ctx, "GetScannerMetadata", ¶ms); res != nil { + return res + } + return c.ScannerAPI.GetScannerMetadata(ctx, params) + }) + api.ProjectGetScannerOfProjectHandler = project.GetScannerOfProjectHandlerFunc(func(params project.GetScannerOfProjectParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetScannerOfProject", ¶ms); res != nil { + return res + } + } + if res := c.ProjectAPI.Prepare(ctx, "GetScannerOfProject", ¶ms); res != nil { + return res + } + return c.ProjectAPI.GetScannerOfProject(ctx, params) + }) + api.ScheduleGetSchedulePausedHandler = schedule.GetSchedulePausedHandlerFunc(func(params schedule.GetSchedulePausedParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetSchedulePaused", ¶ms); res != nil { + return res + } + } + if res := c.ScheduleAPI.Prepare(ctx, "GetSchedulePaused", ¶ms); res != nil { + return res + } + return c.ScheduleAPI.GetSchedulePaused(ctx, params) + }) + api.StatisticGetStatisticHandler = statistic.GetStatisticHandlerFunc(func(params statistic.GetStatisticParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetStatistic", ¶ms); res != nil { + return res + } + } + if res := c.StatisticAPI.Prepare(ctx, "GetStatistic", ¶ms); res != nil { + return res + } + return c.StatisticAPI.GetStatistic(ctx, params) + }) + api.SystemCVEAllowlistGetSystemCVEAllowlistHandler = system_cve_allowlist.GetSystemCVEAllowlistHandlerFunc(func(params system_cve_allowlist.GetSystemCVEAllowlistParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetSystemCVEAllowlist", ¶ms); res != nil { + return res + } + } + if res := c.SystemCVEAllowlistAPI.Prepare(ctx, "GetSystemCVEAllowlist", ¶ms); res != nil { + return res + } + return c.SystemCVEAllowlistAPI.GetSystemCVEAllowlist(ctx, params) + }) + api.SysteminfoGetSystemInfoHandler = systeminfo.GetSystemInfoHandlerFunc(func(params systeminfo.GetSystemInfoParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetSystemInfo", ¶ms); res != nil { + return res + } + } + if res := c.SysteminfoAPI.Prepare(ctx, "GetSystemInfo", ¶ms); res != nil { + return res + } + return c.SysteminfoAPI.GetSystemInfo(ctx, params) + }) + api.UserGetUserHandler = user.GetUserHandlerFunc(func(params user.GetUserParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetUser", ¶ms); res != nil { + return res + } + } + if res := c.UserAPI.Prepare(ctx, "GetUser", ¶ms); res != nil { + return res + } + return c.UserAPI.GetUser(ctx, params) + }) + api.UsergroupGetUserGroupHandler = usergroup.GetUserGroupHandlerFunc(func(params usergroup.GetUserGroupParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetUserGroup", ¶ms); res != nil { + return res + } + } + if res := c.UsergroupAPI.Prepare(ctx, "GetUserGroup", ¶ms); res != nil { + return res + } + return c.UsergroupAPI.GetUserGroup(ctx, params) + }) + api.SysteminfoGetVolumesHandler = systeminfo.GetVolumesHandlerFunc(func(params systeminfo.GetVolumesParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetVolumes", ¶ms); res != nil { + return res + } + } + if res := c.SysteminfoAPI.Prepare(ctx, "GetVolumes", ¶ms); res != nil { + return res + } + return c.SysteminfoAPI.GetVolumes(ctx, params) + }) + api.ArtifactGetVulnerabilitiesAdditionHandler = artifact.GetVulnerabilitiesAdditionHandlerFunc(func(params artifact.GetVulnerabilitiesAdditionParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetVulnerabilitiesAddition", ¶ms); res != nil { + return res + } + } + if res := c.ArtifactAPI.Prepare(ctx, "GetVulnerabilitiesAddition", ¶ms); res != nil { + return res + } + return c.ArtifactAPI.GetVulnerabilitiesAddition(ctx, params) + }) + api.JobserviceGetWorkerPoolsHandler = jobservice.GetWorkerPoolsHandlerFunc(func(params jobservice.GetWorkerPoolsParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetWorkerPools", ¶ms); res != nil { + return res + } + } + if res := c.JobserviceAPI.Prepare(ctx, "GetWorkerPools", ¶ms); res != nil { + return res + } + return c.JobserviceAPI.GetWorkerPools(ctx, params) + }) + api.JobserviceGetWorkersHandler = jobservice.GetWorkersHandlerFunc(func(params jobservice.GetWorkersParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "GetWorkers", ¶ms); res != nil { + return res + } + } + if res := c.JobserviceAPI.Prepare(ctx, "GetWorkers", ¶ms); res != nil { + return res + } + return c.JobserviceAPI.GetWorkers(ctx, params) + }) + api.ProjectHeadProjectHandler = project.HeadProjectHandlerFunc(func(params project.HeadProjectParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "HeadProject", ¶ms); res != nil { + return res + } + } + if res := c.ProjectAPI.Prepare(ctx, "HeadProject", ¶ms); res != nil { + return res + } + return c.ProjectAPI.HeadProject(ctx, params) + }) + api.LdapImportLdapUserHandler = ldap.ImportLdapUserHandlerFunc(func(params ldap.ImportLdapUserParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "ImportLdapUser", ¶ms); res != nil { + return res + } + } + if res := c.LdapAPI.Prepare(ctx, "ImportLdapUser", ¶ms); res != nil { + return res + } + return c.LdapAPI.ImportLdapUser(ctx, params) + }) + api.ArtifactListAccessoriesHandler = artifact.ListAccessoriesHandlerFunc(func(params artifact.ListAccessoriesParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "ListAccessories", ¶ms); res != nil { + return res + } + } + if res := c.ArtifactAPI.Prepare(ctx, "ListAccessories", ¶ms); res != nil { + return res + } + return c.ArtifactAPI.ListAccessories(ctx, params) + }) + api.RepositoryListAllRepositoriesHandler = repository.ListAllRepositoriesHandlerFunc(func(params repository.ListAllRepositoriesParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "ListAllRepositories", ¶ms); res != nil { + return res + } + } + if res := c.RepositoryAPI.Prepare(ctx, "ListAllRepositories", ¶ms); res != nil { + return res + } + return c.RepositoryAPI.ListAllRepositories(ctx, params) + }) + api.ArtifactListArtifactsHandler = artifact.ListArtifactsHandlerFunc(func(params artifact.ListArtifactsParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "ListArtifacts", ¶ms); res != nil { + return res + } + } + if res := c.ArtifactAPI.Prepare(ctx, "ListArtifacts", ¶ms); res != nil { + return res + } + return c.ArtifactAPI.ListArtifacts(ctx, params) + }) + api.AuditlogListAuditLogsHandler = auditlog.ListAuditLogsHandlerFunc(func(params auditlog.ListAuditLogsParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "ListAuditLogs", ¶ms); res != nil { + return res + } + } + if res := c.AuditlogAPI.Prepare(ctx, "ListAuditLogs", ¶ms); res != nil { + return res + } + return c.AuditlogAPI.ListAuditLogs(ctx, params) + }) + api.JobserviceListJobQueuesHandler = jobservice.ListJobQueuesHandlerFunc(func(params jobservice.ListJobQueuesParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "ListJobQueues", ¶ms); res != nil { + return res + } + } + if res := c.JobserviceAPI.Prepare(ctx, "ListJobQueues", ¶ms); res != nil { + return res + } + return c.JobserviceAPI.ListJobQueues(ctx, params) + }) + api.MemberListProjectMembersHandler = member.ListProjectMembersHandlerFunc(func(params member.ListProjectMembersParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "ListProjectMembers", ¶ms); res != nil { + return res + } + } + if res := c.MemberAPI.Prepare(ctx, "ListProjectMembers", ¶ms); res != nil { + return res + } + return c.MemberAPI.ListProjectMembers(ctx, params) + }) + api.ProjectMetadataListProjectMetadatasHandler = project_metadata.ListProjectMetadatasHandlerFunc(func(params project_metadata.ListProjectMetadatasParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "ListProjectMetadatas", ¶ms); res != nil { + return res + } + } + if res := c.ProjectMetadataAPI.Prepare(ctx, "ListProjectMetadatas", ¶ms); res != nil { + return res + } + return c.ProjectMetadataAPI.ListProjectMetadatas(ctx, params) + }) + api.ProjectListProjectsHandler = project.ListProjectsHandlerFunc(func(params project.ListProjectsParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "ListProjects", ¶ms); res != nil { + return res + } + } + if res := c.ProjectAPI.Prepare(ctx, "ListProjects", ¶ms); res != nil { + return res + } + return c.ProjectAPI.ListProjects(ctx, params) + }) + api.QuotaListQuotasHandler = quota.ListQuotasHandlerFunc(func(params quota.ListQuotasParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "ListQuotas", ¶ms); res != nil { + return res + } + } + if res := c.QuotaAPI.Prepare(ctx, "ListQuotas", ¶ms); res != nil { + return res + } + return c.QuotaAPI.ListQuotas(ctx, params) + }) + api.RegistryListRegistriesHandler = registry.ListRegistriesHandlerFunc(func(params registry.ListRegistriesParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "ListRegistries", ¶ms); res != nil { + return res + } + } + if res := c.RegistryAPI.Prepare(ctx, "ListRegistries", ¶ms); res != nil { + return res + } + return c.RegistryAPI.ListRegistries(ctx, params) + }) + api.RegistryListRegistryProviderInfosHandler = registry.ListRegistryProviderInfosHandlerFunc(func(params registry.ListRegistryProviderInfosParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "ListRegistryProviderInfos", ¶ms); res != nil { + return res + } + } + if res := c.RegistryAPI.Prepare(ctx, "ListRegistryProviderInfos", ¶ms); res != nil { + return res + } + return c.RegistryAPI.ListRegistryProviderInfos(ctx, params) + }) + api.RegistryListRegistryProviderTypesHandler = registry.ListRegistryProviderTypesHandlerFunc(func(params registry.ListRegistryProviderTypesParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "ListRegistryProviderTypes", ¶ms); res != nil { + return res + } + } + if res := c.RegistryAPI.Prepare(ctx, "ListRegistryProviderTypes", ¶ms); res != nil { + return res + } + return c.RegistryAPI.ListRegistryProviderTypes(ctx, params) + }) + api.ReplicationListReplicationExecutionsHandler = replication.ListReplicationExecutionsHandlerFunc(func(params replication.ListReplicationExecutionsParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "ListReplicationExecutions", ¶ms); res != nil { + return res + } + } + if res := c.ReplicationAPI.Prepare(ctx, "ListReplicationExecutions", ¶ms); res != nil { + return res + } + return c.ReplicationAPI.ListReplicationExecutions(ctx, params) + }) + api.ReplicationListReplicationPoliciesHandler = replication.ListReplicationPoliciesHandlerFunc(func(params replication.ListReplicationPoliciesParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "ListReplicationPolicies", ¶ms); res != nil { + return res + } + } + if res := c.ReplicationAPI.Prepare(ctx, "ListReplicationPolicies", ¶ms); res != nil { + return res + } + return c.ReplicationAPI.ListReplicationPolicies(ctx, params) + }) + api.ReplicationListReplicationTasksHandler = replication.ListReplicationTasksHandlerFunc(func(params replication.ListReplicationTasksParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "ListReplicationTasks", ¶ms); res != nil { + return res + } + } + if res := c.ReplicationAPI.Prepare(ctx, "ListReplicationTasks", ¶ms); res != nil { + return res + } + return c.ReplicationAPI.ListReplicationTasks(ctx, params) + }) + api.RepositoryListRepositoriesHandler = repository.ListRepositoriesHandlerFunc(func(params repository.ListRepositoriesParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "ListRepositories", ¶ms); res != nil { + return res + } + } + if res := c.RepositoryAPI.Prepare(ctx, "ListRepositories", ¶ms); res != nil { + return res + } + return c.RepositoryAPI.ListRepositories(ctx, params) + }) + api.RetentionListRetentionExecutionsHandler = retention.ListRetentionExecutionsHandlerFunc(func(params retention.ListRetentionExecutionsParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "ListRetentionExecutions", ¶ms); res != nil { + return res + } + } + if res := c.RetentionAPI.Prepare(ctx, "ListRetentionExecutions", ¶ms); res != nil { + return res + } + return c.RetentionAPI.ListRetentionExecutions(ctx, params) + }) + api.RetentionListRetentionTasksHandler = retention.ListRetentionTasksHandlerFunc(func(params retention.ListRetentionTasksParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "ListRetentionTasks", ¶ms); res != nil { + return res + } + } + if res := c.RetentionAPI.Prepare(ctx, "ListRetentionTasks", ¶ms); res != nil { + return res + } + return c.RetentionAPI.ListRetentionTasks(ctx, params) + }) + api.ProjectListScannerCandidatesOfProjectHandler = project.ListScannerCandidatesOfProjectHandlerFunc(func(params project.ListScannerCandidatesOfProjectParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "ListScannerCandidatesOfProject", ¶ms); res != nil { + return res + } + } + if res := c.ProjectAPI.Prepare(ctx, "ListScannerCandidatesOfProject", ¶ms); res != nil { + return res + } + return c.ProjectAPI.ListScannerCandidatesOfProject(ctx, params) + }) + api.ScannerListScannersHandler = scanner.ListScannersHandlerFunc(func(params scanner.ListScannersParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "ListScanners", ¶ms); res != nil { + return res + } + } + if res := c.ScannerAPI.Prepare(ctx, "ListScanners", ¶ms); res != nil { + return res + } + return c.ScannerAPI.ListScanners(ctx, params) + }) + api.ScheduleListSchedulesHandler = schedule.ListSchedulesHandlerFunc(func(params schedule.ListSchedulesParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "ListSchedules", ¶ms); res != nil { + return res + } + } + if res := c.ScheduleAPI.Prepare(ctx, "ListSchedules", ¶ms); res != nil { + return res + } + return c.ScheduleAPI.ListSchedules(ctx, params) + }) + api.ArtifactListTagsHandler = artifact.ListTagsHandlerFunc(func(params artifact.ListTagsParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "ListTags", ¶ms); res != nil { + return res + } + } + if res := c.ArtifactAPI.Prepare(ctx, "ListTags", ¶ms); res != nil { + return res + } + return c.ArtifactAPI.ListTags(ctx, params) + }) + api.UsergroupListUserGroupsHandler = usergroup.ListUserGroupsHandlerFunc(func(params usergroup.ListUserGroupsParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "ListUserGroups", ¶ms); res != nil { + return res + } + } + if res := c.UsergroupAPI.Prepare(ctx, "ListUserGroups", ¶ms); res != nil { + return res + } + return c.UsergroupAPI.ListUserGroups(ctx, params) + }) + api.UserListUsersHandler = user.ListUsersHandlerFunc(func(params user.ListUsersParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "ListUsers", ¶ms); res != nil { + return res + } + } + if res := c.UserAPI.Prepare(ctx, "ListUsers", ¶ms); res != nil { + return res + } + return c.UserAPI.ListUsers(ctx, params) + }) + api.RetentionOperateRetentionExecutionHandler = retention.OperateRetentionExecutionHandlerFunc(func(params retention.OperateRetentionExecutionParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "OperateRetentionExecution", ¶ms); res != nil { + return res + } + } + if res := c.RetentionAPI.Prepare(ctx, "OperateRetentionExecution", ¶ms); res != nil { + return res + } + return c.RetentionAPI.OperateRetentionExecution(ctx, params) + }) + api.LdapPingLdapHandler = ldap.PingLdapHandlerFunc(func(params ldap.PingLdapParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "PingLdap", ¶ms); res != nil { + return res + } + } + if res := c.LdapAPI.Prepare(ctx, "PingLdap", ¶ms); res != nil { + return res + } + return c.LdapAPI.PingLdap(ctx, params) + }) + api.OIDCPingOIDCHandler = oidc.PingOIDCHandlerFunc(func(params oidc.PingOIDCParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "PingOIDC", ¶ms); res != nil { + return res + } + } + if res := c.OIDCAPI.Prepare(ctx, "PingOIDC", ¶ms); res != nil { + return res + } + return c.OIDCAPI.PingOIDC(ctx, params) + }) + api.RegistryPingRegistryHandler = registry.PingRegistryHandlerFunc(func(params registry.PingRegistryParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "PingRegistry", ¶ms); res != nil { + return res + } + } + if res := c.RegistryAPI.Prepare(ctx, "PingRegistry", ¶ms); res != nil { + return res + } + return c.RegistryAPI.PingRegistry(ctx, params) + }) + api.ScannerPingScannerHandler = scanner.PingScannerHandlerFunc(func(params scanner.PingScannerParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "PingScanner", ¶ms); res != nil { + return res + } + } + if res := c.ScannerAPI.Prepare(ctx, "PingScanner", ¶ms); res != nil { + return res + } + return c.ScannerAPI.PingScanner(ctx, params) + }) + api.SystemCVEAllowlistPutSystemCVEAllowlistHandler = system_cve_allowlist.PutSystemCVEAllowlistHandlerFunc(func(params system_cve_allowlist.PutSystemCVEAllowlistParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "PutSystemCVEAllowlist", ¶ms); res != nil { + return res + } + } + if res := c.SystemCVEAllowlistAPI.Prepare(ctx, "PutSystemCVEAllowlist", ¶ms); res != nil { + return res + } + return c.SystemCVEAllowlistAPI.PutSystemCVEAllowlist(ctx, params) + }) + api.ArtifactRemoveLabelHandler = artifact.RemoveLabelHandlerFunc(func(params artifact.RemoveLabelParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "RemoveLabel", ¶ms); res != nil { + return res + } + } + if res := c.ArtifactAPI.Prepare(ctx, "RemoveLabel", ¶ms); res != nil { + return res + } + return c.ArtifactAPI.RemoveLabel(ctx, params) + }) + api.ScanScanArtifactHandler = scan.ScanArtifactHandlerFunc(func(params scan.ScanArtifactParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "ScanArtifact", ¶ms); res != nil { + return res + } + } + if res := c.ScanAPI.Prepare(ctx, "ScanArtifact", ¶ms); res != nil { + return res + } + return c.ScanAPI.ScanArtifact(ctx, params) + }) + api.SearchSearchHandler = search.SearchHandlerFunc(func(params search.SearchParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "Search", ¶ms); res != nil { + return res + } + } + if res := c.SearchAPI.Prepare(ctx, "Search", ¶ms); res != nil { + return res + } + return c.SearchAPI.Search(ctx, params) + }) + api.LdapSearchLdapGroupHandler = ldap.SearchLdapGroupHandlerFunc(func(params ldap.SearchLdapGroupParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "SearchLdapGroup", ¶ms); res != nil { + return res + } + } + if res := c.LdapAPI.Prepare(ctx, "SearchLdapGroup", ¶ms); res != nil { + return res + } + return c.LdapAPI.SearchLdapGroup(ctx, params) + }) + api.LdapSearchLdapUserHandler = ldap.SearchLdapUserHandlerFunc(func(params ldap.SearchLdapUserParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "SearchLdapUser", ¶ms); res != nil { + return res + } + } + if res := c.LdapAPI.Prepare(ctx, "SearchLdapUser", ¶ms); res != nil { + return res + } + return c.LdapAPI.SearchLdapUser(ctx, params) + }) + api.UsergroupSearchUserGroupsHandler = usergroup.SearchUserGroupsHandlerFunc(func(params usergroup.SearchUserGroupsParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "SearchUserGroups", ¶ms); res != nil { + return res + } + } + if res := c.UsergroupAPI.Prepare(ctx, "SearchUserGroups", ¶ms); res != nil { + return res + } + return c.UsergroupAPI.SearchUserGroups(ctx, params) + }) + api.UserSearchUsersHandler = user.SearchUsersHandlerFunc(func(params user.SearchUsersParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "SearchUsers", ¶ms); res != nil { + return res + } + } + if res := c.UserAPI.Prepare(ctx, "SearchUsers", ¶ms); res != nil { + return res + } + return c.UserAPI.SearchUsers(ctx, params) + }) + api.UserSetCliSecretHandler = user.SetCliSecretHandlerFunc(func(params user.SetCliSecretParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "SetCliSecret", ¶ms); res != nil { + return res + } + } + if res := c.UserAPI.Prepare(ctx, "SetCliSecret", ¶ms); res != nil { + return res + } + return c.UserAPI.SetCliSecret(ctx, params) + }) + api.ScannerSetScannerAsDefaultHandler = scanner.SetScannerAsDefaultHandlerFunc(func(params scanner.SetScannerAsDefaultParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "SetScannerAsDefault", ¶ms); res != nil { + return res + } + } + if res := c.ScannerAPI.Prepare(ctx, "SetScannerAsDefault", ¶ms); res != nil { + return res + } + return c.ScannerAPI.SetScannerAsDefault(ctx, params) + }) + api.ProjectSetScannerOfProjectHandler = project.SetScannerOfProjectHandlerFunc(func(params project.SetScannerOfProjectParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "SetScannerOfProject", ¶ms); res != nil { + return res + } + } + if res := c.ProjectAPI.Prepare(ctx, "SetScannerOfProject", ¶ms); res != nil { + return res + } + return c.ProjectAPI.SetScannerOfProject(ctx, params) + }) + api.UserSetUserSysAdminHandler = user.SetUserSysAdminHandlerFunc(func(params user.SetUserSysAdminParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "SetUserSysAdmin", ¶ms); res != nil { + return res + } + } + if res := c.UserAPI.Prepare(ctx, "SetUserSysAdmin", ¶ms); res != nil { + return res + } + return c.UserAPI.SetUserSysAdmin(ctx, params) + }) + api.ReplicationStartReplicationHandler = replication.StartReplicationHandlerFunc(func(params replication.StartReplicationParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "StartReplication", ¶ms); res != nil { + return res + } + } + if res := c.ReplicationAPI.Prepare(ctx, "StartReplication", ¶ms); res != nil { + return res + } + return c.ReplicationAPI.StartReplication(ctx, params) + }) + api.GCStopGCHandler = gc.StopGCHandlerFunc(func(params gc.StopGCParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "StopGC", ¶ms); res != nil { + return res + } + } + if res := c.GCAPI.Prepare(ctx, "StopGC", ¶ms); res != nil { + return res + } + return c.GCAPI.StopGC(ctx, params) + }) + api.PurgeStopPurgeHandler = purge.StopPurgeHandlerFunc(func(params purge.StopPurgeParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "StopPurge", ¶ms); res != nil { + return res + } + } + if res := c.PurgeAPI.Prepare(ctx, "StopPurge", ¶ms); res != nil { + return res + } + return c.PurgeAPI.StopPurge(ctx, params) + }) + api.ReplicationStopReplicationHandler = replication.StopReplicationHandlerFunc(func(params replication.StopReplicationParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "StopReplication", ¶ms); res != nil { + return res + } + } + if res := c.ReplicationAPI.Prepare(ctx, "StopReplication", ¶ms); res != nil { + return res + } + return c.ReplicationAPI.StopReplication(ctx, params) + }) + api.JobserviceStopRunningJobHandler = jobservice.StopRunningJobHandlerFunc(func(params jobservice.StopRunningJobParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "StopRunningJob", ¶ms); res != nil { + return res + } + } + if res := c.JobserviceAPI.Prepare(ctx, "StopRunningJob", ¶ms); res != nil { + return res + } + return c.JobserviceAPI.StopRunningJob(ctx, params) + }) + api.ScanAllStopScanAllHandler = scan_all.StopScanAllHandlerFunc(func(params scan_all.StopScanAllParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "StopScanAll", ¶ms); res != nil { + return res + } + } + if res := c.ScanAllAPI.Prepare(ctx, "StopScanAll", ¶ms); res != nil { + return res + } + return c.ScanAllAPI.StopScanAll(ctx, params) + }) + api.ScanStopScanArtifactHandler = scan.StopScanArtifactHandlerFunc(func(params scan.StopScanArtifactParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "StopScanArtifact", ¶ms); res != nil { + return res + } + } + if res := c.ScanAPI.Prepare(ctx, "StopScanArtifact", ¶ms); res != nil { + return res + } + return c.ScanAPI.StopScanArtifact(ctx, params) + }) + api.RetentionTriggerRetentionExecutionHandler = retention.TriggerRetentionExecutionHandlerFunc(func(params retention.TriggerRetentionExecutionParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "TriggerRetentionExecution", ¶ms); res != nil { + return res + } + } + if res := c.RetentionAPI.Prepare(ctx, "TriggerRetentionExecution", ¶ms); res != nil { + return res + } + return c.RetentionAPI.TriggerRetentionExecution(ctx, params) + }) + api.ConfigureUpdateConfigurationsHandler = configure.UpdateConfigurationsHandlerFunc(func(params configure.UpdateConfigurationsParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "UpdateConfigurations", ¶ms); res != nil { + return res + } + } + if res := c.ConfigureAPI.Prepare(ctx, "UpdateConfigurations", ¶ms); res != nil { + return res + } + return c.ConfigureAPI.UpdateConfigurations(ctx, params) + }) + api.GCUpdateGCScheduleHandler = gc.UpdateGCScheduleHandlerFunc(func(params gc.UpdateGCScheduleParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "UpdateGCSchedule", ¶ms); res != nil { + return res + } + } + if res := c.GCAPI.Prepare(ctx, "UpdateGCSchedule", ¶ms); res != nil { + return res + } + return c.GCAPI.UpdateGCSchedule(ctx, params) + }) + api.ProjectUpdateProjectHandler = project.UpdateProjectHandlerFunc(func(params project.UpdateProjectParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "UpdateProject", ¶ms); res != nil { + return res + } + } + if res := c.ProjectAPI.Prepare(ctx, "UpdateProject", ¶ms); res != nil { + return res + } + return c.ProjectAPI.UpdateProject(ctx, params) + }) + api.MemberUpdateProjectMemberHandler = member.UpdateProjectMemberHandlerFunc(func(params member.UpdateProjectMemberParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "UpdateProjectMember", ¶ms); res != nil { + return res + } + } + if res := c.MemberAPI.Prepare(ctx, "UpdateProjectMember", ¶ms); res != nil { + return res + } + return c.MemberAPI.UpdateProjectMember(ctx, params) + }) + api.ProjectMetadataUpdateProjectMetadataHandler = project_metadata.UpdateProjectMetadataHandlerFunc(func(params project_metadata.UpdateProjectMetadataParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "UpdateProjectMetadata", ¶ms); res != nil { + return res + } + } + if res := c.ProjectMetadataAPI.Prepare(ctx, "UpdateProjectMetadata", ¶ms); res != nil { + return res + } + return c.ProjectMetadataAPI.UpdateProjectMetadata(ctx, params) + }) + api.PurgeUpdatePurgeScheduleHandler = purge.UpdatePurgeScheduleHandlerFunc(func(params purge.UpdatePurgeScheduleParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "UpdatePurgeSchedule", ¶ms); res != nil { + return res + } + } + if res := c.PurgeAPI.Prepare(ctx, "UpdatePurgeSchedule", ¶ms); res != nil { + return res + } + return c.PurgeAPI.UpdatePurgeSchedule(ctx, params) + }) + api.QuotaUpdateQuotaHandler = quota.UpdateQuotaHandlerFunc(func(params quota.UpdateQuotaParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "UpdateQuota", ¶ms); res != nil { + return res + } + } + if res := c.QuotaAPI.Prepare(ctx, "UpdateQuota", ¶ms); res != nil { + return res + } + return c.QuotaAPI.UpdateQuota(ctx, params) + }) + api.RegistryUpdateRegistryHandler = registry.UpdateRegistryHandlerFunc(func(params registry.UpdateRegistryParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "UpdateRegistry", ¶ms); res != nil { + return res + } + } + if res := c.RegistryAPI.Prepare(ctx, "UpdateRegistry", ¶ms); res != nil { + return res + } + return c.RegistryAPI.UpdateRegistry(ctx, params) + }) + api.ReplicationUpdateReplicationPolicyHandler = replication.UpdateReplicationPolicyHandlerFunc(func(params replication.UpdateReplicationPolicyParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "UpdateReplicationPolicy", ¶ms); res != nil { + return res + } + } + if res := c.ReplicationAPI.Prepare(ctx, "UpdateReplicationPolicy", ¶ms); res != nil { + return res + } + return c.ReplicationAPI.UpdateReplicationPolicy(ctx, params) + }) + api.RepositoryUpdateRepositoryHandler = repository.UpdateRepositoryHandlerFunc(func(params repository.UpdateRepositoryParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "UpdateRepository", ¶ms); res != nil { + return res + } + } + if res := c.RepositoryAPI.Prepare(ctx, "UpdateRepository", ¶ms); res != nil { + return res + } + return c.RepositoryAPI.UpdateRepository(ctx, params) + }) + api.RetentionUpdateRetentionHandler = retention.UpdateRetentionHandlerFunc(func(params retention.UpdateRetentionParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "UpdateRetention", ¶ms); res != nil { + return res + } + } + if res := c.RetentionAPI.Prepare(ctx, "UpdateRetention", ¶ms); res != nil { + return res + } + return c.RetentionAPI.UpdateRetention(ctx, params) + }) + api.ScanAllUpdateScanAllScheduleHandler = scan_all.UpdateScanAllScheduleHandlerFunc(func(params scan_all.UpdateScanAllScheduleParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "UpdateScanAllSchedule", ¶ms); res != nil { + return res + } + } + if res := c.ScanAllAPI.Prepare(ctx, "UpdateScanAllSchedule", ¶ms); res != nil { + return res + } + return c.ScanAllAPI.UpdateScanAllSchedule(ctx, params) + }) + api.ScannerUpdateScannerHandler = scanner.UpdateScannerHandlerFunc(func(params scanner.UpdateScannerParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "UpdateScanner", ¶ms); res != nil { + return res + } + } + if res := c.ScannerAPI.Prepare(ctx, "UpdateScanner", ¶ms); res != nil { + return res + } + return c.ScannerAPI.UpdateScanner(ctx, params) + }) + api.UsergroupUpdateUserGroupHandler = usergroup.UpdateUserGroupHandlerFunc(func(params usergroup.UpdateUserGroupParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "UpdateUserGroup", ¶ms); res != nil { + return res + } + } + if res := c.UsergroupAPI.Prepare(ctx, "UpdateUserGroup", ¶ms); res != nil { + return res + } + return c.UsergroupAPI.UpdateUserGroup(ctx, params) + }) + api.UserUpdateUserPasswordHandler = user.UpdateUserPasswordHandlerFunc(func(params user.UpdateUserPasswordParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "UpdateUserPassword", ¶ms); res != nil { + return res + } + } + if res := c.UserAPI.Prepare(ctx, "UpdateUserPassword", ¶ms); res != nil { + return res + } + return c.UserAPI.UpdateUserPassword(ctx, params) + }) + api.UserUpdateUserProfileHandler = user.UpdateUserProfileHandlerFunc(func(params user.UpdateUserProfileParams, principal interface{}) middleware.Responder { + ctx := params.HTTPRequest.Context() + ctx = storeAuth(ctx, principal) + if api.BeforePrepare != nil { + if res := api.BeforePrepare(ctx, "UpdateUserProfile", ¶ms); res != nil { + return res + } + } + if res := c.UserAPI.Prepare(ctx, "UpdateUserProfile", ¶ms); res != nil { + return res + } + return c.UserAPI.UpdateUserProfile(ctx, params) + }) + api.ServerShutdown = func() {} + return api.Serve(c.InnerMiddleware), api, nil +} + +// swaggerCopy copies the swagger json to prevent data races in runtime +func swaggerCopy(orig json.RawMessage) json.RawMessage { + c := make(json.RawMessage, len(orig)) + copy(c, orig) + return c +} + +// authorizer is a helper function to implement the runtime.Authorizer interface. +type authorizer func(*http.Request) error + +func (a authorizer) Authorize(req *http.Request, principal interface{}) error { + if a == nil { + return nil + } + ctx := storeAuth(req.Context(), principal) + return a(req.WithContext(ctx)) +} + +func storeAuth(ctx context.Context, principal interface{}) context.Context { + return context.WithValue(ctx, AuthKey, principal) +} diff --git a/src/server/v2.0/restapi/doc.go b/src/server/v2.0/restapi/doc.go new file mode 100644 index 000000000..304e51ed4 --- /dev/null +++ b/src/server/v2.0/restapi/doc.go @@ -0,0 +1,23 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Package restapi Harbor API +// +// These APIs provide services for manipulating Harbor project. +// Schemes: +// http +// https +// Host: localhost +// BasePath: /api/v2.0 +// Version: 2.0 +// +// Consumes: +// - application/json +// +// Produces: +// - application/octet-stream +// - text/csv +// - application/json +// - text/plain +// +// swagger:meta +package restapi diff --git a/src/server/v2.0/restapi/embedded_spec.go b/src/server/v2.0/restapi/embedded_spec.go new file mode 100644 index 000000000..f25c4839a --- /dev/null +++ b/src/server/v2.0/restapi/embedded_spec.go @@ -0,0 +1,37979 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package restapi + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "encoding/json" +) + +var ( + // SwaggerJSON embedded version of the swagger document used at generation time + SwaggerJSON json.RawMessage + // FlatSwaggerJSON embedded flattened version of the swagger document used at generation time + FlatSwaggerJSON json.RawMessage +) + +func init() { + SwaggerJSON = json.RawMessage([]byte(`{ + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "schemes": [ + "http", + "https" + ], + "swagger": "2.0", + "info": { + "description": "These APIs provide services for manipulating Harbor project.", + "title": "Harbor API", + "version": "2.0" + }, + "host": "localhost", + "basePath": "/api/v2.0", + "paths": { + "/audit-logs": { + "get": { + "description": "This endpoint let user see the recent operation logs of the projects which he is member of\n", + "tags": [ + "auditlog" + ], + "summary": "Get recent logs of the projects which the user is a member of", + "operationId": "listAuditLogs", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/query" + }, + { + "$ref": "#/parameters/sort" + }, + { + "$ref": "#/parameters/page" + }, + { + "$ref": "#/parameters/pageSize" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/AuditLog" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link refers to the previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of auditlogs" + } + } + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/configurations": { + "get": { + "description": "This endpoint is for retrieving system configurations that only provides for admin user.\n", + "tags": [ + "configure" + ], + "summary": "Get system configurations.", + "operationId": "getConfigurations", + "parameters": [ + { + "$ref": "#/parameters/requestId" + } + ], + "responses": { + "200": { + "description": "Get system configurations successfully. The response body is a map.", + "schema": { + "$ref": "#/definitions/ConfigurationsResponse" + } + }, + "401": { + "description": "User need to log in first.ß" + }, + "403": { + "description": "User does not have permission of admin role." + }, + "500": { + "description": "Unexpected internal errors." + } + } + }, + "put": { + "description": "This endpoint is for modifying system configurations that only provides for admin user.\n", + "tags": [ + "configure" + ], + "summary": "Modify system configurations.", + "operationId": "updateConfigurations", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "description": "The configuration map can contain a subset of the attributes of the schema, which are to be updated.", + "name": "configurations", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/Configurations" + } + } + ], + "responses": { + "200": { + "description": "Modify system configurations successfully." + }, + "401": { + "description": "User need to log in first." + }, + "403": { + "description": "User does not have permission of admin role." + }, + "500": { + "description": "Unexpected internal errors." + } + } + } + }, + "/export/cve": { + "post": { + "description": "Export scan data for selected projects", + "tags": [ + "scan data export" + ], + "summary": "Export scan data for selected projects", + "operationId": "exportScanData", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/scanDataType" + }, + { + "description": "The criteria for the export", + "name": "criteria", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ScanDataExportRequest" + } + } + ], + "responses": { + "200": { + "description": "Success.", + "schema": { + "$ref": "#/definitions/ScanDataExportJob" + } + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "405": { + "$ref": "#/responses/405" + }, + "409": { + "$ref": "#/responses/409" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/export/cve/download/{execution_id}": { + "get": { + "description": "Download the scan data report. Default format is CSV", + "produces": [ + "text/csv" + ], + "tags": [ + "scan data export" + ], + "summary": "Download the scan data export file", + "operationId": "downloadScanData", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/executionId" + }, + { + "type": "string", + "description": "The format of the data to be exported. e.g. CSV or PDF", + "name": "format", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Data file containing the export data", + "schema": { + "type": "file" + }, + "headers": { + "Content-Disposition": { + "type": "string", + "description": "Value is a CSV formatted file; filename=export.csv" + } + } + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/export/cve/execution/{execution_id}": { + "get": { + "description": "Get the scan data export execution specified by ID", + "tags": [ + "scan data export" + ], + "summary": "Get the specific scan data export execution", + "operationId": "getScanDataExportExecution", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/executionId" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/ScanDataExportExecution" + } + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/export/cve/executions": { + "get": { + "description": "Get a list of specific scan data export execution jobs for a specified user", + "tags": [ + "scan data export" + ], + "summary": "Get a list of specific scan data export execution jobs for a specified user", + "operationId": "getScanDataExportExecutionList", + "parameters": [ + { + "$ref": "#/parameters/requestId" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/ScanDataExportExecutionList" + } + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/health": { + "get": { + "description": "Check the status of Harbor components", + "tags": [ + "health" + ], + "summary": "Check the status of Harbor components", + "operationId": "getHealth", + "parameters": [ + { + "$ref": "#/parameters/requestId" + } + ], + "responses": { + "200": { + "description": "The health status of Harbor components", + "schema": { + "$ref": "#/definitions/OverallHealthStatus" + } + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/icons/{digest}": { + "get": { + "description": "Get the artifact icon with the specified digest. As the original icon image is resized and encoded before returning, the parameter \"digest\" in the path doesn't match the hash of the returned content", + "tags": [ + "icon" + ], + "summary": "Get artifact icon", + "operationId": "getIcon", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/digest" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/Icon" + } + }, + "400": { + "$ref": "#/responses/400" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/internalconfig": { + "get": { + "description": "This endpoint is for retrieving system configurations that only provides for internal api call.\n", + "tags": [ + "configure" + ], + "summary": "Get internal configurations.", + "operationId": "getInternalconfig", + "parameters": [ + { + "$ref": "#/parameters/requestId" + } + ], + "responses": { + "200": { + "description": "Get system configurations successfully. The response body is a map.", + "schema": { + "$ref": "#/definitions/InternalConfigurationsResponse" + } + }, + "401": { + "description": "User need to log in first." + }, + "403": { + "description": "User does not have permission of admin role." + }, + "500": { + "description": "Unexpected internal errors." + } + } + } + }, + "/jobservice/jobs/{job_id}": { + "put": { + "description": "Stop running job", + "tags": [ + "jobservice" + ], + "summary": "Stop running job", + "operationId": "stopRunningJob", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "type": "string", + "description": "The id of the job.", + "name": "job_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Stop worker successfully." + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/jobservice/pools": { + "get": { + "description": "Get worker pools", + "tags": [ + "jobservice" + ], + "summary": "Get worker pools", + "operationId": "getWorkerPools", + "parameters": [ + { + "$ref": "#/parameters/requestId" + } + ], + "responses": { + "200": { + "description": "Get worker pools successfully.", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/WorkerPool" + } + } + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/jobservice/pools/{pool_id}/workers": { + "get": { + "description": "Get workers in current pool", + "tags": [ + "jobservice" + ], + "summary": "Get workers", + "operationId": "getWorkers", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "type": "string", + "description": "The name of the pool. 'all' stands for all pools", + "name": "pool_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Get workers successfully.", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Worker" + } + } + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/jobservice/queues": { + "get": { + "description": "list job queue", + "tags": [ + "jobservice" + ], + "summary": "list job queues", + "operationId": "listJobQueues", + "parameters": [ + { + "$ref": "#/parameters/requestId" + } + ], + "responses": { + "200": { + "description": "List job queue successfully.", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/JobQueue" + } + } + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/jobservice/queues/{job_type}": { + "put": { + "description": "stop and clean, pause, resume pending jobs in the queue", + "tags": [ + "jobservice" + ], + "summary": "stop and clean, pause, resume pending jobs in the queue", + "operationId": "actionPendingJobs", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "type": "string", + "description": "The type of the job. 'all' stands for all job types", + "name": "job_type", + "in": "path", + "required": true + }, + { + "name": "action_request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ActionRequest" + } + } + ], + "responses": { + "200": { + "description": "take action to the jobs in the queue successfully." + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/labels": { + "get": { + "description": "This endpoint let user list labels by name, scope and project_id\n", + "tags": [ + "label" + ], + "summary": "List labels according to the query strings.", + "operationId": "ListLabels", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/query" + }, + { + "$ref": "#/parameters/sort" + }, + { + "$ref": "#/parameters/page" + }, + { + "$ref": "#/parameters/pageSize" + }, + { + "type": "string", + "description": "The label name.", + "name": "name", + "in": "query" + }, + { + "type": "string", + "description": "The label scope. Valid values are g and p. g for global labels and p for project labels.", + "name": "scope", + "in": "query" + }, + { + "type": "integer", + "format": "int64", + "description": "Relevant project ID, required when scope is p.", + "name": "project_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Get successfully.", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Label" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link to previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of available items" + } + } + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "post": { + "description": "This endpoint let user creates a label.\n", + "tags": [ + "label" + ], + "summary": "Post creates a label", + "operationId": "CreateLabel", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "description": "The json object of label.", + "name": "label", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/Label" + } + } + ], + "responses": { + "201": { + "description": "Create successfully.", + "headers": { + "Location": { + "type": "string", + "description": "The URL of the created resource" + } + } + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "409": { + "$ref": "#/responses/409" + }, + "415": { + "$ref": "#/responses/415" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/labels/{label_id}": { + "get": { + "description": "This endpoint let user get the label by specific ID.\n", + "tags": [ + "label" + ], + "summary": "Get the label specified by ID.", + "operationId": "GetLabelByID", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/labelId" + } + ], + "responses": { + "200": { + "description": "Get successfully.", + "schema": { + "$ref": "#/definitions/Label" + } + }, + "401": { + "$ref": "#/responses/401" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "put": { + "description": "This endpoint let user update label properties.\n", + "tags": [ + "label" + ], + "summary": "Update the label properties.", + "operationId": "UpdateLabel", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/labelId" + }, + { + "description": "The updated label json object.", + "name": "label", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/Label" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/200" + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "404": { + "$ref": "#/responses/404" + }, + "409": { + "$ref": "#/responses/409" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "delete": { + "description": "Delete the label specified by ID.\n", + "tags": [ + "label" + ], + "summary": "Delete the label specified by ID.", + "operationId": "DeleteLabel", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/labelId" + } + ], + "responses": { + "200": { + "$ref": "#/responses/200" + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/ldap/groups/search": { + "get": { + "description": "This endpoint searches the available ldap groups based on related configuration parameters. support to search by groupname or groupdn.\n", + "tags": [ + "Ldap" + ], + "summary": "Search available ldap groups.", + "operationId": "searchLdapGroup", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "type": "string", + "description": "Ldap group name", + "name": "groupname", + "in": "query" + }, + { + "type": "string", + "description": "The LDAP group DN", + "name": "groupdn", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Search ldap group successfully.", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/UserGroup" + } + } + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/ldap/ping": { + "post": { + "description": "This endpoint ping the available ldap service for test related configuration parameters.\n", + "tags": [ + "Ldap" + ], + "summary": "Ping available ldap service.", + "operationId": "pingLdap", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "description": "ldap configuration. support input ldap service configuration. If it is a empty request, will load current configuration from the system.", + "name": "ldapconf", + "in": "body", + "schema": { + "$ref": "#/definitions/LdapConf" + } + } + ], + "responses": { + "200": { + "description": "Ping ldap service successfully.", + "schema": { + "$ref": "#/definitions/LdapPingResult" + } + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/ldap/users/import": { + "post": { + "description": "This endpoint adds the selected available ldap users to harbor based on related configuration parameters from the system. System will try to guess the user email address and realname, add to harbor user information. If have errors when import user, will return the list of importing failed uid and the failed reason.\n", + "tags": [ + "Ldap" + ], + "summary": "Import selected available ldap users.", + "operationId": "importLdapUser", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "description": "The uid listed for importing. This list will check users validity of ldap service based on configuration from the system.", + "name": "uid_list", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/LdapImportUsers" + } + } + ], + "responses": { + "200": { + "description": "Add ldap users successfully." + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "description": "Failed import some users.", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/LdapFailedImportUser" + } + } + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/ldap/users/search": { + "get": { + "description": "This endpoint searches the available ldap users based on related configuration parameters. Support searched by input ladp configuration, load configuration from the system and specific filter.\n", + "tags": [ + "Ldap" + ], + "summary": "Search available ldap users.", + "operationId": "searchLdapUser", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "type": "string", + "description": "Registered user ID", + "name": "username", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Search ldap users successfully.", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/LdapUser" + } + } + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/p2p/preheat/instances": { + "get": { + "description": "List P2P provider instances", + "tags": [ + "preheat" + ], + "summary": "List P2P provider instances", + "operationId": "ListInstances", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/page" + }, + { + "$ref": "#/parameters/pageSize" + }, + { + "$ref": "#/parameters/query" + }, + { + "$ref": "#/parameters/sort" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Instance" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link refers to the previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of preheating provider instances" + } + } + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "post": { + "description": "Create p2p provider instances", + "tags": [ + "preheat" + ], + "summary": "Create p2p provider instances", + "operationId": "CreateInstance", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "description": "The JSON object of instance.", + "name": "instance", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/Instance" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/201" + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "409": { + "$ref": "#/responses/409" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/p2p/preheat/instances/ping": { + "post": { + "description": "This endpoint checks status of a instance, the instance can be given by ID or Endpoint URL (together with credential)\n", + "tags": [ + "preheat" + ], + "summary": "Ping status of a instance.", + "operationId": "PingInstances", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "description": "The JSON object of instance.", + "name": "instance", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/Instance" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/200" + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "404": { + "description": "Instance not found (when instance is provided by ID)." + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/p2p/preheat/instances/{preheat_instance_name}": { + "get": { + "description": "Get a P2P provider instance", + "tags": [ + "preheat" + ], + "summary": "Get a P2P provider instance", + "operationId": "GetInstance", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/instanceName" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/Instance" + } + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "put": { + "description": "Update the specified P2P provider instance", + "tags": [ + "preheat" + ], + "summary": "Update the specified P2P provider instance", + "operationId": "UpdateInstance", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/instanceName" + }, + { + "description": "The instance to update", + "name": "instance", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/Instance" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/200" + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "delete": { + "description": "Delete the specified P2P provider instance", + "tags": [ + "preheat" + ], + "summary": "Delete the specified P2P provider instance", + "operationId": "DeleteInstance", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/instanceName" + } + ], + "responses": { + "200": { + "$ref": "#/responses/200" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/p2p/preheat/providers": { + "get": { + "description": "List P2P providers", + "tags": [ + "preheat" + ], + "summary": "List P2P providers", + "operationId": "ListProviders", + "parameters": [ + { + "$ref": "#/parameters/requestId" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Metadata" + } + } + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/ping": { + "get": { + "description": "This API simply replies a pong to indicate the process to handle API is up, disregarding the health status of dependent components.", + "produces": [ + "text/plain" + ], + "tags": [ + "ping" + ], + "summary": "Ping Harbor to check if it's alive.", + "operationId": "getPing", + "parameters": [ + { + "$ref": "#/parameters/requestId" + } + ], + "responses": { + "200": { + "description": "The API server is alive", + "schema": { + "type": "string" + } + } + } + } + }, + "/projects": { + "get": { + "description": "This endpoint returns projects created by Harbor.", + "tags": [ + "project" + ], + "summary": "List projects", + "operationId": "listProjects", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/query" + }, + { + "$ref": "#/parameters/page" + }, + { + "$ref": "#/parameters/pageSize" + }, + { + "$ref": "#/parameters/sort" + }, + { + "type": "string", + "description": "The name of project.", + "name": "name", + "in": "query" + }, + { + "type": "boolean", + "format": "int32", + "description": "The project is public or private.", + "name": "public", + "in": "query" + }, + { + "type": "string", + "description": "The name of project owner.", + "name": "owner", + "in": "query" + }, + { + "type": "boolean", + "default": true, + "description": "Bool value indicating whether return detailed information of the project", + "name": "with_detail", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Return all matched projects.", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Project" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link refers to the previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of projects" + } + } + }, + "401": { + "$ref": "#/responses/401" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "post": { + "description": "This endpoint is for user to create a new project.", + "tags": [ + "project" + ], + "summary": "Create a new project.", + "operationId": "createProject", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/resourceNameInLocation" + }, + { + "description": "New created project.", + "name": "project", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ProjectReq" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/201" + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "409": { + "$ref": "#/responses/409" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "head": { + "description": "This endpoint is used to check if the project name provided already exist.", + "tags": [ + "project" + ], + "summary": "Check if the project name user provided already exists.", + "operationId": "headProject", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "type": "string", + "description": "Project name for checking exists.", + "name": "project_name", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/200" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/projects/{project_name_or_id}": { + "get": { + "description": "This endpoint returns specific project information by project ID.", + "tags": [ + "project" + ], + "summary": "Return specific project detail information", + "operationId": "getProject", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/isResourceName" + }, + { + "$ref": "#/parameters/projectNameOrId" + } + ], + "responses": { + "200": { + "description": "Return matched project information.", + "schema": { + "$ref": "#/definitions/Project" + } + }, + "401": { + "$ref": "#/responses/401" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "put": { + "description": "This endpoint is aimed to update the properties of a project.", + "tags": [ + "project" + ], + "summary": "Update properties for a selected project.", + "operationId": "updateProject", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/isResourceName" + }, + { + "$ref": "#/parameters/projectNameOrId" + }, + { + "description": "Updates of project.", + "name": "project", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ProjectReq" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/200" + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "delete": { + "description": "This endpoint is aimed to delete project by project ID.", + "tags": [ + "project" + ], + "summary": "Delete project by projectID", + "operationId": "deleteProject", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/isResourceName" + }, + { + "$ref": "#/parameters/projectNameOrId" + } + ], + "responses": { + "200": { + "$ref": "#/responses/200" + }, + "400": { + "$ref": "#/responses/400" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "412": { + "$ref": "#/responses/412" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/projects/{project_name_or_id}/_deletable": { + "get": { + "description": "Get the deletable status of the project", + "tags": [ + "project" + ], + "summary": "Get the deletable status of the project", + "operationId": "getProjectDeletable", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/isResourceName" + }, + { + "$ref": "#/parameters/projectNameOrId" + } + ], + "responses": { + "200": { + "description": "Return deletable status of the project.", + "schema": { + "$ref": "#/definitions/ProjectDeletable" + } + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/projects/{project_name_or_id}/immutabletagrules": { + "get": { + "description": "This endpoint returns the immutable tag rules of a project\n", + "tags": [ + "immutable" + ], + "summary": "List all immutable tag rules of current project", + "operationId": "ListImmuRules", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/isResourceName" + }, + { + "$ref": "#/parameters/projectNameOrId" + }, + { + "$ref": "#/parameters/page" + }, + { + "$ref": "#/parameters/pageSize" + }, + { + "$ref": "#/parameters/query" + }, + { + "$ref": "#/parameters/sort" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/ImmutableRule" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link refers to the previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of immutable tag" + } + } + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "post": { + "description": "This endpoint add an immutable tag rule to the project\n", + "tags": [ + "immutable" + ], + "summary": "Add an immutable tag rule to current project", + "operationId": "CreateImmuRule", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/isResourceName" + }, + { + "$ref": "#/parameters/projectNameOrId" + }, + { + "name": "ImmutableRule", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ImmutableRule" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/201" + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/projects/{project_name_or_id}/immutabletagrules/{immutable_rule_id}": { + "put": { + "tags": [ + "immutable" + ], + "summary": "Update the immutable tag rule or enable or disable the rule", + "operationId": "UpdateImmuRule", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/isResourceName" + }, + { + "$ref": "#/parameters/projectNameOrId" + }, + { + "$ref": "#/parameters/immutableRuleId" + }, + { + "name": "ImmutableRule", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ImmutableRule" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/200" + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "delete": { + "tags": [ + "immutable" + ], + "summary": "Delete the immutable tag rule.", + "operationId": "DeleteImmuRule", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/isResourceName" + }, + { + "$ref": "#/parameters/projectNameOrId" + }, + { + "$ref": "#/parameters/immutableRuleId" + } + ], + "responses": { + "200": { + "$ref": "#/responses/200" + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/projects/{project_name_or_id}/members": { + "get": { + "description": "Get all project member information", + "tags": [ + "member" + ], + "summary": "Get all project member information", + "operationId": "listProjectMembers", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/isResourceName" + }, + { + "$ref": "#/parameters/projectNameOrId" + }, + { + "$ref": "#/parameters/page" + }, + { + "$ref": "#/parameters/pageSize" + }, + { + "type": "string", + "description": "The entity name to search.", + "name": "entityname", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Get project members successfully.", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/ProjectMemberEntity" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link refers to the previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of members" + } + } + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "post": { + "description": "Create project member relationship, the member can be one of the user_member and group_member, The user_member need to specify user_id or username. If the user already exist in harbor DB, specify the user_id, If does not exist in harbor DB, it will SearchAndOnBoard the user. The group_member need to specify id or ldap_group_dn. If the group already exist in harbor DB. specify the user group's id, If does not exist, it will SearchAndOnBoard the group. ", + "tags": [ + "member" + ], + "summary": "Create project member", + "operationId": "createProjectMember", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/isResourceName" + }, + { + "$ref": "#/parameters/projectNameOrId" + }, + { + "name": "project_member", + "in": "body", + "schema": { + "$ref": "#/definitions/ProjectMember" + } + } + ], + "responses": { + "201": { + "description": "Project member created successfully.", + "headers": { + "Location": { + "type": "string", + "description": "The URL of the created resource" + } + } + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "409": { + "$ref": "#/responses/409" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/projects/{project_name_or_id}/members/{mid}": { + "get": { + "description": "Get the project member information", + "tags": [ + "member" + ], + "summary": "Get the project member information", + "operationId": "getProjectMember", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/isResourceName" + }, + { + "$ref": "#/parameters/projectNameOrId" + }, + { + "type": "integer", + "format": "int64", + "description": "The member ID", + "name": "mid", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Project member retrieved successfully.", + "schema": { + "$ref": "#/definitions/ProjectMemberEntity" + } + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "put": { + "description": "Update project member relationship", + "tags": [ + "member" + ], + "summary": "Update project member", + "operationId": "updateProjectMember", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/isResourceName" + }, + { + "$ref": "#/parameters/projectNameOrId" + }, + { + "type": "integer", + "format": "int64", + "description": "Member ID.", + "name": "mid", + "in": "path", + "required": true + }, + { + "name": "role", + "in": "body", + "schema": { + "$ref": "#/definitions/RoleRequest" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/200" + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "delete": { + "tags": [ + "member" + ], + "summary": "Delete project member", + "operationId": "deleteProjectMember", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/isResourceName" + }, + { + "$ref": "#/parameters/projectNameOrId" + }, + { + "type": "integer", + "format": "int64", + "description": "Member ID.", + "name": "mid", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/200" + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/projects/{project_name_or_id}/metadatas/": { + "get": { + "description": "Get the metadata of the specific project", + "tags": [ + "projectMetadata" + ], + "summary": "Get the metadata of the specific project", + "operationId": "listProjectMetadatas", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/isResourceName" + }, + { + "$ref": "#/parameters/projectNameOrId" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "post": { + "description": "Add metadata for the specific project", + "tags": [ + "projectMetadata" + ], + "summary": "Add metadata for the specific project", + "operationId": "addProjectMetadatas", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/isResourceName" + }, + { + "$ref": "#/parameters/projectNameOrId" + }, + { + "name": "metadata", + "in": "body", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/200" + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "409": { + "$ref": "#/responses/409" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/projects/{project_name_or_id}/metadatas/{meta_name}": { + "get": { + "description": "Get the specific metadata of the specific project", + "tags": [ + "projectMetadata" + ], + "summary": "Get the specific metadata of the specific project", + "operationId": "getProjectMetadata", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/isResourceName" + }, + { + "$ref": "#/parameters/projectNameOrId" + }, + { + "type": "string", + "description": "The name of metadata.", + "name": "meta_name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "put": { + "description": "Update the specific metadata for the specific project", + "tags": [ + "projectMetadata" + ], + "summary": "Update the specific metadata for the specific project", + "operationId": "updateProjectMetadata", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/isResourceName" + }, + { + "$ref": "#/parameters/projectNameOrId" + }, + { + "type": "string", + "description": "The name of metadata.", + "name": "meta_name", + "in": "path", + "required": true + }, + { + "name": "metadata", + "in": "body", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/200" + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "409": { + "$ref": "#/responses/409" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "delete": { + "description": "Delete the specific metadata for the specific project", + "tags": [ + "projectMetadata" + ], + "summary": "Delete the specific metadata for the specific project", + "operationId": "deleteProjectMetadata", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/isResourceName" + }, + { + "$ref": "#/parameters/projectNameOrId" + }, + { + "type": "string", + "description": "The name of metadata.", + "name": "meta_name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/200" + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "409": { + "$ref": "#/responses/409" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/projects/{project_name_or_id}/robots": { + "get": { + "description": "Get all robot accounts of specified project", + "tags": [ + "robotv1" + ], + "summary": "Get all robot accounts of specified project", + "operationId": "ListRobotV1", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/isResourceName" + }, + { + "$ref": "#/parameters/projectNameOrId" + }, + { + "$ref": "#/parameters/page" + }, + { + "$ref": "#/parameters/pageSize" + }, + { + "$ref": "#/parameters/query" + }, + { + "$ref": "#/parameters/sort" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Robot" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link refers to the previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of robot accounts" + } + } + }, + "400": { + "$ref": "#/responses/400" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "post": { + "description": "Create a robot account", + "tags": [ + "robotv1" + ], + "summary": "Create a robot account", + "operationId": "CreateRobotV1", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/isResourceName" + }, + { + "$ref": "#/parameters/projectNameOrId" + }, + { + "description": "The JSON object of a robot account.", + "name": "robot", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/RobotCreateV1" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/RobotCreated" + }, + "headers": { + "Location": { + "type": "string", + "description": "The location of the resource" + }, + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/projects/{project_name_or_id}/robots/{robot_id}": { + "get": { + "description": "This endpoint returns specific robot account information by robot ID.", + "tags": [ + "robotv1" + ], + "summary": "Get a robot account", + "operationId": "GetRobotByIDV1", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/isResourceName" + }, + { + "$ref": "#/parameters/projectNameOrId" + }, + { + "$ref": "#/parameters/robotId" + } + ], + "responses": { + "200": { + "description": "Return matched robot information.", + "schema": { + "$ref": "#/definitions/Robot" + } + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "put": { + "description": "Used to disable/enable a specified robot account.", + "tags": [ + "robotv1" + ], + "summary": "Update status of robot account.", + "operationId": "UpdateRobotV1", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/isResourceName" + }, + { + "$ref": "#/parameters/projectNameOrId" + }, + { + "$ref": "#/parameters/robotId" + }, + { + "description": "The JSON object of a robot account.", + "name": "robot", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/Robot" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/200" + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "409": { + "$ref": "#/responses/409" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "delete": { + "description": "This endpoint deletes specific robot account information by robot ID.", + "tags": [ + "robotv1" + ], + "summary": "Delete a robot account", + "operationId": "DeleteRobotV1", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/isResourceName" + }, + { + "$ref": "#/parameters/projectNameOrId" + }, + { + "$ref": "#/parameters/robotId" + } + ], + "responses": { + "200": { + "$ref": "#/responses/200" + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/projects/{project_name_or_id}/scanner": { + "get": { + "description": "Get the scanner registration of the specified project. If no scanner registration is configured for the specified project, the system default scanner registration will be returned.", + "tags": [ + "project" + ], + "summary": "Get project level scanner", + "operationId": "getScannerOfProject", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/isResourceName" + }, + { + "$ref": "#/parameters/projectNameOrId" + } + ], + "responses": { + "200": { + "description": "The details of the scanner registration.", + "schema": { + "$ref": "#/definitions/ScannerRegistration" + } + }, + "400": { + "description": "Bad project ID" + }, + "401": { + "description": "Unauthorized request" + }, + "403": { + "description": "Request is not allowed" + }, + "404": { + "description": "The requested object is not found" + }, + "500": { + "description": "Internal server error happened" + } + } + }, + "put": { + "description": "Set one of the system configured scanner registration as the indepndent scanner of the specified project.", + "tags": [ + "project" + ], + "summary": "Configure scanner for the specified project", + "operationId": "setScannerOfProject", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/isResourceName" + }, + { + "$ref": "#/parameters/projectNameOrId" + }, + { + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ProjectScanner" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/200" + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/projects/{project_name_or_id}/scanner/candidates": { + "get": { + "description": "Retrieve the system configured scanner registrations as candidates of setting project level scanner.", + "tags": [ + "project" + ], + "summary": "Get scanner registration candidates for configurating project level scanner", + "operationId": "listScannerCandidatesOfProject", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/isResourceName" + }, + { + "$ref": "#/parameters/projectNameOrId" + }, + { + "$ref": "#/parameters/query" + }, + { + "$ref": "#/parameters/sort" + }, + { + "$ref": "#/parameters/page" + }, + { + "$ref": "#/parameters/pageSize" + } + ], + "responses": { + "200": { + "description": "A list of scanner registrations.", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/ScannerRegistration" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link to previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of available items" + } + } + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/projects/{project_name_or_id}/summary": { + "get": { + "description": "Get summary of the project.", + "tags": [ + "project" + ], + "summary": "Get summary of the project.", + "operationId": "getProjectSummary", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/isResourceName" + }, + { + "$ref": "#/parameters/projectNameOrId" + } + ], + "responses": { + "200": { + "description": "Get summary of the project successfully.", + "schema": { + "$ref": "#/definitions/ProjectSummary" + } + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/projects/{project_name_or_id}/webhook/events": { + "get": { + "description": "Get supportted event types and notify types.", + "tags": [ + "webhook" + ], + "summary": "Get supported event types and notify types.", + "operationId": "GetSupportedEventTypes", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/isResourceName" + }, + { + "$ref": "#/parameters/projectNameOrId" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/SupportedWebhookEventTypes" + } + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/projects/{project_name_or_id}/webhook/jobs": { + "get": { + "description": "This endpoint returns webhook jobs of a project.\n", + "tags": [ + "webhookjob" + ], + "summary": "List project webhook jobs", + "operationId": "ListWebhookJobs", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/isResourceName" + }, + { + "$ref": "#/parameters/projectNameOrId" + }, + { + "$ref": "#/parameters/query" + }, + { + "$ref": "#/parameters/sort" + }, + { + "$ref": "#/parameters/page" + }, + { + "$ref": "#/parameters/pageSize" + }, + { + "type": "integer", + "format": "int64", + "description": "The policy ID.", + "name": "policy_id", + "in": "query", + "required": true + }, + { + "type": "array", + "items": { + "type": "string" + }, + "description": "The status of webhook job.", + "name": "status", + "in": "query" + } + ], + "responses": { + "200": { + "description": "List project webhook jobs successfully.", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/WebhookJob" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link to previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of available items" + } + } + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/projects/{project_name_or_id}/webhook/lasttrigger": { + "get": { + "description": "This endpoint returns last trigger information of project webhook policy.\n", + "tags": [ + "webhook" + ], + "summary": "Get project webhook policy last trigger info", + "operationId": "LastTrigger", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/isResourceName" + }, + { + "$ref": "#/parameters/projectNameOrId" + } + ], + "responses": { + "200": { + "description": "Test webhook connection successfully.", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/WebhookLastTrigger" + } + } + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/projects/{project_name_or_id}/webhook/policies": { + "get": { + "description": "This endpoint returns webhook policies of a project.\n", + "tags": [ + "webhook" + ], + "summary": "List project webhook policies.", + "operationId": "ListWebhookPoliciesOfProject", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/isResourceName" + }, + { + "$ref": "#/parameters/projectNameOrId" + }, + { + "$ref": "#/parameters/sort" + }, + { + "$ref": "#/parameters/query" + }, + { + "$ref": "#/parameters/page" + }, + { + "$ref": "#/parameters/pageSize" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/WebhookPolicy" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link refers to the previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of webhook policies." + } + } + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "post": { + "description": "This endpoint create a webhook policy if the project does not have one.\n", + "tags": [ + "webhook" + ], + "summary": "Create project webhook policy.", + "operationId": "CreateWebhookPolicyOfProject", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/isResourceName" + }, + { + "$ref": "#/parameters/projectNameOrId" + }, + { + "description": "Properties \"targets\" and \"event_types\" needed.", + "name": "policy", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/WebhookPolicy" + } + } + ], + "responses": { + "201": { + "description": "Project webhook policy create successfully.", + "headers": { + "Location": { + "type": "string", + "description": "The location of the resource" + }, + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}": { + "get": { + "description": "This endpoint returns specified webhook policy of a project.\n", + "tags": [ + "webhook" + ], + "summary": "Get project webhook policy", + "operationId": "GetWebhookPolicyOfProject", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/isResourceName" + }, + { + "$ref": "#/parameters/projectNameOrId" + }, + { + "$ref": "#/parameters/webhookPolicyId" + } + ], + "responses": { + "200": { + "description": "Get webhook policy successfully.", + "schema": { + "$ref": "#/definitions/WebhookPolicy" + } + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "put": { + "description": "This endpoint is aimed to update the webhook policy of a project.\n", + "tags": [ + "webhook" + ], + "summary": "Update webhook policy of a project.", + "operationId": "UpdateWebhookPolicyOfProject", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/isResourceName" + }, + { + "$ref": "#/parameters/projectNameOrId" + }, + { + "$ref": "#/parameters/webhookPolicyId" + }, + { + "description": "All properties needed except \"id\", \"project_id\", \"creation_time\", \"update_time\".", + "name": "policy", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/WebhookPolicy" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/200" + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "delete": { + "description": "This endpoint is aimed to delete webhookpolicy of a project.\n", + "tags": [ + "webhook" + ], + "summary": "Delete webhook policy of a project", + "operationId": "DeleteWebhookPolicyOfProject", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/isResourceName" + }, + { + "$ref": "#/parameters/projectNameOrId" + }, + { + "$ref": "#/parameters/webhookPolicyId" + } + ], + "responses": { + "200": { + "$ref": "#/responses/200" + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/projects/{project_name}/logs": { + "get": { + "description": "Get recent logs of the projects", + "tags": [ + "project" + ], + "summary": "Get recent logs of the projects", + "operationId": "getLogs", + "parameters": [ + { + "$ref": "#/parameters/projectName" + }, + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/query" + }, + { + "$ref": "#/parameters/sort" + }, + { + "$ref": "#/parameters/page" + }, + { + "$ref": "#/parameters/pageSize" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/AuditLog" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link refers to the previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of auditlogs" + } + } + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/projects/{project_name}/preheat/policies": { + "get": { + "description": "List preheat policies", + "tags": [ + "preheat" + ], + "summary": "List preheat policies", + "operationId": "ListPolicies", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/projectName" + }, + { + "$ref": "#/parameters/page" + }, + { + "$ref": "#/parameters/pageSize" + }, + { + "$ref": "#/parameters/query" + }, + { + "$ref": "#/parameters/sort" + } + ], + "responses": { + "200": { + "description": "List preheat policies success", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/PreheatPolicy" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link refers to the previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of policies" + } + } + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "post": { + "description": "Create a preheat policy under a project", + "tags": [ + "preheat" + ], + "summary": "Create a preheat policy under a project", + "operationId": "CreatePolicy", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/projectName" + }, + { + "description": "The policy schema info", + "name": "policy", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/PreheatPolicy" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/201" + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "409": { + "$ref": "#/responses/409" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/projects/{project_name}/preheat/policies/{preheat_policy_name}": { + "get": { + "description": "Get a preheat policy", + "tags": [ + "preheat" + ], + "summary": "Get a preheat policy", + "operationId": "GetPolicy", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/projectName" + }, + { + "$ref": "#/parameters/preheatPolicyName" + } + ], + "responses": { + "200": { + "description": "Get a preheat policy success", + "schema": { + "$ref": "#/definitions/PreheatPolicy" + } + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "put": { + "description": "Update preheat policy", + "tags": [ + "preheat" + ], + "summary": "Update preheat policy", + "operationId": "UpdatePolicy", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/projectName" + }, + { + "$ref": "#/parameters/preheatPolicyName" + }, + { + "description": "The policy schema info", + "name": "policy", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/PreheatPolicy" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/200" + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "409": { + "$ref": "#/responses/409" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "post": { + "description": "Manual preheat", + "tags": [ + "preheat" + ], + "summary": "Manual preheat", + "operationId": "ManualPreheat", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/projectName" + }, + { + "$ref": "#/parameters/preheatPolicyName" + }, + { + "description": "The policy schema info", + "name": "policy", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/PreheatPolicy" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/201" + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "delete": { + "description": "Delete a preheat policy", + "tags": [ + "preheat" + ], + "summary": "Delete a preheat policy", + "operationId": "DeletePolicy", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/projectName" + }, + { + "$ref": "#/parameters/preheatPolicyName" + } + ], + "responses": { + "200": { + "$ref": "#/responses/200" + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/projects/{project_name}/preheat/policies/{preheat_policy_name}/executions": { + "get": { + "description": "List executions for the given policy", + "tags": [ + "preheat" + ], + "summary": "List executions for the given policy", + "operationId": "ListExecutions", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/projectName" + }, + { + "$ref": "#/parameters/preheatPolicyName" + }, + { + "$ref": "#/parameters/page" + }, + { + "$ref": "#/parameters/pageSize" + }, + { + "$ref": "#/parameters/query" + }, + { + "$ref": "#/parameters/sort" + } + ], + "responses": { + "200": { + "description": "List executions success", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Execution" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link refers to the previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of executions" + } + } + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/projects/{project_name}/preheat/policies/{preheat_policy_name}/executions/{execution_id}": { + "get": { + "description": "Get a execution detail by id", + "tags": [ + "preheat" + ], + "summary": "Get a execution detail by id", + "operationId": "GetExecution", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/projectName" + }, + { + "$ref": "#/parameters/preheatPolicyName" + }, + { + "$ref": "#/parameters/executionId" + } + ], + "responses": { + "200": { + "description": "Get execution success", + "schema": { + "$ref": "#/definitions/Execution" + } + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "patch": { + "description": "Stop a execution", + "tags": [ + "preheat" + ], + "summary": "Stop a execution", + "operationId": "StopExecution", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/projectName" + }, + { + "$ref": "#/parameters/preheatPolicyName" + }, + { + "$ref": "#/parameters/executionId" + }, + { + "description": "The data of execution", + "name": "execution", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/Execution" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/200" + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/projects/{project_name}/preheat/policies/{preheat_policy_name}/executions/{execution_id}/tasks": { + "get": { + "description": "List all the related tasks for the given execution", + "tags": [ + "preheat" + ], + "summary": "List all the related tasks for the given execution", + "operationId": "ListTasks", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/projectName" + }, + { + "$ref": "#/parameters/preheatPolicyName" + }, + { + "$ref": "#/parameters/executionId" + }, + { + "$ref": "#/parameters/page" + }, + { + "$ref": "#/parameters/pageSize" + }, + { + "$ref": "#/parameters/query" + }, + { + "$ref": "#/parameters/sort" + } + ], + "responses": { + "200": { + "description": "List tasks success", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Task" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link refers to the previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of tasks" + } + } + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/projects/{project_name}/preheat/policies/{preheat_policy_name}/executions/{execution_id}/tasks/{task_id}/logs": { + "get": { + "description": "Get the log text stream of the specified task for the given execution", + "produces": [ + "text/plain" + ], + "tags": [ + "preheat" + ], + "summary": "Get the log text stream of the specified task for the given execution", + "operationId": "GetPreheatLog", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/projectName" + }, + { + "$ref": "#/parameters/preheatPolicyName" + }, + { + "$ref": "#/parameters/executionId" + }, + { + "$ref": "#/parameters/taskId" + } + ], + "responses": { + "200": { + "description": "Get log success", + "schema": { + "type": "string" + }, + "headers": { + "Content-Type": { + "type": "string", + "description": "Content type of response" + } + } + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/projects/{project_name}/preheat/providers": { + "get": { + "description": "Get all providers at project level", + "tags": [ + "preheat" + ], + "summary": "Get all providers at project level", + "operationId": "ListProvidersUnderProject", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/projectName" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/ProviderUnderProject" + } + } + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/projects/{project_name}/repositories": { + "get": { + "description": "List repositories of the specified project", + "tags": [ + "repository" + ], + "summary": "List repositories", + "operationId": "listRepositories", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/projectName" + }, + { + "$ref": "#/parameters/query" + }, + { + "$ref": "#/parameters/sort" + }, + { + "$ref": "#/parameters/page" + }, + { + "$ref": "#/parameters/pageSize" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Repository" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link refers to the previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of repositories" + } + } + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/projects/{project_name}/repositories/{repository_name}": { + "get": { + "description": "Get the repository specified by name", + "tags": [ + "repository" + ], + "summary": "Get repository", + "operationId": "getRepository", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/projectName" + }, + { + "$ref": "#/parameters/repositoryName" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/Repository" + } + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "put": { + "description": "Update the repository specified by name", + "tags": [ + "repository" + ], + "summary": "Update repository", + "operationId": "updateRepository", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/projectName" + }, + { + "$ref": "#/parameters/repositoryName" + }, + { + "description": "The JSON object of repository.", + "name": "repository", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/Repository" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/200" + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "delete": { + "description": "Delete the repository specified by name", + "tags": [ + "repository" + ], + "summary": "Delete repository", + "operationId": "deleteRepository", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/projectName" + }, + { + "$ref": "#/parameters/repositoryName" + } + ], + "responses": { + "200": { + "$ref": "#/responses/200" + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/projects/{project_name}/repositories/{repository_name}/artifacts": { + "get": { + "description": "List artifacts under the specific project and repository. Except the basic properties, the other supported queries in \"q\" includes \"tags=*\" to list only tagged artifacts, \"tags=nil\" to list only untagged artifacts, \"tags=~v\" to list artifacts whose tag fuzzy matches \"v\", \"tags=v\" to list artifact whose tag exactly matches \"v\", \"labels=(id1, id2)\" to list artifacts that both labels with id1 and id2 are added to", + "tags": [ + "artifact" + ], + "summary": "List artifacts", + "operationId": "listArtifacts", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/projectName" + }, + { + "$ref": "#/parameters/repositoryName" + }, + { + "$ref": "#/parameters/query" + }, + { + "$ref": "#/parameters/sort" + }, + { + "$ref": "#/parameters/page" + }, + { + "$ref": "#/parameters/pageSize" + }, + { + "$ref": "#/parameters/acceptVulnerabilities" + }, + { + "type": "boolean", + "default": true, + "description": "Specify whether the tags are included inside the returning artifacts", + "name": "with_tag", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Specify whether the labels are included inside the returning artifacts", + "name": "with_label", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Specify whether the scan overview is included inside the returning artifacts", + "name": "with_scan_overview", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Specify whether the signature is included inside the tags of the returning artifacts. Only works when setting \"with_tag=true\"", + "name": "with_signature", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Specify whether the immutable status is included inside the tags of the returning artifacts. Only works when setting \"with_immutable_status=true\"", + "name": "with_immutable_status", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Specify whether the accessories are included of the returning artifacts. Only works when setting \"with_accessory=true\"", + "name": "with_accessory", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Artifact" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link refers to the previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of artifacts" + } + } + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "post": { + "description": "Copy the artifact specified in the \"from\" parameter to the repository.", + "tags": [ + "artifact" + ], + "summary": "Copy artifact", + "operationId": "CopyArtifact", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/projectName" + }, + { + "$ref": "#/parameters/repositoryName" + }, + { + "type": "string", + "description": "The artifact from which the new artifact is copied from, the format should be \"project/repository:tag\" or \"project/repository@digest\".", + "name": "from", + "in": "query", + "required": true + } + ], + "responses": { + "201": { + "$ref": "#/responses/201" + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "405": { + "$ref": "#/responses/405" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}": { + "get": { + "description": "Get the artifact specified by the reference under the project and repository. The reference can be digest or tag.", + "tags": [ + "artifact" + ], + "summary": "Get the specific artifact", + "operationId": "getArtifact", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/projectName" + }, + { + "$ref": "#/parameters/repositoryName" + }, + { + "$ref": "#/parameters/reference" + }, + { + "$ref": "#/parameters/page" + }, + { + "$ref": "#/parameters/pageSize" + }, + { + "$ref": "#/parameters/acceptVulnerabilities" + }, + { + "type": "boolean", + "default": true, + "description": "Specify whether the tags are inclued inside the returning artifacts", + "name": "with_tag", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Specify whether the labels are inclued inside the returning artifacts", + "name": "with_label", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Specify whether the scan overview is inclued inside the returning artifacts", + "name": "with_scan_overview", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Specify whether the accessories are included of the returning artifacts.", + "name": "with_accessory", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Specify whether the signature is inclued inside the returning artifacts", + "name": "with_signature", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Specify whether the immutable status is inclued inside the tags of the returning artifacts.", + "name": "with_immutable_status", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/Artifact" + } + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "delete": { + "description": "Delete the artifact specified by the reference under the project and repository. The reference can be digest or tag", + "tags": [ + "artifact" + ], + "summary": "Delete the specific artifact", + "operationId": "deleteArtifact", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/projectName" + }, + { + "$ref": "#/parameters/repositoryName" + }, + { + "$ref": "#/parameters/reference" + } + ], + "responses": { + "200": { + "$ref": "#/responses/200" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/accessories": { + "get": { + "description": "List accessories of the specific artifact", + "tags": [ + "artifact" + ], + "summary": "List accessories", + "operationId": "listAccessories", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/projectName" + }, + { + "$ref": "#/parameters/repositoryName" + }, + { + "$ref": "#/parameters/reference" + }, + { + "$ref": "#/parameters/query" + }, + { + "$ref": "#/parameters/sort" + }, + { + "$ref": "#/parameters/page" + }, + { + "$ref": "#/parameters/pageSize" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Accessory" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link refers to the previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of accessories" + } + } + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/additions/vulnerabilities": { + "get": { + "description": "Get the vulnerabilities addition of the artifact specified by the reference under the project and repository.", + "tags": [ + "artifact" + ], + "summary": "Get the vulnerabilities addition of the specific artifact", + "operationId": "getVulnerabilitiesAddition", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/projectName" + }, + { + "$ref": "#/parameters/repositoryName" + }, + { + "$ref": "#/parameters/reference" + }, + { + "$ref": "#/parameters/acceptVulnerabilities" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "string" + }, + "headers": { + "Content-Type": { + "type": "string", + "description": "The content type of the vulnerabilities addition" + } + } + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/additions/{addition}": { + "get": { + "description": "Get the addition of the artifact specified by the reference under the project and repository.", + "tags": [ + "artifact" + ], + "summary": "Get the addition of the specific artifact", + "operationId": "getAddition", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/projectName" + }, + { + "$ref": "#/parameters/repositoryName" + }, + { + "$ref": "#/parameters/reference" + }, + { + "enum": [ + "build_history", + "values.yaml", + "readme.md", + "dependencies" + ], + "type": "string", + "description": "The type of addition.", + "name": "addition", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "string" + }, + "headers": { + "Content-Type": { + "type": "string", + "description": "The content type of the addition" + } + } + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/labels": { + "post": { + "description": "Add label to the specified artiact.", + "tags": [ + "artifact" + ], + "summary": "Add label to artifact", + "operationId": "addLabel", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/projectName" + }, + { + "$ref": "#/parameters/repositoryName" + }, + { + "$ref": "#/parameters/reference" + }, + { + "description": "The label that added to the artifact. Only the ID property is needed.", + "name": "label", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/Label" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/200" + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "409": { + "$ref": "#/responses/409" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/labels/{label_id}": { + "delete": { + "description": "Remove the label from the specified artiact.", + "tags": [ + "artifact" + ], + "summary": "Remove label from artifact", + "operationId": "removeLabel", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/projectName" + }, + { + "$ref": "#/parameters/repositoryName" + }, + { + "$ref": "#/parameters/reference" + }, + { + "type": "integer", + "format": "int64", + "description": "The ID of the label that removed from the artifact.", + "name": "label_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/200" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "409": { + "$ref": "#/responses/409" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/scan": { + "post": { + "description": "Scan the specified artifact", + "tags": [ + "scan" + ], + "summary": "Scan the artifact", + "operationId": "scanArtifact", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/projectName" + }, + { + "$ref": "#/parameters/repositoryName" + }, + { + "$ref": "#/parameters/reference" + } + ], + "responses": { + "202": { + "$ref": "#/responses/202" + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/scan/stop": { + "post": { + "description": "Cancelling a scan job for a particular artifact", + "tags": [ + "scan" + ], + "summary": "Cancelling a scan job for a particular artifact", + "operationId": "stopScanArtifact", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/projectName" + }, + { + "$ref": "#/parameters/repositoryName" + }, + { + "$ref": "#/parameters/reference" + } + ], + "responses": { + "202": { + "$ref": "#/responses/202" + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/scan/{report_id}/log": { + "get": { + "description": "Get the log of the scan report", + "produces": [ + "text/plain" + ], + "tags": [ + "scan" + ], + "summary": "Get the log of the scan report", + "operationId": "getReportLog", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/projectName" + }, + { + "$ref": "#/parameters/repositoryName" + }, + { + "$ref": "#/parameters/reference" + }, + { + "type": "string", + "description": "The report id to get the log", + "name": "report_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Successfully get scan log file", + "schema": { + "type": "string" + } + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/tags": { + "get": { + "description": "List tags of the specific artifact", + "tags": [ + "artifact" + ], + "summary": "List tags", + "operationId": "listTags", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/projectName" + }, + { + "$ref": "#/parameters/repositoryName" + }, + { + "$ref": "#/parameters/reference" + }, + { + "$ref": "#/parameters/query" + }, + { + "$ref": "#/parameters/sort" + }, + { + "$ref": "#/parameters/page" + }, + { + "$ref": "#/parameters/pageSize" + }, + { + "type": "boolean", + "default": false, + "description": "Specify whether the signature is included inside the returning tags", + "name": "with_signature", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Specify whether the immutable status is included inside the returning tags", + "name": "with_immutable_status", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Tag" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link refers to the previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of tags" + } + } + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "post": { + "description": "Create a tag for the specified artifact", + "tags": [ + "artifact" + ], + "summary": "Create tag", + "operationId": "createTag", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/projectName" + }, + { + "$ref": "#/parameters/repositoryName" + }, + { + "$ref": "#/parameters/reference" + }, + { + "description": "The JSON object of tag.", + "name": "tag", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/Tag" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/201" + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "405": { + "$ref": "#/responses/405" + }, + "409": { + "$ref": "#/responses/409" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/tags/{tag_name}": { + "delete": { + "description": "Delete the tag of the specified artifact", + "tags": [ + "artifact" + ], + "summary": "Delete tag", + "operationId": "deleteTag", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/projectName" + }, + { + "$ref": "#/parameters/repositoryName" + }, + { + "$ref": "#/parameters/reference" + }, + { + "$ref": "#/parameters/tagName" + } + ], + "responses": { + "200": { + "$ref": "#/responses/200" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/quotas": { + "get": { + "description": "List quotas", + "tags": [ + "quota" + ], + "summary": "List quotas", + "operationId": "listQuotas", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/page" + }, + { + "$ref": "#/parameters/pageSize" + }, + { + "type": "string", + "description": "The reference type of quota.", + "name": "reference", + "in": "query" + }, + { + "type": "string", + "description": "The reference id of quota.", + "name": "reference_id", + "in": "query" + }, + { + "type": "string", + "description": "Sort method, valid values include:\n'hard.resource_name', '-hard.resource_name', 'used.resource_name', '-used.resource_name'.\nHere '-' stands for descending order, resource_name should be the real resource name of the quota.\n", + "name": "sort", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successfully retrieved the quotas.", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Quota" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link refers to the previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of access logs" + } + } + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/quotas/{id}": { + "get": { + "description": "Get the specified quota", + "tags": [ + "quota" + ], + "summary": "Get the specified quota", + "operationId": "getQuota", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "type": "integer", + "description": "Quota ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Successfully retrieved the quota.", + "schema": { + "$ref": "#/definitions/Quota" + } + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "put": { + "description": "Update hard limits of the specified quota", + "tags": [ + "quota" + ], + "summary": "Update the specified quota", + "operationId": "updateQuota", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "type": "integer", + "description": "Quota ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "The new hard limits for the quota", + "name": "hard", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/QuotaUpdateReq" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/200" + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/registries": { + "get": { + "description": "List the registries", + "tags": [ + "registry" + ], + "summary": "List the registries", + "operationId": "listRegistries", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/query" + }, + { + "$ref": "#/parameters/sort" + }, + { + "$ref": "#/parameters/page" + }, + { + "$ref": "#/parameters/pageSize" + }, + { + "type": "string", + "description": "Deprecated, use ` + "`" + `q` + "`" + ` instead.", + "name": "name", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Registry" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link refers to the previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of the resources" + } + } + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "post": { + "description": "Create a registry", + "tags": [ + "registry" + ], + "summary": "Create a registry", + "operationId": "createRegistry", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "description": "The registry", + "name": "registry", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/Registry" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/201" + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "409": { + "$ref": "#/responses/409" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/registries/ping": { + "post": { + "description": "Check status of a registry", + "tags": [ + "registry" + ], + "summary": "Check status of a registry", + "operationId": "pingRegistry", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "description": "The registry", + "name": "registry", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/RegistryPing" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/200" + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/registries/{id}": { + "get": { + "description": "Get the specific registry", + "tags": [ + "registry" + ], + "summary": "Get the specific registry", + "operationId": "getRegistry", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "type": "integer", + "format": "int64", + "description": "Registry ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/Registry" + } + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "put": { + "description": "Update the registry", + "tags": [ + "registry" + ], + "summary": "Update the registry", + "operationId": "updateRegistry", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "type": "integer", + "format": "int64", + "description": "The registry ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "The registry", + "name": "registry", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/RegistryUpdate" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/200" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "409": { + "$ref": "#/responses/409" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "delete": { + "description": "Delete the specific registry", + "tags": [ + "registry" + ], + "summary": "Delete the specific registry", + "operationId": "deleteRegistry", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "type": "integer", + "format": "int64", + "description": "Registry ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/200" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "412": { + "$ref": "#/responses/412" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/registries/{id}/info": { + "get": { + "description": "Get the registry info", + "tags": [ + "registry" + ], + "summary": "Get the registry info", + "operationId": "getRegistryInfo", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "type": "integer", + "format": "int64", + "description": "Registry ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/RegistryInfo" + } + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/replication/adapterinfos": { + "get": { + "description": "List all registered registry provider information", + "tags": [ + "registry" + ], + "summary": "List all registered registry provider information", + "operationId": "listRegistryProviderInfos", + "parameters": [ + { + "$ref": "#/parameters/requestId" + } + ], + "responses": { + "200": { + "description": "Success.", + "schema": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/RegistryProviderInfo" + } + } + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/replication/adapters": { + "get": { + "description": "List registry adapters", + "tags": [ + "registry" + ], + "summary": "List registry adapters", + "operationId": "listRegistryProviderTypes", + "parameters": [ + { + "$ref": "#/parameters/requestId" + } + ], + "responses": { + "200": { + "description": "Success.", + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/replication/executions": { + "get": { + "description": "List replication executions", + "tags": [ + "replication" + ], + "summary": "List replication executions", + "operationId": "listReplicationExecutions", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/sort" + }, + { + "$ref": "#/parameters/page" + }, + { + "$ref": "#/parameters/pageSize" + }, + { + "type": "integer", + "description": "The ID of the policy that the executions belong to.", + "name": "policy_id", + "in": "query" + }, + { + "type": "string", + "description": "The execution status.", + "name": "status", + "in": "query" + }, + { + "type": "string", + "description": "The trigger mode.", + "name": "trigger", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/ReplicationExecution" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link refers to the previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of the resources" + } + } + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "post": { + "description": "Start one replication execution according to the policy", + "tags": [ + "replication" + ], + "summary": "Start one replication execution", + "operationId": "startReplication", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "description": "The ID of policy that the execution belongs to", + "name": "execution", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/StartReplicationExecution" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/201" + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/replication/executions/{id}": { + "get": { + "description": "Get the replication execution specified by ID", + "tags": [ + "replication" + ], + "summary": "Get the specific replication execution", + "operationId": "getReplicationExecution", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "type": "integer", + "format": "int64", + "description": "The ID of the execution.", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/ReplicationExecution" + } + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "put": { + "description": "Stop the replication execution specified by ID", + "tags": [ + "replication" + ], + "summary": "Stop the specific replication execution", + "operationId": "stopReplication", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "type": "integer", + "format": "int64", + "description": "The ID of the execution.", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/200" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/replication/executions/{id}/tasks": { + "get": { + "description": "List replication tasks for a specific execution", + "tags": [ + "replication" + ], + "summary": "List replication tasks for a specific execution", + "operationId": "listReplicationTasks", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/sort" + }, + { + "$ref": "#/parameters/page" + }, + { + "$ref": "#/parameters/pageSize" + }, + { + "type": "integer", + "format": "int64", + "description": "The ID of the execution that the tasks belongs to.", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The task status.", + "name": "status", + "in": "query" + }, + { + "type": "string", + "description": "The resource type.", + "name": "resource_type", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/ReplicationTask" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link refers to the previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of the resources" + } + } + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/replication/executions/{id}/tasks/{task_id}/log": { + "get": { + "description": "Get the log of the specific replication task", + "produces": [ + "text/plain" + ], + "tags": [ + "replication" + ], + "summary": "Get the log of the specific replication task", + "operationId": "getReplicationLog", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "type": "integer", + "format": "int64", + "description": "The ID of the execution that the tasks belongs to.", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "The ID of the task.", + "name": "task_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "string" + }, + "headers": { + "Content-Type": { + "type": "string", + "description": "The content type of response body" + } + } + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/replication/policies": { + "get": { + "description": "List replication policies", + "tags": [ + "replication" + ], + "summary": "List replication policies", + "operationId": "listReplicationPolicies", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/query" + }, + { + "$ref": "#/parameters/sort" + }, + { + "$ref": "#/parameters/page" + }, + { + "$ref": "#/parameters/pageSize" + }, + { + "type": "string", + "description": "Deprecated, use \"query\" instead. The policy name.", + "name": "name", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/ReplicationPolicy" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link refers to the previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of the resources" + } + } + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "post": { + "description": "Create a replication policy", + "tags": [ + "replication" + ], + "summary": "Create a replication policy", + "operationId": "createReplicationPolicy", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "description": "The replication policy", + "name": "policy", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ReplicationPolicy" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/201" + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "409": { + "$ref": "#/responses/409" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/replication/policies/{id}": { + "get": { + "description": "Get the specific replication policy", + "tags": [ + "replication" + ], + "summary": "Get the specific replication policy", + "operationId": "getReplicationPolicy", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "type": "integer", + "format": "int64", + "description": "Policy ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/ReplicationPolicy" + } + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "put": { + "description": "Update the replication policy", + "tags": [ + "replication" + ], + "summary": "Update the replication policy", + "operationId": "updateReplicationPolicy", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "type": "integer", + "format": "int64", + "description": "The policy ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "The replication policy", + "name": "policy", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ReplicationPolicy" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/200" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "409": { + "$ref": "#/responses/409" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "delete": { + "description": "Delete the specific replication policy", + "tags": [ + "replication" + ], + "summary": "Delete the specific replication policy", + "operationId": "deleteReplicationPolicy", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "type": "integer", + "format": "int64", + "description": "Replication policy ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/200" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "412": { + "$ref": "#/responses/412" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/repositories": { + "get": { + "description": "List all authorized repositories", + "tags": [ + "repository" + ], + "summary": "List all authorized repositories", + "operationId": "listAllRepositories", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/query" + }, + { + "$ref": "#/parameters/sort" + }, + { + "$ref": "#/parameters/page" + }, + { + "$ref": "#/parameters/pageSize" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Repository" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link refers to the previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of repositories" + } + } + }, + "400": { + "$ref": "#/responses/400" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/retentions": { + "post": { + "description": "Create Retention Policy, you can reference metadatas API for the policy model. You can check project metadatas to find whether a retention policy is already binded. This method should only be called when no retention policy binded to project yet.", + "tags": [ + "Retention" + ], + "summary": "Create Retention Policy", + "operationId": "createRetention", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "description": "Create Retention Policy successfully.", + "name": "policy", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/RetentionPolicy" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/201" + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/retentions/metadatas": { + "get": { + "description": "Get Retention Metadatas.", + "tags": [ + "Retention" + ], + "summary": "Get Retention Metadatas", + "operationId": "getRentenitionMetadata", + "parameters": [ + { + "$ref": "#/parameters/requestId" + } + ], + "responses": { + "200": { + "description": "Get Retention Metadatas successfully.", + "schema": { + "$ref": "#/definitions/RetentionMetadata" + } + } + } + } + }, + "/retentions/{id}": { + "get": { + "description": "Get Retention Policy.", + "tags": [ + "Retention" + ], + "summary": "Get Retention Policy", + "operationId": "getRetention", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "type": "integer", + "format": "int64", + "description": "Retention ID.", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Get Retention Policy successfully.", + "schema": { + "$ref": "#/definitions/RetentionPolicy" + } + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "put": { + "description": "Update Retention Policy, you can reference metadatas API for the policy model. You can check project metadatas to find whether a retention policy is already binded. This method should only be called when retention policy has already binded to project.", + "tags": [ + "Retention" + ], + "summary": "Update Retention Policy", + "operationId": "updateRetention", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "type": "integer", + "format": "int64", + "description": "Retention ID.", + "name": "id", + "in": "path", + "required": true + }, + { + "name": "policy", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/RetentionPolicy" + } + } + ], + "responses": { + "200": { + "description": "Update Retention Policy successfully." + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "delete": { + "description": "Delete Retention Policy, you can reference metadatas API for the policy model. You can check project metadatas to find whether a retention policy is already binded. This method should only be called when retention policy has already binded to project.", + "tags": [ + "Retention" + ], + "summary": "Delete Retention Policy", + "operationId": "deleteRetention", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "type": "integer", + "format": "int64", + "description": "Retention ID.", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Update Retention Policy successfully." + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/retentions/{id}/executions": { + "get": { + "description": "Get Retention executions, execution status may be delayed before job service schedule it up.", + "tags": [ + "Retention" + ], + "summary": "Get Retention executions", + "operationId": "listRetentionExecutions", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "type": "integer", + "format": "int64", + "description": "Retention ID.", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "The page number.", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "format": "int64", + "description": "The size of per page.", + "name": "page_size", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Get a Retention execution successfully.", + "schema": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/RetentionExecution" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link to previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of available items" + } + } + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "post": { + "description": "Trigger a Retention Execution, if dry_run is True, nothing would be deleted actually.", + "produces": [ + "text/plain" + ], + "tags": [ + "Retention" + ], + "summary": "Trigger a Retention Execution", + "operationId": "triggerRetentionExecution", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "type": "integer", + "format": "int64", + "description": "Retention ID.", + "name": "id", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "type": "object", + "properties": { + "dry_run": { + "type": "boolean" + } + } + } + } + ], + "responses": { + "200": { + "description": "Trigger a Retention job successfully." + }, + "201": { + "$ref": "#/responses/201" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/retentions/{id}/executions/{eid}": { + "patch": { + "description": "Stop a Retention execution, only support \"stop\" action now.", + "tags": [ + "Retention" + ], + "summary": "Stop a Retention execution", + "operationId": "operateRetentionExecution", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "type": "integer", + "format": "int64", + "description": "Retention ID.", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "Retention execution ID.", + "name": "eid", + "in": "path", + "required": true + }, + { + "description": "The action, only support \"stop\" now.", + "name": "body", + "in": "body", + "required": true, + "schema": { + "type": "object", + "properties": { + "action": { + "type": "string" + } + } + } + } + ], + "responses": { + "200": { + "description": "Stop a Retention job successfully." + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/retentions/{id}/executions/{eid}/tasks": { + "get": { + "description": "Get Retention tasks, each repository as a task.", + "tags": [ + "Retention" + ], + "summary": "Get Retention tasks", + "operationId": "listRetentionTasks", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "type": "integer", + "format": "int64", + "description": "Retention ID.", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "Retention execution ID.", + "name": "eid", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "The page number.", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "format": "int64", + "description": "The size of per page.", + "name": "page_size", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Get Retention job tasks successfully.", + "schema": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/RetentionExecutionTask" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link to previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of available items" + } + } + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/retentions/{id}/executions/{eid}/tasks/{tid}": { + "get": { + "description": "Get Retention job task log, tags ratain or deletion detail will be shown in a table.", + "produces": [ + "text/plain" + ], + "tags": [ + "Retention" + ], + "summary": "Get Retention job task log", + "operationId": "getRetentionTaskLog", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "type": "integer", + "format": "int64", + "description": "Retention ID.", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "Retention execution ID.", + "name": "eid", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "Retention execution ID.", + "name": "tid", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Get Retention job task log successfully.", + "schema": { + "type": "string" + } + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/robots": { + "get": { + "description": "List the robot accounts with the specified level and project.", + "tags": [ + "robot" + ], + "summary": "Get robot account", + "operationId": "ListRobot", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/query" + }, + { + "$ref": "#/parameters/sort" + }, + { + "$ref": "#/parameters/page" + }, + { + "$ref": "#/parameters/pageSize" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Robot" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link refers to the previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of robot accounts" + } + } + }, + "400": { + "$ref": "#/responses/400" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "post": { + "description": "Create a robot account", + "tags": [ + "robot" + ], + "summary": "Create a robot account", + "operationId": "CreateRobot", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "description": "The JSON object of a robot account.", + "name": "robot", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/RobotCreate" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/RobotCreated" + }, + "headers": { + "Location": { + "type": "string", + "description": "The location of the resource" + }, + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/robots/{robot_id}": { + "get": { + "description": "This endpoint returns specific robot account information by robot ID.", + "tags": [ + "robot" + ], + "summary": "Get a robot account", + "operationId": "GetRobotByID", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/robotId" + } + ], + "responses": { + "200": { + "description": "Return matched robot information.", + "schema": { + "$ref": "#/definitions/Robot" + } + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "put": { + "description": "This endpoint updates specific robot account information by robot ID.", + "tags": [ + "robot" + ], + "summary": "Update a robot account", + "operationId": "UpdateRobot", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/robotId" + }, + { + "description": "The JSON object of a robot account.", + "name": "robot", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/Robot" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/200" + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "409": { + "$ref": "#/responses/409" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "delete": { + "description": "This endpoint deletes specific robot account information by robot ID.", + "tags": [ + "robot" + ], + "summary": "Delete a robot account", + "operationId": "DeleteRobot", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/robotId" + } + ], + "responses": { + "200": { + "$ref": "#/responses/200" + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "patch": { + "description": "Refresh the robot secret", + "tags": [ + "robot" + ], + "summary": "Refresh the robot secret", + "operationId": "RefreshSec", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/robotId" + }, + { + "description": "The JSON object of a robot account.", + "name": "robotSec", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/RobotSec" + } + } + ], + "responses": { + "200": { + "description": "Return refreshed robot sec.", + "schema": { + "$ref": "#/definitions/RobotSec" + } + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/scanners": { + "get": { + "description": "Returns a list of currently configured scanner registrations.\n", + "tags": [ + "scanner" + ], + "summary": "List scanner registrations", + "operationId": "listScanners", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/query" + }, + { + "$ref": "#/parameters/sort" + }, + { + "$ref": "#/parameters/page" + }, + { + "$ref": "#/parameters/pageSize" + } + ], + "responses": { + "200": { + "description": "A list of scanner registrations.", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/ScannerRegistration" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link to previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of available items" + } + } + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "post": { + "description": "Creats a new scanner registration with the given data.\n", + "tags": [ + "scanner" + ], + "summary": "Create a scanner registration", + "operationId": "createScanner", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "description": "A scanner registration to be created.", + "name": "registration", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ScannerRegistrationReq" + } + } + ], + "responses": { + "201": { + "description": "Created successfully", + "headers": { + "Location": { + "type": "string", + "description": "The URL of the created resource" + } + } + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/scanners/ping": { + "post": { + "description": "Pings scanner adapter to test endpoint URL and authorization settings.\n", + "tags": [ + "scanner" + ], + "summary": "Tests scanner registration settings", + "operationId": "pingScanner", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "description": "A scanner registration settings to be tested.", + "name": "settings", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ScannerRegistrationSettings" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/200" + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/scanners/{registration_id}": { + "get": { + "description": "Retruns the details of the specified scanner registration.\n", + "tags": [ + "scanner" + ], + "summary": "Get a scanner registration details", + "operationId": "getScanner", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "type": "string", + "description": "The scanner registration identifer.", + "name": "registration_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "The details of the scanner registration.", + "schema": { + "$ref": "#/definitions/ScannerRegistration" + } + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "put": { + "description": "Updates the specified scanner registration.\n", + "tags": [ + "scanner" + ], + "summary": "Update a scanner registration", + "operationId": "updateScanner", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "type": "string", + "description": "The scanner registration identifier.", + "name": "registration_id", + "in": "path", + "required": true + }, + { + "description": "A scanner registraiton to be updated.", + "name": "registration", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ScannerRegistrationReq" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/200" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "delete": { + "description": "Deletes the specified scanner registration.\n", + "tags": [ + "scanner" + ], + "summary": "Delete a scanner registration", + "operationId": "deleteScanner", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "type": "string", + "description": "The scanner registration identifier.", + "name": "registration_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Deleted successfully and return the deleted registration", + "schema": { + "$ref": "#/definitions/ScannerRegistration" + } + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "patch": { + "description": "Set the specified scanner registration as the system default one.\n", + "tags": [ + "scanner" + ], + "summary": "Set system default scanner registration", + "operationId": "setScannerAsDefault", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "type": "string", + "description": "The scanner registration identifier.", + "name": "registration_id", + "in": "path", + "required": true + }, + { + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/IsDefault" + } + } + ], + "responses": { + "200": { + "description": "Successfully set the specified scanner registration as system default" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/scanners/{registration_id}/metadata": { + "get": { + "description": "Get the metadata of the specified scanner registration, including the capabilities and customized properties.\n", + "tags": [ + "scanner" + ], + "summary": "Get the metadata of the specified scanner registration", + "operationId": "getScannerMetadata", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "type": "string", + "description": "The scanner registration identifier.", + "name": "registration_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "The metadata of the specified scanner adapter", + "schema": { + "$ref": "#/definitions/ScannerAdapterMetadata" + } + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/scans/all/metrics": { + "get": { + "description": "Get the metrics of the latest scan all process", + "tags": [ + "scanAll" + ], + "summary": "Get the metrics of the latest scan all process", + "operationId": "getLatestScanAllMetrics", + "parameters": [ + { + "$ref": "#/parameters/requestId" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/Stats" + } + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "412": { + "$ref": "#/responses/412" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/scans/schedule/metrics": { + "get": { + "description": "Get the metrics of the latest scheduled scan all process", + "tags": [ + "scanAll" + ], + "summary": "Get the metrics of the latest scheduled scan all process", + "operationId": "getLatestScheduledScanAllMetrics", + "deprecated": true, + "parameters": [ + { + "$ref": "#/parameters/requestId" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/Stats" + } + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "412": { + "$ref": "#/responses/412" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/schedules": { + "get": { + "description": "List schedules", + "tags": [ + "schedule" + ], + "operationId": "listSchedules", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/page" + }, + { + "$ref": "#/parameters/pageSize" + } + ], + "responses": { + "200": { + "description": "list schedule successfully.", + "schema": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/ScheduleTask" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link to previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of available items" + } + } + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/schedules/{job_type}/paused": { + "get": { + "description": "Get scheduler paused status", + "tags": [ + "schedule" + ], + "operationId": "getSchedulePaused", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "type": "string", + "description": "The type of the job. 'all' stands for all job types, current only support query with all", + "name": "job_type", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Get scheduler status successfully.", + "schema": { + "type": "object", + "$ref": "#/definitions/SchedulerStatus" + } + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/search": { + "get": { + "description": "The Search endpoint returns information about the projects, repositories and helm charts offered at public status or related to the current logged in user. The response includes the project, repository list and charts in a proper display order.", + "tags": [ + "search" + ], + "summary": "Search for projects, repositories and helm charts", + "operationId": "search", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "type": "string", + "description": "Search parameter for project and repository name.", + "name": "q", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "An array of search results", + "schema": { + "$ref": "#/definitions/Search" + } + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/statistics": { + "get": { + "description": "Get the statistic information about the projects and repositories", + "tags": [ + "statistic" + ], + "summary": "Get the statistic information about the projects and repositories", + "operationId": "getStatistic", + "parameters": [ + { + "$ref": "#/parameters/requestId" + } + ], + "responses": { + "200": { + "description": "The statistic information", + "schema": { + "$ref": "#/definitions/Statistic" + } + }, + "401": { + "$ref": "#/responses/401" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/system/CVEAllowlist": { + "get": { + "description": "Get the system level allowlist of CVE. This API can be called by all authenticated users.", + "tags": [ + "SystemCVEAllowlist" + ], + "summary": "Get the system level allowlist of CVE.", + "operationId": "getSystemCVEAllowlist", + "parameters": [ + { + "$ref": "#/parameters/requestId" + } + ], + "responses": { + "200": { + "description": "Successfully retrieved the CVE allowlist.", + "schema": { + "$ref": "#/definitions/CVEAllowlist" + } + }, + "401": { + "$ref": "#/responses/401" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "put": { + "description": "This API overwrites the system level allowlist of CVE with the list in request body. Only system Admin has permission to call this API.", + "tags": [ + "SystemCVEAllowlist" + ], + "summary": "Update the system level allowlist of CVE.", + "operationId": "putSystemCVEAllowlist", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "description": "The allowlist with new content", + "name": "allowlist", + "in": "body", + "schema": { + "$ref": "#/definitions/CVEAllowlist" + } + } + ], + "responses": { + "200": { + "description": "Successfully updated the CVE allowlist." + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/system/gc": { + "get": { + "description": "This endpoint let user get gc execution history.", + "tags": [ + "gc" + ], + "summary": "Get gc results.", + "operationId": "getGCHistory", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/query" + }, + { + "$ref": "#/parameters/sort" + }, + { + "$ref": "#/parameters/page" + }, + { + "$ref": "#/parameters/pageSize" + } + ], + "responses": { + "200": { + "description": "Get gc results successfully.", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/GCHistory" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link refers to the previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of history" + } + } + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/system/gc/schedule": { + "get": { + "description": "This endpoint is for get schedule of gc job.", + "tags": [ + "gc" + ], + "summary": "Get gc's schedule.", + "operationId": "getGCSchedule", + "parameters": [ + { + "$ref": "#/parameters/requestId" + } + ], + "responses": { + "200": { + "description": "Get gc's schedule.", + "schema": { + "$ref": "#/definitions/GCHistory" + } + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "put": { + "description": "This endpoint is for update gc schedule.\n", + "tags": [ + "gc" + ], + "summary": "Update gc's schedule.", + "operationId": "updateGCSchedule", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "description": "Updates of gc's schedule.", + "name": "schedule", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/Schedule" + } + } + ], + "responses": { + "200": { + "description": "Updated gc's schedule successfully." + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "post": { + "description": "This endpoint is for update gc schedule.\n", + "tags": [ + "gc" + ], + "summary": "Create a gc schedule.", + "operationId": "createGCSchedule", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "description": "Updates of gc's schedule.", + "name": "schedule", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/Schedule" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/201" + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "409": { + "$ref": "#/responses/409" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/system/gc/{gc_id}": { + "get": { + "description": "This endpoint let user get gc status filtered by specific ID.", + "tags": [ + "gc" + ], + "summary": "Get gc status.", + "operationId": "getGC", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/gcId" + } + ], + "responses": { + "200": { + "description": "Get gc results successfully.", + "schema": { + "$ref": "#/definitions/GCHistory" + } + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "put": { + "description": "Stop the GC execution specified by ID", + "tags": [ + "gc" + ], + "summary": "Stop the specific GC execution", + "operationId": "stopGC", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/gcId" + } + ], + "responses": { + "200": { + "$ref": "#/responses/200" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/system/gc/{gc_id}/log": { + "get": { + "description": "This endpoint let user get gc job logs filtered by specific ID.", + "produces": [ + "text/plain" + ], + "tags": [ + "gc" + ], + "summary": "Get gc job log.", + "operationId": "getGCLog", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/gcId" + } + ], + "responses": { + "200": { + "description": "Get successfully.", + "schema": { + "type": "string" + } + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/system/oidc/ping": { + "post": { + "description": "Test the OIDC endpoint, the setting of the endpoint is provided in the request. This API can only be called by system admin.\n", + "tags": [ + "oidc" + ], + "summary": "Test the OIDC endpoint.", + "operationId": "pingOIDC", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "description": "Request body for OIDC endpoint to be tested.", + "name": "endpoint", + "in": "body", + "required": true, + "schema": { + "type": "object", + "properties": { + "url": { + "description": "The URL of OIDC endpoint to be tested.", + "type": "string" + }, + "verify_cert": { + "description": "Whether the certificate should be verified", + "type": "boolean" + } + } + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/200" + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + } + } + } + }, + "/system/purgeaudit": { + "get": { + "description": "get purge job execution history.", + "tags": [ + "purge" + ], + "summary": "Get purge job results.", + "operationId": "getPurgeHistory", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/query" + }, + { + "$ref": "#/parameters/sort" + }, + { + "$ref": "#/parameters/page" + }, + { + "$ref": "#/parameters/pageSize" + } + ], + "responses": { + "200": { + "description": "Get purge job results successfully.", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/ExecHistory" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link refers to the previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of history" + } + } + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/system/purgeaudit/schedule": { + "get": { + "description": "This endpoint is for get schedule of purge job.", + "tags": [ + "purge" + ], + "summary": "Get purge's schedule.", + "operationId": "getPurgeSchedule", + "parameters": [ + { + "$ref": "#/parameters/requestId" + } + ], + "responses": { + "200": { + "description": "Get purge job's schedule.", + "schema": { + "$ref": "#/definitions/ExecHistory" + } + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "put": { + "description": "This endpoint is for update purge job schedule.\n", + "tags": [ + "purge" + ], + "summary": "Update purge job's schedule.", + "operationId": "updatePurgeSchedule", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "description": "The purge job's schedule, it is a json object. |\nThe sample format is |\n{\"parameters\":{\"audit_retention_hour\":168,\"dry_run\":true, \"include_operations\":\"create,delete,pull\"},\"schedule\":{\"type\":\"Hourly\",\"cron\":\"0 0 * * * *\"}} |\nthe include_operation should be a comma separated string, e.g. create,delete,pull, if it is empty, no operation will be purged.\n", + "name": "schedule", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/Schedule" + } + } + ], + "responses": { + "200": { + "description": "Updated purge's schedule successfully." + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "post": { + "description": "This endpoint is for update purge job schedule.\n", + "tags": [ + "purge" + ], + "summary": "Create a purge job schedule.", + "operationId": "createPurgeSchedule", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "description": "The purge job's schedule, it is a json object. |\nThe sample format is |\n{\"parameters\":{\"audit_retention_hour\":168,\"dry_run\":true, \"include_operations\":\"create,delete,pull\"},\"schedule\":{\"type\":\"Hourly\",\"cron\":\"0 0 * * * *\"}} |\nthe include_operation should be a comma separated string, e.g. create,delete,pull, if it is empty, no operation will be purged.\n", + "name": "schedule", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/Schedule" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/201" + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/system/purgeaudit/{purge_id}": { + "get": { + "description": "This endpoint let user get purge job status filtered by specific ID.", + "tags": [ + "purge" + ], + "summary": "Get purge job status.", + "operationId": "getPurgeJob", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/purgeId" + } + ], + "responses": { + "200": { + "description": "Get purge job results successfully.", + "schema": { + "$ref": "#/definitions/ExecHistory" + } + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "put": { + "description": "Stop the purge audit log execution specified by ID", + "tags": [ + "purge" + ], + "summary": "Stop the specific purge audit log execution", + "operationId": "stopPurge", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/purgeId" + } + ], + "responses": { + "200": { + "$ref": "#/responses/200" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/system/purgeaudit/{purge_id}/log": { + "get": { + "description": "This endpoint let user get purge job logs filtered by specific ID.", + "produces": [ + "text/plain" + ], + "tags": [ + "purge" + ], + "summary": "Get purge job log.", + "operationId": "getPurgeJobLog", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/purgeId" + } + ], + "responses": { + "200": { + "description": "Get successfully.", + "schema": { + "type": "string" + } + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/system/scanAll/schedule": { + "get": { + "description": "This endpoint is for getting a schedule for the scan all job, which scans all of images in Harbor.", + "tags": [ + "scanAll" + ], + "summary": "Get scan all's schedule.", + "operationId": "getScanAllSchedule", + "parameters": [ + { + "$ref": "#/parameters/requestId" + } + ], + "responses": { + "200": { + "description": "Get a schedule for the scan all job, which scans all of images in Harbor.", + "schema": { + "$ref": "#/definitions/Schedule" + } + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "412": { + "$ref": "#/responses/412" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "put": { + "description": "This endpoint is for updating the schedule of scan all job, which scans all of images in Harbor.", + "tags": [ + "scanAll" + ], + "summary": "Update scan all's schedule.", + "operationId": "updateScanAllSchedule", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "description": "Updates the schedule of scan all job, which scans all of images in Harbor.", + "name": "schedule", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/Schedule" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/200" + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "412": { + "$ref": "#/responses/412" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "post": { + "description": "This endpoint is for creating a schedule or a manual trigger for the scan all job, which scans all of images in Harbor.", + "tags": [ + "scanAll" + ], + "summary": "Create a schedule or a manual trigger for the scan all job.", + "operationId": "createScanAllSchedule", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "description": "Create a schedule or a manual trigger for the scan all job.", + "name": "schedule", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/Schedule" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/201" + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "409": { + "$ref": "#/responses/409" + }, + "412": { + "$ref": "#/responses/412" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/system/scanAll/stop": { + "post": { + "description": "Stop scanAll job execution", + "tags": [ + "scanAll" + ], + "summary": "Stop scanAll job execution", + "operationId": "stopScanAll", + "parameters": [ + { + "$ref": "#/parameters/requestId" + } + ], + "responses": { + "202": { + "$ref": "#/responses/202" + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/systeminfo": { + "get": { + "description": "This API is for retrieving general system info, this can be called by anonymous request. Some attributes will be omitted in the response when this API is called by anonymous request.\n", + "tags": [ + "systeminfo" + ], + "summary": "Get general system info", + "operationId": "getSystemInfo", + "parameters": [ + { + "$ref": "#/parameters/requestId" + } + ], + "responses": { + "200": { + "description": "Get general info successfully.", + "schema": { + "$ref": "#/definitions/GeneralInfo" + } + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/systeminfo/getcert": { + "get": { + "description": "This endpoint is for downloading a default root certificate.\n", + "produces": [ + "application/octet-stream" + ], + "tags": [ + "systeminfo" + ], + "summary": "Get default root certificate.", + "operationId": "getCert", + "parameters": [ + { + "$ref": "#/parameters/requestId" + } + ], + "responses": { + "200": { + "description": "Get default root certificate successfully.", + "schema": { + "type": "file" + }, + "headers": { + "Content-Disposition": { + "type": "string", + "description": "To set the filename of the downloaded file." + } + } + }, + "404": { + "description": "Not found the default root certificate." + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/systeminfo/volumes": { + "get": { + "description": "This endpoint is for retrieving system volume info that only provides for admin user. Note that the response only reflects the storage status of local disk.\n", + "tags": [ + "systeminfo" + ], + "summary": "Get system volume info (total/free size).", + "operationId": "getVolumes", + "parameters": [ + { + "$ref": "#/parameters/requestId" + } + ], + "responses": { + "200": { + "description": "Get system volumes successfully.", + "schema": { + "$ref": "#/definitions/SystemInfo" + } + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/usergroups": { + "get": { + "description": "Get all user groups information, it is open for system admin", + "tags": [ + "usergroup" + ], + "summary": "Get all user groups information", + "operationId": "listUserGroups", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/page" + }, + { + "$ref": "#/parameters/pageSize" + }, + { + "type": "string", + "description": "search with ldap group DN", + "name": "ldap_group_dn", + "in": "query" + }, + { + "type": "string", + "description": "group name need to search, fuzzy matches", + "name": "group_name", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Get user group successfully.", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/UserGroup" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link to previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of available items" + } + } + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "post": { + "description": "Create user group information", + "tags": [ + "usergroup" + ], + "summary": "Create user group", + "operationId": "createUserGroup", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "name": "usergroup", + "in": "body", + "schema": { + "$ref": "#/definitions/UserGroup" + } + } + ], + "responses": { + "201": { + "description": "User group created successfully.", + "headers": { + "Location": { + "type": "string", + "description": "The URL of the created resource" + } + } + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "409": { + "$ref": "#/responses/409" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/usergroups/search": { + "get": { + "description": "This endpoint is to search groups by group name. It's open for all authenticated requests.\n", + "tags": [ + "usergroup" + ], + "summary": "Search groups by groupname", + "operationId": "searchUserGroups", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/page" + }, + { + "$ref": "#/parameters/pageSize" + }, + { + "type": "string", + "description": "Group name for filtering results.", + "name": "groupname", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "Search groups successfully.", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/UserGroupSearchItem" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link to previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of available items" + } + } + }, + "401": { + "$ref": "#/responses/401" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/usergroups/{group_id}": { + "get": { + "description": "Get user group information", + "tags": [ + "usergroup" + ], + "summary": "Get user group information", + "operationId": "getUserGroup", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "type": "integer", + "format": "int64", + "description": "Group ID", + "name": "group_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "User group get successfully.", + "schema": { + "$ref": "#/definitions/UserGroup" + } + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "put": { + "description": "Update user group information", + "tags": [ + "usergroup" + ], + "summary": "Update group information", + "operationId": "updateUserGroup", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "type": "integer", + "format": "int64", + "description": "Group ID", + "name": "group_id", + "in": "path", + "required": true + }, + { + "name": "usergroup", + "in": "body", + "schema": { + "$ref": "#/definitions/UserGroup" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/200" + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "delete": { + "description": "Delete user group", + "tags": [ + "usergroup" + ], + "summary": "Delete user group", + "operationId": "deleteUserGroup", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "type": "integer", + "name": "group_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/200" + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/users": { + "get": { + "tags": [ + "user" + ], + "summary": "List users", + "operationId": "listUsers", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/query" + }, + { + "$ref": "#/parameters/sort" + }, + { + "$ref": "#/parameters/page" + }, + { + "$ref": "#/parameters/pageSize" + } + ], + "responses": { + "200": { + "description": "return the list of users.", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/UserResp" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link to previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of users" + } + } + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "post": { + "description": "This API can be used only when the authentication mode is for local DB. When self registration is disabled.", + "tags": [ + "user" + ], + "summary": "Create a local user.", + "operationId": "createUser", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "description": "The new user", + "name": "userReq", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/UserCreationReq" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/201" + }, + "400": { + "$ref": "#/responses/400" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "description": "When the self registration is disabled, non-admin does not have permission to create user. When self registration is enabled, this API can only be called from UI portal, calling it via script will get a 403 error." + }, + "409": { + "$ref": "#/responses/409" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/users/current": { + "get": { + "tags": [ + "user" + ], + "summary": "Get current user info.", + "operationId": "getCurrentUserInfo", + "parameters": [ + { + "$ref": "#/parameters/requestId" + } + ], + "responses": { + "200": { + "description": "Get current user information successfully.", + "schema": { + "$ref": "#/definitions/UserResp" + } + }, + "401": { + "$ref": "#/responses/401" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/users/current/permissions": { + "get": { + "tags": [ + "user" + ], + "summary": "Get current user permissions.", + "operationId": "getCurrentUserPermissions", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "type": "string", + "description": "The scope for the permission", + "name": "scope", + "in": "query" + }, + { + "type": "boolean", + "description": "If true, the resources in the response are relative to the scope,\neg for resource '/project/1/repository' if relative is 'true' then the resource in response will be 'repository'.\n", + "name": "relative", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Get current user permission successfully.", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Permission" + } + } + }, + "401": { + "description": "User need to log in first." + }, + "500": { + "description": "Internal errors." + } + } + } + }, + "/users/search": { + "get": { + "description": "This endpoint is to search the users by username. It's open for all authenticated requests.\n", + "tags": [ + "user" + ], + "summary": "Search users by username", + "operationId": "searchUsers", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "$ref": "#/parameters/page" + }, + { + "$ref": "#/parameters/pageSize" + }, + { + "type": "string", + "description": "Username for filtering results.", + "name": "username", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "Search users by username successfully.", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/UserSearchRespItem" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link to previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of available items" + } + } + }, + "401": { + "$ref": "#/responses/401" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/users/{user_id}": { + "get": { + "tags": [ + "user" + ], + "summary": "Get a user's profile.", + "operationId": "getUser", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "type": "integer", + "format": "int", + "name": "user_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Get user's info successfully.", + "schema": { + "$ref": "#/definitions/UserResp" + } + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "put": { + "tags": [ + "user" + ], + "summary": "Update user's profile.", + "operationId": "updateUserProfile", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "type": "integer", + "format": "int", + "description": "Registered user ID", + "name": "user_id", + "in": "path", + "required": true + }, + { + "description": "Only email, realname and comment can be modified.", + "name": "profile", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/UserProfile" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/200" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + }, + "delete": { + "description": "This endpoint let administrator of Harbor mark a registered user as removed.It actually won't be deleted from DB.\n", + "tags": [ + "user" + ], + "summary": "Mark a registered user as be removed.", + "operationId": "deleteUser", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "type": "integer", + "format": "int", + "description": "User ID for marking as to be removed.", + "name": "user_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/200" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/users/{user_id}/cli_secret": { + "put": { + "description": "This endpoint let user generate a new CLI secret for himself. This API only works when auth mode is set to 'OIDC'. Once this API returns with successful status, the old secret will be invalid, as there will be only one CLI secret for a user.", + "tags": [ + "user" + ], + "summary": "Set CLI secret for a user.", + "operationId": "setCliSecret", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "type": "integer", + "format": "int", + "description": "User ID", + "name": "user_id", + "in": "path", + "required": true + }, + { + "name": "secret", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/OIDCCliSecretReq" + } + } + ], + "responses": { + "200": { + "description": "The secret is successfully updated" + }, + "400": { + "description": "Invalid user ID. Or user is not onboarded via OIDC authentication. Or the secret does not meet the standard." + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "412": { + "description": "The auth mode of the system is not \"oidc_auth\", or the user is not onboarded via OIDC AuthN." + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/users/{user_id}/password": { + "put": { + "description": "This endpoint is for user to update password. Users with the admin role can change any user's password. Regular users can change only their own password.\n", + "tags": [ + "user" + ], + "summary": "Change the password on a user that already exists.", + "operationId": "updateUserPassword", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "type": "integer", + "format": "int", + "name": "user_id", + "in": "path", + "required": true + }, + { + "description": "Password to be updated, the attribute 'old_password' is optional when the API is called by the system administrator.", + "name": "password", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/PasswordReq" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/200" + }, + "400": { + "description": "Invalid user ID; Password does not meet requirement" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "description": "The caller does not have permission to update the password of the user with given ID, or the old password in request body is not correct." + }, + "500": { + "$ref": "#/responses/500" + } + } + } + }, + "/users/{user_id}/sysadmin": { + "put": { + "tags": [ + "user" + ], + "summary": "Update a registered user to change to be an administrator of Harbor.", + "operationId": "setUserSysAdmin", + "parameters": [ + { + "$ref": "#/parameters/requestId" + }, + { + "type": "integer", + "format": "int", + "name": "user_id", + "in": "path", + "required": true + }, + { + "description": "Toggle a user to admin or not.", + "name": "sysadmin_flag", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/UserSysAdminFlag" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/200" + }, + "401": { + "$ref": "#/responses/401" + }, + "403": { + "$ref": "#/responses/403" + }, + "404": { + "$ref": "#/responses/404" + }, + "500": { + "description": "Unexpected internal errors." + } + } + } + } + }, + "definitions": { + "Access": { + "type": "object", + "properties": { + "action": { + "description": "The action of the access", + "type": "string" + }, + "effect": { + "description": "The effect of the access", + "type": "string" + }, + "resource": { + "description": "The resource of the access", + "type": "string" + } + } + }, + "Accessory": { + "description": "The accessory of the artifact", + "type": "object", + "properties": { + "artifact_id": { + "description": "The artifact id of the accessory", + "type": "integer", + "format": "int64", + "x-omitempty": false + }, + "creation_time": { + "description": "The creation time of the accessory", + "type": "string", + "format": "date-time" + }, + "digest": { + "description": "The artifact digest of the accessory", + "type": "string", + "x-omitempty": false + }, + "icon": { + "description": "The icon of the accessory", + "type": "string", + "x-omitempty": false + }, + "id": { + "description": "The ID of the accessory", + "type": "integer", + "format": "int64" + }, + "size": { + "description": "The artifact size of the accessory", + "type": "integer", + "format": "int64", + "x-omitempty": false + }, + "subject_artifact_id": { + "description": "The subject artifact id of the accessory", + "type": "integer", + "format": "int64", + "x-omitempty": false + }, + "type": { + "description": "The artifact size of the accessory", + "type": "string", + "x-omitempty": false + } + } + }, + "ActionRequest": { + "description": "The request to stop, pause or resume", + "type": "object", + "properties": { + "action": { + "description": "The action of the request, should be stop, pause or resume", + "type": "string", + "enum": [ + "stop", + "pause", + "resume" + ] + } + } + }, + "AdditionLink": { + "type": "object", + "properties": { + "absolute": { + "description": "Determine whether the link is an absolute URL or not", + "type": "boolean", + "x-omitempty": false + }, + "href": { + "description": "The link of the addition", + "type": "string" + } + } + }, + "AdditionLinks": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/AdditionLink" + } + }, + "Annotations": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "Artifact": { + "type": "object", + "properties": { + "accessories": { + "type": "array", + "items": { + "description": "The accessory of the artifact.", + "$ref": "#/definitions/Accessory" + } + }, + "addition_links": { + "$ref": "#/definitions/AdditionLinks" + }, + "annotations": { + "$ref": "#/definitions/Annotations" + }, + "digest": { + "description": "The digest of the artifact", + "type": "string" + }, + "extra_attrs": { + "$ref": "#/definitions/ExtraAttrs" + }, + "icon": { + "description": "The digest of the icon", + "type": "string" + }, + "id": { + "description": "The ID of the artifact", + "type": "integer", + "format": "int64" + }, + "labels": { + "type": "array", + "items": { + "$ref": "#/definitions/Label" + } + }, + "manifest_media_type": { + "description": "The manifest media type of the artifact", + "type": "string" + }, + "media_type": { + "description": "The media type of the artifact", + "type": "string" + }, + "project_id": { + "description": "The ID of the project that the artifact belongs to", + "type": "integer", + "format": "int64" + }, + "pull_time": { + "description": "The latest pull time of the artifact", + "type": "string", + "format": "date-time" + }, + "push_time": { + "description": "The push time of the artifact", + "type": "string", + "format": "date-time" + }, + "references": { + "type": "array", + "items": { + "$ref": "#/definitions/Reference" + } + }, + "repository_id": { + "description": "The ID of the repository that the artifact belongs to", + "type": "integer", + "format": "int64" + }, + "scan_overview": { + "description": "The overview of the scan result.", + "$ref": "#/definitions/ScanOverview" + }, + "size": { + "description": "The size of the artifact", + "type": "integer", + "format": "int64" + }, + "tags": { + "type": "array", + "items": { + "$ref": "#/definitions/Tag" + } + }, + "type": { + "description": "The type of the artifact, e.g. image, chart, etc", + "type": "string" + } + } + }, + "AuditLog": { + "type": "object", + "properties": { + "id": { + "description": "The ID of the audit log entry.", + "type": "integer" + }, + "op_time": { + "description": "The time when this operation is triggered.", + "type": "string", + "format": "date-time", + "example": "2006-01-02T15:04:05Z" + }, + "operation": { + "description": "The operation against the repository in this log entry.", + "type": "string" + }, + "resource": { + "description": "Name of the repository in this log entry.", + "type": "string" + }, + "resource_type": { + "description": "Tag of the repository in this log entry.", + "type": "string" + }, + "username": { + "description": "Username of the user in this log entry.", + "type": "string" + } + } + }, + "AuthproxySetting": { + "type": "object", + "properties": { + "endpoint": { + "description": "The fully qualified URI of login endpoint of authproxy, such as 'https://192.168.1.2:8443/login'", + "type": "string" + }, + "server_certificate": { + "description": "The certificate to be pinned when connecting auth proxy.", + "type": "string" + }, + "skip_search": { + "description": "The flag to determine whether Harbor can skip search the user/group when adding him as a member.", + "type": "boolean" + }, + "tokenreivew_endpoint": { + "description": "The fully qualified URI of token review endpoint of authproxy, such as 'https://192.168.1.2:8443/tokenreview'", + "type": "string" + }, + "verify_cert": { + "description": "The flag to determine whether Harbor should verify the certificate when connecting to the auth proxy.", + "type": "boolean" + } + } + }, + "BoolConfigItem": { + "type": "object", + "properties": { + "editable": { + "description": "The configure item can be updated or not", + "type": "boolean", + "x-omitempty": false + }, + "value": { + "description": "The boolean value of current config item", + "type": "boolean", + "x-omitempty": false + } + } + }, + "CVEAllowlist": { + "description": "The CVE Allowlist for system or project", + "type": "object", + "properties": { + "creation_time": { + "description": "The creation time of the allowlist.", + "type": "string", + "format": "date-time" + }, + "expires_at": { + "description": "the time for expiration of the allowlist, in the form of seconds since epoch. This is an optional attribute, if it's not set the CVE allowlist does not expire.", + "type": "integer", + "x-nullable": true + }, + "id": { + "description": "ID of the allowlist", + "type": "integer" + }, + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/CVEAllowlistItem" + } + }, + "project_id": { + "description": "ID of the project which the allowlist belongs to. For system level allowlist this attribute is zero.", + "type": "integer" + }, + "update_time": { + "description": "The update time of the allowlist.", + "type": "string", + "format": "date-time" + } + } + }, + "CVEAllowlistItem": { + "description": "The item in CVE allowlist", + "type": "object", + "properties": { + "cve_id": { + "description": "The ID of the CVE, such as \"CVE-2019-10164\"", + "type": "string" + } + } + }, + "ChartMetadata": { + "description": "The metadata of chart version", + "type": "object", + "required": [ + "name", + "version", + "engine", + "icon", + "apiVersion", + "appVersion" + ], + "properties": { + "apiVersion": { + "description": "The API version of this chart", + "type": "string" + }, + "appVersion": { + "description": "The version of the application enclosed in the chart", + "type": "string" + }, + "deprecated": { + "description": "Whether or not this chart is deprecated", + "type": "boolean" + }, + "description": { + "description": "A one-sentence description of chart", + "type": "string" + }, + "engine": { + "description": "The name of template engine", + "type": "string" + }, + "home": { + "description": "The URL to the relevant project page", + "type": "string" + }, + "icon": { + "description": "The URL to an icon file", + "type": "string" + }, + "keywords": { + "description": "A list of string keywords", + "type": "array", + "items": { + "type": "string" + } + }, + "name": { + "description": "The name of the chart", + "type": "string" + }, + "sources": { + "description": "The URL to the source code of chart", + "type": "array", + "items": { + "type": "string" + } + }, + "version": { + "description": "A SemVer 2 version of chart", + "type": "string" + } + } + }, + "ChartVersion": { + "description": "A specified chart entry", + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/ChartMetadata" + }, + { + "type": "object", + "properties": { + "created": { + "description": "The created time of the chart entry", + "type": "string" + }, + "digest": { + "description": "The digest value of the chart entry", + "type": "string" + }, + "removed": { + "description": "A flag to indicate if the chart entry is removed", + "type": "boolean" + }, + "urls": { + "description": "The urls of the chart entry", + "type": "array", + "items": { + "type": "string" + } + } + } + } + ], + "properties": { + "labels": { + "description": "A list of label", + "type": "array", + "items": { + "$ref": "#/definitions/Label" + } + } + } + }, + "ComponentHealthStatus": { + "description": "The health status of component", + "type": "object", + "properties": { + "error": { + "description": "(optional) The error message when the status is \"unhealthy\"", + "type": "string" + }, + "name": { + "description": "The component name", + "type": "string" + }, + "status": { + "description": "The health status of component", + "type": "string" + } + } + }, + "Configurations": { + "type": "object", + "properties": { + "audit_log_forward_endpoint": { + "description": "The audit log forward endpoint", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "auth_mode": { + "description": "The auth mode of current system, such as \"db_auth\", \"ldap_auth\", \"oidc_auth\"", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "http_authproxy_admin_groups": { + "description": "The group which has the harbor admin privileges", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "http_authproxy_admin_usernames": { + "description": "The username which has the harbor admin privileges", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "http_authproxy_endpoint": { + "description": "The endpoint of the HTTP auth", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "http_authproxy_server_certificate": { + "description": "The certificate of the HTTP auth provider", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "http_authproxy_skip_search": { + "description": "Search user before onboard", + "type": "boolean", + "x-isnullable": true, + "x-omitempty": true + }, + "http_authproxy_tokenreview_endpoint": { + "description": "The token review endpoint", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "http_authproxy_verify_cert": { + "description": "Verify the HTTP auth provider's certificate", + "type": "boolean", + "x-isnullable": true, + "x-omitempty": true + }, + "ldap_base_dn": { + "description": "The Base DN for LDAP binding.", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "ldap_filter": { + "description": "The filter for LDAP search", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "ldap_group_admin_dn": { + "description": "Specify the ldap group which have the same privilege with Harbor admin", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "ldap_group_attribute_name": { + "description": "The attribute which is used as identity of the LDAP group, default is cn.'", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "ldap_group_base_dn": { + "description": "The base DN to search LDAP group.", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "ldap_group_membership_attribute": { + "description": "The user attribute to identify the group membership", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "ldap_group_search_filter": { + "description": "The filter to search the ldap group", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "ldap_group_search_scope": { + "description": "The scope to search ldap group. ''0-LDAP_SCOPE_BASE, 1-LDAP_SCOPE_ONELEVEL, 2-LDAP_SCOPE_SUBTREE''", + "type": "integer", + "x-isnullable": true, + "x-omitempty": true + }, + "ldap_scope": { + "description": "The scope to search ldap users,'0-LDAP_SCOPE_BASE, 1-LDAP_SCOPE_ONELEVEL, 2-LDAP_SCOPE_SUBTREE'", + "type": "integer", + "x-isnullable": true, + "x-omitempty": true + }, + "ldap_search_dn": { + "description": "The DN of the user to do the search.", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "ldap_search_password": { + "description": "The password of the ldap search dn", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "ldap_timeout": { + "description": "Timeout in seconds for connection to LDAP server", + "type": "integer", + "x-isnullable": true, + "x-omitempty": true + }, + "ldap_uid": { + "description": "The attribute which is used as identity for the LDAP binding, such as \"CN\" or \"SAMAccountname\"", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "ldap_url": { + "description": "The URL of LDAP server", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "ldap_verify_cert": { + "description": "Whether verify your OIDC server certificate, disable it if your OIDC server is hosted via self-hosted certificate.", + "type": "boolean", + "x-isnullable": true, + "x-omitempty": true + }, + "notification_enable": { + "description": "Enable notification", + "type": "boolean", + "x-isnullable": true, + "x-omitempty": true + }, + "oidc_admin_group": { + "description": "The OIDC group which has the harbor admin privileges", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "oidc_auto_onboard": { + "description": "Auto onboard the OIDC user", + "type": "boolean", + "x-isnullable": true, + "x-omitempty": true + }, + "oidc_client_id": { + "description": "The client ID of the OIDC provider", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "oidc_client_secret": { + "description": "The OIDC provider secret", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "oidc_endpoint": { + "description": "The endpoint of the OIDC provider", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "oidc_extra_redirect_parms": { + "description": "Extra parameters to add when redirect request to OIDC provider", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "oidc_group_filter": { + "description": "The OIDC group filter which filters out the group name doesn't match the regular expression", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "oidc_groups_claim": { + "description": "The attribute claims the group name", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "oidc_name": { + "description": "The OIDC provider name", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "oidc_scope": { + "description": "The scope of the OIDC provider", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "oidc_user_claim": { + "description": "The attribute claims the username", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "oidc_verify_cert": { + "description": "Verify the OIDC provider's certificate'", + "type": "boolean", + "x-isnullable": true, + "x-omitempty": true + }, + "project_creation_restriction": { + "description": "Indicate who can create projects, it could be ''adminonly'' or ''everyone''.", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "quota_per_project_enable": { + "description": "Enable quota per project", + "type": "boolean", + "x-isnullable": true, + "x-omitempty": true + }, + "read_only": { + "description": "The flag to indicate whether Harbor is in readonly mode.", + "type": "boolean", + "x-isnullable": true, + "x-omitempty": true + }, + "robot_name_prefix": { + "description": "The rebot account name prefix", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "robot_token_duration": { + "description": "The robot account token duration in days", + "type": "integer", + "x-isnullable": true, + "x-omitempty": true + }, + "self_registration": { + "description": "Whether the Harbor instance supports self-registration. If it''s set to false, admin need to add user to the instance.", + "type": "boolean", + "x-isnullable": true, + "x-omitempty": true + }, + "session_timeout": { + "description": "The session timeout for harbor, in minutes.", + "type": "integer", + "x-isnullable": true, + "x-omitempty": true + }, + "skip_audit_log_database": { + "description": "Skip audit log database", + "type": "boolean", + "x-isnullable": true, + "x-omitempty": true + }, + "storage_per_project": { + "description": "The storage quota per project", + "type": "integer", + "x-isnullable": true, + "x-omitempty": true + }, + "token_expiration": { + "description": "The expiration time of the token for internal Registry, in minutes.", + "type": "integer", + "x-isnullable": true, + "x-omitempty": true + }, + "uaa_client_id": { + "description": "The client id of UAA", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "uaa_client_secret": { + "description": "The client secret of the UAA", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "uaa_endpoint": { + "description": "The endpoint of the UAA", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "uaa_verify_cert": { + "description": "Verify the certificate in UAA server", + "type": "boolean", + "x-isnullable": true, + "x-omitempty": true + } + } + }, + "ConfigurationsResponse": { + "type": "object", + "properties": { + "audit_log_forward_endpoint": { + "description": "The endpoint of the audit log forwarder", + "$ref": "#/definitions/StringConfigItem" + }, + "auth_mode": { + "description": "The auth mode of current system, such as \"db_auth\", \"ldap_auth\", \"oidc_auth\"", + "$ref": "#/definitions/StringConfigItem" + }, + "http_authproxy_admin_groups": { + "description": "The group which has the harbor admin privileges", + "$ref": "#/definitions/StringConfigItem" + }, + "http_authproxy_admin_usernames": { + "description": "The usernames which has the harbor admin privileges", + "$ref": "#/definitions/StringConfigItem" + }, + "http_authproxy_endpoint": { + "description": "The endpoint of the HTTP auth", + "$ref": "#/definitions/StringConfigItem" + }, + "http_authproxy_server_certificate": { + "description": "The certificate of the HTTP auth provider", + "$ref": "#/definitions/StringConfigItem" + }, + "http_authproxy_skip_search": { + "description": "Search user before onboard", + "$ref": "#/definitions/BoolConfigItem" + }, + "http_authproxy_tokenreview_endpoint": { + "description": "The token review endpoint", + "$ref": "#/definitions/StringConfigItem" + }, + "http_authproxy_verify_cert": { + "description": "Verify the HTTP auth provider's certificate", + "$ref": "#/definitions/BoolConfigItem" + }, + "ldap_base_dn": { + "description": "The Base DN for LDAP binding.", + "$ref": "#/definitions/StringConfigItem" + }, + "ldap_filter": { + "description": "The filter for LDAP search", + "$ref": "#/definitions/StringConfigItem" + }, + "ldap_group_admin_dn": { + "description": "Specify the ldap group which have the same privilege with Harbor admin", + "$ref": "#/definitions/StringConfigItem" + }, + "ldap_group_attribute_name": { + "description": "The attribute which is used as identity of the LDAP group, default is cn.'", + "$ref": "#/definitions/StringConfigItem" + }, + "ldap_group_base_dn": { + "description": "The base DN to search LDAP group.", + "$ref": "#/definitions/StringConfigItem" + }, + "ldap_group_membership_attribute": { + "description": "The user attribute to identify the group membership", + "$ref": "#/definitions/StringConfigItem" + }, + "ldap_group_search_filter": { + "description": "The filter to search the ldap group", + "$ref": "#/definitions/StringConfigItem" + }, + "ldap_group_search_scope": { + "description": "The scope to search ldap group. ''0-LDAP_SCOPE_BASE, 1-LDAP_SCOPE_ONELEVEL, 2-LDAP_SCOPE_SUBTREE''", + "$ref": "#/definitions/IntegerConfigItem" + }, + "ldap_scope": { + "description": "The scope to search ldap users,'0-LDAP_SCOPE_BASE, 1-LDAP_SCOPE_ONELEVEL, 2-LDAP_SCOPE_SUBTREE'", + "$ref": "#/definitions/IntegerConfigItem" + }, + "ldap_search_dn": { + "description": "The DN of the user to do the search.", + "$ref": "#/definitions/StringConfigItem" + }, + "ldap_timeout": { + "description": "Timeout in seconds for connection to LDAP server", + "$ref": "#/definitions/IntegerConfigItem" + }, + "ldap_uid": { + "description": "The attribute which is used as identity for the LDAP binding, such as \"CN\" or \"SAMAccountname\"", + "$ref": "#/definitions/StringConfigItem" + }, + "ldap_url": { + "description": "The URL of LDAP server", + "$ref": "#/definitions/StringConfigItem" + }, + "ldap_verify_cert": { + "description": "Whether verify your OIDC server certificate, disable it if your OIDC server is hosted via self-hosted certificate.", + "$ref": "#/definitions/BoolConfigItem" + }, + "notification_enable": { + "description": "Enable notification", + "$ref": "#/definitions/BoolConfigItem" + }, + "oidc_admin_group": { + "description": "The OIDC group which has the harbor admin privileges", + "$ref": "#/definitions/StringConfigItem" + }, + "oidc_auto_onboard": { + "description": "Auto onboard the OIDC user", + "$ref": "#/definitions/BoolConfigItem" + }, + "oidc_client_id": { + "description": "The client ID of the OIDC provider", + "$ref": "#/definitions/StringConfigItem" + }, + "oidc_endpoint": { + "description": "The endpoint of the OIDC provider", + "$ref": "#/definitions/StringConfigItem" + }, + "oidc_extra_redirect_parms": { + "description": "Extra parameters to add when redirect request to OIDC provider", + "$ref": "#/definitions/StringConfigItem" + }, + "oidc_group_filter": { + "description": "The OIDC group filter which filters out the group doesn't match the regular expression", + "$ref": "#/definitions/StringConfigItem" + }, + "oidc_groups_claim": { + "description": "The attribute claims the group name", + "$ref": "#/definitions/StringConfigItem" + }, + "oidc_name": { + "description": "The OIDC provider name", + "$ref": "#/definitions/StringConfigItem" + }, + "oidc_scope": { + "description": "The scope of the OIDC provider", + "$ref": "#/definitions/StringConfigItem" + }, + "oidc_user_claim": { + "description": "The attribute claims the username", + "$ref": "#/definitions/StringConfigItem" + }, + "oidc_verify_cert": { + "description": "Verify the OIDC provider's certificate'", + "$ref": "#/definitions/BoolConfigItem" + }, + "project_creation_restriction": { + "description": "Indicate who can create projects, it could be ''adminonly'' or ''everyone''.", + "$ref": "#/definitions/StringConfigItem" + }, + "quota_per_project_enable": { + "description": "Enable quota per project", + "$ref": "#/definitions/BoolConfigItem" + }, + "read_only": { + "description": "The flag to indicate whether Harbor is in readonly mode.", + "$ref": "#/definitions/BoolConfigItem" + }, + "robot_name_prefix": { + "description": "The rebot account name prefix", + "$ref": "#/definitions/StringConfigItem" + }, + "robot_token_duration": { + "description": "The robot account token duration in days", + "$ref": "#/definitions/IntegerConfigItem" + }, + "scan_all_policy": { + "type": "object", + "properties": { + "parameter": { + "description": "The parameters of the policy, the values are dependent on the type of the policy.", + "type": "object", + "properties": { + "daily_time": { + "description": "The offset in seconds of UTC 0 o'clock, only valid when the policy type is \"daily\"", + "type": "integer" + } + } + }, + "type": { + "description": "The type of scan all policy, currently the valid values are \"none\" and \"daily\"", + "type": "string" + } + } + }, + "self_registration": { + "description": "Whether the Harbor instance supports self-registration. If it''s set to false, admin need to add user to the instance.", + "$ref": "#/definitions/BoolConfigItem" + }, + "session_timeout": { + "description": "The session timeout in minutes", + "$ref": "#/definitions/IntegerConfigItem" + }, + "skip_audit_log_database": { + "description": "Whether skip the audit log in database", + "$ref": "#/definitions/BoolConfigItem" + }, + "storage_per_project": { + "description": "The storage quota per project", + "$ref": "#/definitions/IntegerConfigItem" + }, + "token_expiration": { + "description": "The expiration time of the token for internal Registry, in minutes.", + "$ref": "#/definitions/IntegerConfigItem" + }, + "uaa_client_id": { + "description": "The client id of UAA", + "$ref": "#/definitions/StringConfigItem" + }, + "uaa_client_secret": { + "description": "The client secret of the UAA", + "$ref": "#/definitions/StringConfigItem" + }, + "uaa_endpoint": { + "description": "The endpoint of the UAA", + "$ref": "#/definitions/StringConfigItem" + }, + "uaa_verify_cert": { + "description": "Verify the certificate in UAA server", + "$ref": "#/definitions/BoolConfigItem" + } + } + }, + "Error": { + "description": "a model for all the error response coming from harbor", + "type": "object", + "properties": { + "code": { + "description": "The error code", + "type": "string" + }, + "message": { + "description": "The error message", + "type": "string" + } + } + }, + "Errors": { + "description": "The error array that describe the errors got during the handling of request", + "type": "object", + "properties": { + "errors": { + "type": "array", + "items": { + "$ref": "#/definitions/Error" + } + } + } + }, + "EventType": { + "description": "Webhook supportted event type.", + "type": "string", + "example": "pullImage" + }, + "ExecHistory": { + "type": "object", + "properties": { + "creation_time": { + "description": "the creation time of purge job.", + "type": "string", + "format": "date-time" + }, + "deleted": { + "description": "if purge job was deleted.", + "type": "boolean" + }, + "id": { + "description": "the id of purge job.", + "type": "integer" + }, + "job_kind": { + "description": "the job kind of purge job.", + "type": "string" + }, + "job_name": { + "description": "the job name of purge job.", + "type": "string" + }, + "job_parameters": { + "description": "the job parameters of purge job.", + "type": "string" + }, + "job_status": { + "description": "the status of purge job.", + "type": "string" + }, + "schedule": { + "$ref": "#/definitions/ScheduleObj" + }, + "update_time": { + "description": "the update time of purge job.", + "type": "string", + "format": "date-time" + } + } + }, + "Execution": { + "type": "object", + "properties": { + "end_time": { + "description": "The end time of execution", + "type": "string" + }, + "extra_attrs": { + "$ref": "#/definitions/ExtraAttrs" + }, + "id": { + "description": "The ID of execution", + "type": "integer" + }, + "metrics": { + "$ref": "#/definitions/Metrics" + }, + "start_time": { + "description": "The start time of execution", + "type": "string" + }, + "status": { + "description": "The status of execution", + "type": "string" + }, + "status_message": { + "description": "The status message of execution", + "type": "string" + }, + "trigger": { + "description": "The trigger of execution", + "type": "string" + }, + "vendor_id": { + "description": "The vendor id of execution", + "type": "integer" + }, + "vendor_type": { + "description": "The vendor type of execution", + "type": "string" + } + } + }, + "ExtraAttrs": { + "type": "object", + "additionalProperties": { + "type": "object" + } + }, + "FilterStyle": { + "description": "The style of the resource filter", + "type": "object", + "properties": { + "style": { + "description": "The filter style", + "type": "string" + }, + "type": { + "description": "The filter type", + "type": "string" + }, + "values": { + "description": "The filter values", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "GCHistory": { + "type": "object", + "properties": { + "creation_time": { + "description": "the creation time of gc job.", + "type": "string", + "format": "date-time" + }, + "deleted": { + "description": "if gc job was deleted.", + "type": "boolean" + }, + "id": { + "description": "the id of gc job.", + "type": "integer" + }, + "job_kind": { + "description": "the job kind of gc job.", + "type": "string" + }, + "job_name": { + "description": "the job name of gc job.", + "type": "string" + }, + "job_parameters": { + "description": "the job parameters of gc job.", + "type": "string" + }, + "job_status": { + "description": "the status of gc job.", + "type": "string" + }, + "schedule": { + "$ref": "#/definitions/ScheduleObj" + }, + "update_time": { + "description": "the update time of gc job.", + "type": "string", + "format": "date-time" + } + } + }, + "GeneralInfo": { + "type": "object", + "properties": { + "auth_mode": { + "description": "The auth mode of current Harbor instance.", + "type": "string", + "x-nullable": true, + "x-omitempty": true + }, + "authproxy_settings": { + "description": "The setting of auth proxy this is only available when Harbor relies on authproxy for authentication.", + "x-nullable": true, + "x-omitempty": true, + "$ref": "#/definitions/AuthproxySetting" + }, + "current_time": { + "description": "The current time of the server.", + "type": "string", + "format": "date-time", + "x-nullable": true, + "x-omitempty": true + }, + "external_url": { + "description": "The external URL of Harbor, with protocol.", + "type": "string", + "x-nullable": true, + "x-omitempty": true + }, + "harbor_version": { + "description": "The build version of Harbor.", + "type": "string", + "x-nullable": true, + "x-omitempty": true + }, + "has_ca_root": { + "description": "Indicate whether there is a ca root cert file ready for download in the file system.", + "type": "boolean", + "x-nullable": true, + "x-omitempty": true + }, + "notification_enable": { + "description": "The flag to indicate whether notification mechanism is enabled on Harbor instance.", + "type": "boolean", + "x-nullable": true, + "x-omitempty": true + }, + "project_creation_restriction": { + "description": "Indicate who can create projects, it could be 'adminonly' or 'everyone'.", + "type": "string", + "x-nullable": true, + "x-omitempty": true + }, + "read_only": { + "description": "The flag to indicate whether Harbor is in readonly mode.", + "type": "boolean", + "x-nullable": true, + "x-omitempty": true + }, + "registry_storage_provider_name": { + "description": "The storage provider's name of Harbor registry", + "type": "string", + "x-nullable": true, + "x-omitempty": true + }, + "registry_url": { + "description": "The url of registry against which the docker command should be issued.", + "type": "string", + "x-nullable": true, + "x-omitempty": true + }, + "self_registration": { + "description": "Indicate whether the Harbor instance enable user to register himself.", + "type": "boolean", + "x-nullable": true, + "x-omitempty": true + }, + "with_chartmuseum": { + "description": "If the Harbor instance is deployed with nested chartmuseum.", + "type": "boolean", + "x-nullable": true, + "x-omitempty": true + }, + "with_notary": { + "description": "If the Harbor instance is deployed with nested notary.", + "type": "boolean", + "x-nullable": true, + "x-omitempty": true + } + } + }, + "Icon": { + "type": "object", + "properties": { + "content": { + "description": "The base64 encoded content of the icon", + "type": "string" + }, + "content-type": { + "description": "The content type of the icon", + "type": "string" + } + } + }, + "ImmutableRule": { + "type": "object", + "properties": { + "action": { + "type": "string" + }, + "disabled": { + "type": "boolean" + }, + "id": { + "type": "integer" + }, + "params": { + "type": "object", + "additionalProperties": { + "type": "object" + } + }, + "priority": { + "type": "integer" + }, + "scope_selectors": { + "type": "object", + "additionalProperties": { + "type": "array", + "items": { + "$ref": "#/definitions/ImmutableSelector" + } + } + }, + "tag_selectors": { + "type": "array", + "items": { + "$ref": "#/definitions/ImmutableSelector" + } + }, + "template": { + "type": "string" + } + } + }, + "ImmutableSelector": { + "type": "object", + "properties": { + "decoration": { + "type": "string" + }, + "extras": { + "type": "string" + }, + "kind": { + "type": "string" + }, + "pattern": { + "type": "string" + } + } + }, + "Instance": { + "type": "object", + "properties": { + "auth_info": { + "description": "The auth credential data if exists", + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "auth_mode": { + "description": "The authentication way supported", + "type": "string" + }, + "default": { + "description": "Whether the instance is default or not", + "type": "boolean", + "x-omitempty": false + }, + "description": { + "description": "Description of instance", + "type": "string" + }, + "enabled": { + "description": "Whether the instance is activated or not", + "type": "boolean", + "x-omitempty": false + }, + "endpoint": { + "description": "The service endpoint of this instance", + "type": "string" + }, + "id": { + "description": "Unique ID", + "type": "integer" + }, + "insecure": { + "description": "Whether the instance endpoint is insecure or not", + "type": "boolean", + "x-omitempty": false + }, + "name": { + "description": "Instance name", + "type": "string" + }, + "setup_timestamp": { + "description": "The timestamp of instance setting up", + "type": "integer", + "format": "int64" + }, + "status": { + "description": "The health status", + "type": "string" + }, + "vendor": { + "description": "Based on which driver, identified by ID", + "type": "string" + } + } + }, + "IntegerConfigItem": { + "type": "object", + "properties": { + "editable": { + "description": "The configure item can be updated or not", + "type": "boolean", + "x-omitempty": false + }, + "value": { + "description": "The integer value of current config item", + "type": "integer", + "x-omitempty": false + } + } + }, + "InternalConfigurationValue": { + "type": "object", + "properties": { + "editable": { + "description": "The configure item can be updated or not", + "type": "boolean", + "x-omitempty": false + }, + "value": { + "description": "The value of current config item", + "type": "object" + } + } + }, + "InternalConfigurationsResponse": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/InternalConfigurationValue" + } + }, + "IsDefault": { + "type": "object", + "properties": { + "is_default": { + "description": "A flag indicating whether a scanner registration is default.", + "type": "boolean" + } + } + }, + "JobQueue": { + "description": "the job queue info", + "type": "object", + "properties": { + "count": { + "description": "The count of jobs in the job queue", + "type": "integer" + }, + "job_type": { + "description": "The type of the job queue", + "type": "string" + }, + "latency": { + "description": "The latency the job queue (seconds)", + "type": "integer" + }, + "paused": { + "description": "The paused status of the job queue", + "type": "boolean", + "x-omitempty": false + } + } + }, + "Label": { + "type": "object", + "properties": { + "color": { + "description": "The color the label", + "type": "string" + }, + "creation_time": { + "description": "The creation time the label", + "type": "string", + "format": "date-time" + }, + "description": { + "description": "The description the label", + "type": "string" + }, + "id": { + "description": "The ID of the label", + "type": "integer", + "format": "int64" + }, + "name": { + "description": "The name the label", + "type": "string" + }, + "project_id": { + "description": "The ID of project that the label belongs to", + "type": "integer", + "format": "int64" + }, + "scope": { + "description": "The scope the label", + "type": "string" + }, + "update_time": { + "description": "The update time of the label", + "type": "string", + "format": "date-time" + } + } + }, + "LdapConf": { + "description": "The ldap configure properties", + "type": "object", + "properties": { + "ldap_base_dn": { + "description": "The base dn of ldap service.", + "type": "string" + }, + "ldap_connection_timeout": { + "description": "The connect timeout of ldap service(second).", + "type": "integer", + "format": "int64" + }, + "ldap_filter": { + "description": "The serach filter of ldap service.", + "type": "string" + }, + "ldap_scope": { + "description": "The serach scope of ldap service.", + "type": "integer", + "format": "int64" + }, + "ldap_search_dn": { + "description": "The search dn of ldap service.", + "type": "string" + }, + "ldap_search_password": { + "description": "The search password of ldap service.", + "type": "string" + }, + "ldap_uid": { + "description": "The serach uid from ldap service attributes.", + "type": "string" + }, + "ldap_url": { + "description": "The url of ldap service.", + "type": "string" + }, + "ldap_verify_cert": { + "description": "Verify Ldap server certificate.", + "type": "boolean" + } + } + }, + "LdapFailedImportUser": { + "type": "object", + "properties": { + "error": { + "description": "fail reason.", + "type": "string" + }, + "uid": { + "description": "the uid can't add to system.", + "type": "string" + } + } + }, + "LdapImportUsers": { + "type": "object", + "properties": { + "ldap_uid_list": { + "description": "selected uid list", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "LdapPingResult": { + "description": "The ldap ping result", + "type": "object", + "properties": { + "message": { + "description": "The ping operation output message.", + "type": "string" + }, + "success": { + "description": "Test success", + "type": "boolean" + } + } + }, + "LdapUser": { + "type": "object", + "properties": { + "email": { + "description": "The user email address from \"mail\" or \"email\" attribute.", + "type": "string" + }, + "realname": { + "description": "The user realname from \"uid\" or \"cn\" attribute.", + "type": "string" + }, + "username": { + "description": "ldap username.", + "type": "string" + } + } + }, + "Metadata": { + "type": "object", + "properties": { + "icon": { + "description": "icon", + "type": "string" + }, + "id": { + "description": "id", + "type": "string" + }, + "maintainers": { + "description": "maintainers", + "type": "array", + "items": { + "type": "string" + } + }, + "name": { + "description": "name", + "type": "string" + }, + "source": { + "description": "source", + "type": "string" + }, + "version": { + "description": "version", + "type": "string" + } + } + }, + "Metrics": { + "type": "object", + "properties": { + "error_task_count": { + "description": "The count of error task", + "type": "integer" + }, + "pending_task_count": { + "description": "The count of pending task", + "type": "integer" + }, + "running_task_count": { + "description": "The count of running task", + "type": "integer" + }, + "scheduled_task_count": { + "description": "The count of scheduled task", + "type": "integer" + }, + "stopped_task_count": { + "description": "The count of stopped task", + "type": "integer" + }, + "success_task_count": { + "description": "The count of success task", + "type": "integer" + }, + "task_count": { + "description": "The count of task", + "type": "integer" + } + } + }, + "NativeReportSummary": { + "description": "The summary for the native report", + "type": "object", + "properties": { + "complete_percent": { + "description": "The complete percent of the scanning which value is between 0 and 100", + "type": "integer", + "example": 100 + }, + "duration": { + "description": "The seconds spent for generating the report", + "type": "integer", + "format": "int64", + "example": 300 + }, + "end_time": { + "description": "The end time of the scan process that generating report", + "type": "string", + "format": "date-time", + "example": "2006-01-02T15:04:05Z" + }, + "report_id": { + "description": "id of the native scan report", + "type": "string", + "example": "5f62c830-f996-11e9-957f-0242c0a89008" + }, + "scan_status": { + "description": "The status of the report generating process", + "type": "string", + "example": "Success" + }, + "scanner": { + "$ref": "#/definitions/Scanner" + }, + "severity": { + "description": "The overall severity", + "type": "string", + "example": "High" + }, + "start_time": { + "description": "The start time of the scan process that generating report", + "type": "string", + "format": "date-time", + "example": "2006-01-02T14:04:05Z" + }, + "summary": { + "$ref": "#/definitions/VulnerabilitySummary" + } + } + }, + "NotifyType": { + "description": "Webhook supportted notify type.", + "type": "string", + "example": "http" + }, + "OIDCCliSecretReq": { + "type": "object", + "properties": { + "secret": { + "description": "The new secret", + "type": "string" + } + } + }, + "OIDCUserInfo": { + "type": "object", + "properties": { + "creation_time": { + "description": "The creation time of the OIDC user info record.", + "type": "string", + "format": "date-time" + }, + "id": { + "description": "the ID of the OIDC info record", + "type": "integer", + "format": "int" + }, + "secret": { + "description": "the secret of the OIDC user that can be used for CLI to push/pull artifacts", + "type": "string" + }, + "subiss": { + "description": "the concatenation of sub and issuer in the ID token", + "type": "string" + }, + "update_time": { + "description": "The update time of the OIDC user info record.", + "type": "string", + "format": "date-time" + }, + "user_id": { + "description": "the ID of the user", + "type": "integer", + "format": "int" + } + } + }, + "OverallHealthStatus": { + "description": "The system health status", + "type": "object", + "properties": { + "components": { + "type": "array", + "items": { + "$ref": "#/definitions/ComponentHealthStatus" + } + }, + "status": { + "description": "The overall health status. It is \"healthy\" only when all the components' status are \"healthy\"", + "type": "string" + } + } + }, + "PasswordReq": { + "type": "object", + "properties": { + "new_password": { + "description": "New password for marking as to be updated.", + "type": "string" + }, + "old_password": { + "description": "The user's existing password.", + "type": "string" + } + } + }, + "Permission": { + "type": "object", + "properties": { + "action": { + "description": "The permission action", + "type": "string" + }, + "resource": { + "description": "The permission resoruce", + "type": "string" + } + } + }, + "Platform": { + "type": "object", + "properties": { + "'os.features'": { + "description": "The features of the OS that the artifact applys to", + "type": "array", + "items": { + "type": "string" + } + }, + "'os.version'": { + "description": "The version of the OS that the artifact applys to", + "type": "string" + }, + "architecture": { + "description": "The architecture that the artifact applys to", + "type": "string" + }, + "os": { + "description": "The OS that the artifact applys to", + "type": "string" + }, + "variant": { + "description": "The variant of the CPU", + "type": "string" + } + } + }, + "PreheatPolicy": { + "type": "object", + "properties": { + "creation_time": { + "description": "The Create Time of preheat policy", + "type": "string", + "format": "date-time" + }, + "description": { + "description": "The Description of preheat policy", + "type": "string" + }, + "enabled": { + "description": "Whether the preheat policy enabled", + "type": "boolean", + "x-omitempty": false + }, + "filters": { + "description": "The Filters of preheat policy", + "type": "string" + }, + "id": { + "description": "The ID of preheat policy", + "type": "integer" + }, + "name": { + "description": "The Name of preheat policy", + "type": "string" + }, + "project_id": { + "description": "The ID of preheat policy project", + "type": "integer" + }, + "provider_id": { + "description": "The ID of preheat policy provider", + "type": "integer" + }, + "provider_name": { + "description": "The Name of preheat policy provider", + "type": "string" + }, + "trigger": { + "description": "The Trigger of preheat policy", + "type": "string" + }, + "update_time": { + "description": "The Update Time of preheat policy", + "type": "string", + "format": "date-time" + } + } + }, + "Project": { + "type": "object", + "properties": { + "chart_count": { + "description": "The total number of charts under this project.", + "type": "integer", + "x-omitempty": false + }, + "creation_time": { + "description": "The creation time of the project.", + "type": "string", + "format": "date-time" + }, + "current_user_role_id": { + "description": "The role ID with highest permission of the current user who triggered the API (for UI). This attribute is deprecated and will be removed in future versions.", + "type": "integer" + }, + "current_user_role_ids": { + "description": "The list of role ID of the current user who triggered the API (for UI)", + "type": "array", + "items": { + "type": "integer", + "format": "int32" + } + }, + "cve_allowlist": { + "description": "The CVE allowlist of this project.", + "$ref": "#/definitions/CVEAllowlist" + }, + "deleted": { + "description": "A deletion mark of the project.", + "type": "boolean" + }, + "metadata": { + "description": "The metadata of the project.", + "$ref": "#/definitions/ProjectMetadata" + }, + "name": { + "description": "The name of the project.", + "type": "string" + }, + "owner_id": { + "description": "The owner ID of the project always means the creator of the project.", + "type": "integer", + "format": "int32" + }, + "owner_name": { + "description": "The owner name of the project.", + "type": "string" + }, + "project_id": { + "description": "Project ID", + "type": "integer", + "format": "int32" + }, + "registry_id": { + "description": "The ID of referenced registry when the project is a proxy cache project.", + "type": "integer", + "format": "int64" + }, + "repo_count": { + "description": "The number of the repositories under this project.", + "type": "integer", + "x-omitempty": false + }, + "togglable": { + "description": "Correspond to the UI about whether the project's publicity is updatable (for UI)", + "type": "boolean" + }, + "update_time": { + "description": "The update time of the project.", + "type": "string", + "format": "date-time" + } + } + }, + "ProjectDeletable": { + "type": "object", + "properties": { + "deletable": { + "description": "Whether the project can be deleted.", + "type": "boolean" + }, + "message": { + "description": "The detail message when the project can not be deleted.", + "type": "string" + } + } + }, + "ProjectMember": { + "type": "object", + "properties": { + "member_group": { + "$ref": "#/definitions/UserGroup" + }, + "member_user": { + "$ref": "#/definitions/UserEntity" + }, + "role_id": { + "description": "The role id 1 for projectAdmin, 2 for developer, 3 for guest, 4 for maintainer", + "type": "integer" + } + } + }, + "ProjectMemberEntity": { + "type": "object", + "properties": { + "entity_id": { + "description": "the id of entity, if the member is a user, it is user_id in user table. if the member is a user group, it is the user group's ID in user_group table.", + "type": "integer" + }, + "entity_name": { + "description": "the name of the group member.", + "type": "string" + }, + "entity_type": { + "description": "the entity's type, u for user entity, g for group entity.", + "type": "string" + }, + "id": { + "description": "the project member id", + "type": "integer" + }, + "project_id": { + "description": "the project id", + "type": "integer" + }, + "role_id": { + "description": "the role id", + "type": "integer" + }, + "role_name": { + "description": "the name of the role", + "type": "string" + } + } + }, + "ProjectMetadata": { + "type": "object", + "properties": { + "auto_scan": { + "description": "Whether scan images automatically when pushing. The valid values are \"true\", \"false\".", + "type": "string", + "x-nullable": true + }, + "enable_content_trust": { + "description": "Whether content trust is enabled or not. If it is enabled, user can't pull unsigned images from this project. The valid values are \"true\", \"false\".", + "type": "string", + "x-nullable": true + }, + "enable_content_trust_cosign": { + "description": "Whether cosign content trust is enabled or not. If it is enabled, user can't pull images without cosign signature from this project. The valid values are \"true\", \"false\".", + "type": "string", + "x-nullable": true + }, + "prevent_vul": { + "description": "Whether prevent the vulnerable images from running. The valid values are \"true\", \"false\".", + "type": "string", + "x-nullable": true + }, + "public": { + "description": "The public status of the project. The valid values are \"true\", \"false\".", + "type": "string" + }, + "retention_id": { + "description": "The ID of the tag retention policy for the project", + "type": "string", + "x-nullable": true + }, + "reuse_sys_cve_allowlist": { + "description": "Whether this project reuse the system level CVE allowlist as the allowlist of its own. The valid values are \"true\", \"false\". If it is set to \"true\" the actual allowlist associate with this project, if any, will be ignored.", + "type": "string", + "x-nullable": true + }, + "severity": { + "description": "If the vulnerability is high than severity defined here, the images can't be pulled. The valid values are \"none\", \"low\", \"medium\", \"high\", \"critical\".", + "type": "string", + "x-nullable": true + } + } + }, + "ProjectReq": { + "type": "object", + "properties": { + "cve_allowlist": { + "description": "The CVE allowlist of the project.", + "$ref": "#/definitions/CVEAllowlist" + }, + "metadata": { + "description": "The metadata of the project.", + "$ref": "#/definitions/ProjectMetadata" + }, + "project_name": { + "description": "The name of the project.", + "type": "string", + "maxLength": 255 + }, + "public": { + "description": "deprecated, reserved for project creation in replication", + "type": "boolean", + "x-nullable": true + }, + "registry_id": { + "description": "The ID of referenced registry when creating the proxy cache project", + "type": "integer", + "format": "int64", + "x-nullable": true + }, + "storage_limit": { + "description": "The storage quota of the project.", + "type": "integer", + "format": "int64", + "x-nullable": true + } + } + }, + "ProjectScanner": { + "type": "object", + "required": [ + "uuid" + ], + "properties": { + "uuid": { + "description": "The identifier of the scanner registration", + "type": "string" + } + } + }, + "ProjectSummary": { + "type": "object", + "properties": { + "chart_count": { + "description": "The total number of charts under this project.", + "type": "integer", + "x-omitempty": false + }, + "developer_count": { + "description": "The total number of developer members.", + "type": "integer" + }, + "guest_count": { + "description": "The total number of guest members.", + "type": "integer" + }, + "limited_guest_count": { + "description": "The total number of limited guest members.", + "type": "integer" + }, + "maintainer_count": { + "description": "The total number of maintainer members.", + "type": "integer" + }, + "project_admin_count": { + "description": "The total number of project admin members.", + "type": "integer" + }, + "quota": { + "$ref": "#/definitions/ProjectSummaryQuota" + }, + "registry": { + "$ref": "#/definitions/Registry" + }, + "repo_count": { + "description": "The number of the repositories under this project.", + "type": "integer", + "x-omitempty": false + } + } + }, + "ProjectSummaryQuota": { + "type": "object", + "properties": { + "hard": { + "description": "The hard limits of the quota", + "$ref": "#/definitions/ResourceList" + }, + "used": { + "description": "The used status of the quota", + "$ref": "#/definitions/ResourceList" + } + } + }, + "ProviderUnderProject": { + "type": "object", + "properties": { + "default": { + "type": "boolean" + }, + "enabled": { + "type": "boolean" + }, + "id": { + "type": "integer" + }, + "provider": { + "type": "string" + } + } + }, + "Quota": { + "description": "The quota object", + "type": "object", + "properties": { + "creation_time": { + "description": "the creation time of the quota", + "type": "string", + "format": "date-time" + }, + "hard": { + "description": "The hard limits of the quota", + "x-omitempty": false, + "$ref": "#/definitions/ResourceList" + }, + "id": { + "description": "ID of the quota", + "type": "integer" + }, + "ref": { + "description": "The reference object of the quota", + "$ref": "#/definitions/QuotaRefObject" + }, + "update_time": { + "description": "the update time of the quota", + "type": "string", + "format": "date-time" + }, + "used": { + "description": "The used status of the quota", + "x-omitempty": false, + "$ref": "#/definitions/ResourceList" + } + } + }, + "QuotaRefObject": { + "type": "object", + "additionalProperties": false + }, + "QuotaUpdateReq": { + "type": "object", + "properties": { + "hard": { + "description": "The new hard limits for the quota", + "$ref": "#/definitions/ResourceList" + } + } + }, + "Reference": { + "type": "object", + "properties": { + "annotations": { + "$ref": "#/definitions/Annotations" + }, + "child_digest": { + "description": "The digest of the child artifact", + "type": "string" + }, + "child_id": { + "description": "The child ID of the reference", + "type": "integer", + "format": "int64" + }, + "parent_id": { + "description": "The parent ID of the reference", + "type": "integer", + "format": "int64" + }, + "platform": { + "$ref": "#/definitions/Platform" + }, + "urls": { + "description": "The download URLs", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "Registry": { + "type": "object", + "properties": { + "creation_time": { + "description": "The create time of the policy.", + "type": "string", + "format": "date-time" + }, + "credential": { + "$ref": "#/definitions/RegistryCredential" + }, + "description": { + "description": "Description of the registry.", + "type": "string" + }, + "id": { + "description": "The registry ID.", + "type": "integer", + "format": "int64", + "x-omitempty": false + }, + "insecure": { + "description": "Whether or not the certificate will be verified when Harbor tries to access the server.", + "type": "boolean" + }, + "name": { + "description": "The registry name.", + "type": "string" + }, + "status": { + "description": "Health status of the registry.", + "type": "string" + }, + "type": { + "description": "Type of the registry, e.g. 'harbor'.", + "type": "string" + }, + "update_time": { + "description": "The update time of the policy.", + "type": "string", + "format": "date-time" + }, + "url": { + "description": "The registry URL string.", + "type": "string" + } + } + }, + "RegistryCredential": { + "type": "object", + "properties": { + "access_key": { + "description": "Access key, e.g. user name when credential type is 'basic'.", + "type": "string" + }, + "access_secret": { + "description": "Access secret, e.g. password when credential type is 'basic'.", + "type": "string" + }, + "type": { + "description": "Credential type, such as 'basic', 'oauth'.", + "type": "string" + } + } + }, + "RegistryEndpoint": { + "description": "The style of the resource filter", + "type": "object", + "properties": { + "key": { + "description": "The endpoint key", + "type": "string" + }, + "value": { + "description": "The endpoint value", + "type": "string" + } + } + }, + "RegistryInfo": { + "description": "The registry info contains the base info and capability declarations of the registry", + "type": "object", + "properties": { + "description": { + "description": "The description", + "type": "string" + }, + "supported_copy_by_chunk": { + "description": "The registry whether support copy by chunk.", + "type": "boolean", + "x-isnullable": true, + "x-omitempty": true + }, + "supported_resource_filters": { + "description": "The filters that the registry supports", + "type": "array", + "items": { + "$ref": "#/definitions/FilterStyle" + } + }, + "supported_triggers": { + "description": "The triggers that the registry supports", + "type": "array", + "items": { + "type": "string" + } + }, + "type": { + "description": "The registry type", + "type": "string" + } + } + }, + "RegistryPing": { + "type": "object", + "properties": { + "access_key": { + "description": "The registry access key.", + "type": "string", + "x-nullable": true + }, + "access_secret": { + "description": "The registry access secret.", + "type": "string", + "x-nullable": true + }, + "credential_type": { + "description": "Credential type of the registry, e.g. 'basic'.", + "type": "string", + "x-nullable": true + }, + "id": { + "description": "The registry ID.", + "type": "integer", + "format": "int64", + "x-nullable": true + }, + "insecure": { + "description": "Whether or not the certificate will be verified when Harbor tries to access the server.", + "type": "boolean", + "x-nullable": true + }, + "type": { + "description": "Type of the registry, e.g. 'harbor'.", + "type": "string", + "x-nullable": true + }, + "url": { + "description": "The registry URL.", + "type": "string", + "x-nullable": true + } + } + }, + "RegistryProviderCredentialPattern": { + "description": "The registry credential pattern", + "type": "object", + "properties": { + "access_key_data": { + "description": "The access key data", + "type": "string" + }, + "access_key_type": { + "description": "The access key type", + "type": "string" + }, + "access_secret_data": { + "description": "The access secret data", + "type": "string" + }, + "access_secret_type": { + "description": "The access secret type", + "type": "string" + } + } + }, + "RegistryProviderEndpointPattern": { + "description": "The registry endpoint pattern", + "type": "object", + "properties": { + "endpoint_type": { + "description": "The endpoint type", + "type": "string" + }, + "endpoints": { + "description": "The endpoint list", + "type": "array", + "items": { + "$ref": "#/definitions/RegistryEndpoint" + } + } + } + }, + "RegistryProviderInfo": { + "description": "The registry provider info contains the base info and capability declarations of the registry provider", + "type": "object", + "properties": { + "credential_pattern": { + "description": "The credential pattern", + "$ref": "#/definitions/RegistryProviderCredentialPattern" + }, + "endpoint_pattern": { + "description": "The endpoint pattern", + "$ref": "#/definitions/RegistryProviderEndpointPattern" + } + } + }, + "RegistryUpdate": { + "type": "object", + "properties": { + "access_key": { + "description": "The registry access key.", + "type": "string", + "x-nullable": true + }, + "access_secret": { + "description": "The registry access secret.", + "type": "string", + "x-nullable": true + }, + "credential_type": { + "description": "Credential type of the registry, e.g. 'basic'.", + "type": "string", + "x-nullable": true + }, + "description": { + "description": "Description of the registry.", + "type": "string", + "x-nullable": true + }, + "insecure": { + "description": "Whether or not the certificate will be verified when Harbor tries to access the server.", + "type": "boolean", + "x-nullable": true + }, + "name": { + "description": "The registry name.", + "type": "string", + "x-nullable": true + }, + "url": { + "description": "The registry URL.", + "type": "string", + "x-nullable": true + } + } + }, + "ReplicationExecution": { + "description": "The replication execution", + "type": "object", + "properties": { + "end_time": { + "description": "The end time", + "type": "string", + "format": "date-time" + }, + "failed": { + "description": "The count of failed executions", + "type": "integer", + "x-omitempty": false + }, + "id": { + "description": "The ID of the execution", + "type": "integer" + }, + "in_progress": { + "description": "The count of in_progress executions", + "type": "integer", + "x-omitempty": false + }, + "policy_id": { + "description": "The ID if the policy that the execution belongs to", + "type": "integer" + }, + "start_time": { + "description": "The start time", + "type": "string", + "format": "date-time" + }, + "status": { + "description": "The status of the execution", + "type": "string" + }, + "status_text": { + "description": "The status text", + "type": "string", + "x-omitempty": false + }, + "stopped": { + "description": "The count of stopped executions", + "type": "integer", + "x-omitempty": false + }, + "succeed": { + "description": "The count of succeed executions", + "type": "integer", + "x-omitempty": false + }, + "total": { + "description": "The total count of all executions", + "type": "integer", + "x-omitempty": false + }, + "trigger": { + "description": "The trigger mode", + "type": "string" + } + } + }, + "ReplicationFilter": { + "type": "object", + "properties": { + "decoration": { + "description": "matches or excludes the result", + "type": "string" + }, + "type": { + "description": "The replication policy filter type.", + "type": "string" + }, + "value": { + "description": "The value of replication policy filter.", + "type": "object" + } + } + }, + "ReplicationPolicy": { + "type": "object", + "properties": { + "copy_by_chunk": { + "description": "Whether to enable copy by chunk.", + "type": "boolean", + "x-isnullable": true + }, + "creation_time": { + "description": "The create time of the policy.", + "type": "string", + "format": "date-time" + }, + "deletion": { + "description": "Deprecated, use \"replicate_deletion\" instead. Whether to replicate the deletion operation.", + "type": "boolean" + }, + "description": { + "description": "The description of the policy.", + "type": "string" + }, + "dest_namespace": { + "description": "The destination namespace.", + "type": "string" + }, + "dest_namespace_replace_count": { + "description": "Specify how many path components will be replaced by the provided destination namespace.\nThe default value is -1 in which case the legacy mode will be applied.", + "type": "integer", + "format": "int8", + "x-isnullable": true + }, + "dest_registry": { + "description": "The destination registry.", + "$ref": "#/definitions/Registry" + }, + "enabled": { + "description": "Whether the policy is enabled or not.", + "type": "boolean" + }, + "filters": { + "description": "The replication policy filter array.", + "type": "array", + "items": { + "$ref": "#/definitions/ReplicationFilter" + } + }, + "id": { + "description": "The policy ID.", + "type": "integer", + "format": "int64" + }, + "name": { + "description": "The policy name.", + "type": "string" + }, + "override": { + "description": "Whether to override the resources on the destination registry.", + "type": "boolean" + }, + "replicate_deletion": { + "description": "Whether to replicate the deletion operation.", + "type": "boolean" + }, + "speed": { + "description": "speed limit for each task", + "type": "integer", + "format": "int32", + "x-isnullable": true + }, + "src_registry": { + "description": "The source registry.", + "$ref": "#/definitions/Registry" + }, + "trigger": { + "$ref": "#/definitions/ReplicationTrigger" + }, + "update_time": { + "description": "The update time of the policy.", + "type": "string", + "format": "date-time" + } + } + }, + "ReplicationTask": { + "description": "The replication task", + "type": "object", + "properties": { + "dst_resource": { + "description": "The destination resource that the task operates", + "type": "string" + }, + "end_time": { + "description": "The end time of the task", + "type": "string", + "format": "date-time" + }, + "execution_id": { + "description": "The ID of the execution that the task belongs to", + "type": "integer" + }, + "id": { + "description": "The ID of the task", + "type": "integer" + }, + "job_id": { + "description": "The ID of the underlying job that the task related to", + "type": "string" + }, + "operation": { + "description": "The operation of the task", + "type": "string" + }, + "resource_type": { + "description": "The type of the resource that the task operates", + "type": "string" + }, + "src_resource": { + "description": "The source resource that the task operates", + "type": "string" + }, + "start_time": { + "description": "The start time of the task", + "type": "string", + "format": "date-time" + }, + "status": { + "description": "The status of the task", + "type": "string" + } + } + }, + "ReplicationTrigger": { + "type": "object", + "properties": { + "trigger_settings": { + "$ref": "#/definitions/ReplicationTriggerSettings" + }, + "type": { + "description": "The replication policy trigger type. The valid values are manual, event_based and scheduled.", + "type": "string" + } + } + }, + "ReplicationTriggerSettings": { + "type": "object", + "properties": { + "cron": { + "description": "The cron string for scheduled trigger", + "type": "string" + } + } + }, + "Repository": { + "type": "object", + "properties": { + "artifact_count": { + "description": "The count of the artifacts inside the repository", + "type": "integer", + "format": "int64", + "x-omitempty": false + }, + "creation_time": { + "description": "The creation time of the repository", + "type": "string", + "format": "date-time", + "x-nullable": true, + "x-omitempty": true + }, + "description": { + "description": "The description of the repository", + "type": "string" + }, + "id": { + "description": "The ID of the repository", + "type": "integer", + "format": "int64" + }, + "name": { + "description": "The name of the repository", + "type": "string" + }, + "project_id": { + "description": "The ID of the project that the repository belongs to", + "type": "integer", + "format": "int64" + }, + "pull_count": { + "description": "The count that the artifact inside the repository pulled", + "type": "integer", + "format": "int64", + "x-omitempty": false + }, + "update_time": { + "description": "The update time of the repository", + "type": "string", + "format": "date-time" + } + } + }, + "ResourceList": { + "type": "object", + "additionalProperties": { + "type": "integer", + "format": "int64" + } + }, + "RetentionExecution": { + "type": "object", + "properties": { + "dry_run": { + "type": "boolean" + }, + "end_time": { + "type": "string" + }, + "id": { + "type": "integer", + "format": "int64" + }, + "policy_id": { + "type": "integer", + "format": "int64" + }, + "start_time": { + "type": "string" + }, + "status": { + "type": "string" + }, + "trigger": { + "type": "string" + } + } + }, + "RetentionExecutionTask": { + "type": "object", + "properties": { + "end_time": { + "type": "string" + }, + "execution_id": { + "type": "integer", + "format": "int64" + }, + "id": { + "type": "integer", + "format": "int64" + }, + "job_id": { + "type": "string" + }, + "repository": { + "type": "string" + }, + "retained": { + "type": "integer", + "x-omitempty": false + }, + "start_time": { + "type": "string" + }, + "status": { + "type": "string" + }, + "status_code": { + "type": "integer", + "x-omitempty": false + }, + "status_revision": { + "type": "integer", + "format": "int64" + }, + "total": { + "type": "integer", + "x-omitempty": false + } + } + }, + "RetentionMetadata": { + "description": "the tag retention metadata", + "type": "object", + "properties": { + "scope_selectors": { + "description": "supported scope selectors", + "type": "array", + "items": { + "$ref": "#/definitions/RetentionSelectorMetadata" + } + }, + "tag_selectors": { + "description": "supported tag selectors", + "type": "array", + "items": { + "$ref": "#/definitions/RetentionSelectorMetadata" + } + }, + "templates": { + "description": "templates", + "type": "array", + "items": { + "$ref": "#/definitions/RetentionRuleMetadata" + } + } + } + }, + "RetentionPolicy": { + "description": "retention policy", + "type": "object", + "properties": { + "algorithm": { + "type": "string" + }, + "id": { + "type": "integer", + "format": "int64" + }, + "rules": { + "type": "array", + "items": { + "$ref": "#/definitions/RetentionRule" + } + }, + "scope": { + "type": "object", + "$ref": "#/definitions/RetentionPolicyScope" + }, + "trigger": { + "type": "object", + "$ref": "#/definitions/RetentionRuleTrigger" + } + } + }, + "RetentionPolicyScope": { + "type": "object", + "properties": { + "level": { + "type": "string" + }, + "ref": { + "type": "integer" + } + } + }, + "RetentionRule": { + "type": "object", + "properties": { + "action": { + "type": "string" + }, + "disabled": { + "type": "boolean" + }, + "id": { + "type": "integer" + }, + "params": { + "type": "object", + "additionalProperties": { + "type": "object" + } + }, + "priority": { + "type": "integer" + }, + "scope_selectors": { + "type": "object", + "additionalProperties": { + "type": "array", + "items": { + "$ref": "#/definitions/RetentionSelector" + } + } + }, + "tag_selectors": { + "type": "array", + "items": { + "$ref": "#/definitions/RetentionSelector" + } + }, + "template": { + "type": "string" + } + } + }, + "RetentionRuleMetadata": { + "description": "the tag retention rule metadata", + "type": "object", + "properties": { + "action": { + "description": "rule action", + "type": "string" + }, + "display_text": { + "description": "rule display text", + "type": "string" + }, + "params": { + "description": "rule params", + "type": "array", + "items": { + "$ref": "#/definitions/RetentionRuleParamMetadata" + } + }, + "rule_template": { + "description": "rule id", + "type": "string" + } + } + }, + "RetentionRuleParamMetadata": { + "description": "rule param", + "type": "object", + "properties": { + "required": { + "type": "boolean" + }, + "type": { + "type": "string" + }, + "unit": { + "type": "string" + } + } + }, + "RetentionRuleTrigger": { + "type": "object", + "properties": { + "kind": { + "type": "string" + }, + "references": { + "type": "object" + }, + "settings": { + "type": "object" + } + } + }, + "RetentionSelector": { + "type": "object", + "properties": { + "decoration": { + "type": "string" + }, + "extras": { + "type": "string" + }, + "kind": { + "type": "string" + }, + "pattern": { + "type": "string" + } + } + }, + "RetentionSelectorMetadata": { + "description": "retention selector", + "type": "object", + "properties": { + "decorations": { + "type": "array", + "items": { + "type": "string" + } + }, + "display_text": { + "type": "string" + }, + "kind": { + "type": "string" + } + } + }, + "Robot": { + "type": "object", + "properties": { + "creation_time": { + "description": "The creation time of the robot.", + "type": "string", + "format": "date-time" + }, + "description": { + "description": "The description of the robot", + "type": "string" + }, + "disable": { + "description": "The disable status of the robot", + "type": "boolean", + "x-omitempty": false + }, + "duration": { + "description": "The duration of the robot in days", + "type": "integer", + "format": "int64" + }, + "editable": { + "description": "The editable status of the robot", + "type": "boolean", + "x-omitempty": false + }, + "expires_at": { + "description": "The expiration data of the robot", + "type": "integer", + "format": "int64" + }, + "id": { + "description": "The ID of the robot", + "type": "integer", + "format": "int64" + }, + "level": { + "description": "The level of the robot, project or system", + "type": "string" + }, + "name": { + "description": "The name of the tag", + "type": "string" + }, + "permissions": { + "type": "array", + "items": { + "$ref": "#/definitions/RobotPermission" + } + }, + "secret": { + "description": "The secret of the robot", + "type": "string" + }, + "update_time": { + "description": "The update time of the robot.", + "type": "string", + "format": "date-time" + } + } + }, + "RobotCreate": { + "description": "The request for robot account creation.", + "type": "object", + "properties": { + "description": { + "description": "The description of the robot", + "type": "string" + }, + "disable": { + "description": "The disable status of the robot", + "type": "boolean" + }, + "duration": { + "description": "The duration of the robot in days", + "type": "integer", + "format": "int64" + }, + "level": { + "description": "The level of the robot, project or system", + "type": "string" + }, + "name": { + "description": "The name of the tag", + "type": "string" + }, + "permissions": { + "type": "array", + "items": { + "$ref": "#/definitions/RobotPermission" + } + }, + "secret": { + "description": "The secret of the robot", + "type": "string" + } + } + }, + "RobotCreateV1": { + "type": "object", + "properties": { + "access": { + "description": "The permission of robot account", + "type": "array", + "items": { + "$ref": "#/definitions/Access" + } + }, + "description": { + "description": "The description of robot account", + "type": "string" + }, + "expires_at": { + "description": "The expiration time on or after which the JWT MUST NOT be accepted for processing.", + "type": "integer" + }, + "name": { + "description": "The name of robot account", + "type": "string" + } + } + }, + "RobotCreated": { + "description": "The response for robot account creation.", + "type": "object", + "properties": { + "creation_time": { + "description": "The creation time of the robot.", + "type": "string", + "format": "date-time" + }, + "expires_at": { + "description": "The expiration data of the robot", + "type": "integer", + "format": "int64" + }, + "id": { + "description": "The ID of the robot", + "type": "integer", + "format": "int64" + }, + "name": { + "description": "The name of the tag", + "type": "string" + }, + "secret": { + "description": "The secret of the robot", + "type": "string" + } + } + }, + "RobotPermission": { + "type": "object", + "properties": { + "access": { + "type": "array", + "items": { + "$ref": "#/definitions/Access" + } + }, + "kind": { + "description": "The kind of the permission", + "type": "string" + }, + "namespace": { + "description": "The namespace of the permission", + "type": "string" + } + } + }, + "RobotSec": { + "description": "The response for refresh/update robot account secret.", + "type": "object", + "properties": { + "secret": { + "description": "The secret of the robot", + "type": "string" + } + } + }, + "RoleRequest": { + "type": "object", + "properties": { + "role_id": { + "description": "The role id 1 for projectAdmin, 2 for developer, 3 for guest, 4 for maintainer", + "type": "integer" + } + } + }, + "ScanDataExportExecution": { + "description": "The replication execution", + "type": "object", + "properties": { + "end_time": { + "description": "The end time", + "type": "string", + "format": "date-time" + }, + "file_present": { + "description": "Indicates whether the export artifact is present in registry", + "type": "boolean", + "x-omitempty": false + }, + "id": { + "description": "The ID of the execution", + "type": "integer" + }, + "start_time": { + "description": "The start time", + "type": "string", + "format": "date-time" + }, + "status": { + "description": "The status of the execution", + "type": "string" + }, + "status_text": { + "description": "The status text", + "type": "string", + "x-omitempty": false + }, + "trigger": { + "description": "The trigger mode", + "type": "string" + }, + "user_id": { + "description": "The ID if the user triggering the export job", + "type": "integer" + }, + "user_name": { + "description": "The name of the user triggering the job", + "type": "string", + "x-omitempty": false + } + } + }, + "ScanDataExportExecutionList": { + "description": "The list of scan data export executions", + "type": "object", + "properties": { + "items": { + "description": "The list of scan data export executions", + "type": "array", + "items": { + "$ref": "#/definitions/ScanDataExportExecution" + } + } + } + }, + "ScanDataExportJob": { + "description": "The metadata associated with the scan data export job", + "type": "object", + "properties": { + "id": { + "description": "The id of the scan data export job", + "type": "integer", + "format": "int64" + } + } + }, + "ScanDataExportRequest": { + "description": "The criteria to select the scan data to export.", + "type": "object", + "properties": { + "cveIds": { + "description": "CVE-IDs for which to export data. Multiple CVE-IDs can be specified by separating using ',' and enclosed between '{}'. Defaults to all if empty", + "type": "string" + }, + "job_name": { + "description": "Name of the scan data export job", + "type": "string" + }, + "labels": { + "description": "A list of one or more labels for which to export the scan data, defaults to all if empty", + "type": "array", + "items": { + "type": "integer", + "format": "int64" + } + }, + "projects": { + "description": "A list of one or more projects for which to export the scan data, currently only one project is supported due to performance concerns, but define as array for extension in the future.", + "type": "array", + "items": { + "type": "integer", + "format": "int64" + } + }, + "repositories": { + "description": "A list of repositories for which to export the scan data, defaults to all if empty", + "type": "string" + }, + "tags": { + "description": "A list of tags enclosed within '{}'. Defaults to all if empty", + "type": "string" + } + } + }, + "ScanOverview": { + "description": "The scan overview attached in the metadata of tag", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/NativeReportSummary" + } + }, + "Scanner": { + "type": "object", + "properties": { + "name": { + "description": "Name of the scanner", + "type": "string", + "example": "Trivy" + }, + "vendor": { + "description": "Name of the scanner provider", + "type": "string", + "example": "Aqua Security" + }, + "version": { + "description": "Version of the scanner adapter", + "type": "string", + "example": "v0.9.1" + } + } + }, + "ScannerAdapterMetadata": { + "description": "The metadata info of the scanner adapter", + "type": "object", + "properties": { + "capabilities": { + "type": "array", + "items": { + "$ref": "#/definitions/ScannerCapability" + } + }, + "properties": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "harbor.scanner-adapter/registry-authorization-type": "Bearer" + } + }, + "scanner": { + "$ref": "#/definitions/Scanner" + } + } + }, + "ScannerCapability": { + "type": "object", + "properties": { + "consumes_mime_types": { + "type": "array", + "items": { + "type": "string", + "example": "application/vnd.docker.distribution.manifest.v2+json" + } + }, + "produces_mime_types": { + "type": "array", + "items": { + "type": "string", + "example": "application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0" + } + } + } + }, + "ScannerRegistration": { + "description": "Registration represents a named configuration for invoking a scanner via its adapter.\n", + "type": "object", + "properties": { + "access_credential": { + "description": "An optional value of the HTTP Authorization header sent with each request to the Scanner Adapter API.\n", + "type": "string", + "x-omitempty": false, + "example": "Bearer: JWTTOKENGOESHERE" + }, + "adapter": { + "description": "Optional property to describe the name of the scanner registration", + "type": "string", + "example": "Trivy" + }, + "auth": { + "description": "Specify what authentication approach is adopted for the HTTP communications.\nSupported types Basic\", \"Bearer\" and api key header \"X-ScannerAdapter-API-Key\"\n", + "type": "string", + "default": "", + "x-omitempty": false, + "example": "Bearer" + }, + "create_time": { + "description": "The creation time of this registration", + "type": "string", + "format": "date-time" + }, + "description": { + "description": "An optional description of this registration.", + "type": "string", + "x-omitempty": false, + "example": "A free-to-use tool that scans container images for package vulnerabilities.\n" + }, + "disabled": { + "description": "Indicate whether the registration is enabled or not", + "type": "boolean", + "default": false, + "x-omitempty": false + }, + "health": { + "description": "Indicate the healthy of the registration", + "type": "string", + "default": "", + "example": "healthy" + }, + "is_default": { + "description": "Indicate if the registration is set as the system default one", + "type": "boolean", + "default": false, + "x-omitempty": false + }, + "name": { + "description": "The name of this registration.", + "type": "string", + "example": "Trivy" + }, + "skip_certVerify": { + "description": "Indicate if skip the certificate verification when sending HTTP requests", + "type": "boolean", + "default": false, + "x-omitempty": false + }, + "update_time": { + "description": "The update time of this registration", + "type": "string", + "format": "date-time" + }, + "url": { + "description": "A base URL of the scanner adapter", + "type": "string", + "format": "url", + "example": "http://harbor-scanner-trivy:8080" + }, + "use_internal_addr": { + "description": "Indicate whether use internal registry addr for the scanner to pull content or not", + "type": "boolean", + "default": false, + "x-omitempty": false + }, + "uuid": { + "description": "The unique identifier of this registration.", + "type": "string" + }, + "vendor": { + "description": "Optional property to describe the vendor of the scanner registration", + "type": "string", + "example": "CentOS" + }, + "version": { + "description": "Optional property to describe the version of the scanner registration", + "type": "string", + "example": "1.0.1" + } + } + }, + "ScannerRegistrationReq": { + "type": "object", + "required": [ + "name", + "url" + ], + "properties": { + "access_credential": { + "description": "An optional value of the HTTP Authorization header sent with each request to the Scanner Adapter API.\n", + "type": "string", + "example": "Bearer: JWTTOKENGOESHERE" + }, + "auth": { + "description": "Specify what authentication approach is adopted for the HTTP communications.\nSupported types Basic\", \"Bearer\" and api key header \"X-ScannerAdapter-API-Key\"\n", + "type": "string", + "example": "Bearer" + }, + "description": { + "description": "An optional description of this registration.", + "type": "string", + "example": "A free-to-use tool that scans container images for package vulnerabilities.\n" + }, + "disabled": { + "description": "Indicate whether the registration is enabled or not", + "type": "boolean", + "default": false + }, + "name": { + "description": "The name of this registration", + "type": "string", + "example": "Trivy" + }, + "skip_certVerify": { + "description": "Indicate if skip the certificate verification when sending HTTP requests", + "type": "boolean", + "default": false + }, + "url": { + "description": "A base URL of the scanner adapter.", + "type": "string", + "format": "uri", + "example": "http://harbor-scanner-trivy:8080" + }, + "use_internal_addr": { + "description": "Indicate whether use internal registry addr for the scanner to pull content or not", + "type": "boolean", + "default": false + } + } + }, + "ScannerRegistrationSettings": { + "type": "object", + "required": [ + "name", + "url" + ], + "properties": { + "access_credential": { + "description": "An optional value of the HTTP Authorization header sent with each request to the Scanner Adapter API.\n", + "type": "string", + "example": "Bearer: JWTTOKENGOESHERE" + }, + "auth": { + "description": "Specify what authentication approach is adopted for the HTTP communications.\nSupported types Basic\", \"Bearer\" and api key header \"X-ScannerAdapter-API-Key\"\n", + "type": "string", + "default": "" + }, + "name": { + "description": "The name of this registration", + "type": "string", + "example": "Trivy" + }, + "url": { + "description": "A base URL of the scanner adapter.", + "type": "string", + "format": "uri", + "example": "http://harbor-scanner-trivy:8080" + } + } + }, + "Schedule": { + "type": "object", + "properties": { + "creation_time": { + "description": "the creation time of the schedule.", + "type": "string", + "format": "date-time", + "readOnly": true + }, + "id": { + "description": "The id of the schedule.", + "type": "integer", + "readOnly": true + }, + "parameters": { + "description": "The parameters of schedule job", + "type": "object", + "additionalProperties": { + "type": "object" + } + }, + "schedule": { + "$ref": "#/definitions/ScheduleObj" + }, + "status": { + "description": "The status of the schedule.", + "type": "string", + "readOnly": true + }, + "update_time": { + "description": "the update time of the schedule.", + "type": "string", + "format": "date-time", + "readOnly": true + } + } + }, + "ScheduleObj": { + "type": "object", + "properties": { + "cron": { + "description": "A cron expression, a time-based job scheduler.", + "type": "string" + }, + "next_scheduled_time": { + "description": "The next time to schedule to run the job.", + "type": "string", + "format": "date-time" + }, + "type": { + "description": "The schedule type. The valid values are 'Hourly', 'Daily', 'Weekly', 'Custom', 'Manual' and 'None'.\n'Manual' means to trigger it right away and 'None' means to cancel the schedule.\n", + "type": "string", + "enum": [ + "Hourly", + "Daily", + "Weekly", + "Custom", + "Manual", + "None" + ] + } + } + }, + "ScheduleTask": { + "description": "the schedule task info", + "type": "object", + "properties": { + "cron": { + "description": "the cron of the current schedule task", + "type": "string" + }, + "id": { + "description": "the id of the Schedule task", + "type": "integer" + }, + "update_time": { + "description": "the update time of the schedule task", + "type": "string", + "format": "date-time" + }, + "vendor_id": { + "description": "the vendor id of the current task", + "type": "integer" + }, + "vendor_type": { + "description": "the vendor type of the current schedule task", + "type": "string" + } + } + }, + "SchedulerStatus": { + "description": "the scheduler status", + "type": "object", + "properties": { + "paused": { + "description": "if the scheduler is paused", + "type": "boolean", + "x-omitempty": false + } + } + }, + "Search": { + "type": "object", + "properties": { + "chart": { + "description": "Search results of the charts that macthed the filter keywords.", + "type": "array", + "items": { + "$ref": "#/definitions/SearchResult" + }, + "x-isnullable": true, + "x-omitempty": true + }, + "project": { + "description": "Search results of the projects that matched the filter keywords.", + "type": "array", + "items": { + "$ref": "#/definitions/Project" + } + }, + "repository": { + "description": "Search results of the repositories that matched the filter keywords.", + "type": "array", + "items": { + "$ref": "#/definitions/SearchRepository" + } + } + } + }, + "SearchRepository": { + "type": "object", + "properties": { + "artifact_count": { + "description": "The count of artifacts in the repository", + "type": "integer" + }, + "project_id": { + "description": "The ID of the project that the repository belongs to", + "type": "integer" + }, + "project_name": { + "description": "The name of the project that the repository belongs to", + "type": "string" + }, + "project_public": { + "description": "The flag to indicate the publicity of the project that the repository belongs to (1 is public, 0 is not)", + "type": "boolean" + }, + "pull_count": { + "description": "The count how many times the repository is pulled", + "type": "integer" + }, + "repository_name": { + "description": "The name of the repository", + "type": "string" + } + } + }, + "SearchResult": { + "description": "The chart search result item", + "type": "object", + "properties": { + "Chart": { + "$ref": "#/definitions/ChartVersion" + }, + "Name": { + "description": "The chart name with repo name", + "type": "string" + }, + "Score": { + "description": "The matched level", + "type": "integer" + } + } + }, + "StartReplicationExecution": { + "type": "object", + "properties": { + "policy_id": { + "description": "The ID of policy that the execution belongs to.", + "type": "integer", + "format": "int64" + } + } + }, + "Statistic": { + "type": "object", + "properties": { + "private_project_count": { + "description": "The count of the private projects", + "type": "integer", + "format": "int64", + "x-omitempty": false + }, + "private_repo_count": { + "description": "The count of the private repositories", + "type": "integer", + "format": "int64", + "x-omitempty": false + }, + "public_project_count": { + "description": "The count of the public projects", + "type": "integer", + "format": "int64", + "x-omitempty": false + }, + "public_repo_count": { + "description": "The count of the public repositories", + "type": "integer", + "format": "int64", + "x-omitempty": false + }, + "total_project_count": { + "description": "The count of the total projects, only be seen by the system admin", + "type": "integer", + "format": "int64", + "x-omitempty": false + }, + "total_repo_count": { + "description": "The count of the total repositories, only be seen by the system admin", + "type": "integer", + "format": "int64", + "x-omitempty": false + }, + "total_storage_consumption": { + "description": "The total storage consumption of blobs, only be seen by the system admin", + "type": "integer", + "format": "int64", + "x-omitempty": false + } + } + }, + "Stats": { + "description": "Stats provides the overall progress of the scan all process.", + "type": "object", + "properties": { + "completed": { + "description": "The number of the finished scan processes triggered by the scan all action", + "type": "integer", + "format": "int", + "x-omitempty": false, + "example": 90 + }, + "metrics": { + "description": "The metrics data for the each status", + "type": "object", + "additionalProperties": { + "type": "integer", + "format": "int", + "example": 10 + }, + "example": { + "Error": 2, + "Running": 3, + "Success": 5 + } + }, + "ongoing": { + "description": "A flag indicating job status of scan all.", + "type": "boolean", + "x-omitempty": false + }, + "total": { + "description": "The total number of scan processes triggered by the scan all action", + "type": "integer", + "format": "int", + "x-omitempty": false, + "example": 100 + }, + "trigger": { + "description": "The trigger of the scan all job.", + "type": "string", + "enum": [ + "Manual", + "Schedule", + "Event" + ] + } + } + }, + "Storage": { + "type": "object", + "properties": { + "free": { + "description": "Free volume size.", + "type": "integer", + "format": "uint64" + }, + "total": { + "description": "Total volume size.", + "type": "integer", + "format": "uint64" + } + } + }, + "StringConfigItem": { + "type": "object", + "properties": { + "editable": { + "description": "The configure item can be updated or not", + "type": "boolean", + "x-omitempty": false + }, + "value": { + "description": "The string value of current config item", + "type": "string", + "x-omitempty": false + } + } + }, + "SupportedWebhookEventTypes": { + "description": "Supportted webhook event types and notify types.", + "type": "object", + "properties": { + "event_type": { + "type": "array", + "items": { + "$ref": "#/definitions/EventType" + } + }, + "notify_type": { + "type": "array", + "items": { + "$ref": "#/definitions/NotifyType" + } + } + } + }, + "SystemInfo": { + "type": "object", + "properties": { + "storage": { + "description": "The storage of system.", + "type": "array", + "items": { + "$ref": "#/definitions/Storage" + } + } + } + }, + "Tag": { + "type": "object", + "properties": { + "artifact_id": { + "description": "The ID of the artifact that the tag attached to", + "type": "integer", + "format": "int64" + }, + "id": { + "description": "The ID of the tag", + "type": "integer", + "format": "int64" + }, + "immutable": { + "description": "The immutable status of the tag", + "type": "boolean", + "x-omitempty": false + }, + "name": { + "description": "The name of the tag", + "type": "string" + }, + "pull_time": { + "description": "The latest pull time of the tag", + "type": "string", + "format": "date-time" + }, + "push_time": { + "description": "The push time of the tag", + "type": "string", + "format": "date-time" + }, + "repository_id": { + "description": "The ID of the repository that the tag belongs to", + "type": "integer", + "format": "int64" + }, + "signed": { + "description": "The attribute indicates whether the tag is signed or not", + "type": "boolean", + "x-omitempty": false + } + } + }, + "Task": { + "type": "object", + "properties": { + "creation_time": { + "description": "The creation time of task", + "type": "string" + }, + "end_time": { + "description": "The end time of task", + "type": "string" + }, + "execution_id": { + "description": "The ID of task execution", + "type": "integer" + }, + "extra_attrs": { + "$ref": "#/definitions/ExtraAttrs" + }, + "id": { + "description": "The ID of task", + "type": "integer" + }, + "run_count": { + "description": "The count of task run", + "type": "integer", + "format": "int32" + }, + "start_time": { + "description": "The start time of task", + "type": "string" + }, + "status": { + "description": "The status of task", + "type": "string" + }, + "status_message": { + "description": "The status message of task", + "type": "string" + }, + "update_time": { + "description": "The update time of task", + "type": "string" + } + } + }, + "UserCreationReq": { + "type": "object", + "properties": { + "comment": { + "type": "string" + }, + "email": { + "type": "string", + "maxLength": 255 + }, + "password": { + "type": "string" + }, + "realname": { + "type": "string" + }, + "username": { + "type": "string", + "maxLength": 255 + } + } + }, + "UserEntity": { + "type": "object", + "properties": { + "user_id": { + "description": "The ID of the user.", + "type": "integer" + }, + "username": { + "description": "The name of the user.", + "type": "string" + } + } + }, + "UserGroup": { + "type": "object", + "properties": { + "group_name": { + "description": "The name of the user group", + "type": "string" + }, + "group_type": { + "description": "The group type, 1 for LDAP group, 2 for HTTP group, 3 for OIDC group.", + "type": "integer" + }, + "id": { + "description": "The ID of the user group", + "type": "integer" + }, + "ldap_group_dn": { + "description": "The DN of the LDAP group if group type is 1 (LDAP group).", + "type": "string" + } + } + }, + "UserGroupSearchItem": { + "type": "object", + "properties": { + "group_name": { + "description": "The name of the user group", + "type": "string" + }, + "group_type": { + "description": "The group type, 1 for LDAP group, 2 for HTTP group, 3 for OIDC group.", + "type": "integer" + }, + "id": { + "description": "The ID of the user group", + "type": "integer" + } + } + }, + "UserProfile": { + "type": "object", + "properties": { + "comment": { + "type": "string" + }, + "email": { + "type": "string" + }, + "realname": { + "type": "string" + } + } + }, + "UserResp": { + "type": "object", + "properties": { + "admin_role_in_auth": { + "description": "indicate the admin privilege is grant by authenticator (LDAP), is always false unless it is the current login user", + "type": "boolean", + "x-omitempty": false + }, + "comment": { + "type": "string" + }, + "creation_time": { + "description": "The creation time of the user.", + "type": "string", + "format": "date-time" + }, + "email": { + "type": "string" + }, + "oidc_user_meta": { + "$ref": "#/definitions/OIDCUserInfo" + }, + "realname": { + "type": "string" + }, + "sysadmin_flag": { + "type": "boolean", + "x-omitempty": false + }, + "update_time": { + "description": "The update time of the user.", + "type": "string", + "format": "date-time" + }, + "user_id": { + "type": "integer", + "format": "int" + }, + "username": { + "type": "string" + } + } + }, + "UserSearch": { + "type": "object", + "properties": { + "user_id": { + "description": "The ID of the user.", + "type": "integer", + "format": "int" + }, + "username": { + "type": "string" + } + } + }, + "UserSearchRespItem": { + "type": "object", + "properties": { + "user_id": { + "description": "The ID of the user.", + "type": "integer", + "format": "int" + }, + "username": { + "type": "string" + } + } + }, + "UserSysAdminFlag": { + "type": "object", + "properties": { + "sysadmin_flag": { + "description": "true-admin, false-not admin.", + "type": "boolean" + } + } + }, + "VulnerabilitySummary": { + "description": "VulnerabilitySummary contains the total number of the foun d vulnerabilities number and numbers of each severity level.\n", + "type": "object", + "properties": { + "fixable": { + "description": "The number of the fixable vulnerabilities", + "type": "integer", + "format": "int", + "x-omitempty": false, + "example": 100 + }, + "summary": { + "description": "Numbers of the vulnerabilities with different severity", + "type": "object", + "additionalProperties": { + "type": "integer", + "format": "int", + "example": 10 + }, + "x-omitempty": false, + "example": { + "Critical": 5, + "High": 5 + } + }, + "total": { + "description": "The total number of the found vulnerabilities", + "type": "integer", + "format": "int", + "x-omitempty": false, + "example": 500 + } + } + }, + "WebhookJob": { + "description": "The webhook job.", + "type": "object", + "properties": { + "creation_time": { + "description": "The webhook job creation time.", + "type": "string", + "format": "date-time" + }, + "event_type": { + "description": "The webhook job event type.", + "type": "string" + }, + "id": { + "description": "The webhook job ID.", + "type": "integer", + "format": "int64" + }, + "job_detail": { + "description": "The webhook job notify detailed data.", + "type": "string" + }, + "notify_type": { + "description": "The webhook job notify type.", + "type": "string" + }, + "policy_id": { + "description": "The webhook policy ID.", + "type": "integer", + "format": "int64" + }, + "status": { + "description": "The webhook job status.", + "type": "string" + }, + "update_time": { + "description": "The webhook job update time.", + "type": "string", + "format": "date-time" + } + } + }, + "WebhookLastTrigger": { + "description": "The webhook policy and last trigger time group by event type.", + "type": "object", + "properties": { + "creation_time": { + "description": "The creation time of webhook policy.", + "type": "string", + "format": "date-time" + }, + "enabled": { + "description": "Whether or not the webhook policy enabled.", + "type": "boolean" + }, + "event_type": { + "description": "The webhook event type.", + "type": "string" + }, + "last_trigger_time": { + "description": "The last trigger time of webhook policy.", + "type": "string", + "format": "date-time" + }, + "policy_name": { + "description": "The webhook policy name.", + "type": "string" + } + } + }, + "WebhookPolicy": { + "description": "The webhook policy object", + "type": "object", + "properties": { + "creation_time": { + "description": "The create time of the webhook policy.", + "type": "string", + "format": "date-time" + }, + "creator": { + "description": "The creator of the webhook policy.", + "type": "string" + }, + "description": { + "description": "The description of webhook policy.", + "type": "string" + }, + "enabled": { + "description": "Whether the webhook policy is enabled or not.", + "type": "boolean", + "x-omitempty": false + }, + "event_types": { + "type": "array", + "items": { + "type": "string" + } + }, + "id": { + "description": "The webhook policy ID.", + "type": "integer", + "format": "int64" + }, + "name": { + "description": "The name of webhook policy.", + "type": "string" + }, + "project_id": { + "description": "The project ID of webhook policy.", + "type": "integer" + }, + "targets": { + "type": "array", + "items": { + "$ref": "#/definitions/WebhookTargetObject" + } + }, + "update_time": { + "description": "The update time of the webhook policy.", + "type": "string", + "format": "date-time" + } + } + }, + "WebhookTargetObject": { + "description": "The webhook policy target object.", + "type": "object", + "properties": { + "address": { + "description": "The webhook target address.", + "type": "string" + }, + "auth_header": { + "description": "The webhook auth header.", + "type": "string" + }, + "skip_cert_verify": { + "description": "Whether or not to skip cert verify.", + "type": "boolean" + }, + "type": { + "description": "The webhook target notify type.", + "type": "string" + } + } + }, + "Worker": { + "description": "worker in the pool", + "type": "object", + "properties": { + "check_in": { + "description": "the checkin of the running job in the worker", + "type": "string" + }, + "checkin_at": { + "description": "The checkin time of the worker", + "type": "string", + "format": "date-time", + "x-nullable": true, + "x-omitempty": true + }, + "id": { + "description": "the id of the worker", + "type": "string" + }, + "job_id": { + "description": "the id of the running job in the worker", + "type": "string" + }, + "job_name": { + "description": "the name of the running job in the worker", + "type": "string" + }, + "pool_id": { + "description": "the id of the worker pool", + "type": "string" + }, + "start_at": { + "description": "The start time of the worker", + "type": "string", + "format": "date-time", + "x-nullable": true, + "x-omitempty": true + } + } + }, + "WorkerPool": { + "description": "the worker pool of job service", + "type": "object", + "properties": { + "concurrency": { + "description": "The concurrency of the work pool", + "type": "integer" + }, + "heartbeat_at": { + "description": "The heartbeat time of the work pool", + "type": "string", + "format": "date-time" + }, + "host": { + "description": "The host of the work pool", + "type": "string" + }, + "pid": { + "description": "the process id of jobservice", + "type": "integer" + }, + "start_at": { + "description": "The start time of the work pool", + "type": "string", + "format": "date-time" + }, + "worker_pool_id": { + "description": "the id of the worker pool", + "type": "string" + } + } + } + }, + "parameters": { + "acceptVulnerabilities": { + "type": "string", + "default": "application/vnd.security.vulnerability.report; version=1.1, application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0", + "description": "A comma-separated lists of MIME types for the scan report or scan summary. The first mime type will be used when the report found for it.\nCurrently the mime type supports 'application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0' and 'application/vnd.security.vulnerability.report; version=1.1'", + "name": "X-Accept-Vulnerabilities", + "in": "header" + }, + "accessoryId": { + "type": "integer", + "format": "int64", + "description": "The ID of the accessory", + "name": "accessory_id", + "in": "path", + "required": true + }, + "digest": { + "type": "string", + "description": "The digest of the resource", + "name": "digest", + "in": "path", + "required": true + }, + "executionId": { + "type": "integer", + "description": "Execution ID", + "name": "execution_id", + "in": "path", + "required": true + }, + "gcId": { + "type": "integer", + "format": "int64", + "description": "The ID of the gc log", + "name": "gc_id", + "in": "path", + "required": true + }, + "immutableRuleId": { + "type": "integer", + "format": "int64", + "description": "The ID of the immutable rule", + "name": "immutable_rule_id", + "in": "path", + "required": true + }, + "instanceName": { + "type": "string", + "description": "Instance Name", + "name": "preheat_instance_name", + "in": "path", + "required": true + }, + "isResourceName": { + "type": "boolean", + "default": false, + "description": "The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.", + "name": "X-Is-Resource-Name", + "in": "header" + }, + "labelId": { + "type": "integer", + "format": "int64", + "description": "Label ID", + "name": "label_id", + "in": "path", + "required": true + }, + "page": { + "type": "integer", + "format": "int64", + "default": 1, + "description": "The page number", + "name": "page", + "in": "query" + }, + "pageSize": { + "maximum": 100, + "type": "integer", + "format": "int64", + "default": 10, + "description": "The size of per page", + "name": "page_size", + "in": "query" + }, + "preheatPolicyName": { + "type": "string", + "description": "Preheat Policy Name", + "name": "preheat_policy_name", + "in": "path", + "required": true + }, + "projectName": { + "type": "string", + "description": "The name of the project", + "name": "project_name", + "in": "path", + "required": true + }, + "projectNameOrId": { + "type": "string", + "description": "The name or id of the project", + "name": "project_name_or_id", + "in": "path", + "required": true + }, + "purgeId": { + "type": "integer", + "format": "int64", + "description": "The ID of the purge log", + "name": "purge_id", + "in": "path", + "required": true + }, + "query": { + "type": "string", + "description": "Query string to query resources. Supported query patterns are \"exact match(k=v)\", \"fuzzy match(k=~v)\", \"range(k=[min~max])\", \"list with union releationship(k={v1 v2 v3})\" and \"list with intersetion relationship(k=(v1 v2 v3))\". The value of range and list can be string(enclosed by \" or '), integer or time(in format \"2020-04-09 02:36:00\"). All of these query patterns should be put in the query string \"q=xxx\" and splitted by \",\". e.g. q=k1=v1,k2=~v2,k3=[min~max]", + "name": "q", + "in": "query" + }, + "reference": { + "type": "string", + "description": "The reference of the artifact, can be digest or tag", + "name": "reference", + "in": "path", + "required": true + }, + "repositoryName": { + "type": "string", + "description": "The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -\u003e a%252Fb", + "name": "repository_name", + "in": "path", + "required": true + }, + "requestId": { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + "resourceNameInLocation": { + "type": "boolean", + "default": false, + "description": "The flag to indicate whether to return the name of the resource in Location. When X-Resource-Name-In-Location is true, the Location will return the name of the resource.", + "name": "X-Resource-Name-In-Location", + "in": "header" + }, + "robotId": { + "type": "integer", + "description": "Robot ID", + "name": "robot_id", + "in": "path", + "required": true + }, + "scanDataType": { + "type": "string", + "description": "The type of scan data to export", + "name": "X-Scan-Data-Type", + "in": "header", + "required": true + }, + "sort": { + "type": "string", + "description": "Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with \"sort=field1,-field2\"", + "name": "sort", + "in": "query" + }, + "tagName": { + "type": "string", + "description": "The name of the tag", + "name": "tag_name", + "in": "path", + "required": true + }, + "taskId": { + "type": "integer", + "description": "Task ID", + "name": "task_id", + "in": "path", + "required": true + }, + "userName": { + "type": "string", + "description": "The name of the user", + "name": "user_name", + "in": "query", + "required": true + }, + "webhookPolicyId": { + "type": "integer", + "format": "int64", + "description": "The ID of the webhook policy", + "name": "webhook_policy_id", + "in": "path", + "required": true + } + }, + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "201": { + "description": "Created", + "headers": { + "Location": { + "type": "string", + "description": "The location of the resource" + }, + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "202": { + "description": "Accepted", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "405": { + "description": "Method not allowed", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "409": { + "description": "Conflict", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "412": { + "description": "Precondition failed", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "415": { + "description": "Unsupported MediaType", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + }, + "securityDefinitions": { + "basic": { + "type": "basic" + } + }, + "security": [ + { + "basic": [] + }, + {} + ] +}`)) + FlatSwaggerJSON = json.RawMessage([]byte(`{ + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "schemes": [ + "http", + "https" + ], + "swagger": "2.0", + "info": { + "description": "These APIs provide services for manipulating Harbor project.", + "title": "Harbor API", + "version": "2.0" + }, + "host": "localhost", + "basePath": "/api/v2.0", + "paths": { + "/audit-logs": { + "get": { + "description": "This endpoint let user see the recent operation logs of the projects which he is member of\n", + "tags": [ + "auditlog" + ], + "summary": "Get recent logs of the projects which the user is a member of", + "operationId": "listAuditLogs", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "Query string to query resources. Supported query patterns are \"exact match(k=v)\", \"fuzzy match(k=~v)\", \"range(k=[min~max])\", \"list with union releationship(k={v1 v2 v3})\" and \"list with intersetion relationship(k=(v1 v2 v3))\". The value of range and list can be string(enclosed by \" or '), integer or time(in format \"2020-04-09 02:36:00\"). All of these query patterns should be put in the query string \"q=xxx\" and splitted by \",\". e.g. q=k1=v1,k2=~v2,k3=[min~max]", + "name": "q", + "in": "query" + }, + { + "type": "string", + "description": "Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with \"sort=field1,-field2\"", + "name": "sort", + "in": "query" + }, + { + "type": "integer", + "format": "int64", + "default": 1, + "description": "The page number", + "name": "page", + "in": "query" + }, + { + "maximum": 100, + "type": "integer", + "format": "int64", + "default": 10, + "description": "The size of per page", + "name": "page_size", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/AuditLog" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link refers to the previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of auditlogs" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/configurations": { + "get": { + "description": "This endpoint is for retrieving system configurations that only provides for admin user.\n", + "tags": [ + "configure" + ], + "summary": "Get system configurations.", + "operationId": "getConfigurations", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + } + ], + "responses": { + "200": { + "description": "Get system configurations successfully. The response body is a map.", + "schema": { + "$ref": "#/definitions/ConfigurationsResponse" + } + }, + "401": { + "description": "User need to log in first.ß" + }, + "403": { + "description": "User does not have permission of admin role." + }, + "500": { + "description": "Unexpected internal errors." + } + } + }, + "put": { + "description": "This endpoint is for modifying system configurations that only provides for admin user.\n", + "tags": [ + "configure" + ], + "summary": "Modify system configurations.", + "operationId": "updateConfigurations", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "description": "The configuration map can contain a subset of the attributes of the schema, which are to be updated.", + "name": "configurations", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/Configurations" + } + } + ], + "responses": { + "200": { + "description": "Modify system configurations successfully." + }, + "401": { + "description": "User need to log in first." + }, + "403": { + "description": "User does not have permission of admin role." + }, + "500": { + "description": "Unexpected internal errors." + } + } + } + }, + "/export/cve": { + "post": { + "description": "Export scan data for selected projects", + "tags": [ + "scan data export" + ], + "summary": "Export scan data for selected projects", + "operationId": "exportScanData", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "The type of scan data to export", + "name": "X-Scan-Data-Type", + "in": "header", + "required": true + }, + { + "description": "The criteria for the export", + "name": "criteria", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ScanDataExportRequest" + } + } + ], + "responses": { + "200": { + "description": "Success.", + "schema": { + "$ref": "#/definitions/ScanDataExportJob" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "405": { + "description": "Method not allowed", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "409": { + "description": "Conflict", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/export/cve/download/{execution_id}": { + "get": { + "description": "Download the scan data report. Default format is CSV", + "produces": [ + "text/csv" + ], + "tags": [ + "scan data export" + ], + "summary": "Download the scan data export file", + "operationId": "downloadScanData", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "integer", + "description": "Execution ID", + "name": "execution_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The format of the data to be exported. e.g. CSV or PDF", + "name": "format", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Data file containing the export data", + "schema": { + "type": "file" + }, + "headers": { + "Content-Disposition": { + "type": "string", + "description": "Value is a CSV formatted file; filename=export.csv" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/export/cve/execution/{execution_id}": { + "get": { + "description": "Get the scan data export execution specified by ID", + "tags": [ + "scan data export" + ], + "summary": "Get the specific scan data export execution", + "operationId": "getScanDataExportExecution", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "integer", + "description": "Execution ID", + "name": "execution_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/ScanDataExportExecution" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/export/cve/executions": { + "get": { + "description": "Get a list of specific scan data export execution jobs for a specified user", + "tags": [ + "scan data export" + ], + "summary": "Get a list of specific scan data export execution jobs for a specified user", + "operationId": "getScanDataExportExecutionList", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/ScanDataExportExecutionList" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/health": { + "get": { + "description": "Check the status of Harbor components", + "tags": [ + "health" + ], + "summary": "Check the status of Harbor components", + "operationId": "getHealth", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + } + ], + "responses": { + "200": { + "description": "The health status of Harbor components", + "schema": { + "$ref": "#/definitions/OverallHealthStatus" + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/icons/{digest}": { + "get": { + "description": "Get the artifact icon with the specified digest. As the original icon image is resized and encoded before returning, the parameter \"digest\" in the path doesn't match the hash of the returned content", + "tags": [ + "icon" + ], + "summary": "Get artifact icon", + "operationId": "getIcon", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "The digest of the resource", + "name": "digest", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/Icon" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/internalconfig": { + "get": { + "description": "This endpoint is for retrieving system configurations that only provides for internal api call.\n", + "tags": [ + "configure" + ], + "summary": "Get internal configurations.", + "operationId": "getInternalconfig", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + } + ], + "responses": { + "200": { + "description": "Get system configurations successfully. The response body is a map.", + "schema": { + "$ref": "#/definitions/InternalConfigurationsResponse" + } + }, + "401": { + "description": "User need to log in first." + }, + "403": { + "description": "User does not have permission of admin role." + }, + "500": { + "description": "Unexpected internal errors." + } + } + } + }, + "/jobservice/jobs/{job_id}": { + "put": { + "description": "Stop running job", + "tags": [ + "jobservice" + ], + "summary": "Stop running job", + "operationId": "stopRunningJob", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "The id of the job.", + "name": "job_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Stop worker successfully." + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/jobservice/pools": { + "get": { + "description": "Get worker pools", + "tags": [ + "jobservice" + ], + "summary": "Get worker pools", + "operationId": "getWorkerPools", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + } + ], + "responses": { + "200": { + "description": "Get worker pools successfully.", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/WorkerPool" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/jobservice/pools/{pool_id}/workers": { + "get": { + "description": "Get workers in current pool", + "tags": [ + "jobservice" + ], + "summary": "Get workers", + "operationId": "getWorkers", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "The name of the pool. 'all' stands for all pools", + "name": "pool_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Get workers successfully.", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Worker" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/jobservice/queues": { + "get": { + "description": "list job queue", + "tags": [ + "jobservice" + ], + "summary": "list job queues", + "operationId": "listJobQueues", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + } + ], + "responses": { + "200": { + "description": "List job queue successfully.", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/JobQueue" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/jobservice/queues/{job_type}": { + "put": { + "description": "stop and clean, pause, resume pending jobs in the queue", + "tags": [ + "jobservice" + ], + "summary": "stop and clean, pause, resume pending jobs in the queue", + "operationId": "actionPendingJobs", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "The type of the job. 'all' stands for all job types", + "name": "job_type", + "in": "path", + "required": true + }, + { + "name": "action_request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ActionRequest" + } + } + ], + "responses": { + "200": { + "description": "take action to the jobs in the queue successfully." + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/labels": { + "get": { + "description": "This endpoint let user list labels by name, scope and project_id\n", + "tags": [ + "label" + ], + "summary": "List labels according to the query strings.", + "operationId": "ListLabels", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "Query string to query resources. Supported query patterns are \"exact match(k=v)\", \"fuzzy match(k=~v)\", \"range(k=[min~max])\", \"list with union releationship(k={v1 v2 v3})\" and \"list with intersetion relationship(k=(v1 v2 v3))\". The value of range and list can be string(enclosed by \" or '), integer or time(in format \"2020-04-09 02:36:00\"). All of these query patterns should be put in the query string \"q=xxx\" and splitted by \",\". e.g. q=k1=v1,k2=~v2,k3=[min~max]", + "name": "q", + "in": "query" + }, + { + "type": "string", + "description": "Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with \"sort=field1,-field2\"", + "name": "sort", + "in": "query" + }, + { + "type": "integer", + "format": "int64", + "default": 1, + "description": "The page number", + "name": "page", + "in": "query" + }, + { + "maximum": 100, + "type": "integer", + "format": "int64", + "default": 10, + "description": "The size of per page", + "name": "page_size", + "in": "query" + }, + { + "type": "string", + "description": "The label name.", + "name": "name", + "in": "query" + }, + { + "type": "string", + "description": "The label scope. Valid values are g and p. g for global labels and p for project labels.", + "name": "scope", + "in": "query" + }, + { + "type": "integer", + "format": "int64", + "description": "Relevant project ID, required when scope is p.", + "name": "project_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Get successfully.", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Label" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link to previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of available items" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "post": { + "description": "This endpoint let user creates a label.\n", + "tags": [ + "label" + ], + "summary": "Post creates a label", + "operationId": "CreateLabel", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "description": "The json object of label.", + "name": "label", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/Label" + } + } + ], + "responses": { + "201": { + "description": "Create successfully.", + "headers": { + "Location": { + "type": "string", + "description": "The URL of the created resource" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "409": { + "description": "Conflict", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "415": { + "description": "Unsupported MediaType", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/labels/{label_id}": { + "get": { + "description": "This endpoint let user get the label by specific ID.\n", + "tags": [ + "label" + ], + "summary": "Get the label specified by ID.", + "operationId": "GetLabelByID", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "integer", + "format": "int64", + "description": "Label ID", + "name": "label_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Get successfully.", + "schema": { + "$ref": "#/definitions/Label" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "put": { + "description": "This endpoint let user update label properties.\n", + "tags": [ + "label" + ], + "summary": "Update the label properties.", + "operationId": "UpdateLabel", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "integer", + "format": "int64", + "description": "Label ID", + "name": "label_id", + "in": "path", + "required": true + }, + { + "description": "The updated label json object.", + "name": "label", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/Label" + } + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "409": { + "description": "Conflict", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "delete": { + "description": "Delete the label specified by ID.\n", + "tags": [ + "label" + ], + "summary": "Delete the label specified by ID.", + "operationId": "DeleteLabel", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "integer", + "format": "int64", + "description": "Label ID", + "name": "label_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/ldap/groups/search": { + "get": { + "description": "This endpoint searches the available ldap groups based on related configuration parameters. support to search by groupname or groupdn.\n", + "tags": [ + "Ldap" + ], + "summary": "Search available ldap groups.", + "operationId": "searchLdapGroup", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "Ldap group name", + "name": "groupname", + "in": "query" + }, + { + "type": "string", + "description": "The LDAP group DN", + "name": "groupdn", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Search ldap group successfully.", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/UserGroup" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/ldap/ping": { + "post": { + "description": "This endpoint ping the available ldap service for test related configuration parameters.\n", + "tags": [ + "Ldap" + ], + "summary": "Ping available ldap service.", + "operationId": "pingLdap", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "description": "ldap configuration. support input ldap service configuration. If it is a empty request, will load current configuration from the system.", + "name": "ldapconf", + "in": "body", + "schema": { + "$ref": "#/definitions/LdapConf" + } + } + ], + "responses": { + "200": { + "description": "Ping ldap service successfully.", + "schema": { + "$ref": "#/definitions/LdapPingResult" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/ldap/users/import": { + "post": { + "description": "This endpoint adds the selected available ldap users to harbor based on related configuration parameters from the system. System will try to guess the user email address and realname, add to harbor user information. If have errors when import user, will return the list of importing failed uid and the failed reason.\n", + "tags": [ + "Ldap" + ], + "summary": "Import selected available ldap users.", + "operationId": "importLdapUser", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "description": "The uid listed for importing. This list will check users validity of ldap service based on configuration from the system.", + "name": "uid_list", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/LdapImportUsers" + } + } + ], + "responses": { + "200": { + "description": "Add ldap users successfully." + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Failed import some users.", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/LdapFailedImportUser" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/ldap/users/search": { + "get": { + "description": "This endpoint searches the available ldap users based on related configuration parameters. Support searched by input ladp configuration, load configuration from the system and specific filter.\n", + "tags": [ + "Ldap" + ], + "summary": "Search available ldap users.", + "operationId": "searchLdapUser", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "Registered user ID", + "name": "username", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Search ldap users successfully.", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/LdapUser" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/p2p/preheat/instances": { + "get": { + "description": "List P2P provider instances", + "tags": [ + "preheat" + ], + "summary": "List P2P provider instances", + "operationId": "ListInstances", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "integer", + "format": "int64", + "default": 1, + "description": "The page number", + "name": "page", + "in": "query" + }, + { + "maximum": 100, + "type": "integer", + "format": "int64", + "default": 10, + "description": "The size of per page", + "name": "page_size", + "in": "query" + }, + { + "type": "string", + "description": "Query string to query resources. Supported query patterns are \"exact match(k=v)\", \"fuzzy match(k=~v)\", \"range(k=[min~max])\", \"list with union releationship(k={v1 v2 v3})\" and \"list with intersetion relationship(k=(v1 v2 v3))\". The value of range and list can be string(enclosed by \" or '), integer or time(in format \"2020-04-09 02:36:00\"). All of these query patterns should be put in the query string \"q=xxx\" and splitted by \",\". e.g. q=k1=v1,k2=~v2,k3=[min~max]", + "name": "q", + "in": "query" + }, + { + "type": "string", + "description": "Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with \"sort=field1,-field2\"", + "name": "sort", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Instance" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link refers to the previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of preheating provider instances" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "post": { + "description": "Create p2p provider instances", + "tags": [ + "preheat" + ], + "summary": "Create p2p provider instances", + "operationId": "CreateInstance", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "description": "The JSON object of instance.", + "name": "instance", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/Instance" + } + } + ], + "responses": { + "201": { + "description": "Created", + "headers": { + "Location": { + "type": "string", + "description": "The location of the resource" + }, + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "409": { + "description": "Conflict", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/p2p/preheat/instances/ping": { + "post": { + "description": "This endpoint checks status of a instance, the instance can be given by ID or Endpoint URL (together with credential)\n", + "tags": [ + "preheat" + ], + "summary": "Ping status of a instance.", + "operationId": "PingInstances", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "description": "The JSON object of instance.", + "name": "instance", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/Instance" + } + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Instance not found (when instance is provided by ID)." + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/p2p/preheat/instances/{preheat_instance_name}": { + "get": { + "description": "Get a P2P provider instance", + "tags": [ + "preheat" + ], + "summary": "Get a P2P provider instance", + "operationId": "GetInstance", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "Instance Name", + "name": "preheat_instance_name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/Instance" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "put": { + "description": "Update the specified P2P provider instance", + "tags": [ + "preheat" + ], + "summary": "Update the specified P2P provider instance", + "operationId": "UpdateInstance", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "Instance Name", + "name": "preheat_instance_name", + "in": "path", + "required": true + }, + { + "description": "The instance to update", + "name": "instance", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/Instance" + } + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "delete": { + "description": "Delete the specified P2P provider instance", + "tags": [ + "preheat" + ], + "summary": "Delete the specified P2P provider instance", + "operationId": "DeleteInstance", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "Instance Name", + "name": "preheat_instance_name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/p2p/preheat/providers": { + "get": { + "description": "List P2P providers", + "tags": [ + "preheat" + ], + "summary": "List P2P providers", + "operationId": "ListProviders", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Metadata" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/ping": { + "get": { + "description": "This API simply replies a pong to indicate the process to handle API is up, disregarding the health status of dependent components.", + "produces": [ + "text/plain" + ], + "tags": [ + "ping" + ], + "summary": "Ping Harbor to check if it's alive.", + "operationId": "getPing", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + } + ], + "responses": { + "200": { + "description": "The API server is alive", + "schema": { + "type": "string" + } + } + } + } + }, + "/projects": { + "get": { + "description": "This endpoint returns projects created by Harbor.", + "tags": [ + "project" + ], + "summary": "List projects", + "operationId": "listProjects", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "Query string to query resources. Supported query patterns are \"exact match(k=v)\", \"fuzzy match(k=~v)\", \"range(k=[min~max])\", \"list with union releationship(k={v1 v2 v3})\" and \"list with intersetion relationship(k=(v1 v2 v3))\". The value of range and list can be string(enclosed by \" or '), integer or time(in format \"2020-04-09 02:36:00\"). All of these query patterns should be put in the query string \"q=xxx\" and splitted by \",\". e.g. q=k1=v1,k2=~v2,k3=[min~max]", + "name": "q", + "in": "query" + }, + { + "type": "integer", + "format": "int64", + "default": 1, + "description": "The page number", + "name": "page", + "in": "query" + }, + { + "maximum": 100, + "type": "integer", + "format": "int64", + "default": 10, + "description": "The size of per page", + "name": "page_size", + "in": "query" + }, + { + "type": "string", + "description": "Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with \"sort=field1,-field2\"", + "name": "sort", + "in": "query" + }, + { + "type": "string", + "description": "The name of project.", + "name": "name", + "in": "query" + }, + { + "type": "boolean", + "format": "int32", + "description": "The project is public or private.", + "name": "public", + "in": "query" + }, + { + "type": "string", + "description": "The name of project owner.", + "name": "owner", + "in": "query" + }, + { + "type": "boolean", + "default": true, + "description": "Bool value indicating whether return detailed information of the project", + "name": "with_detail", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Return all matched projects.", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Project" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link refers to the previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of projects" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "post": { + "description": "This endpoint is for user to create a new project.", + "tags": [ + "project" + ], + "summary": "Create a new project.", + "operationId": "createProject", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "boolean", + "default": false, + "description": "The flag to indicate whether to return the name of the resource in Location. When X-Resource-Name-In-Location is true, the Location will return the name of the resource.", + "name": "X-Resource-Name-In-Location", + "in": "header" + }, + { + "description": "New created project.", + "name": "project", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ProjectReq" + } + } + ], + "responses": { + "201": { + "description": "Created", + "headers": { + "Location": { + "type": "string", + "description": "The location of the resource" + }, + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "409": { + "description": "Conflict", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "head": { + "description": "This endpoint is used to check if the project name provided already exist.", + "tags": [ + "project" + ], + "summary": "Check if the project name user provided already exists.", + "operationId": "headProject", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "Project name for checking exists.", + "name": "project_name", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/projects/{project_name_or_id}": { + "get": { + "description": "This endpoint returns specific project information by project ID.", + "tags": [ + "project" + ], + "summary": "Return specific project detail information", + "operationId": "getProject", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "boolean", + "default": false, + "description": "The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.", + "name": "X-Is-Resource-Name", + "in": "header" + }, + { + "type": "string", + "description": "The name or id of the project", + "name": "project_name_or_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Return matched project information.", + "schema": { + "$ref": "#/definitions/Project" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "put": { + "description": "This endpoint is aimed to update the properties of a project.", + "tags": [ + "project" + ], + "summary": "Update properties for a selected project.", + "operationId": "updateProject", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "boolean", + "default": false, + "description": "The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.", + "name": "X-Is-Resource-Name", + "in": "header" + }, + { + "type": "string", + "description": "The name or id of the project", + "name": "project_name_or_id", + "in": "path", + "required": true + }, + { + "description": "Updates of project.", + "name": "project", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ProjectReq" + } + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "delete": { + "description": "This endpoint is aimed to delete project by project ID.", + "tags": [ + "project" + ], + "summary": "Delete project by projectID", + "operationId": "deleteProject", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "boolean", + "default": false, + "description": "The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.", + "name": "X-Is-Resource-Name", + "in": "header" + }, + { + "type": "string", + "description": "The name or id of the project", + "name": "project_name_or_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "412": { + "description": "Precondition failed", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/projects/{project_name_or_id}/_deletable": { + "get": { + "description": "Get the deletable status of the project", + "tags": [ + "project" + ], + "summary": "Get the deletable status of the project", + "operationId": "getProjectDeletable", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "boolean", + "default": false, + "description": "The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.", + "name": "X-Is-Resource-Name", + "in": "header" + }, + { + "type": "string", + "description": "The name or id of the project", + "name": "project_name_or_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Return deletable status of the project.", + "schema": { + "$ref": "#/definitions/ProjectDeletable" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/projects/{project_name_or_id}/immutabletagrules": { + "get": { + "description": "This endpoint returns the immutable tag rules of a project\n", + "tags": [ + "immutable" + ], + "summary": "List all immutable tag rules of current project", + "operationId": "ListImmuRules", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "boolean", + "default": false, + "description": "The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.", + "name": "X-Is-Resource-Name", + "in": "header" + }, + { + "type": "string", + "description": "The name or id of the project", + "name": "project_name_or_id", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "default": 1, + "description": "The page number", + "name": "page", + "in": "query" + }, + { + "maximum": 100, + "type": "integer", + "format": "int64", + "default": 10, + "description": "The size of per page", + "name": "page_size", + "in": "query" + }, + { + "type": "string", + "description": "Query string to query resources. Supported query patterns are \"exact match(k=v)\", \"fuzzy match(k=~v)\", \"range(k=[min~max])\", \"list with union releationship(k={v1 v2 v3})\" and \"list with intersetion relationship(k=(v1 v2 v3))\". The value of range and list can be string(enclosed by \" or '), integer or time(in format \"2020-04-09 02:36:00\"). All of these query patterns should be put in the query string \"q=xxx\" and splitted by \",\". e.g. q=k1=v1,k2=~v2,k3=[min~max]", + "name": "q", + "in": "query" + }, + { + "type": "string", + "description": "Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with \"sort=field1,-field2\"", + "name": "sort", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/ImmutableRule" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link refers to the previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of immutable tag" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "post": { + "description": "This endpoint add an immutable tag rule to the project\n", + "tags": [ + "immutable" + ], + "summary": "Add an immutable tag rule to current project", + "operationId": "CreateImmuRule", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "boolean", + "default": false, + "description": "The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.", + "name": "X-Is-Resource-Name", + "in": "header" + }, + { + "type": "string", + "description": "The name or id of the project", + "name": "project_name_or_id", + "in": "path", + "required": true + }, + { + "name": "ImmutableRule", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ImmutableRule" + } + } + ], + "responses": { + "201": { + "description": "Created", + "headers": { + "Location": { + "type": "string", + "description": "The location of the resource" + }, + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/projects/{project_name_or_id}/immutabletagrules/{immutable_rule_id}": { + "put": { + "tags": [ + "immutable" + ], + "summary": "Update the immutable tag rule or enable or disable the rule", + "operationId": "UpdateImmuRule", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "boolean", + "default": false, + "description": "The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.", + "name": "X-Is-Resource-Name", + "in": "header" + }, + { + "type": "string", + "description": "The name or id of the project", + "name": "project_name_or_id", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "The ID of the immutable rule", + "name": "immutable_rule_id", + "in": "path", + "required": true + }, + { + "name": "ImmutableRule", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ImmutableRule" + } + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "delete": { + "tags": [ + "immutable" + ], + "summary": "Delete the immutable tag rule.", + "operationId": "DeleteImmuRule", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "boolean", + "default": false, + "description": "The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.", + "name": "X-Is-Resource-Name", + "in": "header" + }, + { + "type": "string", + "description": "The name or id of the project", + "name": "project_name_or_id", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "The ID of the immutable rule", + "name": "immutable_rule_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/projects/{project_name_or_id}/members": { + "get": { + "description": "Get all project member information", + "tags": [ + "member" + ], + "summary": "Get all project member information", + "operationId": "listProjectMembers", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "boolean", + "default": false, + "description": "The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.", + "name": "X-Is-Resource-Name", + "in": "header" + }, + { + "type": "string", + "description": "The name or id of the project", + "name": "project_name_or_id", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "default": 1, + "description": "The page number", + "name": "page", + "in": "query" + }, + { + "maximum": 100, + "type": "integer", + "format": "int64", + "default": 10, + "description": "The size of per page", + "name": "page_size", + "in": "query" + }, + { + "type": "string", + "description": "The entity name to search.", + "name": "entityname", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Get project members successfully.", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/ProjectMemberEntity" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link refers to the previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of members" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "post": { + "description": "Create project member relationship, the member can be one of the user_member and group_member, The user_member need to specify user_id or username. If the user already exist in harbor DB, specify the user_id, If does not exist in harbor DB, it will SearchAndOnBoard the user. The group_member need to specify id or ldap_group_dn. If the group already exist in harbor DB. specify the user group's id, If does not exist, it will SearchAndOnBoard the group. ", + "tags": [ + "member" + ], + "summary": "Create project member", + "operationId": "createProjectMember", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "boolean", + "default": false, + "description": "The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.", + "name": "X-Is-Resource-Name", + "in": "header" + }, + { + "type": "string", + "description": "The name or id of the project", + "name": "project_name_or_id", + "in": "path", + "required": true + }, + { + "name": "project_member", + "in": "body", + "schema": { + "$ref": "#/definitions/ProjectMember" + } + } + ], + "responses": { + "201": { + "description": "Project member created successfully.", + "headers": { + "Location": { + "type": "string", + "description": "The URL of the created resource" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "409": { + "description": "Conflict", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/projects/{project_name_or_id}/members/{mid}": { + "get": { + "description": "Get the project member information", + "tags": [ + "member" + ], + "summary": "Get the project member information", + "operationId": "getProjectMember", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "boolean", + "default": false, + "description": "The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.", + "name": "X-Is-Resource-Name", + "in": "header" + }, + { + "type": "string", + "description": "The name or id of the project", + "name": "project_name_or_id", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "The member ID", + "name": "mid", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Project member retrieved successfully.", + "schema": { + "$ref": "#/definitions/ProjectMemberEntity" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "put": { + "description": "Update project member relationship", + "tags": [ + "member" + ], + "summary": "Update project member", + "operationId": "updateProjectMember", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "boolean", + "default": false, + "description": "The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.", + "name": "X-Is-Resource-Name", + "in": "header" + }, + { + "type": "string", + "description": "The name or id of the project", + "name": "project_name_or_id", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "Member ID.", + "name": "mid", + "in": "path", + "required": true + }, + { + "name": "role", + "in": "body", + "schema": { + "$ref": "#/definitions/RoleRequest" + } + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "delete": { + "tags": [ + "member" + ], + "summary": "Delete project member", + "operationId": "deleteProjectMember", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "boolean", + "default": false, + "description": "The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.", + "name": "X-Is-Resource-Name", + "in": "header" + }, + { + "type": "string", + "description": "The name or id of the project", + "name": "project_name_or_id", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "Member ID.", + "name": "mid", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/projects/{project_name_or_id}/metadatas/": { + "get": { + "description": "Get the metadata of the specific project", + "tags": [ + "projectMetadata" + ], + "summary": "Get the metadata of the specific project", + "operationId": "listProjectMetadatas", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "boolean", + "default": false, + "description": "The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.", + "name": "X-Is-Resource-Name", + "in": "header" + }, + { + "type": "string", + "description": "The name or id of the project", + "name": "project_name_or_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "post": { + "description": "Add metadata for the specific project", + "tags": [ + "projectMetadata" + ], + "summary": "Add metadata for the specific project", + "operationId": "addProjectMetadatas", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "boolean", + "default": false, + "description": "The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.", + "name": "X-Is-Resource-Name", + "in": "header" + }, + { + "type": "string", + "description": "The name or id of the project", + "name": "project_name_or_id", + "in": "path", + "required": true + }, + { + "name": "metadata", + "in": "body", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "409": { + "description": "Conflict", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/projects/{project_name_or_id}/metadatas/{meta_name}": { + "get": { + "description": "Get the specific metadata of the specific project", + "tags": [ + "projectMetadata" + ], + "summary": "Get the specific metadata of the specific project", + "operationId": "getProjectMetadata", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "boolean", + "default": false, + "description": "The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.", + "name": "X-Is-Resource-Name", + "in": "header" + }, + { + "type": "string", + "description": "The name or id of the project", + "name": "project_name_or_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The name of metadata.", + "name": "meta_name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "put": { + "description": "Update the specific metadata for the specific project", + "tags": [ + "projectMetadata" + ], + "summary": "Update the specific metadata for the specific project", + "operationId": "updateProjectMetadata", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "boolean", + "default": false, + "description": "The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.", + "name": "X-Is-Resource-Name", + "in": "header" + }, + { + "type": "string", + "description": "The name or id of the project", + "name": "project_name_or_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The name of metadata.", + "name": "meta_name", + "in": "path", + "required": true + }, + { + "name": "metadata", + "in": "body", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "409": { + "description": "Conflict", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "delete": { + "description": "Delete the specific metadata for the specific project", + "tags": [ + "projectMetadata" + ], + "summary": "Delete the specific metadata for the specific project", + "operationId": "deleteProjectMetadata", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "boolean", + "default": false, + "description": "The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.", + "name": "X-Is-Resource-Name", + "in": "header" + }, + { + "type": "string", + "description": "The name or id of the project", + "name": "project_name_or_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The name of metadata.", + "name": "meta_name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "409": { + "description": "Conflict", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/projects/{project_name_or_id}/robots": { + "get": { + "description": "Get all robot accounts of specified project", + "tags": [ + "robotv1" + ], + "summary": "Get all robot accounts of specified project", + "operationId": "ListRobotV1", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "boolean", + "default": false, + "description": "The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.", + "name": "X-Is-Resource-Name", + "in": "header" + }, + { + "type": "string", + "description": "The name or id of the project", + "name": "project_name_or_id", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "default": 1, + "description": "The page number", + "name": "page", + "in": "query" + }, + { + "maximum": 100, + "type": "integer", + "format": "int64", + "default": 10, + "description": "The size of per page", + "name": "page_size", + "in": "query" + }, + { + "type": "string", + "description": "Query string to query resources. Supported query patterns are \"exact match(k=v)\", \"fuzzy match(k=~v)\", \"range(k=[min~max])\", \"list with union releationship(k={v1 v2 v3})\" and \"list with intersetion relationship(k=(v1 v2 v3))\". The value of range and list can be string(enclosed by \" or '), integer or time(in format \"2020-04-09 02:36:00\"). All of these query patterns should be put in the query string \"q=xxx\" and splitted by \",\". e.g. q=k1=v1,k2=~v2,k3=[min~max]", + "name": "q", + "in": "query" + }, + { + "type": "string", + "description": "Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with \"sort=field1,-field2\"", + "name": "sort", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Robot" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link refers to the previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of robot accounts" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "post": { + "description": "Create a robot account", + "tags": [ + "robotv1" + ], + "summary": "Create a robot account", + "operationId": "CreateRobotV1", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "boolean", + "default": false, + "description": "The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.", + "name": "X-Is-Resource-Name", + "in": "header" + }, + { + "type": "string", + "description": "The name or id of the project", + "name": "project_name_or_id", + "in": "path", + "required": true + }, + { + "description": "The JSON object of a robot account.", + "name": "robot", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/RobotCreateV1" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/RobotCreated" + }, + "headers": { + "Location": { + "type": "string", + "description": "The location of the resource" + }, + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/projects/{project_name_or_id}/robots/{robot_id}": { + "get": { + "description": "This endpoint returns specific robot account information by robot ID.", + "tags": [ + "robotv1" + ], + "summary": "Get a robot account", + "operationId": "GetRobotByIDV1", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "boolean", + "default": false, + "description": "The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.", + "name": "X-Is-Resource-Name", + "in": "header" + }, + { + "type": "string", + "description": "The name or id of the project", + "name": "project_name_or_id", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "Robot ID", + "name": "robot_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Return matched robot information.", + "schema": { + "$ref": "#/definitions/Robot" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "put": { + "description": "Used to disable/enable a specified robot account.", + "tags": [ + "robotv1" + ], + "summary": "Update status of robot account.", + "operationId": "UpdateRobotV1", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "boolean", + "default": false, + "description": "The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.", + "name": "X-Is-Resource-Name", + "in": "header" + }, + { + "type": "string", + "description": "The name or id of the project", + "name": "project_name_or_id", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "Robot ID", + "name": "robot_id", + "in": "path", + "required": true + }, + { + "description": "The JSON object of a robot account.", + "name": "robot", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/Robot" + } + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "409": { + "description": "Conflict", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "delete": { + "description": "This endpoint deletes specific robot account information by robot ID.", + "tags": [ + "robotv1" + ], + "summary": "Delete a robot account", + "operationId": "DeleteRobotV1", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "boolean", + "default": false, + "description": "The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.", + "name": "X-Is-Resource-Name", + "in": "header" + }, + { + "type": "string", + "description": "The name or id of the project", + "name": "project_name_or_id", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "Robot ID", + "name": "robot_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/projects/{project_name_or_id}/scanner": { + "get": { + "description": "Get the scanner registration of the specified project. If no scanner registration is configured for the specified project, the system default scanner registration will be returned.", + "tags": [ + "project" + ], + "summary": "Get project level scanner", + "operationId": "getScannerOfProject", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "boolean", + "default": false, + "description": "The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.", + "name": "X-Is-Resource-Name", + "in": "header" + }, + { + "type": "string", + "description": "The name or id of the project", + "name": "project_name_or_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "The details of the scanner registration.", + "schema": { + "$ref": "#/definitions/ScannerRegistration" + } + }, + "400": { + "description": "Bad project ID" + }, + "401": { + "description": "Unauthorized request" + }, + "403": { + "description": "Request is not allowed" + }, + "404": { + "description": "The requested object is not found" + }, + "500": { + "description": "Internal server error happened" + } + } + }, + "put": { + "description": "Set one of the system configured scanner registration as the indepndent scanner of the specified project.", + "tags": [ + "project" + ], + "summary": "Configure scanner for the specified project", + "operationId": "setScannerOfProject", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "boolean", + "default": false, + "description": "The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.", + "name": "X-Is-Resource-Name", + "in": "header" + }, + { + "type": "string", + "description": "The name or id of the project", + "name": "project_name_or_id", + "in": "path", + "required": true + }, + { + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ProjectScanner" + } + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/projects/{project_name_or_id}/scanner/candidates": { + "get": { + "description": "Retrieve the system configured scanner registrations as candidates of setting project level scanner.", + "tags": [ + "project" + ], + "summary": "Get scanner registration candidates for configurating project level scanner", + "operationId": "listScannerCandidatesOfProject", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "boolean", + "default": false, + "description": "The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.", + "name": "X-Is-Resource-Name", + "in": "header" + }, + { + "type": "string", + "description": "The name or id of the project", + "name": "project_name_or_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Query string to query resources. Supported query patterns are \"exact match(k=v)\", \"fuzzy match(k=~v)\", \"range(k=[min~max])\", \"list with union releationship(k={v1 v2 v3})\" and \"list with intersetion relationship(k=(v1 v2 v3))\". The value of range and list can be string(enclosed by \" or '), integer or time(in format \"2020-04-09 02:36:00\"). All of these query patterns should be put in the query string \"q=xxx\" and splitted by \",\". e.g. q=k1=v1,k2=~v2,k3=[min~max]", + "name": "q", + "in": "query" + }, + { + "type": "string", + "description": "Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with \"sort=field1,-field2\"", + "name": "sort", + "in": "query" + }, + { + "type": "integer", + "format": "int64", + "default": 1, + "description": "The page number", + "name": "page", + "in": "query" + }, + { + "maximum": 100, + "type": "integer", + "format": "int64", + "default": 10, + "description": "The size of per page", + "name": "page_size", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A list of scanner registrations.", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/ScannerRegistration" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link to previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of available items" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/projects/{project_name_or_id}/summary": { + "get": { + "description": "Get summary of the project.", + "tags": [ + "project" + ], + "summary": "Get summary of the project.", + "operationId": "getProjectSummary", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "boolean", + "default": false, + "description": "The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.", + "name": "X-Is-Resource-Name", + "in": "header" + }, + { + "type": "string", + "description": "The name or id of the project", + "name": "project_name_or_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Get summary of the project successfully.", + "schema": { + "$ref": "#/definitions/ProjectSummary" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/projects/{project_name_or_id}/webhook/events": { + "get": { + "description": "Get supportted event types and notify types.", + "tags": [ + "webhook" + ], + "summary": "Get supported event types and notify types.", + "operationId": "GetSupportedEventTypes", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "boolean", + "default": false, + "description": "The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.", + "name": "X-Is-Resource-Name", + "in": "header" + }, + { + "type": "string", + "description": "The name or id of the project", + "name": "project_name_or_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/SupportedWebhookEventTypes" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/projects/{project_name_or_id}/webhook/jobs": { + "get": { + "description": "This endpoint returns webhook jobs of a project.\n", + "tags": [ + "webhookjob" + ], + "summary": "List project webhook jobs", + "operationId": "ListWebhookJobs", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "boolean", + "default": false, + "description": "The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.", + "name": "X-Is-Resource-Name", + "in": "header" + }, + { + "type": "string", + "description": "The name or id of the project", + "name": "project_name_or_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Query string to query resources. Supported query patterns are \"exact match(k=v)\", \"fuzzy match(k=~v)\", \"range(k=[min~max])\", \"list with union releationship(k={v1 v2 v3})\" and \"list with intersetion relationship(k=(v1 v2 v3))\". The value of range and list can be string(enclosed by \" or '), integer or time(in format \"2020-04-09 02:36:00\"). All of these query patterns should be put in the query string \"q=xxx\" and splitted by \",\". e.g. q=k1=v1,k2=~v2,k3=[min~max]", + "name": "q", + "in": "query" + }, + { + "type": "string", + "description": "Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with \"sort=field1,-field2\"", + "name": "sort", + "in": "query" + }, + { + "type": "integer", + "format": "int64", + "default": 1, + "description": "The page number", + "name": "page", + "in": "query" + }, + { + "maximum": 100, + "type": "integer", + "format": "int64", + "default": 10, + "description": "The size of per page", + "name": "page_size", + "in": "query" + }, + { + "type": "integer", + "format": "int64", + "description": "The policy ID.", + "name": "policy_id", + "in": "query", + "required": true + }, + { + "type": "array", + "items": { + "type": "string" + }, + "description": "The status of webhook job.", + "name": "status", + "in": "query" + } + ], + "responses": { + "200": { + "description": "List project webhook jobs successfully.", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/WebhookJob" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link to previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of available items" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/projects/{project_name_or_id}/webhook/lasttrigger": { + "get": { + "description": "This endpoint returns last trigger information of project webhook policy.\n", + "tags": [ + "webhook" + ], + "summary": "Get project webhook policy last trigger info", + "operationId": "LastTrigger", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "boolean", + "default": false, + "description": "The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.", + "name": "X-Is-Resource-Name", + "in": "header" + }, + { + "type": "string", + "description": "The name or id of the project", + "name": "project_name_or_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Test webhook connection successfully.", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/WebhookLastTrigger" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/projects/{project_name_or_id}/webhook/policies": { + "get": { + "description": "This endpoint returns webhook policies of a project.\n", + "tags": [ + "webhook" + ], + "summary": "List project webhook policies.", + "operationId": "ListWebhookPoliciesOfProject", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "boolean", + "default": false, + "description": "The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.", + "name": "X-Is-Resource-Name", + "in": "header" + }, + { + "type": "string", + "description": "The name or id of the project", + "name": "project_name_or_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with \"sort=field1,-field2\"", + "name": "sort", + "in": "query" + }, + { + "type": "string", + "description": "Query string to query resources. Supported query patterns are \"exact match(k=v)\", \"fuzzy match(k=~v)\", \"range(k=[min~max])\", \"list with union releationship(k={v1 v2 v3})\" and \"list with intersetion relationship(k=(v1 v2 v3))\". The value of range and list can be string(enclosed by \" or '), integer or time(in format \"2020-04-09 02:36:00\"). All of these query patterns should be put in the query string \"q=xxx\" and splitted by \",\". e.g. q=k1=v1,k2=~v2,k3=[min~max]", + "name": "q", + "in": "query" + }, + { + "type": "integer", + "format": "int64", + "default": 1, + "description": "The page number", + "name": "page", + "in": "query" + }, + { + "maximum": 100, + "type": "integer", + "format": "int64", + "default": 10, + "description": "The size of per page", + "name": "page_size", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/WebhookPolicy" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link refers to the previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of webhook policies." + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "post": { + "description": "This endpoint create a webhook policy if the project does not have one.\n", + "tags": [ + "webhook" + ], + "summary": "Create project webhook policy.", + "operationId": "CreateWebhookPolicyOfProject", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "boolean", + "default": false, + "description": "The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.", + "name": "X-Is-Resource-Name", + "in": "header" + }, + { + "type": "string", + "description": "The name or id of the project", + "name": "project_name_or_id", + "in": "path", + "required": true + }, + { + "description": "Properties \"targets\" and \"event_types\" needed.", + "name": "policy", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/WebhookPolicy" + } + } + ], + "responses": { + "201": { + "description": "Project webhook policy create successfully.", + "headers": { + "Location": { + "type": "string", + "description": "The location of the resource" + }, + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}": { + "get": { + "description": "This endpoint returns specified webhook policy of a project.\n", + "tags": [ + "webhook" + ], + "summary": "Get project webhook policy", + "operationId": "GetWebhookPolicyOfProject", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "boolean", + "default": false, + "description": "The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.", + "name": "X-Is-Resource-Name", + "in": "header" + }, + { + "type": "string", + "description": "The name or id of the project", + "name": "project_name_or_id", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "The ID of the webhook policy", + "name": "webhook_policy_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Get webhook policy successfully.", + "schema": { + "$ref": "#/definitions/WebhookPolicy" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "put": { + "description": "This endpoint is aimed to update the webhook policy of a project.\n", + "tags": [ + "webhook" + ], + "summary": "Update webhook policy of a project.", + "operationId": "UpdateWebhookPolicyOfProject", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "boolean", + "default": false, + "description": "The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.", + "name": "X-Is-Resource-Name", + "in": "header" + }, + { + "type": "string", + "description": "The name or id of the project", + "name": "project_name_or_id", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "The ID of the webhook policy", + "name": "webhook_policy_id", + "in": "path", + "required": true + }, + { + "description": "All properties needed except \"id\", \"project_id\", \"creation_time\", \"update_time\".", + "name": "policy", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/WebhookPolicy" + } + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "delete": { + "description": "This endpoint is aimed to delete webhookpolicy of a project.\n", + "tags": [ + "webhook" + ], + "summary": "Delete webhook policy of a project", + "operationId": "DeleteWebhookPolicyOfProject", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "boolean", + "default": false, + "description": "The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.", + "name": "X-Is-Resource-Name", + "in": "header" + }, + { + "type": "string", + "description": "The name or id of the project", + "name": "project_name_or_id", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "The ID of the webhook policy", + "name": "webhook_policy_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/projects/{project_name}/logs": { + "get": { + "description": "Get recent logs of the projects", + "tags": [ + "project" + ], + "summary": "Get recent logs of the projects", + "operationId": "getLogs", + "parameters": [ + { + "type": "string", + "description": "The name of the project", + "name": "project_name", + "in": "path", + "required": true + }, + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "Query string to query resources. Supported query patterns are \"exact match(k=v)\", \"fuzzy match(k=~v)\", \"range(k=[min~max])\", \"list with union releationship(k={v1 v2 v3})\" and \"list with intersetion relationship(k=(v1 v2 v3))\". The value of range and list can be string(enclosed by \" or '), integer or time(in format \"2020-04-09 02:36:00\"). All of these query patterns should be put in the query string \"q=xxx\" and splitted by \",\". e.g. q=k1=v1,k2=~v2,k3=[min~max]", + "name": "q", + "in": "query" + }, + { + "type": "string", + "description": "Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with \"sort=field1,-field2\"", + "name": "sort", + "in": "query" + }, + { + "type": "integer", + "format": "int64", + "default": 1, + "description": "The page number", + "name": "page", + "in": "query" + }, + { + "maximum": 100, + "type": "integer", + "format": "int64", + "default": 10, + "description": "The size of per page", + "name": "page_size", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/AuditLog" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link refers to the previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of auditlogs" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/projects/{project_name}/preheat/policies": { + "get": { + "description": "List preheat policies", + "tags": [ + "preheat" + ], + "summary": "List preheat policies", + "operationId": "ListPolicies", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "The name of the project", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "default": 1, + "description": "The page number", + "name": "page", + "in": "query" + }, + { + "maximum": 100, + "type": "integer", + "format": "int64", + "default": 10, + "description": "The size of per page", + "name": "page_size", + "in": "query" + }, + { + "type": "string", + "description": "Query string to query resources. Supported query patterns are \"exact match(k=v)\", \"fuzzy match(k=~v)\", \"range(k=[min~max])\", \"list with union releationship(k={v1 v2 v3})\" and \"list with intersetion relationship(k=(v1 v2 v3))\". The value of range and list can be string(enclosed by \" or '), integer or time(in format \"2020-04-09 02:36:00\"). All of these query patterns should be put in the query string \"q=xxx\" and splitted by \",\". e.g. q=k1=v1,k2=~v2,k3=[min~max]", + "name": "q", + "in": "query" + }, + { + "type": "string", + "description": "Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with \"sort=field1,-field2\"", + "name": "sort", + "in": "query" + } + ], + "responses": { + "200": { + "description": "List preheat policies success", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/PreheatPolicy" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link refers to the previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of policies" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "post": { + "description": "Create a preheat policy under a project", + "tags": [ + "preheat" + ], + "summary": "Create a preheat policy under a project", + "operationId": "CreatePolicy", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "The name of the project", + "name": "project_name", + "in": "path", + "required": true + }, + { + "description": "The policy schema info", + "name": "policy", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/PreheatPolicy" + } + } + ], + "responses": { + "201": { + "description": "Created", + "headers": { + "Location": { + "type": "string", + "description": "The location of the resource" + }, + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "409": { + "description": "Conflict", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/projects/{project_name}/preheat/policies/{preheat_policy_name}": { + "get": { + "description": "Get a preheat policy", + "tags": [ + "preheat" + ], + "summary": "Get a preheat policy", + "operationId": "GetPolicy", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "The name of the project", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Preheat Policy Name", + "name": "preheat_policy_name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Get a preheat policy success", + "schema": { + "$ref": "#/definitions/PreheatPolicy" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "put": { + "description": "Update preheat policy", + "tags": [ + "preheat" + ], + "summary": "Update preheat policy", + "operationId": "UpdatePolicy", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "The name of the project", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Preheat Policy Name", + "name": "preheat_policy_name", + "in": "path", + "required": true + }, + { + "description": "The policy schema info", + "name": "policy", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/PreheatPolicy" + } + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "409": { + "description": "Conflict", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "post": { + "description": "Manual preheat", + "tags": [ + "preheat" + ], + "summary": "Manual preheat", + "operationId": "ManualPreheat", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "The name of the project", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Preheat Policy Name", + "name": "preheat_policy_name", + "in": "path", + "required": true + }, + { + "description": "The policy schema info", + "name": "policy", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/PreheatPolicy" + } + } + ], + "responses": { + "201": { + "description": "Created", + "headers": { + "Location": { + "type": "string", + "description": "The location of the resource" + }, + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "delete": { + "description": "Delete a preheat policy", + "tags": [ + "preheat" + ], + "summary": "Delete a preheat policy", + "operationId": "DeletePolicy", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "The name of the project", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Preheat Policy Name", + "name": "preheat_policy_name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/projects/{project_name}/preheat/policies/{preheat_policy_name}/executions": { + "get": { + "description": "List executions for the given policy", + "tags": [ + "preheat" + ], + "summary": "List executions for the given policy", + "operationId": "ListExecutions", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "The name of the project", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Preheat Policy Name", + "name": "preheat_policy_name", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "default": 1, + "description": "The page number", + "name": "page", + "in": "query" + }, + { + "maximum": 100, + "type": "integer", + "format": "int64", + "default": 10, + "description": "The size of per page", + "name": "page_size", + "in": "query" + }, + { + "type": "string", + "description": "Query string to query resources. Supported query patterns are \"exact match(k=v)\", \"fuzzy match(k=~v)\", \"range(k=[min~max])\", \"list with union releationship(k={v1 v2 v3})\" and \"list with intersetion relationship(k=(v1 v2 v3))\". The value of range and list can be string(enclosed by \" or '), integer or time(in format \"2020-04-09 02:36:00\"). All of these query patterns should be put in the query string \"q=xxx\" and splitted by \",\". e.g. q=k1=v1,k2=~v2,k3=[min~max]", + "name": "q", + "in": "query" + }, + { + "type": "string", + "description": "Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with \"sort=field1,-field2\"", + "name": "sort", + "in": "query" + } + ], + "responses": { + "200": { + "description": "List executions success", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Execution" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link refers to the previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of executions" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/projects/{project_name}/preheat/policies/{preheat_policy_name}/executions/{execution_id}": { + "get": { + "description": "Get a execution detail by id", + "tags": [ + "preheat" + ], + "summary": "Get a execution detail by id", + "operationId": "GetExecution", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "The name of the project", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Preheat Policy Name", + "name": "preheat_policy_name", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "Execution ID", + "name": "execution_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Get execution success", + "schema": { + "$ref": "#/definitions/Execution" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "patch": { + "description": "Stop a execution", + "tags": [ + "preheat" + ], + "summary": "Stop a execution", + "operationId": "StopExecution", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "The name of the project", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Preheat Policy Name", + "name": "preheat_policy_name", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "Execution ID", + "name": "execution_id", + "in": "path", + "required": true + }, + { + "description": "The data of execution", + "name": "execution", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/Execution" + } + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/projects/{project_name}/preheat/policies/{preheat_policy_name}/executions/{execution_id}/tasks": { + "get": { + "description": "List all the related tasks for the given execution", + "tags": [ + "preheat" + ], + "summary": "List all the related tasks for the given execution", + "operationId": "ListTasks", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "The name of the project", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Preheat Policy Name", + "name": "preheat_policy_name", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "Execution ID", + "name": "execution_id", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "default": 1, + "description": "The page number", + "name": "page", + "in": "query" + }, + { + "maximum": 100, + "type": "integer", + "format": "int64", + "default": 10, + "description": "The size of per page", + "name": "page_size", + "in": "query" + }, + { + "type": "string", + "description": "Query string to query resources. Supported query patterns are \"exact match(k=v)\", \"fuzzy match(k=~v)\", \"range(k=[min~max])\", \"list with union releationship(k={v1 v2 v3})\" and \"list with intersetion relationship(k=(v1 v2 v3))\". The value of range and list can be string(enclosed by \" or '), integer or time(in format \"2020-04-09 02:36:00\"). All of these query patterns should be put in the query string \"q=xxx\" and splitted by \",\". e.g. q=k1=v1,k2=~v2,k3=[min~max]", + "name": "q", + "in": "query" + }, + { + "type": "string", + "description": "Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with \"sort=field1,-field2\"", + "name": "sort", + "in": "query" + } + ], + "responses": { + "200": { + "description": "List tasks success", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Task" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link refers to the previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of tasks" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/projects/{project_name}/preheat/policies/{preheat_policy_name}/executions/{execution_id}/tasks/{task_id}/logs": { + "get": { + "description": "Get the log text stream of the specified task for the given execution", + "produces": [ + "text/plain" + ], + "tags": [ + "preheat" + ], + "summary": "Get the log text stream of the specified task for the given execution", + "operationId": "GetPreheatLog", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "The name of the project", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Preheat Policy Name", + "name": "preheat_policy_name", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "Execution ID", + "name": "execution_id", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "Task ID", + "name": "task_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Get log success", + "schema": { + "type": "string" + }, + "headers": { + "Content-Type": { + "type": "string", + "description": "Content type of response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/projects/{project_name}/preheat/providers": { + "get": { + "description": "Get all providers at project level", + "tags": [ + "preheat" + ], + "summary": "Get all providers at project level", + "operationId": "ListProvidersUnderProject", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "The name of the project", + "name": "project_name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/ProviderUnderProject" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/projects/{project_name}/repositories": { + "get": { + "description": "List repositories of the specified project", + "tags": [ + "repository" + ], + "summary": "List repositories", + "operationId": "listRepositories", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "The name of the project", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Query string to query resources. Supported query patterns are \"exact match(k=v)\", \"fuzzy match(k=~v)\", \"range(k=[min~max])\", \"list with union releationship(k={v1 v2 v3})\" and \"list with intersetion relationship(k=(v1 v2 v3))\". The value of range and list can be string(enclosed by \" or '), integer or time(in format \"2020-04-09 02:36:00\"). All of these query patterns should be put in the query string \"q=xxx\" and splitted by \",\". e.g. q=k1=v1,k2=~v2,k3=[min~max]", + "name": "q", + "in": "query" + }, + { + "type": "string", + "description": "Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with \"sort=field1,-field2\"", + "name": "sort", + "in": "query" + }, + { + "type": "integer", + "format": "int64", + "default": 1, + "description": "The page number", + "name": "page", + "in": "query" + }, + { + "maximum": 100, + "type": "integer", + "format": "int64", + "default": 10, + "description": "The size of per page", + "name": "page_size", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Repository" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link refers to the previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of repositories" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/projects/{project_name}/repositories/{repository_name}": { + "get": { + "description": "Get the repository specified by name", + "tags": [ + "repository" + ], + "summary": "Get repository", + "operationId": "getRepository", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "The name of the project", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -\u003e a%252Fb", + "name": "repository_name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/Repository" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "put": { + "description": "Update the repository specified by name", + "tags": [ + "repository" + ], + "summary": "Update repository", + "operationId": "updateRepository", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "The name of the project", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -\u003e a%252Fb", + "name": "repository_name", + "in": "path", + "required": true + }, + { + "description": "The JSON object of repository.", + "name": "repository", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/Repository" + } + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "delete": { + "description": "Delete the repository specified by name", + "tags": [ + "repository" + ], + "summary": "Delete repository", + "operationId": "deleteRepository", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "The name of the project", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -\u003e a%252Fb", + "name": "repository_name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/projects/{project_name}/repositories/{repository_name}/artifacts": { + "get": { + "description": "List artifacts under the specific project and repository. Except the basic properties, the other supported queries in \"q\" includes \"tags=*\" to list only tagged artifacts, \"tags=nil\" to list only untagged artifacts, \"tags=~v\" to list artifacts whose tag fuzzy matches \"v\", \"tags=v\" to list artifact whose tag exactly matches \"v\", \"labels=(id1, id2)\" to list artifacts that both labels with id1 and id2 are added to", + "tags": [ + "artifact" + ], + "summary": "List artifacts", + "operationId": "listArtifacts", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "The name of the project", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -\u003e a%252Fb", + "name": "repository_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Query string to query resources. Supported query patterns are \"exact match(k=v)\", \"fuzzy match(k=~v)\", \"range(k=[min~max])\", \"list with union releationship(k={v1 v2 v3})\" and \"list with intersetion relationship(k=(v1 v2 v3))\". The value of range and list can be string(enclosed by \" or '), integer or time(in format \"2020-04-09 02:36:00\"). All of these query patterns should be put in the query string \"q=xxx\" and splitted by \",\". e.g. q=k1=v1,k2=~v2,k3=[min~max]", + "name": "q", + "in": "query" + }, + { + "type": "string", + "description": "Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with \"sort=field1,-field2\"", + "name": "sort", + "in": "query" + }, + { + "type": "integer", + "format": "int64", + "default": 1, + "description": "The page number", + "name": "page", + "in": "query" + }, + { + "maximum": 100, + "type": "integer", + "format": "int64", + "default": 10, + "description": "The size of per page", + "name": "page_size", + "in": "query" + }, + { + "type": "string", + "default": "application/vnd.security.vulnerability.report; version=1.1, application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0", + "description": "A comma-separated lists of MIME types for the scan report or scan summary. The first mime type will be used when the report found for it.\nCurrently the mime type supports 'application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0' and 'application/vnd.security.vulnerability.report; version=1.1'", + "name": "X-Accept-Vulnerabilities", + "in": "header" + }, + { + "type": "boolean", + "default": true, + "description": "Specify whether the tags are included inside the returning artifacts", + "name": "with_tag", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Specify whether the labels are included inside the returning artifacts", + "name": "with_label", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Specify whether the scan overview is included inside the returning artifacts", + "name": "with_scan_overview", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Specify whether the signature is included inside the tags of the returning artifacts. Only works when setting \"with_tag=true\"", + "name": "with_signature", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Specify whether the immutable status is included inside the tags of the returning artifacts. Only works when setting \"with_immutable_status=true\"", + "name": "with_immutable_status", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Specify whether the accessories are included of the returning artifacts. Only works when setting \"with_accessory=true\"", + "name": "with_accessory", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Artifact" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link refers to the previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of artifacts" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "post": { + "description": "Copy the artifact specified in the \"from\" parameter to the repository.", + "tags": [ + "artifact" + ], + "summary": "Copy artifact", + "operationId": "CopyArtifact", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "The name of the project", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -\u003e a%252Fb", + "name": "repository_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The artifact from which the new artifact is copied from, the format should be \"project/repository:tag\" or \"project/repository@digest\".", + "name": "from", + "in": "query", + "required": true + } + ], + "responses": { + "201": { + "description": "Created", + "headers": { + "Location": { + "type": "string", + "description": "The location of the resource" + }, + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "405": { + "description": "Method not allowed", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}": { + "get": { + "description": "Get the artifact specified by the reference under the project and repository. The reference can be digest or tag.", + "tags": [ + "artifact" + ], + "summary": "Get the specific artifact", + "operationId": "getArtifact", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "The name of the project", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -\u003e a%252Fb", + "name": "repository_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The reference of the artifact, can be digest or tag", + "name": "reference", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "default": 1, + "description": "The page number", + "name": "page", + "in": "query" + }, + { + "maximum": 100, + "type": "integer", + "format": "int64", + "default": 10, + "description": "The size of per page", + "name": "page_size", + "in": "query" + }, + { + "type": "string", + "default": "application/vnd.security.vulnerability.report; version=1.1, application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0", + "description": "A comma-separated lists of MIME types for the scan report or scan summary. The first mime type will be used when the report found for it.\nCurrently the mime type supports 'application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0' and 'application/vnd.security.vulnerability.report; version=1.1'", + "name": "X-Accept-Vulnerabilities", + "in": "header" + }, + { + "type": "boolean", + "default": true, + "description": "Specify whether the tags are inclued inside the returning artifacts", + "name": "with_tag", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Specify whether the labels are inclued inside the returning artifacts", + "name": "with_label", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Specify whether the scan overview is inclued inside the returning artifacts", + "name": "with_scan_overview", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Specify whether the accessories are included of the returning artifacts.", + "name": "with_accessory", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Specify whether the signature is inclued inside the returning artifacts", + "name": "with_signature", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Specify whether the immutable status is inclued inside the tags of the returning artifacts.", + "name": "with_immutable_status", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/Artifact" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "delete": { + "description": "Delete the artifact specified by the reference under the project and repository. The reference can be digest or tag", + "tags": [ + "artifact" + ], + "summary": "Delete the specific artifact", + "operationId": "deleteArtifact", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "The name of the project", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -\u003e a%252Fb", + "name": "repository_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The reference of the artifact, can be digest or tag", + "name": "reference", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/accessories": { + "get": { + "description": "List accessories of the specific artifact", + "tags": [ + "artifact" + ], + "summary": "List accessories", + "operationId": "listAccessories", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "The name of the project", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -\u003e a%252Fb", + "name": "repository_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The reference of the artifact, can be digest or tag", + "name": "reference", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Query string to query resources. Supported query patterns are \"exact match(k=v)\", \"fuzzy match(k=~v)\", \"range(k=[min~max])\", \"list with union releationship(k={v1 v2 v3})\" and \"list with intersetion relationship(k=(v1 v2 v3))\". The value of range and list can be string(enclosed by \" or '), integer or time(in format \"2020-04-09 02:36:00\"). All of these query patterns should be put in the query string \"q=xxx\" and splitted by \",\". e.g. q=k1=v1,k2=~v2,k3=[min~max]", + "name": "q", + "in": "query" + }, + { + "type": "string", + "description": "Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with \"sort=field1,-field2\"", + "name": "sort", + "in": "query" + }, + { + "type": "integer", + "format": "int64", + "default": 1, + "description": "The page number", + "name": "page", + "in": "query" + }, + { + "maximum": 100, + "type": "integer", + "format": "int64", + "default": 10, + "description": "The size of per page", + "name": "page_size", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Accessory" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link refers to the previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of accessories" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/additions/vulnerabilities": { + "get": { + "description": "Get the vulnerabilities addition of the artifact specified by the reference under the project and repository.", + "tags": [ + "artifact" + ], + "summary": "Get the vulnerabilities addition of the specific artifact", + "operationId": "getVulnerabilitiesAddition", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "The name of the project", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -\u003e a%252Fb", + "name": "repository_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The reference of the artifact, can be digest or tag", + "name": "reference", + "in": "path", + "required": true + }, + { + "type": "string", + "default": "application/vnd.security.vulnerability.report; version=1.1, application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0", + "description": "A comma-separated lists of MIME types for the scan report or scan summary. The first mime type will be used when the report found for it.\nCurrently the mime type supports 'application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0' and 'application/vnd.security.vulnerability.report; version=1.1'", + "name": "X-Accept-Vulnerabilities", + "in": "header" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "string" + }, + "headers": { + "Content-Type": { + "type": "string", + "description": "The content type of the vulnerabilities addition" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/additions/{addition}": { + "get": { + "description": "Get the addition of the artifact specified by the reference under the project and repository.", + "tags": [ + "artifact" + ], + "summary": "Get the addition of the specific artifact", + "operationId": "getAddition", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "The name of the project", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -\u003e a%252Fb", + "name": "repository_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The reference of the artifact, can be digest or tag", + "name": "reference", + "in": "path", + "required": true + }, + { + "enum": [ + "build_history", + "values.yaml", + "readme.md", + "dependencies" + ], + "type": "string", + "description": "The type of addition.", + "name": "addition", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "string" + }, + "headers": { + "Content-Type": { + "type": "string", + "description": "The content type of the addition" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/labels": { + "post": { + "description": "Add label to the specified artiact.", + "tags": [ + "artifact" + ], + "summary": "Add label to artifact", + "operationId": "addLabel", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "The name of the project", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -\u003e a%252Fb", + "name": "repository_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The reference of the artifact, can be digest or tag", + "name": "reference", + "in": "path", + "required": true + }, + { + "description": "The label that added to the artifact. Only the ID property is needed.", + "name": "label", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/Label" + } + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "409": { + "description": "Conflict", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/labels/{label_id}": { + "delete": { + "description": "Remove the label from the specified artiact.", + "tags": [ + "artifact" + ], + "summary": "Remove label from artifact", + "operationId": "removeLabel", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "The name of the project", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -\u003e a%252Fb", + "name": "repository_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The reference of the artifact, can be digest or tag", + "name": "reference", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "The ID of the label that removed from the artifact.", + "name": "label_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "409": { + "description": "Conflict", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/scan": { + "post": { + "description": "Scan the specified artifact", + "tags": [ + "scan" + ], + "summary": "Scan the artifact", + "operationId": "scanArtifact", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "The name of the project", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -\u003e a%252Fb", + "name": "repository_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The reference of the artifact, can be digest or tag", + "name": "reference", + "in": "path", + "required": true + } + ], + "responses": { + "202": { + "description": "Accepted", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/scan/stop": { + "post": { + "description": "Cancelling a scan job for a particular artifact", + "tags": [ + "scan" + ], + "summary": "Cancelling a scan job for a particular artifact", + "operationId": "stopScanArtifact", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "The name of the project", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -\u003e a%252Fb", + "name": "repository_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The reference of the artifact, can be digest or tag", + "name": "reference", + "in": "path", + "required": true + } + ], + "responses": { + "202": { + "description": "Accepted", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/scan/{report_id}/log": { + "get": { + "description": "Get the log of the scan report", + "produces": [ + "text/plain" + ], + "tags": [ + "scan" + ], + "summary": "Get the log of the scan report", + "operationId": "getReportLog", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "The name of the project", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -\u003e a%252Fb", + "name": "repository_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The reference of the artifact, can be digest or tag", + "name": "reference", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The report id to get the log", + "name": "report_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Successfully get scan log file", + "schema": { + "type": "string" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/tags": { + "get": { + "description": "List tags of the specific artifact", + "tags": [ + "artifact" + ], + "summary": "List tags", + "operationId": "listTags", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "The name of the project", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -\u003e a%252Fb", + "name": "repository_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The reference of the artifact, can be digest or tag", + "name": "reference", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Query string to query resources. Supported query patterns are \"exact match(k=v)\", \"fuzzy match(k=~v)\", \"range(k=[min~max])\", \"list with union releationship(k={v1 v2 v3})\" and \"list with intersetion relationship(k=(v1 v2 v3))\". The value of range and list can be string(enclosed by \" or '), integer or time(in format \"2020-04-09 02:36:00\"). All of these query patterns should be put in the query string \"q=xxx\" and splitted by \",\". e.g. q=k1=v1,k2=~v2,k3=[min~max]", + "name": "q", + "in": "query" + }, + { + "type": "string", + "description": "Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with \"sort=field1,-field2\"", + "name": "sort", + "in": "query" + }, + { + "type": "integer", + "format": "int64", + "default": 1, + "description": "The page number", + "name": "page", + "in": "query" + }, + { + "maximum": 100, + "type": "integer", + "format": "int64", + "default": 10, + "description": "The size of per page", + "name": "page_size", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Specify whether the signature is included inside the returning tags", + "name": "with_signature", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Specify whether the immutable status is included inside the returning tags", + "name": "with_immutable_status", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Tag" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link refers to the previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of tags" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "post": { + "description": "Create a tag for the specified artifact", + "tags": [ + "artifact" + ], + "summary": "Create tag", + "operationId": "createTag", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "The name of the project", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -\u003e a%252Fb", + "name": "repository_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The reference of the artifact, can be digest or tag", + "name": "reference", + "in": "path", + "required": true + }, + { + "description": "The JSON object of tag.", + "name": "tag", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/Tag" + } + } + ], + "responses": { + "201": { + "description": "Created", + "headers": { + "Location": { + "type": "string", + "description": "The location of the resource" + }, + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "405": { + "description": "Method not allowed", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "409": { + "description": "Conflict", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/tags/{tag_name}": { + "delete": { + "description": "Delete the tag of the specified artifact", + "tags": [ + "artifact" + ], + "summary": "Delete tag", + "operationId": "deleteTag", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "The name of the project", + "name": "project_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -\u003e a%252Fb", + "name": "repository_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The reference of the artifact, can be digest or tag", + "name": "reference", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The name of the tag", + "name": "tag_name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/quotas": { + "get": { + "description": "List quotas", + "tags": [ + "quota" + ], + "summary": "List quotas", + "operationId": "listQuotas", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "integer", + "format": "int64", + "default": 1, + "description": "The page number", + "name": "page", + "in": "query" + }, + { + "maximum": 100, + "type": "integer", + "format": "int64", + "default": 10, + "description": "The size of per page", + "name": "page_size", + "in": "query" + }, + { + "type": "string", + "description": "The reference type of quota.", + "name": "reference", + "in": "query" + }, + { + "type": "string", + "description": "The reference id of quota.", + "name": "reference_id", + "in": "query" + }, + { + "type": "string", + "description": "Sort method, valid values include:\n'hard.resource_name', '-hard.resource_name', 'used.resource_name', '-used.resource_name'.\nHere '-' stands for descending order, resource_name should be the real resource name of the quota.\n", + "name": "sort", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successfully retrieved the quotas.", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Quota" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link refers to the previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of access logs" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/quotas/{id}": { + "get": { + "description": "Get the specified quota", + "tags": [ + "quota" + ], + "summary": "Get the specified quota", + "operationId": "getQuota", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "integer", + "description": "Quota ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Successfully retrieved the quota.", + "schema": { + "$ref": "#/definitions/Quota" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "put": { + "description": "Update hard limits of the specified quota", + "tags": [ + "quota" + ], + "summary": "Update the specified quota", + "operationId": "updateQuota", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "integer", + "description": "Quota ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "The new hard limits for the quota", + "name": "hard", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/QuotaUpdateReq" + } + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/registries": { + "get": { + "description": "List the registries", + "tags": [ + "registry" + ], + "summary": "List the registries", + "operationId": "listRegistries", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "Query string to query resources. Supported query patterns are \"exact match(k=v)\", \"fuzzy match(k=~v)\", \"range(k=[min~max])\", \"list with union releationship(k={v1 v2 v3})\" and \"list with intersetion relationship(k=(v1 v2 v3))\". The value of range and list can be string(enclosed by \" or '), integer or time(in format \"2020-04-09 02:36:00\"). All of these query patterns should be put in the query string \"q=xxx\" and splitted by \",\". e.g. q=k1=v1,k2=~v2,k3=[min~max]", + "name": "q", + "in": "query" + }, + { + "type": "string", + "description": "Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with \"sort=field1,-field2\"", + "name": "sort", + "in": "query" + }, + { + "type": "integer", + "format": "int64", + "default": 1, + "description": "The page number", + "name": "page", + "in": "query" + }, + { + "maximum": 100, + "type": "integer", + "format": "int64", + "default": 10, + "description": "The size of per page", + "name": "page_size", + "in": "query" + }, + { + "type": "string", + "description": "Deprecated, use ` + "`" + `q` + "`" + ` instead.", + "name": "name", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Registry" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link refers to the previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of the resources" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "post": { + "description": "Create a registry", + "tags": [ + "registry" + ], + "summary": "Create a registry", + "operationId": "createRegistry", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "description": "The registry", + "name": "registry", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/Registry" + } + } + ], + "responses": { + "201": { + "description": "Created", + "headers": { + "Location": { + "type": "string", + "description": "The location of the resource" + }, + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "409": { + "description": "Conflict", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/registries/ping": { + "post": { + "description": "Check status of a registry", + "tags": [ + "registry" + ], + "summary": "Check status of a registry", + "operationId": "pingRegistry", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "description": "The registry", + "name": "registry", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/RegistryPing" + } + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/registries/{id}": { + "get": { + "description": "Get the specific registry", + "tags": [ + "registry" + ], + "summary": "Get the specific registry", + "operationId": "getRegistry", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "integer", + "format": "int64", + "description": "Registry ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/Registry" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "put": { + "description": "Update the registry", + "tags": [ + "registry" + ], + "summary": "Update the registry", + "operationId": "updateRegistry", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "integer", + "format": "int64", + "description": "The registry ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "The registry", + "name": "registry", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/RegistryUpdate" + } + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "409": { + "description": "Conflict", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "delete": { + "description": "Delete the specific registry", + "tags": [ + "registry" + ], + "summary": "Delete the specific registry", + "operationId": "deleteRegistry", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "integer", + "format": "int64", + "description": "Registry ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "412": { + "description": "Precondition failed", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/registries/{id}/info": { + "get": { + "description": "Get the registry info", + "tags": [ + "registry" + ], + "summary": "Get the registry info", + "operationId": "getRegistryInfo", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "integer", + "format": "int64", + "description": "Registry ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/RegistryInfo" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/replication/adapterinfos": { + "get": { + "description": "List all registered registry provider information", + "tags": [ + "registry" + ], + "summary": "List all registered registry provider information", + "operationId": "listRegistryProviderInfos", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + } + ], + "responses": { + "200": { + "description": "Success.", + "schema": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/RegistryProviderInfo" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/replication/adapters": { + "get": { + "description": "List registry adapters", + "tags": [ + "registry" + ], + "summary": "List registry adapters", + "operationId": "listRegistryProviderTypes", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + } + ], + "responses": { + "200": { + "description": "Success.", + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/replication/executions": { + "get": { + "description": "List replication executions", + "tags": [ + "replication" + ], + "summary": "List replication executions", + "operationId": "listReplicationExecutions", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with \"sort=field1,-field2\"", + "name": "sort", + "in": "query" + }, + { + "type": "integer", + "format": "int64", + "default": 1, + "description": "The page number", + "name": "page", + "in": "query" + }, + { + "maximum": 100, + "type": "integer", + "format": "int64", + "default": 10, + "description": "The size of per page", + "name": "page_size", + "in": "query" + }, + { + "type": "integer", + "description": "The ID of the policy that the executions belong to.", + "name": "policy_id", + "in": "query" + }, + { + "type": "string", + "description": "The execution status.", + "name": "status", + "in": "query" + }, + { + "type": "string", + "description": "The trigger mode.", + "name": "trigger", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/ReplicationExecution" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link refers to the previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of the resources" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "post": { + "description": "Start one replication execution according to the policy", + "tags": [ + "replication" + ], + "summary": "Start one replication execution", + "operationId": "startReplication", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "description": "The ID of policy that the execution belongs to", + "name": "execution", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/StartReplicationExecution" + } + } + ], + "responses": { + "201": { + "description": "Created", + "headers": { + "Location": { + "type": "string", + "description": "The location of the resource" + }, + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/replication/executions/{id}": { + "get": { + "description": "Get the replication execution specified by ID", + "tags": [ + "replication" + ], + "summary": "Get the specific replication execution", + "operationId": "getReplicationExecution", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "integer", + "format": "int64", + "description": "The ID of the execution.", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/ReplicationExecution" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "put": { + "description": "Stop the replication execution specified by ID", + "tags": [ + "replication" + ], + "summary": "Stop the specific replication execution", + "operationId": "stopReplication", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "integer", + "format": "int64", + "description": "The ID of the execution.", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/replication/executions/{id}/tasks": { + "get": { + "description": "List replication tasks for a specific execution", + "tags": [ + "replication" + ], + "summary": "List replication tasks for a specific execution", + "operationId": "listReplicationTasks", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with \"sort=field1,-field2\"", + "name": "sort", + "in": "query" + }, + { + "type": "integer", + "format": "int64", + "default": 1, + "description": "The page number", + "name": "page", + "in": "query" + }, + { + "maximum": 100, + "type": "integer", + "format": "int64", + "default": 10, + "description": "The size of per page", + "name": "page_size", + "in": "query" + }, + { + "type": "integer", + "format": "int64", + "description": "The ID of the execution that the tasks belongs to.", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The task status.", + "name": "status", + "in": "query" + }, + { + "type": "string", + "description": "The resource type.", + "name": "resource_type", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/ReplicationTask" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link refers to the previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of the resources" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/replication/executions/{id}/tasks/{task_id}/log": { + "get": { + "description": "Get the log of the specific replication task", + "produces": [ + "text/plain" + ], + "tags": [ + "replication" + ], + "summary": "Get the log of the specific replication task", + "operationId": "getReplicationLog", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "integer", + "format": "int64", + "description": "The ID of the execution that the tasks belongs to.", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "The ID of the task.", + "name": "task_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "string" + }, + "headers": { + "Content-Type": { + "type": "string", + "description": "The content type of response body" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/replication/policies": { + "get": { + "description": "List replication policies", + "tags": [ + "replication" + ], + "summary": "List replication policies", + "operationId": "listReplicationPolicies", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "Query string to query resources. Supported query patterns are \"exact match(k=v)\", \"fuzzy match(k=~v)\", \"range(k=[min~max])\", \"list with union releationship(k={v1 v2 v3})\" and \"list with intersetion relationship(k=(v1 v2 v3))\". The value of range and list can be string(enclosed by \" or '), integer or time(in format \"2020-04-09 02:36:00\"). All of these query patterns should be put in the query string \"q=xxx\" and splitted by \",\". e.g. q=k1=v1,k2=~v2,k3=[min~max]", + "name": "q", + "in": "query" + }, + { + "type": "string", + "description": "Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with \"sort=field1,-field2\"", + "name": "sort", + "in": "query" + }, + { + "type": "integer", + "format": "int64", + "default": 1, + "description": "The page number", + "name": "page", + "in": "query" + }, + { + "maximum": 100, + "type": "integer", + "format": "int64", + "default": 10, + "description": "The size of per page", + "name": "page_size", + "in": "query" + }, + { + "type": "string", + "description": "Deprecated, use \"query\" instead. The policy name.", + "name": "name", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/ReplicationPolicy" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link refers to the previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of the resources" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "post": { + "description": "Create a replication policy", + "tags": [ + "replication" + ], + "summary": "Create a replication policy", + "operationId": "createReplicationPolicy", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "description": "The replication policy", + "name": "policy", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ReplicationPolicy" + } + } + ], + "responses": { + "201": { + "description": "Created", + "headers": { + "Location": { + "type": "string", + "description": "The location of the resource" + }, + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "409": { + "description": "Conflict", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/replication/policies/{id}": { + "get": { + "description": "Get the specific replication policy", + "tags": [ + "replication" + ], + "summary": "Get the specific replication policy", + "operationId": "getReplicationPolicy", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "integer", + "format": "int64", + "description": "Policy ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/ReplicationPolicy" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "put": { + "description": "Update the replication policy", + "tags": [ + "replication" + ], + "summary": "Update the replication policy", + "operationId": "updateReplicationPolicy", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "integer", + "format": "int64", + "description": "The policy ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "The replication policy", + "name": "policy", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ReplicationPolicy" + } + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "409": { + "description": "Conflict", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "delete": { + "description": "Delete the specific replication policy", + "tags": [ + "replication" + ], + "summary": "Delete the specific replication policy", + "operationId": "deleteReplicationPolicy", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "integer", + "format": "int64", + "description": "Replication policy ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "412": { + "description": "Precondition failed", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/repositories": { + "get": { + "description": "List all authorized repositories", + "tags": [ + "repository" + ], + "summary": "List all authorized repositories", + "operationId": "listAllRepositories", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "Query string to query resources. Supported query patterns are \"exact match(k=v)\", \"fuzzy match(k=~v)\", \"range(k=[min~max])\", \"list with union releationship(k={v1 v2 v3})\" and \"list with intersetion relationship(k=(v1 v2 v3))\". The value of range and list can be string(enclosed by \" or '), integer or time(in format \"2020-04-09 02:36:00\"). All of these query patterns should be put in the query string \"q=xxx\" and splitted by \",\". e.g. q=k1=v1,k2=~v2,k3=[min~max]", + "name": "q", + "in": "query" + }, + { + "type": "string", + "description": "Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with \"sort=field1,-field2\"", + "name": "sort", + "in": "query" + }, + { + "type": "integer", + "format": "int64", + "default": 1, + "description": "The page number", + "name": "page", + "in": "query" + }, + { + "maximum": 100, + "type": "integer", + "format": "int64", + "default": 10, + "description": "The size of per page", + "name": "page_size", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Repository" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link refers to the previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of repositories" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/retentions": { + "post": { + "description": "Create Retention Policy, you can reference metadatas API for the policy model. You can check project metadatas to find whether a retention policy is already binded. This method should only be called when no retention policy binded to project yet.", + "tags": [ + "Retention" + ], + "summary": "Create Retention Policy", + "operationId": "createRetention", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "description": "Create Retention Policy successfully.", + "name": "policy", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/RetentionPolicy" + } + } + ], + "responses": { + "201": { + "description": "Created", + "headers": { + "Location": { + "type": "string", + "description": "The location of the resource" + }, + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/retentions/metadatas": { + "get": { + "description": "Get Retention Metadatas.", + "tags": [ + "Retention" + ], + "summary": "Get Retention Metadatas", + "operationId": "getRentenitionMetadata", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + } + ], + "responses": { + "200": { + "description": "Get Retention Metadatas successfully.", + "schema": { + "$ref": "#/definitions/RetentionMetadata" + } + } + } + } + }, + "/retentions/{id}": { + "get": { + "description": "Get Retention Policy.", + "tags": [ + "Retention" + ], + "summary": "Get Retention Policy", + "operationId": "getRetention", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "integer", + "format": "int64", + "description": "Retention ID.", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Get Retention Policy successfully.", + "schema": { + "$ref": "#/definitions/RetentionPolicy" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "put": { + "description": "Update Retention Policy, you can reference metadatas API for the policy model. You can check project metadatas to find whether a retention policy is already binded. This method should only be called when retention policy has already binded to project.", + "tags": [ + "Retention" + ], + "summary": "Update Retention Policy", + "operationId": "updateRetention", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "integer", + "format": "int64", + "description": "Retention ID.", + "name": "id", + "in": "path", + "required": true + }, + { + "name": "policy", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/RetentionPolicy" + } + } + ], + "responses": { + "200": { + "description": "Update Retention Policy successfully." + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "delete": { + "description": "Delete Retention Policy, you can reference metadatas API for the policy model. You can check project metadatas to find whether a retention policy is already binded. This method should only be called when retention policy has already binded to project.", + "tags": [ + "Retention" + ], + "summary": "Delete Retention Policy", + "operationId": "deleteRetention", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "integer", + "format": "int64", + "description": "Retention ID.", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Update Retention Policy successfully." + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/retentions/{id}/executions": { + "get": { + "description": "Get Retention executions, execution status may be delayed before job service schedule it up.", + "tags": [ + "Retention" + ], + "summary": "Get Retention executions", + "operationId": "listRetentionExecutions", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "integer", + "format": "int64", + "description": "Retention ID.", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "The page number.", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "format": "int64", + "description": "The size of per page.", + "name": "page_size", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Get a Retention execution successfully.", + "schema": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/RetentionExecution" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link to previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of available items" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "post": { + "description": "Trigger a Retention Execution, if dry_run is True, nothing would be deleted actually.", + "produces": [ + "text/plain" + ], + "tags": [ + "Retention" + ], + "summary": "Trigger a Retention Execution", + "operationId": "triggerRetentionExecution", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "integer", + "format": "int64", + "description": "Retention ID.", + "name": "id", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "type": "object", + "properties": { + "dry_run": { + "type": "boolean" + } + } + } + } + ], + "responses": { + "200": { + "description": "Trigger a Retention job successfully." + }, + "201": { + "description": "Created", + "headers": { + "Location": { + "type": "string", + "description": "The location of the resource" + }, + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/retentions/{id}/executions/{eid}": { + "patch": { + "description": "Stop a Retention execution, only support \"stop\" action now.", + "tags": [ + "Retention" + ], + "summary": "Stop a Retention execution", + "operationId": "operateRetentionExecution", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "integer", + "format": "int64", + "description": "Retention ID.", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "Retention execution ID.", + "name": "eid", + "in": "path", + "required": true + }, + { + "description": "The action, only support \"stop\" now.", + "name": "body", + "in": "body", + "required": true, + "schema": { + "type": "object", + "properties": { + "action": { + "type": "string" + } + } + } + } + ], + "responses": { + "200": { + "description": "Stop a Retention job successfully." + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/retentions/{id}/executions/{eid}/tasks": { + "get": { + "description": "Get Retention tasks, each repository as a task.", + "tags": [ + "Retention" + ], + "summary": "Get Retention tasks", + "operationId": "listRetentionTasks", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "integer", + "format": "int64", + "description": "Retention ID.", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "Retention execution ID.", + "name": "eid", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "The page number.", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "format": "int64", + "description": "The size of per page.", + "name": "page_size", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Get Retention job tasks successfully.", + "schema": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/RetentionExecutionTask" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link to previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of available items" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/retentions/{id}/executions/{eid}/tasks/{tid}": { + "get": { + "description": "Get Retention job task log, tags ratain or deletion detail will be shown in a table.", + "produces": [ + "text/plain" + ], + "tags": [ + "Retention" + ], + "summary": "Get Retention job task log", + "operationId": "getRetentionTaskLog", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "integer", + "format": "int64", + "description": "Retention ID.", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "Retention execution ID.", + "name": "eid", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "Retention execution ID.", + "name": "tid", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Get Retention job task log successfully.", + "schema": { + "type": "string" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/robots": { + "get": { + "description": "List the robot accounts with the specified level and project.", + "tags": [ + "robot" + ], + "summary": "Get robot account", + "operationId": "ListRobot", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "Query string to query resources. Supported query patterns are \"exact match(k=v)\", \"fuzzy match(k=~v)\", \"range(k=[min~max])\", \"list with union releationship(k={v1 v2 v3})\" and \"list with intersetion relationship(k=(v1 v2 v3))\". The value of range and list can be string(enclosed by \" or '), integer or time(in format \"2020-04-09 02:36:00\"). All of these query patterns should be put in the query string \"q=xxx\" and splitted by \",\". e.g. q=k1=v1,k2=~v2,k3=[min~max]", + "name": "q", + "in": "query" + }, + { + "type": "string", + "description": "Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with \"sort=field1,-field2\"", + "name": "sort", + "in": "query" + }, + { + "type": "integer", + "format": "int64", + "default": 1, + "description": "The page number", + "name": "page", + "in": "query" + }, + { + "maximum": 100, + "type": "integer", + "format": "int64", + "default": 10, + "description": "The size of per page", + "name": "page_size", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Robot" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link refers to the previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of robot accounts" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "post": { + "description": "Create a robot account", + "tags": [ + "robot" + ], + "summary": "Create a robot account", + "operationId": "CreateRobot", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "description": "The JSON object of a robot account.", + "name": "robot", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/RobotCreate" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/RobotCreated" + }, + "headers": { + "Location": { + "type": "string", + "description": "The location of the resource" + }, + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/robots/{robot_id}": { + "get": { + "description": "This endpoint returns specific robot account information by robot ID.", + "tags": [ + "robot" + ], + "summary": "Get a robot account", + "operationId": "GetRobotByID", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "integer", + "description": "Robot ID", + "name": "robot_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Return matched robot information.", + "schema": { + "$ref": "#/definitions/Robot" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "put": { + "description": "This endpoint updates specific robot account information by robot ID.", + "tags": [ + "robot" + ], + "summary": "Update a robot account", + "operationId": "UpdateRobot", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "integer", + "description": "Robot ID", + "name": "robot_id", + "in": "path", + "required": true + }, + { + "description": "The JSON object of a robot account.", + "name": "robot", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/Robot" + } + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "409": { + "description": "Conflict", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "delete": { + "description": "This endpoint deletes specific robot account information by robot ID.", + "tags": [ + "robot" + ], + "summary": "Delete a robot account", + "operationId": "DeleteRobot", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "integer", + "description": "Robot ID", + "name": "robot_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "patch": { + "description": "Refresh the robot secret", + "tags": [ + "robot" + ], + "summary": "Refresh the robot secret", + "operationId": "RefreshSec", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "integer", + "description": "Robot ID", + "name": "robot_id", + "in": "path", + "required": true + }, + { + "description": "The JSON object of a robot account.", + "name": "robotSec", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/RobotSec" + } + } + ], + "responses": { + "200": { + "description": "Return refreshed robot sec.", + "schema": { + "$ref": "#/definitions/RobotSec" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/scanners": { + "get": { + "description": "Returns a list of currently configured scanner registrations.\n", + "tags": [ + "scanner" + ], + "summary": "List scanner registrations", + "operationId": "listScanners", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "Query string to query resources. Supported query patterns are \"exact match(k=v)\", \"fuzzy match(k=~v)\", \"range(k=[min~max])\", \"list with union releationship(k={v1 v2 v3})\" and \"list with intersetion relationship(k=(v1 v2 v3))\". The value of range and list can be string(enclosed by \" or '), integer or time(in format \"2020-04-09 02:36:00\"). All of these query patterns should be put in the query string \"q=xxx\" and splitted by \",\". e.g. q=k1=v1,k2=~v2,k3=[min~max]", + "name": "q", + "in": "query" + }, + { + "type": "string", + "description": "Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with \"sort=field1,-field2\"", + "name": "sort", + "in": "query" + }, + { + "type": "integer", + "format": "int64", + "default": 1, + "description": "The page number", + "name": "page", + "in": "query" + }, + { + "maximum": 100, + "type": "integer", + "format": "int64", + "default": 10, + "description": "The size of per page", + "name": "page_size", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A list of scanner registrations.", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/ScannerRegistration" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link to previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of available items" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "post": { + "description": "Creats a new scanner registration with the given data.\n", + "tags": [ + "scanner" + ], + "summary": "Create a scanner registration", + "operationId": "createScanner", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "description": "A scanner registration to be created.", + "name": "registration", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ScannerRegistrationReq" + } + } + ], + "responses": { + "201": { + "description": "Created successfully", + "headers": { + "Location": { + "type": "string", + "description": "The URL of the created resource" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/scanners/ping": { + "post": { + "description": "Pings scanner adapter to test endpoint URL and authorization settings.\n", + "tags": [ + "scanner" + ], + "summary": "Tests scanner registration settings", + "operationId": "pingScanner", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "description": "A scanner registration settings to be tested.", + "name": "settings", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ScannerRegistrationSettings" + } + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/scanners/{registration_id}": { + "get": { + "description": "Retruns the details of the specified scanner registration.\n", + "tags": [ + "scanner" + ], + "summary": "Get a scanner registration details", + "operationId": "getScanner", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "The scanner registration identifer.", + "name": "registration_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "The details of the scanner registration.", + "schema": { + "$ref": "#/definitions/ScannerRegistration" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "put": { + "description": "Updates the specified scanner registration.\n", + "tags": [ + "scanner" + ], + "summary": "Update a scanner registration", + "operationId": "updateScanner", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "The scanner registration identifier.", + "name": "registration_id", + "in": "path", + "required": true + }, + { + "description": "A scanner registraiton to be updated.", + "name": "registration", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ScannerRegistrationReq" + } + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "delete": { + "description": "Deletes the specified scanner registration.\n", + "tags": [ + "scanner" + ], + "summary": "Delete a scanner registration", + "operationId": "deleteScanner", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "The scanner registration identifier.", + "name": "registration_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Deleted successfully and return the deleted registration", + "schema": { + "$ref": "#/definitions/ScannerRegistration" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "patch": { + "description": "Set the specified scanner registration as the system default one.\n", + "tags": [ + "scanner" + ], + "summary": "Set system default scanner registration", + "operationId": "setScannerAsDefault", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "The scanner registration identifier.", + "name": "registration_id", + "in": "path", + "required": true + }, + { + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/IsDefault" + } + } + ], + "responses": { + "200": { + "description": "Successfully set the specified scanner registration as system default" + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/scanners/{registration_id}/metadata": { + "get": { + "description": "Get the metadata of the specified scanner registration, including the capabilities and customized properties.\n", + "tags": [ + "scanner" + ], + "summary": "Get the metadata of the specified scanner registration", + "operationId": "getScannerMetadata", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "The scanner registration identifier.", + "name": "registration_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "The metadata of the specified scanner adapter", + "schema": { + "$ref": "#/definitions/ScannerAdapterMetadata" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/scans/all/metrics": { + "get": { + "description": "Get the metrics of the latest scan all process", + "tags": [ + "scanAll" + ], + "summary": "Get the metrics of the latest scan all process", + "operationId": "getLatestScanAllMetrics", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/Stats" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "412": { + "description": "Precondition failed", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/scans/schedule/metrics": { + "get": { + "description": "Get the metrics of the latest scheduled scan all process", + "tags": [ + "scanAll" + ], + "summary": "Get the metrics of the latest scheduled scan all process", + "operationId": "getLatestScheduledScanAllMetrics", + "deprecated": true, + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/Stats" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "412": { + "description": "Precondition failed", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/schedules": { + "get": { + "description": "List schedules", + "tags": [ + "schedule" + ], + "operationId": "listSchedules", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "integer", + "format": "int64", + "default": 1, + "description": "The page number", + "name": "page", + "in": "query" + }, + { + "maximum": 100, + "type": "integer", + "format": "int64", + "default": 10, + "description": "The size of per page", + "name": "page_size", + "in": "query" + } + ], + "responses": { + "200": { + "description": "list schedule successfully.", + "schema": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/ScheduleTask" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link to previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of available items" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/schedules/{job_type}/paused": { + "get": { + "description": "Get scheduler paused status", + "tags": [ + "schedule" + ], + "operationId": "getSchedulePaused", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "The type of the job. 'all' stands for all job types, current only support query with all", + "name": "job_type", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Get scheduler status successfully.", + "schema": { + "type": "object", + "$ref": "#/definitions/SchedulerStatus" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/search": { + "get": { + "description": "The Search endpoint returns information about the projects, repositories and helm charts offered at public status or related to the current logged in user. The response includes the project, repository list and charts in a proper display order.", + "tags": [ + "search" + ], + "summary": "Search for projects, repositories and helm charts", + "operationId": "search", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "Search parameter for project and repository name.", + "name": "q", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "An array of search results", + "schema": { + "$ref": "#/definitions/Search" + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/statistics": { + "get": { + "description": "Get the statistic information about the projects and repositories", + "tags": [ + "statistic" + ], + "summary": "Get the statistic information about the projects and repositories", + "operationId": "getStatistic", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + } + ], + "responses": { + "200": { + "description": "The statistic information", + "schema": { + "$ref": "#/definitions/Statistic" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/system/CVEAllowlist": { + "get": { + "description": "Get the system level allowlist of CVE. This API can be called by all authenticated users.", + "tags": [ + "SystemCVEAllowlist" + ], + "summary": "Get the system level allowlist of CVE.", + "operationId": "getSystemCVEAllowlist", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + } + ], + "responses": { + "200": { + "description": "Successfully retrieved the CVE allowlist.", + "schema": { + "$ref": "#/definitions/CVEAllowlist" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "put": { + "description": "This API overwrites the system level allowlist of CVE with the list in request body. Only system Admin has permission to call this API.", + "tags": [ + "SystemCVEAllowlist" + ], + "summary": "Update the system level allowlist of CVE.", + "operationId": "putSystemCVEAllowlist", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "description": "The allowlist with new content", + "name": "allowlist", + "in": "body", + "schema": { + "$ref": "#/definitions/CVEAllowlist" + } + } + ], + "responses": { + "200": { + "description": "Successfully updated the CVE allowlist." + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/system/gc": { + "get": { + "description": "This endpoint let user get gc execution history.", + "tags": [ + "gc" + ], + "summary": "Get gc results.", + "operationId": "getGCHistory", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "Query string to query resources. Supported query patterns are \"exact match(k=v)\", \"fuzzy match(k=~v)\", \"range(k=[min~max])\", \"list with union releationship(k={v1 v2 v3})\" and \"list with intersetion relationship(k=(v1 v2 v3))\". The value of range and list can be string(enclosed by \" or '), integer or time(in format \"2020-04-09 02:36:00\"). All of these query patterns should be put in the query string \"q=xxx\" and splitted by \",\". e.g. q=k1=v1,k2=~v2,k3=[min~max]", + "name": "q", + "in": "query" + }, + { + "type": "string", + "description": "Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with \"sort=field1,-field2\"", + "name": "sort", + "in": "query" + }, + { + "type": "integer", + "format": "int64", + "default": 1, + "description": "The page number", + "name": "page", + "in": "query" + }, + { + "maximum": 100, + "type": "integer", + "format": "int64", + "default": 10, + "description": "The size of per page", + "name": "page_size", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Get gc results successfully.", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/GCHistory" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link refers to the previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of history" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/system/gc/schedule": { + "get": { + "description": "This endpoint is for get schedule of gc job.", + "tags": [ + "gc" + ], + "summary": "Get gc's schedule.", + "operationId": "getGCSchedule", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + } + ], + "responses": { + "200": { + "description": "Get gc's schedule.", + "schema": { + "$ref": "#/definitions/GCHistory" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "put": { + "description": "This endpoint is for update gc schedule.\n", + "tags": [ + "gc" + ], + "summary": "Update gc's schedule.", + "operationId": "updateGCSchedule", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "description": "Updates of gc's schedule.", + "name": "schedule", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/Schedule" + } + } + ], + "responses": { + "200": { + "description": "Updated gc's schedule successfully." + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "post": { + "description": "This endpoint is for update gc schedule.\n", + "tags": [ + "gc" + ], + "summary": "Create a gc schedule.", + "operationId": "createGCSchedule", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "description": "Updates of gc's schedule.", + "name": "schedule", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/Schedule" + } + } + ], + "responses": { + "201": { + "description": "Created", + "headers": { + "Location": { + "type": "string", + "description": "The location of the resource" + }, + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "409": { + "description": "Conflict", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/system/gc/{gc_id}": { + "get": { + "description": "This endpoint let user get gc status filtered by specific ID.", + "tags": [ + "gc" + ], + "summary": "Get gc status.", + "operationId": "getGC", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "integer", + "format": "int64", + "description": "The ID of the gc log", + "name": "gc_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Get gc results successfully.", + "schema": { + "$ref": "#/definitions/GCHistory" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "put": { + "description": "Stop the GC execution specified by ID", + "tags": [ + "gc" + ], + "summary": "Stop the specific GC execution", + "operationId": "stopGC", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "integer", + "format": "int64", + "description": "The ID of the gc log", + "name": "gc_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/system/gc/{gc_id}/log": { + "get": { + "description": "This endpoint let user get gc job logs filtered by specific ID.", + "produces": [ + "text/plain" + ], + "tags": [ + "gc" + ], + "summary": "Get gc job log.", + "operationId": "getGCLog", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "integer", + "format": "int64", + "description": "The ID of the gc log", + "name": "gc_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Get successfully.", + "schema": { + "type": "string" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/system/oidc/ping": { + "post": { + "description": "Test the OIDC endpoint, the setting of the endpoint is provided in the request. This API can only be called by system admin.\n", + "tags": [ + "oidc" + ], + "summary": "Test the OIDC endpoint.", + "operationId": "pingOIDC", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "description": "Request body for OIDC endpoint to be tested.", + "name": "endpoint", + "in": "body", + "required": true, + "schema": { + "type": "object", + "properties": { + "url": { + "description": "The URL of OIDC endpoint to be tested.", + "type": "string" + }, + "verify_cert": { + "description": "Whether the certificate should be verified", + "type": "boolean" + } + } + } + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/system/purgeaudit": { + "get": { + "description": "get purge job execution history.", + "tags": [ + "purge" + ], + "summary": "Get purge job results.", + "operationId": "getPurgeHistory", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "Query string to query resources. Supported query patterns are \"exact match(k=v)\", \"fuzzy match(k=~v)\", \"range(k=[min~max])\", \"list with union releationship(k={v1 v2 v3})\" and \"list with intersetion relationship(k=(v1 v2 v3))\". The value of range and list can be string(enclosed by \" or '), integer or time(in format \"2020-04-09 02:36:00\"). All of these query patterns should be put in the query string \"q=xxx\" and splitted by \",\". e.g. q=k1=v1,k2=~v2,k3=[min~max]", + "name": "q", + "in": "query" + }, + { + "type": "string", + "description": "Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with \"sort=field1,-field2\"", + "name": "sort", + "in": "query" + }, + { + "type": "integer", + "format": "int64", + "default": 1, + "description": "The page number", + "name": "page", + "in": "query" + }, + { + "maximum": 100, + "type": "integer", + "format": "int64", + "default": 10, + "description": "The size of per page", + "name": "page_size", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Get purge job results successfully.", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/ExecHistory" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link refers to the previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of history" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/system/purgeaudit/schedule": { + "get": { + "description": "This endpoint is for get schedule of purge job.", + "tags": [ + "purge" + ], + "summary": "Get purge's schedule.", + "operationId": "getPurgeSchedule", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + } + ], + "responses": { + "200": { + "description": "Get purge job's schedule.", + "schema": { + "$ref": "#/definitions/ExecHistory" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "put": { + "description": "This endpoint is for update purge job schedule.\n", + "tags": [ + "purge" + ], + "summary": "Update purge job's schedule.", + "operationId": "updatePurgeSchedule", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "description": "The purge job's schedule, it is a json object. |\nThe sample format is |\n{\"parameters\":{\"audit_retention_hour\":168,\"dry_run\":true, \"include_operations\":\"create,delete,pull\"},\"schedule\":{\"type\":\"Hourly\",\"cron\":\"0 0 * * * *\"}} |\nthe include_operation should be a comma separated string, e.g. create,delete,pull, if it is empty, no operation will be purged.\n", + "name": "schedule", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/Schedule" + } + } + ], + "responses": { + "200": { + "description": "Updated purge's schedule successfully." + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "post": { + "description": "This endpoint is for update purge job schedule.\n", + "tags": [ + "purge" + ], + "summary": "Create a purge job schedule.", + "operationId": "createPurgeSchedule", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "description": "The purge job's schedule, it is a json object. |\nThe sample format is |\n{\"parameters\":{\"audit_retention_hour\":168,\"dry_run\":true, \"include_operations\":\"create,delete,pull\"},\"schedule\":{\"type\":\"Hourly\",\"cron\":\"0 0 * * * *\"}} |\nthe include_operation should be a comma separated string, e.g. create,delete,pull, if it is empty, no operation will be purged.\n", + "name": "schedule", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/Schedule" + } + } + ], + "responses": { + "201": { + "description": "Created", + "headers": { + "Location": { + "type": "string", + "description": "The location of the resource" + }, + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/system/purgeaudit/{purge_id}": { + "get": { + "description": "This endpoint let user get purge job status filtered by specific ID.", + "tags": [ + "purge" + ], + "summary": "Get purge job status.", + "operationId": "getPurgeJob", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "integer", + "format": "int64", + "description": "The ID of the purge log", + "name": "purge_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Get purge job results successfully.", + "schema": { + "$ref": "#/definitions/ExecHistory" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "put": { + "description": "Stop the purge audit log execution specified by ID", + "tags": [ + "purge" + ], + "summary": "Stop the specific purge audit log execution", + "operationId": "stopPurge", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "integer", + "format": "int64", + "description": "The ID of the purge log", + "name": "purge_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/system/purgeaudit/{purge_id}/log": { + "get": { + "description": "This endpoint let user get purge job logs filtered by specific ID.", + "produces": [ + "text/plain" + ], + "tags": [ + "purge" + ], + "summary": "Get purge job log.", + "operationId": "getPurgeJobLog", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "integer", + "format": "int64", + "description": "The ID of the purge log", + "name": "purge_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Get successfully.", + "schema": { + "type": "string" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/system/scanAll/schedule": { + "get": { + "description": "This endpoint is for getting a schedule for the scan all job, which scans all of images in Harbor.", + "tags": [ + "scanAll" + ], + "summary": "Get scan all's schedule.", + "operationId": "getScanAllSchedule", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + } + ], + "responses": { + "200": { + "description": "Get a schedule for the scan all job, which scans all of images in Harbor.", + "schema": { + "$ref": "#/definitions/Schedule" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "412": { + "description": "Precondition failed", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "put": { + "description": "This endpoint is for updating the schedule of scan all job, which scans all of images in Harbor.", + "tags": [ + "scanAll" + ], + "summary": "Update scan all's schedule.", + "operationId": "updateScanAllSchedule", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "description": "Updates the schedule of scan all job, which scans all of images in Harbor.", + "name": "schedule", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/Schedule" + } + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "412": { + "description": "Precondition failed", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "post": { + "description": "This endpoint is for creating a schedule or a manual trigger for the scan all job, which scans all of images in Harbor.", + "tags": [ + "scanAll" + ], + "summary": "Create a schedule or a manual trigger for the scan all job.", + "operationId": "createScanAllSchedule", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "description": "Create a schedule or a manual trigger for the scan all job.", + "name": "schedule", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/Schedule" + } + } + ], + "responses": { + "201": { + "description": "Created", + "headers": { + "Location": { + "type": "string", + "description": "The location of the resource" + }, + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "409": { + "description": "Conflict", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "412": { + "description": "Precondition failed", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/system/scanAll/stop": { + "post": { + "description": "Stop scanAll job execution", + "tags": [ + "scanAll" + ], + "summary": "Stop scanAll job execution", + "operationId": "stopScanAll", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + } + ], + "responses": { + "202": { + "description": "Accepted", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/systeminfo": { + "get": { + "description": "This API is for retrieving general system info, this can be called by anonymous request. Some attributes will be omitted in the response when this API is called by anonymous request.\n", + "tags": [ + "systeminfo" + ], + "summary": "Get general system info", + "operationId": "getSystemInfo", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + } + ], + "responses": { + "200": { + "description": "Get general info successfully.", + "schema": { + "$ref": "#/definitions/GeneralInfo" + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/systeminfo/getcert": { + "get": { + "description": "This endpoint is for downloading a default root certificate.\n", + "produces": [ + "application/octet-stream" + ], + "tags": [ + "systeminfo" + ], + "summary": "Get default root certificate.", + "operationId": "getCert", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + } + ], + "responses": { + "200": { + "description": "Get default root certificate successfully.", + "schema": { + "type": "file" + }, + "headers": { + "Content-Disposition": { + "type": "string", + "description": "To set the filename of the downloaded file." + } + } + }, + "404": { + "description": "Not found the default root certificate." + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/systeminfo/volumes": { + "get": { + "description": "This endpoint is for retrieving system volume info that only provides for admin user. Note that the response only reflects the storage status of local disk.\n", + "tags": [ + "systeminfo" + ], + "summary": "Get system volume info (total/free size).", + "operationId": "getVolumes", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + } + ], + "responses": { + "200": { + "description": "Get system volumes successfully.", + "schema": { + "$ref": "#/definitions/SystemInfo" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/usergroups": { + "get": { + "description": "Get all user groups information, it is open for system admin", + "tags": [ + "usergroup" + ], + "summary": "Get all user groups information", + "operationId": "listUserGroups", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "integer", + "format": "int64", + "default": 1, + "description": "The page number", + "name": "page", + "in": "query" + }, + { + "maximum": 100, + "type": "integer", + "format": "int64", + "default": 10, + "description": "The size of per page", + "name": "page_size", + "in": "query" + }, + { + "type": "string", + "description": "search with ldap group DN", + "name": "ldap_group_dn", + "in": "query" + }, + { + "type": "string", + "description": "group name need to search, fuzzy matches", + "name": "group_name", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Get user group successfully.", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/UserGroup" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link to previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of available items" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "post": { + "description": "Create user group information", + "tags": [ + "usergroup" + ], + "summary": "Create user group", + "operationId": "createUserGroup", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "name": "usergroup", + "in": "body", + "schema": { + "$ref": "#/definitions/UserGroup" + } + } + ], + "responses": { + "201": { + "description": "User group created successfully.", + "headers": { + "Location": { + "type": "string", + "description": "The URL of the created resource" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "409": { + "description": "Conflict", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/usergroups/search": { + "get": { + "description": "This endpoint is to search groups by group name. It's open for all authenticated requests.\n", + "tags": [ + "usergroup" + ], + "summary": "Search groups by groupname", + "operationId": "searchUserGroups", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "integer", + "format": "int64", + "default": 1, + "description": "The page number", + "name": "page", + "in": "query" + }, + { + "maximum": 100, + "type": "integer", + "format": "int64", + "default": 10, + "description": "The size of per page", + "name": "page_size", + "in": "query" + }, + { + "type": "string", + "description": "Group name for filtering results.", + "name": "groupname", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "Search groups successfully.", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/UserGroupSearchItem" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link to previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of available items" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/usergroups/{group_id}": { + "get": { + "description": "Get user group information", + "tags": [ + "usergroup" + ], + "summary": "Get user group information", + "operationId": "getUserGroup", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "integer", + "format": "int64", + "description": "Group ID", + "name": "group_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "User group get successfully.", + "schema": { + "$ref": "#/definitions/UserGroup" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "put": { + "description": "Update user group information", + "tags": [ + "usergroup" + ], + "summary": "Update group information", + "operationId": "updateUserGroup", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "integer", + "format": "int64", + "description": "Group ID", + "name": "group_id", + "in": "path", + "required": true + }, + { + "name": "usergroup", + "in": "body", + "schema": { + "$ref": "#/definitions/UserGroup" + } + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "delete": { + "description": "Delete user group", + "tags": [ + "usergroup" + ], + "summary": "Delete user group", + "operationId": "deleteUserGroup", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "integer", + "name": "group_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/users": { + "get": { + "tags": [ + "user" + ], + "summary": "List users", + "operationId": "listUsers", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "Query string to query resources. Supported query patterns are \"exact match(k=v)\", \"fuzzy match(k=~v)\", \"range(k=[min~max])\", \"list with union releationship(k={v1 v2 v3})\" and \"list with intersetion relationship(k=(v1 v2 v3))\". The value of range and list can be string(enclosed by \" or '), integer or time(in format \"2020-04-09 02:36:00\"). All of these query patterns should be put in the query string \"q=xxx\" and splitted by \",\". e.g. q=k1=v1,k2=~v2,k3=[min~max]", + "name": "q", + "in": "query" + }, + { + "type": "string", + "description": "Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with \"sort=field1,-field2\"", + "name": "sort", + "in": "query" + }, + { + "type": "integer", + "format": "int64", + "default": 1, + "description": "The page number", + "name": "page", + "in": "query" + }, + { + "maximum": 100, + "type": "integer", + "format": "int64", + "default": 10, + "description": "The size of per page", + "name": "page_size", + "in": "query" + } + ], + "responses": { + "200": { + "description": "return the list of users.", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/UserResp" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link to previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of users" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "post": { + "description": "This API can be used only when the authentication mode is for local DB. When self registration is disabled.", + "tags": [ + "user" + ], + "summary": "Create a local user.", + "operationId": "createUser", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "description": "The new user", + "name": "userReq", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/UserCreationReq" + } + } + ], + "responses": { + "201": { + "description": "Created", + "headers": { + "Location": { + "type": "string", + "description": "The location of the resource" + }, + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "When the self registration is disabled, non-admin does not have permission to create user. When self registration is enabled, this API can only be called from UI portal, calling it via script will get a 403 error." + }, + "409": { + "description": "Conflict", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/users/current": { + "get": { + "tags": [ + "user" + ], + "summary": "Get current user info.", + "operationId": "getCurrentUserInfo", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + } + ], + "responses": { + "200": { + "description": "Get current user information successfully.", + "schema": { + "$ref": "#/definitions/UserResp" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/users/current/permissions": { + "get": { + "tags": [ + "user" + ], + "summary": "Get current user permissions.", + "operationId": "getCurrentUserPermissions", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "string", + "description": "The scope for the permission", + "name": "scope", + "in": "query" + }, + { + "type": "boolean", + "description": "If true, the resources in the response are relative to the scope,\neg for resource '/project/1/repository' if relative is 'true' then the resource in response will be 'repository'.\n", + "name": "relative", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Get current user permission successfully.", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Permission" + } + } + }, + "401": { + "description": "User need to log in first." + }, + "500": { + "description": "Internal errors." + } + } + } + }, + "/users/search": { + "get": { + "description": "This endpoint is to search the users by username. It's open for all authenticated requests.\n", + "tags": [ + "user" + ], + "summary": "Search users by username", + "operationId": "searchUsers", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "integer", + "format": "int64", + "default": 1, + "description": "The page number", + "name": "page", + "in": "query" + }, + { + "maximum": 100, + "type": "integer", + "format": "int64", + "default": 10, + "description": "The size of per page", + "name": "page_size", + "in": "query" + }, + { + "type": "string", + "description": "Username for filtering results.", + "name": "username", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "Search users by username successfully.", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/UserSearchRespItem" + } + }, + "headers": { + "Link": { + "type": "string", + "description": "Link to previous page and next page" + }, + "X-Total-Count": { + "type": "integer", + "description": "The total count of available items" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/users/{user_id}": { + "get": { + "tags": [ + "user" + ], + "summary": "Get a user's profile.", + "operationId": "getUser", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "integer", + "format": "int", + "name": "user_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Get user's info successfully.", + "schema": { + "$ref": "#/definitions/UserResp" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "put": { + "tags": [ + "user" + ], + "summary": "Update user's profile.", + "operationId": "updateUserProfile", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "integer", + "format": "int", + "description": "Registered user ID", + "name": "user_id", + "in": "path", + "required": true + }, + { + "description": "Only email, realname and comment can be modified.", + "name": "profile", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/UserProfile" + } + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + }, + "delete": { + "description": "This endpoint let administrator of Harbor mark a registered user as removed.It actually won't be deleted from DB.\n", + "tags": [ + "user" + ], + "summary": "Mark a registered user as be removed.", + "operationId": "deleteUser", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "integer", + "format": "int", + "description": "User ID for marking as to be removed.", + "name": "user_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/users/{user_id}/cli_secret": { + "put": { + "description": "This endpoint let user generate a new CLI secret for himself. This API only works when auth mode is set to 'OIDC'. Once this API returns with successful status, the old secret will be invalid, as there will be only one CLI secret for a user.", + "tags": [ + "user" + ], + "summary": "Set CLI secret for a user.", + "operationId": "setCliSecret", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "integer", + "format": "int", + "description": "User ID", + "name": "user_id", + "in": "path", + "required": true + }, + { + "name": "secret", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/OIDCCliSecretReq" + } + } + ], + "responses": { + "200": { + "description": "The secret is successfully updated" + }, + "400": { + "description": "Invalid user ID. Or user is not onboarded via OIDC authentication. Or the secret does not meet the standard." + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "412": { + "description": "The auth mode of the system is not \"oidc_auth\", or the user is not onboarded via OIDC AuthN." + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/users/{user_id}/password": { + "put": { + "description": "This endpoint is for user to update password. Users with the admin role can change any user's password. Regular users can change only their own password.\n", + "tags": [ + "user" + ], + "summary": "Change the password on a user that already exists.", + "operationId": "updateUserPassword", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "integer", + "format": "int", + "name": "user_id", + "in": "path", + "required": true + }, + { + "description": "Password to be updated, the attribute 'old_password' is optional when the API is called by the system administrator.", + "name": "password", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/PasswordReq" + } + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Invalid user ID; Password does not meet requirement" + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "The caller does not have permission to update the password of the user with given ID, or the old password in request body is not correct." + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + } + } + }, + "/users/{user_id}/sysadmin": { + "put": { + "tags": [ + "user" + ], + "summary": "Update a registered user to change to be an administrator of Harbor.", + "operationId": "setUserSysAdmin", + "parameters": [ + { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + { + "type": "integer", + "format": "int", + "name": "user_id", + "in": "path", + "required": true + }, + { + "description": "Toggle a user to admin or not.", + "name": "sysadmin_flag", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/UserSysAdminFlag" + } + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Unexpected internal errors." + } + } + } + } + }, + "definitions": { + "Access": { + "type": "object", + "properties": { + "action": { + "description": "The action of the access", + "type": "string" + }, + "effect": { + "description": "The effect of the access", + "type": "string" + }, + "resource": { + "description": "The resource of the access", + "type": "string" + } + } + }, + "Accessory": { + "description": "The accessory of the artifact", + "type": "object", + "properties": { + "artifact_id": { + "description": "The artifact id of the accessory", + "type": "integer", + "format": "int64", + "x-omitempty": false + }, + "creation_time": { + "description": "The creation time of the accessory", + "type": "string", + "format": "date-time" + }, + "digest": { + "description": "The artifact digest of the accessory", + "type": "string", + "x-omitempty": false + }, + "icon": { + "description": "The icon of the accessory", + "type": "string", + "x-omitempty": false + }, + "id": { + "description": "The ID of the accessory", + "type": "integer", + "format": "int64" + }, + "size": { + "description": "The artifact size of the accessory", + "type": "integer", + "format": "int64", + "x-omitempty": false + }, + "subject_artifact_id": { + "description": "The subject artifact id of the accessory", + "type": "integer", + "format": "int64", + "x-omitempty": false + }, + "type": { + "description": "The artifact size of the accessory", + "type": "string", + "x-omitempty": false + } + } + }, + "ActionRequest": { + "description": "The request to stop, pause or resume", + "type": "object", + "properties": { + "action": { + "description": "The action of the request, should be stop, pause or resume", + "type": "string", + "enum": [ + "stop", + "pause", + "resume" + ] + } + } + }, + "AdditionLink": { + "type": "object", + "properties": { + "absolute": { + "description": "Determine whether the link is an absolute URL or not", + "type": "boolean", + "x-omitempty": false + }, + "href": { + "description": "The link of the addition", + "type": "string" + } + } + }, + "AdditionLinks": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/AdditionLink" + } + }, + "Annotations": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "Artifact": { + "type": "object", + "properties": { + "accessories": { + "type": "array", + "items": { + "description": "The accessory of the artifact.", + "$ref": "#/definitions/Accessory" + } + }, + "addition_links": { + "$ref": "#/definitions/AdditionLinks" + }, + "annotations": { + "$ref": "#/definitions/Annotations" + }, + "digest": { + "description": "The digest of the artifact", + "type": "string" + }, + "extra_attrs": { + "$ref": "#/definitions/ExtraAttrs" + }, + "icon": { + "description": "The digest of the icon", + "type": "string" + }, + "id": { + "description": "The ID of the artifact", + "type": "integer", + "format": "int64" + }, + "labels": { + "type": "array", + "items": { + "$ref": "#/definitions/Label" + } + }, + "manifest_media_type": { + "description": "The manifest media type of the artifact", + "type": "string" + }, + "media_type": { + "description": "The media type of the artifact", + "type": "string" + }, + "project_id": { + "description": "The ID of the project that the artifact belongs to", + "type": "integer", + "format": "int64" + }, + "pull_time": { + "description": "The latest pull time of the artifact", + "type": "string", + "format": "date-time" + }, + "push_time": { + "description": "The push time of the artifact", + "type": "string", + "format": "date-time" + }, + "references": { + "type": "array", + "items": { + "$ref": "#/definitions/Reference" + } + }, + "repository_id": { + "description": "The ID of the repository that the artifact belongs to", + "type": "integer", + "format": "int64" + }, + "scan_overview": { + "description": "The overview of the scan result.", + "$ref": "#/definitions/ScanOverview" + }, + "size": { + "description": "The size of the artifact", + "type": "integer", + "format": "int64" + }, + "tags": { + "type": "array", + "items": { + "$ref": "#/definitions/Tag" + } + }, + "type": { + "description": "The type of the artifact, e.g. image, chart, etc", + "type": "string" + } + } + }, + "AuditLog": { + "type": "object", + "properties": { + "id": { + "description": "The ID of the audit log entry.", + "type": "integer" + }, + "op_time": { + "description": "The time when this operation is triggered.", + "type": "string", + "format": "date-time", + "example": "2006-01-02T15:04:05Z" + }, + "operation": { + "description": "The operation against the repository in this log entry.", + "type": "string" + }, + "resource": { + "description": "Name of the repository in this log entry.", + "type": "string" + }, + "resource_type": { + "description": "Tag of the repository in this log entry.", + "type": "string" + }, + "username": { + "description": "Username of the user in this log entry.", + "type": "string" + } + } + }, + "AuthproxySetting": { + "type": "object", + "properties": { + "endpoint": { + "description": "The fully qualified URI of login endpoint of authproxy, such as 'https://192.168.1.2:8443/login'", + "type": "string" + }, + "server_certificate": { + "description": "The certificate to be pinned when connecting auth proxy.", + "type": "string" + }, + "skip_search": { + "description": "The flag to determine whether Harbor can skip search the user/group when adding him as a member.", + "type": "boolean" + }, + "tokenreivew_endpoint": { + "description": "The fully qualified URI of token review endpoint of authproxy, such as 'https://192.168.1.2:8443/tokenreview'", + "type": "string" + }, + "verify_cert": { + "description": "The flag to determine whether Harbor should verify the certificate when connecting to the auth proxy.", + "type": "boolean" + } + } + }, + "BoolConfigItem": { + "type": "object", + "properties": { + "editable": { + "description": "The configure item can be updated or not", + "type": "boolean", + "x-omitempty": false + }, + "value": { + "description": "The boolean value of current config item", + "type": "boolean", + "x-omitempty": false + } + } + }, + "CVEAllowlist": { + "description": "The CVE Allowlist for system or project", + "type": "object", + "properties": { + "creation_time": { + "description": "The creation time of the allowlist.", + "type": "string", + "format": "date-time" + }, + "expires_at": { + "description": "the time for expiration of the allowlist, in the form of seconds since epoch. This is an optional attribute, if it's not set the CVE allowlist does not expire.", + "type": "integer", + "x-nullable": true + }, + "id": { + "description": "ID of the allowlist", + "type": "integer" + }, + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/CVEAllowlistItem" + } + }, + "project_id": { + "description": "ID of the project which the allowlist belongs to. For system level allowlist this attribute is zero.", + "type": "integer" + }, + "update_time": { + "description": "The update time of the allowlist.", + "type": "string", + "format": "date-time" + } + } + }, + "CVEAllowlistItem": { + "description": "The item in CVE allowlist", + "type": "object", + "properties": { + "cve_id": { + "description": "The ID of the CVE, such as \"CVE-2019-10164\"", + "type": "string" + } + } + }, + "ChartMetadata": { + "description": "The metadata of chart version", + "type": "object", + "required": [ + "name", + "version", + "engine", + "icon", + "apiVersion", + "appVersion" + ], + "properties": { + "apiVersion": { + "description": "The API version of this chart", + "type": "string" + }, + "appVersion": { + "description": "The version of the application enclosed in the chart", + "type": "string" + }, + "deprecated": { + "description": "Whether or not this chart is deprecated", + "type": "boolean" + }, + "description": { + "description": "A one-sentence description of chart", + "type": "string" + }, + "engine": { + "description": "The name of template engine", + "type": "string" + }, + "home": { + "description": "The URL to the relevant project page", + "type": "string" + }, + "icon": { + "description": "The URL to an icon file", + "type": "string" + }, + "keywords": { + "description": "A list of string keywords", + "type": "array", + "items": { + "type": "string" + } + }, + "name": { + "description": "The name of the chart", + "type": "string" + }, + "sources": { + "description": "The URL to the source code of chart", + "type": "array", + "items": { + "type": "string" + } + }, + "version": { + "description": "A SemVer 2 version of chart", + "type": "string" + } + } + }, + "ChartVersion": { + "description": "A specified chart entry", + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/ChartMetadata" + }, + { + "type": "object", + "properties": { + "created": { + "description": "The created time of the chart entry", + "type": "string" + }, + "digest": { + "description": "The digest value of the chart entry", + "type": "string" + }, + "removed": { + "description": "A flag to indicate if the chart entry is removed", + "type": "boolean" + }, + "urls": { + "description": "The urls of the chart entry", + "type": "array", + "items": { + "type": "string" + } + } + } + } + ], + "properties": { + "labels": { + "description": "A list of label", + "type": "array", + "items": { + "$ref": "#/definitions/Label" + } + } + } + }, + "ComponentHealthStatus": { + "description": "The health status of component", + "type": "object", + "properties": { + "error": { + "description": "(optional) The error message when the status is \"unhealthy\"", + "type": "string" + }, + "name": { + "description": "The component name", + "type": "string" + }, + "status": { + "description": "The health status of component", + "type": "string" + } + } + }, + "Configurations": { + "type": "object", + "properties": { + "audit_log_forward_endpoint": { + "description": "The audit log forward endpoint", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "auth_mode": { + "description": "The auth mode of current system, such as \"db_auth\", \"ldap_auth\", \"oidc_auth\"", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "http_authproxy_admin_groups": { + "description": "The group which has the harbor admin privileges", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "http_authproxy_admin_usernames": { + "description": "The username which has the harbor admin privileges", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "http_authproxy_endpoint": { + "description": "The endpoint of the HTTP auth", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "http_authproxy_server_certificate": { + "description": "The certificate of the HTTP auth provider", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "http_authproxy_skip_search": { + "description": "Search user before onboard", + "type": "boolean", + "x-isnullable": true, + "x-omitempty": true + }, + "http_authproxy_tokenreview_endpoint": { + "description": "The token review endpoint", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "http_authproxy_verify_cert": { + "description": "Verify the HTTP auth provider's certificate", + "type": "boolean", + "x-isnullable": true, + "x-omitempty": true + }, + "ldap_base_dn": { + "description": "The Base DN for LDAP binding.", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "ldap_filter": { + "description": "The filter for LDAP search", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "ldap_group_admin_dn": { + "description": "Specify the ldap group which have the same privilege with Harbor admin", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "ldap_group_attribute_name": { + "description": "The attribute which is used as identity of the LDAP group, default is cn.'", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "ldap_group_base_dn": { + "description": "The base DN to search LDAP group.", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "ldap_group_membership_attribute": { + "description": "The user attribute to identify the group membership", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "ldap_group_search_filter": { + "description": "The filter to search the ldap group", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "ldap_group_search_scope": { + "description": "The scope to search ldap group. ''0-LDAP_SCOPE_BASE, 1-LDAP_SCOPE_ONELEVEL, 2-LDAP_SCOPE_SUBTREE''", + "type": "integer", + "x-isnullable": true, + "x-omitempty": true + }, + "ldap_scope": { + "description": "The scope to search ldap users,'0-LDAP_SCOPE_BASE, 1-LDAP_SCOPE_ONELEVEL, 2-LDAP_SCOPE_SUBTREE'", + "type": "integer", + "x-isnullable": true, + "x-omitempty": true + }, + "ldap_search_dn": { + "description": "The DN of the user to do the search.", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "ldap_search_password": { + "description": "The password of the ldap search dn", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "ldap_timeout": { + "description": "Timeout in seconds for connection to LDAP server", + "type": "integer", + "x-isnullable": true, + "x-omitempty": true + }, + "ldap_uid": { + "description": "The attribute which is used as identity for the LDAP binding, such as \"CN\" or \"SAMAccountname\"", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "ldap_url": { + "description": "The URL of LDAP server", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "ldap_verify_cert": { + "description": "Whether verify your OIDC server certificate, disable it if your OIDC server is hosted via self-hosted certificate.", + "type": "boolean", + "x-isnullable": true, + "x-omitempty": true + }, + "notification_enable": { + "description": "Enable notification", + "type": "boolean", + "x-isnullable": true, + "x-omitempty": true + }, + "oidc_admin_group": { + "description": "The OIDC group which has the harbor admin privileges", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "oidc_auto_onboard": { + "description": "Auto onboard the OIDC user", + "type": "boolean", + "x-isnullable": true, + "x-omitempty": true + }, + "oidc_client_id": { + "description": "The client ID of the OIDC provider", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "oidc_client_secret": { + "description": "The OIDC provider secret", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "oidc_endpoint": { + "description": "The endpoint of the OIDC provider", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "oidc_extra_redirect_parms": { + "description": "Extra parameters to add when redirect request to OIDC provider", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "oidc_group_filter": { + "description": "The OIDC group filter which filters out the group name doesn't match the regular expression", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "oidc_groups_claim": { + "description": "The attribute claims the group name", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "oidc_name": { + "description": "The OIDC provider name", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "oidc_scope": { + "description": "The scope of the OIDC provider", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "oidc_user_claim": { + "description": "The attribute claims the username", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "oidc_verify_cert": { + "description": "Verify the OIDC provider's certificate'", + "type": "boolean", + "x-isnullable": true, + "x-omitempty": true + }, + "project_creation_restriction": { + "description": "Indicate who can create projects, it could be ''adminonly'' or ''everyone''.", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "quota_per_project_enable": { + "description": "Enable quota per project", + "type": "boolean", + "x-isnullable": true, + "x-omitempty": true + }, + "read_only": { + "description": "The flag to indicate whether Harbor is in readonly mode.", + "type": "boolean", + "x-isnullable": true, + "x-omitempty": true + }, + "robot_name_prefix": { + "description": "The rebot account name prefix", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "robot_token_duration": { + "description": "The robot account token duration in days", + "type": "integer", + "x-isnullable": true, + "x-omitempty": true + }, + "self_registration": { + "description": "Whether the Harbor instance supports self-registration. If it''s set to false, admin need to add user to the instance.", + "type": "boolean", + "x-isnullable": true, + "x-omitempty": true + }, + "session_timeout": { + "description": "The session timeout for harbor, in minutes.", + "type": "integer", + "x-isnullable": true, + "x-omitempty": true + }, + "skip_audit_log_database": { + "description": "Skip audit log database", + "type": "boolean", + "x-isnullable": true, + "x-omitempty": true + }, + "storage_per_project": { + "description": "The storage quota per project", + "type": "integer", + "x-isnullable": true, + "x-omitempty": true + }, + "token_expiration": { + "description": "The expiration time of the token for internal Registry, in minutes.", + "type": "integer", + "x-isnullable": true, + "x-omitempty": true + }, + "uaa_client_id": { + "description": "The client id of UAA", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "uaa_client_secret": { + "description": "The client secret of the UAA", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "uaa_endpoint": { + "description": "The endpoint of the UAA", + "type": "string", + "x-isnullable": true, + "x-omitempty": true + }, + "uaa_verify_cert": { + "description": "Verify the certificate in UAA server", + "type": "boolean", + "x-isnullable": true, + "x-omitempty": true + } + } + }, + "ConfigurationsResponse": { + "type": "object", + "properties": { + "audit_log_forward_endpoint": { + "description": "The endpoint of the audit log forwarder", + "$ref": "#/definitions/StringConfigItem" + }, + "auth_mode": { + "description": "The auth mode of current system, such as \"db_auth\", \"ldap_auth\", \"oidc_auth\"", + "$ref": "#/definitions/StringConfigItem" + }, + "http_authproxy_admin_groups": { + "description": "The group which has the harbor admin privileges", + "$ref": "#/definitions/StringConfigItem" + }, + "http_authproxy_admin_usernames": { + "description": "The usernames which has the harbor admin privileges", + "$ref": "#/definitions/StringConfigItem" + }, + "http_authproxy_endpoint": { + "description": "The endpoint of the HTTP auth", + "$ref": "#/definitions/StringConfigItem" + }, + "http_authproxy_server_certificate": { + "description": "The certificate of the HTTP auth provider", + "$ref": "#/definitions/StringConfigItem" + }, + "http_authproxy_skip_search": { + "description": "Search user before onboard", + "$ref": "#/definitions/BoolConfigItem" + }, + "http_authproxy_tokenreview_endpoint": { + "description": "The token review endpoint", + "$ref": "#/definitions/StringConfigItem" + }, + "http_authproxy_verify_cert": { + "description": "Verify the HTTP auth provider's certificate", + "$ref": "#/definitions/BoolConfigItem" + }, + "ldap_base_dn": { + "description": "The Base DN for LDAP binding.", + "$ref": "#/definitions/StringConfigItem" + }, + "ldap_filter": { + "description": "The filter for LDAP search", + "$ref": "#/definitions/StringConfigItem" + }, + "ldap_group_admin_dn": { + "description": "Specify the ldap group which have the same privilege with Harbor admin", + "$ref": "#/definitions/StringConfigItem" + }, + "ldap_group_attribute_name": { + "description": "The attribute which is used as identity of the LDAP group, default is cn.'", + "$ref": "#/definitions/StringConfigItem" + }, + "ldap_group_base_dn": { + "description": "The base DN to search LDAP group.", + "$ref": "#/definitions/StringConfigItem" + }, + "ldap_group_membership_attribute": { + "description": "The user attribute to identify the group membership", + "$ref": "#/definitions/StringConfigItem" + }, + "ldap_group_search_filter": { + "description": "The filter to search the ldap group", + "$ref": "#/definitions/StringConfigItem" + }, + "ldap_group_search_scope": { + "description": "The scope to search ldap group. ''0-LDAP_SCOPE_BASE, 1-LDAP_SCOPE_ONELEVEL, 2-LDAP_SCOPE_SUBTREE''", + "$ref": "#/definitions/IntegerConfigItem" + }, + "ldap_scope": { + "description": "The scope to search ldap users,'0-LDAP_SCOPE_BASE, 1-LDAP_SCOPE_ONELEVEL, 2-LDAP_SCOPE_SUBTREE'", + "$ref": "#/definitions/IntegerConfigItem" + }, + "ldap_search_dn": { + "description": "The DN of the user to do the search.", + "$ref": "#/definitions/StringConfigItem" + }, + "ldap_timeout": { + "description": "Timeout in seconds for connection to LDAP server", + "$ref": "#/definitions/IntegerConfigItem" + }, + "ldap_uid": { + "description": "The attribute which is used as identity for the LDAP binding, such as \"CN\" or \"SAMAccountname\"", + "$ref": "#/definitions/StringConfigItem" + }, + "ldap_url": { + "description": "The URL of LDAP server", + "$ref": "#/definitions/StringConfigItem" + }, + "ldap_verify_cert": { + "description": "Whether verify your OIDC server certificate, disable it if your OIDC server is hosted via self-hosted certificate.", + "$ref": "#/definitions/BoolConfigItem" + }, + "notification_enable": { + "description": "Enable notification", + "$ref": "#/definitions/BoolConfigItem" + }, + "oidc_admin_group": { + "description": "The OIDC group which has the harbor admin privileges", + "$ref": "#/definitions/StringConfigItem" + }, + "oidc_auto_onboard": { + "description": "Auto onboard the OIDC user", + "$ref": "#/definitions/BoolConfigItem" + }, + "oidc_client_id": { + "description": "The client ID of the OIDC provider", + "$ref": "#/definitions/StringConfigItem" + }, + "oidc_endpoint": { + "description": "The endpoint of the OIDC provider", + "$ref": "#/definitions/StringConfigItem" + }, + "oidc_extra_redirect_parms": { + "description": "Extra parameters to add when redirect request to OIDC provider", + "$ref": "#/definitions/StringConfigItem" + }, + "oidc_group_filter": { + "description": "The OIDC group filter which filters out the group doesn't match the regular expression", + "$ref": "#/definitions/StringConfigItem" + }, + "oidc_groups_claim": { + "description": "The attribute claims the group name", + "$ref": "#/definitions/StringConfigItem" + }, + "oidc_name": { + "description": "The OIDC provider name", + "$ref": "#/definitions/StringConfigItem" + }, + "oidc_scope": { + "description": "The scope of the OIDC provider", + "$ref": "#/definitions/StringConfigItem" + }, + "oidc_user_claim": { + "description": "The attribute claims the username", + "$ref": "#/definitions/StringConfigItem" + }, + "oidc_verify_cert": { + "description": "Verify the OIDC provider's certificate'", + "$ref": "#/definitions/BoolConfigItem" + }, + "project_creation_restriction": { + "description": "Indicate who can create projects, it could be ''adminonly'' or ''everyone''.", + "$ref": "#/definitions/StringConfigItem" + }, + "quota_per_project_enable": { + "description": "Enable quota per project", + "$ref": "#/definitions/BoolConfigItem" + }, + "read_only": { + "description": "The flag to indicate whether Harbor is in readonly mode.", + "$ref": "#/definitions/BoolConfigItem" + }, + "robot_name_prefix": { + "description": "The rebot account name prefix", + "$ref": "#/definitions/StringConfigItem" + }, + "robot_token_duration": { + "description": "The robot account token duration in days", + "$ref": "#/definitions/IntegerConfigItem" + }, + "scan_all_policy": { + "type": "object", + "properties": { + "parameter": { + "description": "The parameters of the policy, the values are dependent on the type of the policy.", + "type": "object", + "properties": { + "daily_time": { + "description": "The offset in seconds of UTC 0 o'clock, only valid when the policy type is \"daily\"", + "type": "integer" + } + } + }, + "type": { + "description": "The type of scan all policy, currently the valid values are \"none\" and \"daily\"", + "type": "string" + } + } + }, + "self_registration": { + "description": "Whether the Harbor instance supports self-registration. If it''s set to false, admin need to add user to the instance.", + "$ref": "#/definitions/BoolConfigItem" + }, + "session_timeout": { + "description": "The session timeout in minutes", + "$ref": "#/definitions/IntegerConfigItem" + }, + "skip_audit_log_database": { + "description": "Whether skip the audit log in database", + "$ref": "#/definitions/BoolConfigItem" + }, + "storage_per_project": { + "description": "The storage quota per project", + "$ref": "#/definitions/IntegerConfigItem" + }, + "token_expiration": { + "description": "The expiration time of the token for internal Registry, in minutes.", + "$ref": "#/definitions/IntegerConfigItem" + }, + "uaa_client_id": { + "description": "The client id of UAA", + "$ref": "#/definitions/StringConfigItem" + }, + "uaa_client_secret": { + "description": "The client secret of the UAA", + "$ref": "#/definitions/StringConfigItem" + }, + "uaa_endpoint": { + "description": "The endpoint of the UAA", + "$ref": "#/definitions/StringConfigItem" + }, + "uaa_verify_cert": { + "description": "Verify the certificate in UAA server", + "$ref": "#/definitions/BoolConfigItem" + } + } + }, + "ConfigurationsResponseScanAllPolicy": { + "type": "object", + "properties": { + "parameter": { + "description": "The parameters of the policy, the values are dependent on the type of the policy.", + "type": "object", + "properties": { + "daily_time": { + "description": "The offset in seconds of UTC 0 o'clock, only valid when the policy type is \"daily\"", + "type": "integer" + } + } + }, + "type": { + "description": "The type of scan all policy, currently the valid values are \"none\" and \"daily\"", + "type": "string" + } + } + }, + "ConfigurationsResponseScanAllPolicyParameter": { + "description": "The parameters of the policy, the values are dependent on the type of the policy.", + "type": "object", + "properties": { + "daily_time": { + "description": "The offset in seconds of UTC 0 o'clock, only valid when the policy type is \"daily\"", + "type": "integer" + } + } + }, + "Error": { + "description": "a model for all the error response coming from harbor", + "type": "object", + "properties": { + "code": { + "description": "The error code", + "type": "string" + }, + "message": { + "description": "The error message", + "type": "string" + } + } + }, + "Errors": { + "description": "The error array that describe the errors got during the handling of request", + "type": "object", + "properties": { + "errors": { + "type": "array", + "items": { + "$ref": "#/definitions/Error" + } + } + } + }, + "EventType": { + "description": "Webhook supportted event type.", + "type": "string", + "example": "pullImage" + }, + "ExecHistory": { + "type": "object", + "properties": { + "creation_time": { + "description": "the creation time of purge job.", + "type": "string", + "format": "date-time" + }, + "deleted": { + "description": "if purge job was deleted.", + "type": "boolean" + }, + "id": { + "description": "the id of purge job.", + "type": "integer" + }, + "job_kind": { + "description": "the job kind of purge job.", + "type": "string" + }, + "job_name": { + "description": "the job name of purge job.", + "type": "string" + }, + "job_parameters": { + "description": "the job parameters of purge job.", + "type": "string" + }, + "job_status": { + "description": "the status of purge job.", + "type": "string" + }, + "schedule": { + "$ref": "#/definitions/ScheduleObj" + }, + "update_time": { + "description": "the update time of purge job.", + "type": "string", + "format": "date-time" + } + } + }, + "Execution": { + "type": "object", + "properties": { + "end_time": { + "description": "The end time of execution", + "type": "string" + }, + "extra_attrs": { + "$ref": "#/definitions/ExtraAttrs" + }, + "id": { + "description": "The ID of execution", + "type": "integer" + }, + "metrics": { + "$ref": "#/definitions/Metrics" + }, + "start_time": { + "description": "The start time of execution", + "type": "string" + }, + "status": { + "description": "The status of execution", + "type": "string" + }, + "status_message": { + "description": "The status message of execution", + "type": "string" + }, + "trigger": { + "description": "The trigger of execution", + "type": "string" + }, + "vendor_id": { + "description": "The vendor id of execution", + "type": "integer" + }, + "vendor_type": { + "description": "The vendor type of execution", + "type": "string" + } + } + }, + "ExtraAttrs": { + "type": "object", + "additionalProperties": { + "type": "object" + } + }, + "FilterStyle": { + "description": "The style of the resource filter", + "type": "object", + "properties": { + "style": { + "description": "The filter style", + "type": "string" + }, + "type": { + "description": "The filter type", + "type": "string" + }, + "values": { + "description": "The filter values", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "GCHistory": { + "type": "object", + "properties": { + "creation_time": { + "description": "the creation time of gc job.", + "type": "string", + "format": "date-time" + }, + "deleted": { + "description": "if gc job was deleted.", + "type": "boolean" + }, + "id": { + "description": "the id of gc job.", + "type": "integer" + }, + "job_kind": { + "description": "the job kind of gc job.", + "type": "string" + }, + "job_name": { + "description": "the job name of gc job.", + "type": "string" + }, + "job_parameters": { + "description": "the job parameters of gc job.", + "type": "string" + }, + "job_status": { + "description": "the status of gc job.", + "type": "string" + }, + "schedule": { + "$ref": "#/definitions/ScheduleObj" + }, + "update_time": { + "description": "the update time of gc job.", + "type": "string", + "format": "date-time" + } + } + }, + "GeneralInfo": { + "type": "object", + "properties": { + "auth_mode": { + "description": "The auth mode of current Harbor instance.", + "type": "string", + "x-nullable": true, + "x-omitempty": true + }, + "authproxy_settings": { + "description": "The setting of auth proxy this is only available when Harbor relies on authproxy for authentication.", + "x-nullable": true, + "x-omitempty": true, + "$ref": "#/definitions/AuthproxySetting" + }, + "current_time": { + "description": "The current time of the server.", + "type": "string", + "format": "date-time", + "x-nullable": true, + "x-omitempty": true + }, + "external_url": { + "description": "The external URL of Harbor, with protocol.", + "type": "string", + "x-nullable": true, + "x-omitempty": true + }, + "harbor_version": { + "description": "The build version of Harbor.", + "type": "string", + "x-nullable": true, + "x-omitempty": true + }, + "has_ca_root": { + "description": "Indicate whether there is a ca root cert file ready for download in the file system.", + "type": "boolean", + "x-nullable": true, + "x-omitempty": true + }, + "notification_enable": { + "description": "The flag to indicate whether notification mechanism is enabled on Harbor instance.", + "type": "boolean", + "x-nullable": true, + "x-omitempty": true + }, + "project_creation_restriction": { + "description": "Indicate who can create projects, it could be 'adminonly' or 'everyone'.", + "type": "string", + "x-nullable": true, + "x-omitempty": true + }, + "read_only": { + "description": "The flag to indicate whether Harbor is in readonly mode.", + "type": "boolean", + "x-nullable": true, + "x-omitempty": true + }, + "registry_storage_provider_name": { + "description": "The storage provider's name of Harbor registry", + "type": "string", + "x-nullable": true, + "x-omitempty": true + }, + "registry_url": { + "description": "The url of registry against which the docker command should be issued.", + "type": "string", + "x-nullable": true, + "x-omitempty": true + }, + "self_registration": { + "description": "Indicate whether the Harbor instance enable user to register himself.", + "type": "boolean", + "x-nullable": true, + "x-omitempty": true + }, + "with_chartmuseum": { + "description": "If the Harbor instance is deployed with nested chartmuseum.", + "type": "boolean", + "x-nullable": true, + "x-omitempty": true + }, + "with_notary": { + "description": "If the Harbor instance is deployed with nested notary.", + "type": "boolean", + "x-nullable": true, + "x-omitempty": true + } + } + }, + "Icon": { + "type": "object", + "properties": { + "content": { + "description": "The base64 encoded content of the icon", + "type": "string" + }, + "content-type": { + "description": "The content type of the icon", + "type": "string" + } + } + }, + "ImmutableRule": { + "type": "object", + "properties": { + "action": { + "type": "string" + }, + "disabled": { + "type": "boolean" + }, + "id": { + "type": "integer" + }, + "params": { + "type": "object", + "additionalProperties": { + "type": "object" + } + }, + "priority": { + "type": "integer" + }, + "scope_selectors": { + "type": "object", + "additionalProperties": { + "type": "array", + "items": { + "$ref": "#/definitions/ImmutableSelector" + } + } + }, + "tag_selectors": { + "type": "array", + "items": { + "$ref": "#/definitions/ImmutableSelector" + } + }, + "template": { + "type": "string" + } + } + }, + "ImmutableSelector": { + "type": "object", + "properties": { + "decoration": { + "type": "string" + }, + "extras": { + "type": "string" + }, + "kind": { + "type": "string" + }, + "pattern": { + "type": "string" + } + } + }, + "Instance": { + "type": "object", + "properties": { + "auth_info": { + "description": "The auth credential data if exists", + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "auth_mode": { + "description": "The authentication way supported", + "type": "string" + }, + "default": { + "description": "Whether the instance is default or not", + "type": "boolean", + "x-omitempty": false + }, + "description": { + "description": "Description of instance", + "type": "string" + }, + "enabled": { + "description": "Whether the instance is activated or not", + "type": "boolean", + "x-omitempty": false + }, + "endpoint": { + "description": "The service endpoint of this instance", + "type": "string" + }, + "id": { + "description": "Unique ID", + "type": "integer" + }, + "insecure": { + "description": "Whether the instance endpoint is insecure or not", + "type": "boolean", + "x-omitempty": false + }, + "name": { + "description": "Instance name", + "type": "string" + }, + "setup_timestamp": { + "description": "The timestamp of instance setting up", + "type": "integer", + "format": "int64" + }, + "status": { + "description": "The health status", + "type": "string" + }, + "vendor": { + "description": "Based on which driver, identified by ID", + "type": "string" + } + } + }, + "IntegerConfigItem": { + "type": "object", + "properties": { + "editable": { + "description": "The configure item can be updated or not", + "type": "boolean", + "x-omitempty": false + }, + "value": { + "description": "The integer value of current config item", + "type": "integer", + "x-omitempty": false + } + } + }, + "InternalConfigurationValue": { + "type": "object", + "properties": { + "editable": { + "description": "The configure item can be updated or not", + "type": "boolean", + "x-omitempty": false + }, + "value": { + "description": "The value of current config item", + "type": "object" + } + } + }, + "InternalConfigurationsResponse": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/InternalConfigurationValue" + } + }, + "IsDefault": { + "type": "object", + "properties": { + "is_default": { + "description": "A flag indicating whether a scanner registration is default.", + "type": "boolean" + } + } + }, + "JobQueue": { + "description": "the job queue info", + "type": "object", + "properties": { + "count": { + "description": "The count of jobs in the job queue", + "type": "integer" + }, + "job_type": { + "description": "The type of the job queue", + "type": "string" + }, + "latency": { + "description": "The latency the job queue (seconds)", + "type": "integer" + }, + "paused": { + "description": "The paused status of the job queue", + "type": "boolean", + "x-omitempty": false + } + } + }, + "Label": { + "type": "object", + "properties": { + "color": { + "description": "The color the label", + "type": "string" + }, + "creation_time": { + "description": "The creation time the label", + "type": "string", + "format": "date-time" + }, + "description": { + "description": "The description the label", + "type": "string" + }, + "id": { + "description": "The ID of the label", + "type": "integer", + "format": "int64" + }, + "name": { + "description": "The name the label", + "type": "string" + }, + "project_id": { + "description": "The ID of project that the label belongs to", + "type": "integer", + "format": "int64" + }, + "scope": { + "description": "The scope the label", + "type": "string" + }, + "update_time": { + "description": "The update time of the label", + "type": "string", + "format": "date-time" + } + } + }, + "LdapConf": { + "description": "The ldap configure properties", + "type": "object", + "properties": { + "ldap_base_dn": { + "description": "The base dn of ldap service.", + "type": "string" + }, + "ldap_connection_timeout": { + "description": "The connect timeout of ldap service(second).", + "type": "integer", + "format": "int64" + }, + "ldap_filter": { + "description": "The serach filter of ldap service.", + "type": "string" + }, + "ldap_scope": { + "description": "The serach scope of ldap service.", + "type": "integer", + "format": "int64" + }, + "ldap_search_dn": { + "description": "The search dn of ldap service.", + "type": "string" + }, + "ldap_search_password": { + "description": "The search password of ldap service.", + "type": "string" + }, + "ldap_uid": { + "description": "The serach uid from ldap service attributes.", + "type": "string" + }, + "ldap_url": { + "description": "The url of ldap service.", + "type": "string" + }, + "ldap_verify_cert": { + "description": "Verify Ldap server certificate.", + "type": "boolean" + } + } + }, + "LdapFailedImportUser": { + "type": "object", + "properties": { + "error": { + "description": "fail reason.", + "type": "string" + }, + "uid": { + "description": "the uid can't add to system.", + "type": "string" + } + } + }, + "LdapImportUsers": { + "type": "object", + "properties": { + "ldap_uid_list": { + "description": "selected uid list", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "LdapPingResult": { + "description": "The ldap ping result", + "type": "object", + "properties": { + "message": { + "description": "The ping operation output message.", + "type": "string" + }, + "success": { + "description": "Test success", + "type": "boolean" + } + } + }, + "LdapUser": { + "type": "object", + "properties": { + "email": { + "description": "The user email address from \"mail\" or \"email\" attribute.", + "type": "string" + }, + "realname": { + "description": "The user realname from \"uid\" or \"cn\" attribute.", + "type": "string" + }, + "username": { + "description": "ldap username.", + "type": "string" + } + } + }, + "Metadata": { + "type": "object", + "properties": { + "icon": { + "description": "icon", + "type": "string" + }, + "id": { + "description": "id", + "type": "string" + }, + "maintainers": { + "description": "maintainers", + "type": "array", + "items": { + "type": "string" + } + }, + "name": { + "description": "name", + "type": "string" + }, + "source": { + "description": "source", + "type": "string" + }, + "version": { + "description": "version", + "type": "string" + } + } + }, + "Metrics": { + "type": "object", + "properties": { + "error_task_count": { + "description": "The count of error task", + "type": "integer" + }, + "pending_task_count": { + "description": "The count of pending task", + "type": "integer" + }, + "running_task_count": { + "description": "The count of running task", + "type": "integer" + }, + "scheduled_task_count": { + "description": "The count of scheduled task", + "type": "integer" + }, + "stopped_task_count": { + "description": "The count of stopped task", + "type": "integer" + }, + "success_task_count": { + "description": "The count of success task", + "type": "integer" + }, + "task_count": { + "description": "The count of task", + "type": "integer" + } + } + }, + "NativeReportSummary": { + "description": "The summary for the native report", + "type": "object", + "properties": { + "complete_percent": { + "description": "The complete percent of the scanning which value is between 0 and 100", + "type": "integer", + "example": 100 + }, + "duration": { + "description": "The seconds spent for generating the report", + "type": "integer", + "format": "int64", + "example": 300 + }, + "end_time": { + "description": "The end time of the scan process that generating report", + "type": "string", + "format": "date-time", + "example": "2006-01-02T15:04:05Z" + }, + "report_id": { + "description": "id of the native scan report", + "type": "string", + "example": "5f62c830-f996-11e9-957f-0242c0a89008" + }, + "scan_status": { + "description": "The status of the report generating process", + "type": "string", + "example": "Success" + }, + "scanner": { + "$ref": "#/definitions/Scanner" + }, + "severity": { + "description": "The overall severity", + "type": "string", + "example": "High" + }, + "start_time": { + "description": "The start time of the scan process that generating report", + "type": "string", + "format": "date-time", + "example": "2006-01-02T14:04:05Z" + }, + "summary": { + "$ref": "#/definitions/VulnerabilitySummary" + } + } + }, + "NotifyType": { + "description": "Webhook supportted notify type.", + "type": "string", + "example": "http" + }, + "OIDCCliSecretReq": { + "type": "object", + "properties": { + "secret": { + "description": "The new secret", + "type": "string" + } + } + }, + "OIDCUserInfo": { + "type": "object", + "properties": { + "creation_time": { + "description": "The creation time of the OIDC user info record.", + "type": "string", + "format": "date-time" + }, + "id": { + "description": "the ID of the OIDC info record", + "type": "integer", + "format": "int" + }, + "secret": { + "description": "the secret of the OIDC user that can be used for CLI to push/pull artifacts", + "type": "string" + }, + "subiss": { + "description": "the concatenation of sub and issuer in the ID token", + "type": "string" + }, + "update_time": { + "description": "The update time of the OIDC user info record.", + "type": "string", + "format": "date-time" + }, + "user_id": { + "description": "the ID of the user", + "type": "integer", + "format": "int" + } + } + }, + "OverallHealthStatus": { + "description": "The system health status", + "type": "object", + "properties": { + "components": { + "type": "array", + "items": { + "$ref": "#/definitions/ComponentHealthStatus" + } + }, + "status": { + "description": "The overall health status. It is \"healthy\" only when all the components' status are \"healthy\"", + "type": "string" + } + } + }, + "PasswordReq": { + "type": "object", + "properties": { + "new_password": { + "description": "New password for marking as to be updated.", + "type": "string" + }, + "old_password": { + "description": "The user's existing password.", + "type": "string" + } + } + }, + "Permission": { + "type": "object", + "properties": { + "action": { + "description": "The permission action", + "type": "string" + }, + "resource": { + "description": "The permission resoruce", + "type": "string" + } + } + }, + "Platform": { + "type": "object", + "properties": { + "'os.features'": { + "description": "The features of the OS that the artifact applys to", + "type": "array", + "items": { + "type": "string" + } + }, + "'os.version'": { + "description": "The version of the OS that the artifact applys to", + "type": "string" + }, + "architecture": { + "description": "The architecture that the artifact applys to", + "type": "string" + }, + "os": { + "description": "The OS that the artifact applys to", + "type": "string" + }, + "variant": { + "description": "The variant of the CPU", + "type": "string" + } + } + }, + "PreheatPolicy": { + "type": "object", + "properties": { + "creation_time": { + "description": "The Create Time of preheat policy", + "type": "string", + "format": "date-time" + }, + "description": { + "description": "The Description of preheat policy", + "type": "string" + }, + "enabled": { + "description": "Whether the preheat policy enabled", + "type": "boolean", + "x-omitempty": false + }, + "filters": { + "description": "The Filters of preheat policy", + "type": "string" + }, + "id": { + "description": "The ID of preheat policy", + "type": "integer" + }, + "name": { + "description": "The Name of preheat policy", + "type": "string" + }, + "project_id": { + "description": "The ID of preheat policy project", + "type": "integer" + }, + "provider_id": { + "description": "The ID of preheat policy provider", + "type": "integer" + }, + "provider_name": { + "description": "The Name of preheat policy provider", + "type": "string" + }, + "trigger": { + "description": "The Trigger of preheat policy", + "type": "string" + }, + "update_time": { + "description": "The Update Time of preheat policy", + "type": "string", + "format": "date-time" + } + } + }, + "Project": { + "type": "object", + "properties": { + "chart_count": { + "description": "The total number of charts under this project.", + "type": "integer", + "x-omitempty": false + }, + "creation_time": { + "description": "The creation time of the project.", + "type": "string", + "format": "date-time" + }, + "current_user_role_id": { + "description": "The role ID with highest permission of the current user who triggered the API (for UI). This attribute is deprecated and will be removed in future versions.", + "type": "integer" + }, + "current_user_role_ids": { + "description": "The list of role ID of the current user who triggered the API (for UI)", + "type": "array", + "items": { + "type": "integer", + "format": "int32" + } + }, + "cve_allowlist": { + "description": "The CVE allowlist of this project.", + "$ref": "#/definitions/CVEAllowlist" + }, + "deleted": { + "description": "A deletion mark of the project.", + "type": "boolean" + }, + "metadata": { + "description": "The metadata of the project.", + "$ref": "#/definitions/ProjectMetadata" + }, + "name": { + "description": "The name of the project.", + "type": "string" + }, + "owner_id": { + "description": "The owner ID of the project always means the creator of the project.", + "type": "integer", + "format": "int32" + }, + "owner_name": { + "description": "The owner name of the project.", + "type": "string" + }, + "project_id": { + "description": "Project ID", + "type": "integer", + "format": "int32" + }, + "registry_id": { + "description": "The ID of referenced registry when the project is a proxy cache project.", + "type": "integer", + "format": "int64" + }, + "repo_count": { + "description": "The number of the repositories under this project.", + "type": "integer", + "x-omitempty": false + }, + "togglable": { + "description": "Correspond to the UI about whether the project's publicity is updatable (for UI)", + "type": "boolean" + }, + "update_time": { + "description": "The update time of the project.", + "type": "string", + "format": "date-time" + } + } + }, + "ProjectDeletable": { + "type": "object", + "properties": { + "deletable": { + "description": "Whether the project can be deleted.", + "type": "boolean" + }, + "message": { + "description": "The detail message when the project can not be deleted.", + "type": "string" + } + } + }, + "ProjectMember": { + "type": "object", + "properties": { + "member_group": { + "$ref": "#/definitions/UserGroup" + }, + "member_user": { + "$ref": "#/definitions/UserEntity" + }, + "role_id": { + "description": "The role id 1 for projectAdmin, 2 for developer, 3 for guest, 4 for maintainer", + "type": "integer" + } + } + }, + "ProjectMemberEntity": { + "type": "object", + "properties": { + "entity_id": { + "description": "the id of entity, if the member is a user, it is user_id in user table. if the member is a user group, it is the user group's ID in user_group table.", + "type": "integer" + }, + "entity_name": { + "description": "the name of the group member.", + "type": "string" + }, + "entity_type": { + "description": "the entity's type, u for user entity, g for group entity.", + "type": "string" + }, + "id": { + "description": "the project member id", + "type": "integer" + }, + "project_id": { + "description": "the project id", + "type": "integer" + }, + "role_id": { + "description": "the role id", + "type": "integer" + }, + "role_name": { + "description": "the name of the role", + "type": "string" + } + } + }, + "ProjectMetadata": { + "type": "object", + "properties": { + "auto_scan": { + "description": "Whether scan images automatically when pushing. The valid values are \"true\", \"false\".", + "type": "string", + "x-nullable": true + }, + "enable_content_trust": { + "description": "Whether content trust is enabled or not. If it is enabled, user can't pull unsigned images from this project. The valid values are \"true\", \"false\".", + "type": "string", + "x-nullable": true + }, + "enable_content_trust_cosign": { + "description": "Whether cosign content trust is enabled or not. If it is enabled, user can't pull images without cosign signature from this project. The valid values are \"true\", \"false\".", + "type": "string", + "x-nullable": true + }, + "prevent_vul": { + "description": "Whether prevent the vulnerable images from running. The valid values are \"true\", \"false\".", + "type": "string", + "x-nullable": true + }, + "public": { + "description": "The public status of the project. The valid values are \"true\", \"false\".", + "type": "string" + }, + "retention_id": { + "description": "The ID of the tag retention policy for the project", + "type": "string", + "x-nullable": true + }, + "reuse_sys_cve_allowlist": { + "description": "Whether this project reuse the system level CVE allowlist as the allowlist of its own. The valid values are \"true\", \"false\". If it is set to \"true\" the actual allowlist associate with this project, if any, will be ignored.", + "type": "string", + "x-nullable": true + }, + "severity": { + "description": "If the vulnerability is high than severity defined here, the images can't be pulled. The valid values are \"none\", \"low\", \"medium\", \"high\", \"critical\".", + "type": "string", + "x-nullable": true + } + } + }, + "ProjectReq": { + "type": "object", + "properties": { + "cve_allowlist": { + "description": "The CVE allowlist of the project.", + "$ref": "#/definitions/CVEAllowlist" + }, + "metadata": { + "description": "The metadata of the project.", + "$ref": "#/definitions/ProjectMetadata" + }, + "project_name": { + "description": "The name of the project.", + "type": "string", + "maxLength": 255 + }, + "public": { + "description": "deprecated, reserved for project creation in replication", + "type": "boolean", + "x-nullable": true + }, + "registry_id": { + "description": "The ID of referenced registry when creating the proxy cache project", + "type": "integer", + "format": "int64", + "x-nullable": true + }, + "storage_limit": { + "description": "The storage quota of the project.", + "type": "integer", + "format": "int64", + "x-nullable": true + } + } + }, + "ProjectScanner": { + "type": "object", + "required": [ + "uuid" + ], + "properties": { + "uuid": { + "description": "The identifier of the scanner registration", + "type": "string" + } + } + }, + "ProjectSummary": { + "type": "object", + "properties": { + "chart_count": { + "description": "The total number of charts under this project.", + "type": "integer", + "x-omitempty": false + }, + "developer_count": { + "description": "The total number of developer members.", + "type": "integer" + }, + "guest_count": { + "description": "The total number of guest members.", + "type": "integer" + }, + "limited_guest_count": { + "description": "The total number of limited guest members.", + "type": "integer" + }, + "maintainer_count": { + "description": "The total number of maintainer members.", + "type": "integer" + }, + "project_admin_count": { + "description": "The total number of project admin members.", + "type": "integer" + }, + "quota": { + "$ref": "#/definitions/ProjectSummaryQuota" + }, + "registry": { + "$ref": "#/definitions/Registry" + }, + "repo_count": { + "description": "The number of the repositories under this project.", + "type": "integer", + "x-omitempty": false + } + } + }, + "ProjectSummaryQuota": { + "type": "object", + "properties": { + "hard": { + "description": "The hard limits of the quota", + "$ref": "#/definitions/ResourceList" + }, + "used": { + "description": "The used status of the quota", + "$ref": "#/definitions/ResourceList" + } + } + }, + "ProviderUnderProject": { + "type": "object", + "properties": { + "default": { + "type": "boolean" + }, + "enabled": { + "type": "boolean" + }, + "id": { + "type": "integer" + }, + "provider": { + "type": "string" + } + } + }, + "Quota": { + "description": "The quota object", + "type": "object", + "properties": { + "creation_time": { + "description": "the creation time of the quota", + "type": "string", + "format": "date-time" + }, + "hard": { + "description": "The hard limits of the quota", + "x-omitempty": false, + "$ref": "#/definitions/ResourceList" + }, + "id": { + "description": "ID of the quota", + "type": "integer" + }, + "ref": { + "description": "The reference object of the quota", + "$ref": "#/definitions/QuotaRefObject" + }, + "update_time": { + "description": "the update time of the quota", + "type": "string", + "format": "date-time" + }, + "used": { + "description": "The used status of the quota", + "x-omitempty": false, + "$ref": "#/definitions/ResourceList" + } + } + }, + "QuotaRefObject": { + "type": "object", + "additionalProperties": false + }, + "QuotaUpdateReq": { + "type": "object", + "properties": { + "hard": { + "description": "The new hard limits for the quota", + "$ref": "#/definitions/ResourceList" + } + } + }, + "Reference": { + "type": "object", + "properties": { + "annotations": { + "$ref": "#/definitions/Annotations" + }, + "child_digest": { + "description": "The digest of the child artifact", + "type": "string" + }, + "child_id": { + "description": "The child ID of the reference", + "type": "integer", + "format": "int64" + }, + "parent_id": { + "description": "The parent ID of the reference", + "type": "integer", + "format": "int64" + }, + "platform": { + "$ref": "#/definitions/Platform" + }, + "urls": { + "description": "The download URLs", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "Registry": { + "type": "object", + "properties": { + "creation_time": { + "description": "The create time of the policy.", + "type": "string", + "format": "date-time" + }, + "credential": { + "$ref": "#/definitions/RegistryCredential" + }, + "description": { + "description": "Description of the registry.", + "type": "string" + }, + "id": { + "description": "The registry ID.", + "type": "integer", + "format": "int64", + "x-omitempty": false + }, + "insecure": { + "description": "Whether or not the certificate will be verified when Harbor tries to access the server.", + "type": "boolean" + }, + "name": { + "description": "The registry name.", + "type": "string" + }, + "status": { + "description": "Health status of the registry.", + "type": "string" + }, + "type": { + "description": "Type of the registry, e.g. 'harbor'.", + "type": "string" + }, + "update_time": { + "description": "The update time of the policy.", + "type": "string", + "format": "date-time" + }, + "url": { + "description": "The registry URL string.", + "type": "string" + } + } + }, + "RegistryCredential": { + "type": "object", + "properties": { + "access_key": { + "description": "Access key, e.g. user name when credential type is 'basic'.", + "type": "string" + }, + "access_secret": { + "description": "Access secret, e.g. password when credential type is 'basic'.", + "type": "string" + }, + "type": { + "description": "Credential type, such as 'basic', 'oauth'.", + "type": "string" + } + } + }, + "RegistryEndpoint": { + "description": "The style of the resource filter", + "type": "object", + "properties": { + "key": { + "description": "The endpoint key", + "type": "string" + }, + "value": { + "description": "The endpoint value", + "type": "string" + } + } + }, + "RegistryInfo": { + "description": "The registry info contains the base info and capability declarations of the registry", + "type": "object", + "properties": { + "description": { + "description": "The description", + "type": "string" + }, + "supported_copy_by_chunk": { + "description": "The registry whether support copy by chunk.", + "type": "boolean", + "x-isnullable": true, + "x-omitempty": true + }, + "supported_resource_filters": { + "description": "The filters that the registry supports", + "type": "array", + "items": { + "$ref": "#/definitions/FilterStyle" + } + }, + "supported_triggers": { + "description": "The triggers that the registry supports", + "type": "array", + "items": { + "type": "string" + } + }, + "type": { + "description": "The registry type", + "type": "string" + } + } + }, + "RegistryPing": { + "type": "object", + "properties": { + "access_key": { + "description": "The registry access key.", + "type": "string", + "x-nullable": true + }, + "access_secret": { + "description": "The registry access secret.", + "type": "string", + "x-nullable": true + }, + "credential_type": { + "description": "Credential type of the registry, e.g. 'basic'.", + "type": "string", + "x-nullable": true + }, + "id": { + "description": "The registry ID.", + "type": "integer", + "format": "int64", + "x-nullable": true + }, + "insecure": { + "description": "Whether or not the certificate will be verified when Harbor tries to access the server.", + "type": "boolean", + "x-nullable": true + }, + "type": { + "description": "Type of the registry, e.g. 'harbor'.", + "type": "string", + "x-nullable": true + }, + "url": { + "description": "The registry URL.", + "type": "string", + "x-nullable": true + } + } + }, + "RegistryProviderCredentialPattern": { + "description": "The registry credential pattern", + "type": "object", + "properties": { + "access_key_data": { + "description": "The access key data", + "type": "string" + }, + "access_key_type": { + "description": "The access key type", + "type": "string" + }, + "access_secret_data": { + "description": "The access secret data", + "type": "string" + }, + "access_secret_type": { + "description": "The access secret type", + "type": "string" + } + } + }, + "RegistryProviderEndpointPattern": { + "description": "The registry endpoint pattern", + "type": "object", + "properties": { + "endpoint_type": { + "description": "The endpoint type", + "type": "string" + }, + "endpoints": { + "description": "The endpoint list", + "type": "array", + "items": { + "$ref": "#/definitions/RegistryEndpoint" + } + } + } + }, + "RegistryProviderInfo": { + "description": "The registry provider info contains the base info and capability declarations of the registry provider", + "type": "object", + "properties": { + "credential_pattern": { + "description": "The credential pattern", + "$ref": "#/definitions/RegistryProviderCredentialPattern" + }, + "endpoint_pattern": { + "description": "The endpoint pattern", + "$ref": "#/definitions/RegistryProviderEndpointPattern" + } + } + }, + "RegistryUpdate": { + "type": "object", + "properties": { + "access_key": { + "description": "The registry access key.", + "type": "string", + "x-nullable": true + }, + "access_secret": { + "description": "The registry access secret.", + "type": "string", + "x-nullable": true + }, + "credential_type": { + "description": "Credential type of the registry, e.g. 'basic'.", + "type": "string", + "x-nullable": true + }, + "description": { + "description": "Description of the registry.", + "type": "string", + "x-nullable": true + }, + "insecure": { + "description": "Whether or not the certificate will be verified when Harbor tries to access the server.", + "type": "boolean", + "x-nullable": true + }, + "name": { + "description": "The registry name.", + "type": "string", + "x-nullable": true + }, + "url": { + "description": "The registry URL.", + "type": "string", + "x-nullable": true + } + } + }, + "ReplicationExecution": { + "description": "The replication execution", + "type": "object", + "properties": { + "end_time": { + "description": "The end time", + "type": "string", + "format": "date-time" + }, + "failed": { + "description": "The count of failed executions", + "type": "integer", + "x-omitempty": false + }, + "id": { + "description": "The ID of the execution", + "type": "integer" + }, + "in_progress": { + "description": "The count of in_progress executions", + "type": "integer", + "x-omitempty": false + }, + "policy_id": { + "description": "The ID if the policy that the execution belongs to", + "type": "integer" + }, + "start_time": { + "description": "The start time", + "type": "string", + "format": "date-time" + }, + "status": { + "description": "The status of the execution", + "type": "string" + }, + "status_text": { + "description": "The status text", + "type": "string", + "x-omitempty": false + }, + "stopped": { + "description": "The count of stopped executions", + "type": "integer", + "x-omitempty": false + }, + "succeed": { + "description": "The count of succeed executions", + "type": "integer", + "x-omitempty": false + }, + "total": { + "description": "The total count of all executions", + "type": "integer", + "x-omitempty": false + }, + "trigger": { + "description": "The trigger mode", + "type": "string" + } + } + }, + "ReplicationFilter": { + "type": "object", + "properties": { + "decoration": { + "description": "matches or excludes the result", + "type": "string" + }, + "type": { + "description": "The replication policy filter type.", + "type": "string" + }, + "value": { + "description": "The value of replication policy filter.", + "type": "object" + } + } + }, + "ReplicationPolicy": { + "type": "object", + "properties": { + "copy_by_chunk": { + "description": "Whether to enable copy by chunk.", + "type": "boolean", + "x-isnullable": true + }, + "creation_time": { + "description": "The create time of the policy.", + "type": "string", + "format": "date-time" + }, + "deletion": { + "description": "Deprecated, use \"replicate_deletion\" instead. Whether to replicate the deletion operation.", + "type": "boolean" + }, + "description": { + "description": "The description of the policy.", + "type": "string" + }, + "dest_namespace": { + "description": "The destination namespace.", + "type": "string" + }, + "dest_namespace_replace_count": { + "description": "Specify how many path components will be replaced by the provided destination namespace.\nThe default value is -1 in which case the legacy mode will be applied.", + "type": "integer", + "format": "int8", + "x-isnullable": true + }, + "dest_registry": { + "description": "The destination registry.", + "$ref": "#/definitions/Registry" + }, + "enabled": { + "description": "Whether the policy is enabled or not.", + "type": "boolean" + }, + "filters": { + "description": "The replication policy filter array.", + "type": "array", + "items": { + "$ref": "#/definitions/ReplicationFilter" + } + }, + "id": { + "description": "The policy ID.", + "type": "integer", + "format": "int64" + }, + "name": { + "description": "The policy name.", + "type": "string" + }, + "override": { + "description": "Whether to override the resources on the destination registry.", + "type": "boolean" + }, + "replicate_deletion": { + "description": "Whether to replicate the deletion operation.", + "type": "boolean" + }, + "speed": { + "description": "speed limit for each task", + "type": "integer", + "format": "int32", + "x-isnullable": true + }, + "src_registry": { + "description": "The source registry.", + "$ref": "#/definitions/Registry" + }, + "trigger": { + "$ref": "#/definitions/ReplicationTrigger" + }, + "update_time": { + "description": "The update time of the policy.", + "type": "string", + "format": "date-time" + } + } + }, + "ReplicationTask": { + "description": "The replication task", + "type": "object", + "properties": { + "dst_resource": { + "description": "The destination resource that the task operates", + "type": "string" + }, + "end_time": { + "description": "The end time of the task", + "type": "string", + "format": "date-time" + }, + "execution_id": { + "description": "The ID of the execution that the task belongs to", + "type": "integer" + }, + "id": { + "description": "The ID of the task", + "type": "integer" + }, + "job_id": { + "description": "The ID of the underlying job that the task related to", + "type": "string" + }, + "operation": { + "description": "The operation of the task", + "type": "string" + }, + "resource_type": { + "description": "The type of the resource that the task operates", + "type": "string" + }, + "src_resource": { + "description": "The source resource that the task operates", + "type": "string" + }, + "start_time": { + "description": "The start time of the task", + "type": "string", + "format": "date-time" + }, + "status": { + "description": "The status of the task", + "type": "string" + } + } + }, + "ReplicationTrigger": { + "type": "object", + "properties": { + "trigger_settings": { + "$ref": "#/definitions/ReplicationTriggerSettings" + }, + "type": { + "description": "The replication policy trigger type. The valid values are manual, event_based and scheduled.", + "type": "string" + } + } + }, + "ReplicationTriggerSettings": { + "type": "object", + "properties": { + "cron": { + "description": "The cron string for scheduled trigger", + "type": "string" + } + } + }, + "Repository": { + "type": "object", + "properties": { + "artifact_count": { + "description": "The count of the artifacts inside the repository", + "type": "integer", + "format": "int64", + "x-omitempty": false + }, + "creation_time": { + "description": "The creation time of the repository", + "type": "string", + "format": "date-time", + "x-nullable": true, + "x-omitempty": true + }, + "description": { + "description": "The description of the repository", + "type": "string" + }, + "id": { + "description": "The ID of the repository", + "type": "integer", + "format": "int64" + }, + "name": { + "description": "The name of the repository", + "type": "string" + }, + "project_id": { + "description": "The ID of the project that the repository belongs to", + "type": "integer", + "format": "int64" + }, + "pull_count": { + "description": "The count that the artifact inside the repository pulled", + "type": "integer", + "format": "int64", + "x-omitempty": false + }, + "update_time": { + "description": "The update time of the repository", + "type": "string", + "format": "date-time" + } + } + }, + "ResourceList": { + "type": "object", + "additionalProperties": { + "type": "integer", + "format": "int64" + } + }, + "RetentionExecution": { + "type": "object", + "properties": { + "dry_run": { + "type": "boolean" + }, + "end_time": { + "type": "string" + }, + "id": { + "type": "integer", + "format": "int64" + }, + "policy_id": { + "type": "integer", + "format": "int64" + }, + "start_time": { + "type": "string" + }, + "status": { + "type": "string" + }, + "trigger": { + "type": "string" + } + } + }, + "RetentionExecutionTask": { + "type": "object", + "properties": { + "end_time": { + "type": "string" + }, + "execution_id": { + "type": "integer", + "format": "int64" + }, + "id": { + "type": "integer", + "format": "int64" + }, + "job_id": { + "type": "string" + }, + "repository": { + "type": "string" + }, + "retained": { + "type": "integer", + "x-omitempty": false + }, + "start_time": { + "type": "string" + }, + "status": { + "type": "string" + }, + "status_code": { + "type": "integer", + "x-omitempty": false + }, + "status_revision": { + "type": "integer", + "format": "int64" + }, + "total": { + "type": "integer", + "x-omitempty": false + } + } + }, + "RetentionMetadata": { + "description": "the tag retention metadata", + "type": "object", + "properties": { + "scope_selectors": { + "description": "supported scope selectors", + "type": "array", + "items": { + "$ref": "#/definitions/RetentionSelectorMetadata" + } + }, + "tag_selectors": { + "description": "supported tag selectors", + "type": "array", + "items": { + "$ref": "#/definitions/RetentionSelectorMetadata" + } + }, + "templates": { + "description": "templates", + "type": "array", + "items": { + "$ref": "#/definitions/RetentionRuleMetadata" + } + } + } + }, + "RetentionPolicy": { + "description": "retention policy", + "type": "object", + "properties": { + "algorithm": { + "type": "string" + }, + "id": { + "type": "integer", + "format": "int64" + }, + "rules": { + "type": "array", + "items": { + "$ref": "#/definitions/RetentionRule" + } + }, + "scope": { + "type": "object", + "$ref": "#/definitions/RetentionPolicyScope" + }, + "trigger": { + "type": "object", + "$ref": "#/definitions/RetentionRuleTrigger" + } + } + }, + "RetentionPolicyScope": { + "type": "object", + "properties": { + "level": { + "type": "string" + }, + "ref": { + "type": "integer" + } + } + }, + "RetentionRule": { + "type": "object", + "properties": { + "action": { + "type": "string" + }, + "disabled": { + "type": "boolean" + }, + "id": { + "type": "integer" + }, + "params": { + "type": "object", + "additionalProperties": { + "type": "object" + } + }, + "priority": { + "type": "integer" + }, + "scope_selectors": { + "type": "object", + "additionalProperties": { + "type": "array", + "items": { + "$ref": "#/definitions/RetentionSelector" + } + } + }, + "tag_selectors": { + "type": "array", + "items": { + "$ref": "#/definitions/RetentionSelector" + } + }, + "template": { + "type": "string" + } + } + }, + "RetentionRuleMetadata": { + "description": "the tag retention rule metadata", + "type": "object", + "properties": { + "action": { + "description": "rule action", + "type": "string" + }, + "display_text": { + "description": "rule display text", + "type": "string" + }, + "params": { + "description": "rule params", + "type": "array", + "items": { + "$ref": "#/definitions/RetentionRuleParamMetadata" + } + }, + "rule_template": { + "description": "rule id", + "type": "string" + } + } + }, + "RetentionRuleParamMetadata": { + "description": "rule param", + "type": "object", + "properties": { + "required": { + "type": "boolean" + }, + "type": { + "type": "string" + }, + "unit": { + "type": "string" + } + } + }, + "RetentionRuleTrigger": { + "type": "object", + "properties": { + "kind": { + "type": "string" + }, + "references": { + "type": "object" + }, + "settings": { + "type": "object" + } + } + }, + "RetentionSelector": { + "type": "object", + "properties": { + "decoration": { + "type": "string" + }, + "extras": { + "type": "string" + }, + "kind": { + "type": "string" + }, + "pattern": { + "type": "string" + } + } + }, + "RetentionSelectorMetadata": { + "description": "retention selector", + "type": "object", + "properties": { + "decorations": { + "type": "array", + "items": { + "type": "string" + } + }, + "display_text": { + "type": "string" + }, + "kind": { + "type": "string" + } + } + }, + "Robot": { + "type": "object", + "properties": { + "creation_time": { + "description": "The creation time of the robot.", + "type": "string", + "format": "date-time" + }, + "description": { + "description": "The description of the robot", + "type": "string" + }, + "disable": { + "description": "The disable status of the robot", + "type": "boolean", + "x-omitempty": false + }, + "duration": { + "description": "The duration of the robot in days", + "type": "integer", + "format": "int64" + }, + "editable": { + "description": "The editable status of the robot", + "type": "boolean", + "x-omitempty": false + }, + "expires_at": { + "description": "The expiration data of the robot", + "type": "integer", + "format": "int64" + }, + "id": { + "description": "The ID of the robot", + "type": "integer", + "format": "int64" + }, + "level": { + "description": "The level of the robot, project or system", + "type": "string" + }, + "name": { + "description": "The name of the tag", + "type": "string" + }, + "permissions": { + "type": "array", + "items": { + "$ref": "#/definitions/RobotPermission" + } + }, + "secret": { + "description": "The secret of the robot", + "type": "string" + }, + "update_time": { + "description": "The update time of the robot.", + "type": "string", + "format": "date-time" + } + } + }, + "RobotCreate": { + "description": "The request for robot account creation.", + "type": "object", + "properties": { + "description": { + "description": "The description of the robot", + "type": "string" + }, + "disable": { + "description": "The disable status of the robot", + "type": "boolean" + }, + "duration": { + "description": "The duration of the robot in days", + "type": "integer", + "format": "int64" + }, + "level": { + "description": "The level of the robot, project or system", + "type": "string" + }, + "name": { + "description": "The name of the tag", + "type": "string" + }, + "permissions": { + "type": "array", + "items": { + "$ref": "#/definitions/RobotPermission" + } + }, + "secret": { + "description": "The secret of the robot", + "type": "string" + } + } + }, + "RobotCreateV1": { + "type": "object", + "properties": { + "access": { + "description": "The permission of robot account", + "type": "array", + "items": { + "$ref": "#/definitions/Access" + } + }, + "description": { + "description": "The description of robot account", + "type": "string" + }, + "expires_at": { + "description": "The expiration time on or after which the JWT MUST NOT be accepted for processing.", + "type": "integer" + }, + "name": { + "description": "The name of robot account", + "type": "string" + } + } + }, + "RobotCreated": { + "description": "The response for robot account creation.", + "type": "object", + "properties": { + "creation_time": { + "description": "The creation time of the robot.", + "type": "string", + "format": "date-time" + }, + "expires_at": { + "description": "The expiration data of the robot", + "type": "integer", + "format": "int64" + }, + "id": { + "description": "The ID of the robot", + "type": "integer", + "format": "int64" + }, + "name": { + "description": "The name of the tag", + "type": "string" + }, + "secret": { + "description": "The secret of the robot", + "type": "string" + } + } + }, + "RobotPermission": { + "type": "object", + "properties": { + "access": { + "type": "array", + "items": { + "$ref": "#/definitions/Access" + } + }, + "kind": { + "description": "The kind of the permission", + "type": "string" + }, + "namespace": { + "description": "The namespace of the permission", + "type": "string" + } + } + }, + "RobotSec": { + "description": "The response for refresh/update robot account secret.", + "type": "object", + "properties": { + "secret": { + "description": "The secret of the robot", + "type": "string" + } + } + }, + "RoleRequest": { + "type": "object", + "properties": { + "role_id": { + "description": "The role id 1 for projectAdmin, 2 for developer, 3 for guest, 4 for maintainer", + "type": "integer" + } + } + }, + "ScanDataExportExecution": { + "description": "The replication execution", + "type": "object", + "properties": { + "end_time": { + "description": "The end time", + "type": "string", + "format": "date-time" + }, + "file_present": { + "description": "Indicates whether the export artifact is present in registry", + "type": "boolean", + "x-omitempty": false + }, + "id": { + "description": "The ID of the execution", + "type": "integer" + }, + "start_time": { + "description": "The start time", + "type": "string", + "format": "date-time" + }, + "status": { + "description": "The status of the execution", + "type": "string" + }, + "status_text": { + "description": "The status text", + "type": "string", + "x-omitempty": false + }, + "trigger": { + "description": "The trigger mode", + "type": "string" + }, + "user_id": { + "description": "The ID if the user triggering the export job", + "type": "integer" + }, + "user_name": { + "description": "The name of the user triggering the job", + "type": "string", + "x-omitempty": false + } + } + }, + "ScanDataExportExecutionList": { + "description": "The list of scan data export executions", + "type": "object", + "properties": { + "items": { + "description": "The list of scan data export executions", + "type": "array", + "items": { + "$ref": "#/definitions/ScanDataExportExecution" + } + } + } + }, + "ScanDataExportJob": { + "description": "The metadata associated with the scan data export job", + "type": "object", + "properties": { + "id": { + "description": "The id of the scan data export job", + "type": "integer", + "format": "int64" + } + } + }, + "ScanDataExportRequest": { + "description": "The criteria to select the scan data to export.", + "type": "object", + "properties": { + "cveIds": { + "description": "CVE-IDs for which to export data. Multiple CVE-IDs can be specified by separating using ',' and enclosed between '{}'. Defaults to all if empty", + "type": "string" + }, + "job_name": { + "description": "Name of the scan data export job", + "type": "string" + }, + "labels": { + "description": "A list of one or more labels for which to export the scan data, defaults to all if empty", + "type": "array", + "items": { + "type": "integer", + "format": "int64" + } + }, + "projects": { + "description": "A list of one or more projects for which to export the scan data, currently only one project is supported due to performance concerns, but define as array for extension in the future.", + "type": "array", + "items": { + "type": "integer", + "format": "int64" + } + }, + "repositories": { + "description": "A list of repositories for which to export the scan data, defaults to all if empty", + "type": "string" + }, + "tags": { + "description": "A list of tags enclosed within '{}'. Defaults to all if empty", + "type": "string" + } + } + }, + "ScanOverview": { + "description": "The scan overview attached in the metadata of tag", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/NativeReportSummary" + } + }, + "Scanner": { + "type": "object", + "properties": { + "name": { + "description": "Name of the scanner", + "type": "string", + "example": "Trivy" + }, + "vendor": { + "description": "Name of the scanner provider", + "type": "string", + "example": "Aqua Security" + }, + "version": { + "description": "Version of the scanner adapter", + "type": "string", + "example": "v0.9.1" + } + } + }, + "ScannerAdapterMetadata": { + "description": "The metadata info of the scanner adapter", + "type": "object", + "properties": { + "capabilities": { + "type": "array", + "items": { + "$ref": "#/definitions/ScannerCapability" + } + }, + "properties": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "harbor.scanner-adapter/registry-authorization-type": "Bearer" + } + }, + "scanner": { + "$ref": "#/definitions/Scanner" + } + } + }, + "ScannerCapability": { + "type": "object", + "properties": { + "consumes_mime_types": { + "type": "array", + "items": { + "type": "string", + "example": "application/vnd.docker.distribution.manifest.v2+json" + } + }, + "produces_mime_types": { + "type": "array", + "items": { + "type": "string", + "example": "application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0" + } + } + } + }, + "ScannerRegistration": { + "description": "Registration represents a named configuration for invoking a scanner via its adapter.\n", + "type": "object", + "properties": { + "access_credential": { + "description": "An optional value of the HTTP Authorization header sent with each request to the Scanner Adapter API.\n", + "type": "string", + "x-omitempty": false, + "example": "Bearer: JWTTOKENGOESHERE" + }, + "adapter": { + "description": "Optional property to describe the name of the scanner registration", + "type": "string", + "example": "Trivy" + }, + "auth": { + "description": "Specify what authentication approach is adopted for the HTTP communications.\nSupported types Basic\", \"Bearer\" and api key header \"X-ScannerAdapter-API-Key\"\n", + "type": "string", + "default": "", + "x-omitempty": false, + "example": "Bearer" + }, + "create_time": { + "description": "The creation time of this registration", + "type": "string", + "format": "date-time" + }, + "description": { + "description": "An optional description of this registration.", + "type": "string", + "x-omitempty": false, + "example": "A free-to-use tool that scans container images for package vulnerabilities.\n" + }, + "disabled": { + "description": "Indicate whether the registration is enabled or not", + "type": "boolean", + "default": false, + "x-omitempty": false + }, + "health": { + "description": "Indicate the healthy of the registration", + "type": "string", + "default": "", + "example": "healthy" + }, + "is_default": { + "description": "Indicate if the registration is set as the system default one", + "type": "boolean", + "default": false, + "x-omitempty": false + }, + "name": { + "description": "The name of this registration.", + "type": "string", + "example": "Trivy" + }, + "skip_certVerify": { + "description": "Indicate if skip the certificate verification when sending HTTP requests", + "type": "boolean", + "default": false, + "x-omitempty": false + }, + "update_time": { + "description": "The update time of this registration", + "type": "string", + "format": "date-time" + }, + "url": { + "description": "A base URL of the scanner adapter", + "type": "string", + "format": "url", + "example": "http://harbor-scanner-trivy:8080" + }, + "use_internal_addr": { + "description": "Indicate whether use internal registry addr for the scanner to pull content or not", + "type": "boolean", + "default": false, + "x-omitempty": false + }, + "uuid": { + "description": "The unique identifier of this registration.", + "type": "string" + }, + "vendor": { + "description": "Optional property to describe the vendor of the scanner registration", + "type": "string", + "example": "CentOS" + }, + "version": { + "description": "Optional property to describe the version of the scanner registration", + "type": "string", + "example": "1.0.1" + } + } + }, + "ScannerRegistrationReq": { + "type": "object", + "required": [ + "name", + "url" + ], + "properties": { + "access_credential": { + "description": "An optional value of the HTTP Authorization header sent with each request to the Scanner Adapter API.\n", + "type": "string", + "example": "Bearer: JWTTOKENGOESHERE" + }, + "auth": { + "description": "Specify what authentication approach is adopted for the HTTP communications.\nSupported types Basic\", \"Bearer\" and api key header \"X-ScannerAdapter-API-Key\"\n", + "type": "string", + "example": "Bearer" + }, + "description": { + "description": "An optional description of this registration.", + "type": "string", + "example": "A free-to-use tool that scans container images for package vulnerabilities.\n" + }, + "disabled": { + "description": "Indicate whether the registration is enabled or not", + "type": "boolean", + "default": false + }, + "name": { + "description": "The name of this registration", + "type": "string", + "example": "Trivy" + }, + "skip_certVerify": { + "description": "Indicate if skip the certificate verification when sending HTTP requests", + "type": "boolean", + "default": false + }, + "url": { + "description": "A base URL of the scanner adapter.", + "type": "string", + "format": "uri", + "example": "http://harbor-scanner-trivy:8080" + }, + "use_internal_addr": { + "description": "Indicate whether use internal registry addr for the scanner to pull content or not", + "type": "boolean", + "default": false + } + } + }, + "ScannerRegistrationSettings": { + "type": "object", + "required": [ + "name", + "url" + ], + "properties": { + "access_credential": { + "description": "An optional value of the HTTP Authorization header sent with each request to the Scanner Adapter API.\n", + "type": "string", + "example": "Bearer: JWTTOKENGOESHERE" + }, + "auth": { + "description": "Specify what authentication approach is adopted for the HTTP communications.\nSupported types Basic\", \"Bearer\" and api key header \"X-ScannerAdapter-API-Key\"\n", + "type": "string", + "default": "" + }, + "name": { + "description": "The name of this registration", + "type": "string", + "example": "Trivy" + }, + "url": { + "description": "A base URL of the scanner adapter.", + "type": "string", + "format": "uri", + "example": "http://harbor-scanner-trivy:8080" + } + } + }, + "Schedule": { + "type": "object", + "properties": { + "creation_time": { + "description": "the creation time of the schedule.", + "type": "string", + "format": "date-time", + "readOnly": true + }, + "id": { + "description": "The id of the schedule.", + "type": "integer", + "readOnly": true + }, + "parameters": { + "description": "The parameters of schedule job", + "type": "object", + "additionalProperties": { + "type": "object" + } + }, + "schedule": { + "$ref": "#/definitions/ScheduleObj" + }, + "status": { + "description": "The status of the schedule.", + "type": "string", + "readOnly": true + }, + "update_time": { + "description": "the update time of the schedule.", + "type": "string", + "format": "date-time", + "readOnly": true + } + } + }, + "ScheduleObj": { + "type": "object", + "properties": { + "cron": { + "description": "A cron expression, a time-based job scheduler.", + "type": "string" + }, + "next_scheduled_time": { + "description": "The next time to schedule to run the job.", + "type": "string", + "format": "date-time" + }, + "type": { + "description": "The schedule type. The valid values are 'Hourly', 'Daily', 'Weekly', 'Custom', 'Manual' and 'None'.\n'Manual' means to trigger it right away and 'None' means to cancel the schedule.\n", + "type": "string", + "enum": [ + "Hourly", + "Daily", + "Weekly", + "Custom", + "Manual", + "None" + ] + } + } + }, + "ScheduleTask": { + "description": "the schedule task info", + "type": "object", + "properties": { + "cron": { + "description": "the cron of the current schedule task", + "type": "string" + }, + "id": { + "description": "the id of the Schedule task", + "type": "integer" + }, + "update_time": { + "description": "the update time of the schedule task", + "type": "string", + "format": "date-time" + }, + "vendor_id": { + "description": "the vendor id of the current task", + "type": "integer" + }, + "vendor_type": { + "description": "the vendor type of the current schedule task", + "type": "string" + } + } + }, + "SchedulerStatus": { + "description": "the scheduler status", + "type": "object", + "properties": { + "paused": { + "description": "if the scheduler is paused", + "type": "boolean", + "x-omitempty": false + } + } + }, + "Search": { + "type": "object", + "properties": { + "chart": { + "description": "Search results of the charts that macthed the filter keywords.", + "type": "array", + "items": { + "$ref": "#/definitions/SearchResult" + }, + "x-isnullable": true, + "x-omitempty": true + }, + "project": { + "description": "Search results of the projects that matched the filter keywords.", + "type": "array", + "items": { + "$ref": "#/definitions/Project" + } + }, + "repository": { + "description": "Search results of the repositories that matched the filter keywords.", + "type": "array", + "items": { + "$ref": "#/definitions/SearchRepository" + } + } + } + }, + "SearchRepository": { + "type": "object", + "properties": { + "artifact_count": { + "description": "The count of artifacts in the repository", + "type": "integer" + }, + "project_id": { + "description": "The ID of the project that the repository belongs to", + "type": "integer" + }, + "project_name": { + "description": "The name of the project that the repository belongs to", + "type": "string" + }, + "project_public": { + "description": "The flag to indicate the publicity of the project that the repository belongs to (1 is public, 0 is not)", + "type": "boolean" + }, + "pull_count": { + "description": "The count how many times the repository is pulled", + "type": "integer" + }, + "repository_name": { + "description": "The name of the repository", + "type": "string" + } + } + }, + "SearchResult": { + "description": "The chart search result item", + "type": "object", + "properties": { + "Chart": { + "$ref": "#/definitions/ChartVersion" + }, + "Name": { + "description": "The chart name with repo name", + "type": "string" + }, + "Score": { + "description": "The matched level", + "type": "integer" + } + } + }, + "StartReplicationExecution": { + "type": "object", + "properties": { + "policy_id": { + "description": "The ID of policy that the execution belongs to.", + "type": "integer", + "format": "int64" + } + } + }, + "Statistic": { + "type": "object", + "properties": { + "private_project_count": { + "description": "The count of the private projects", + "type": "integer", + "format": "int64", + "x-omitempty": false + }, + "private_repo_count": { + "description": "The count of the private repositories", + "type": "integer", + "format": "int64", + "x-omitempty": false + }, + "public_project_count": { + "description": "The count of the public projects", + "type": "integer", + "format": "int64", + "x-omitempty": false + }, + "public_repo_count": { + "description": "The count of the public repositories", + "type": "integer", + "format": "int64", + "x-omitempty": false + }, + "total_project_count": { + "description": "The count of the total projects, only be seen by the system admin", + "type": "integer", + "format": "int64", + "x-omitempty": false + }, + "total_repo_count": { + "description": "The count of the total repositories, only be seen by the system admin", + "type": "integer", + "format": "int64", + "x-omitempty": false + }, + "total_storage_consumption": { + "description": "The total storage consumption of blobs, only be seen by the system admin", + "type": "integer", + "format": "int64", + "x-omitempty": false + } + } + }, + "Stats": { + "description": "Stats provides the overall progress of the scan all process.", + "type": "object", + "properties": { + "completed": { + "description": "The number of the finished scan processes triggered by the scan all action", + "type": "integer", + "format": "int", + "x-omitempty": false, + "example": 90 + }, + "metrics": { + "description": "The metrics data for the each status", + "type": "object", + "additionalProperties": { + "type": "integer", + "format": "int", + "example": 10 + }, + "example": { + "Error": 2, + "Running": 3, + "Success": 5 + } + }, + "ongoing": { + "description": "A flag indicating job status of scan all.", + "type": "boolean", + "x-omitempty": false + }, + "total": { + "description": "The total number of scan processes triggered by the scan all action", + "type": "integer", + "format": "int", + "x-omitempty": false, + "example": 100 + }, + "trigger": { + "description": "The trigger of the scan all job.", + "type": "string", + "enum": [ + "Manual", + "Schedule", + "Event" + ] + } + } + }, + "Storage": { + "type": "object", + "properties": { + "free": { + "description": "Free volume size.", + "type": "integer", + "format": "uint64" + }, + "total": { + "description": "Total volume size.", + "type": "integer", + "format": "uint64" + } + } + }, + "StringConfigItem": { + "type": "object", + "properties": { + "editable": { + "description": "The configure item can be updated or not", + "type": "boolean", + "x-omitempty": false + }, + "value": { + "description": "The string value of current config item", + "type": "string", + "x-omitempty": false + } + } + }, + "SupportedWebhookEventTypes": { + "description": "Supportted webhook event types and notify types.", + "type": "object", + "properties": { + "event_type": { + "type": "array", + "items": { + "$ref": "#/definitions/EventType" + } + }, + "notify_type": { + "type": "array", + "items": { + "$ref": "#/definitions/NotifyType" + } + } + } + }, + "SystemInfo": { + "type": "object", + "properties": { + "storage": { + "description": "The storage of system.", + "type": "array", + "items": { + "$ref": "#/definitions/Storage" + } + } + } + }, + "Tag": { + "type": "object", + "properties": { + "artifact_id": { + "description": "The ID of the artifact that the tag attached to", + "type": "integer", + "format": "int64" + }, + "id": { + "description": "The ID of the tag", + "type": "integer", + "format": "int64" + }, + "immutable": { + "description": "The immutable status of the tag", + "type": "boolean", + "x-omitempty": false + }, + "name": { + "description": "The name of the tag", + "type": "string" + }, + "pull_time": { + "description": "The latest pull time of the tag", + "type": "string", + "format": "date-time" + }, + "push_time": { + "description": "The push time of the tag", + "type": "string", + "format": "date-time" + }, + "repository_id": { + "description": "The ID of the repository that the tag belongs to", + "type": "integer", + "format": "int64" + }, + "signed": { + "description": "The attribute indicates whether the tag is signed or not", + "type": "boolean", + "x-omitempty": false + } + } + }, + "Task": { + "type": "object", + "properties": { + "creation_time": { + "description": "The creation time of task", + "type": "string" + }, + "end_time": { + "description": "The end time of task", + "type": "string" + }, + "execution_id": { + "description": "The ID of task execution", + "type": "integer" + }, + "extra_attrs": { + "$ref": "#/definitions/ExtraAttrs" + }, + "id": { + "description": "The ID of task", + "type": "integer" + }, + "run_count": { + "description": "The count of task run", + "type": "integer", + "format": "int32" + }, + "start_time": { + "description": "The start time of task", + "type": "string" + }, + "status": { + "description": "The status of task", + "type": "string" + }, + "status_message": { + "description": "The status message of task", + "type": "string" + }, + "update_time": { + "description": "The update time of task", + "type": "string" + } + } + }, + "UserCreationReq": { + "type": "object", + "properties": { + "comment": { + "type": "string" + }, + "email": { + "type": "string", + "maxLength": 255 + }, + "password": { + "type": "string" + }, + "realname": { + "type": "string" + }, + "username": { + "type": "string", + "maxLength": 255 + } + } + }, + "UserEntity": { + "type": "object", + "properties": { + "user_id": { + "description": "The ID of the user.", + "type": "integer" + }, + "username": { + "description": "The name of the user.", + "type": "string" + } + } + }, + "UserGroup": { + "type": "object", + "properties": { + "group_name": { + "description": "The name of the user group", + "type": "string" + }, + "group_type": { + "description": "The group type, 1 for LDAP group, 2 for HTTP group, 3 for OIDC group.", + "type": "integer" + }, + "id": { + "description": "The ID of the user group", + "type": "integer" + }, + "ldap_group_dn": { + "description": "The DN of the LDAP group if group type is 1 (LDAP group).", + "type": "string" + } + } + }, + "UserGroupSearchItem": { + "type": "object", + "properties": { + "group_name": { + "description": "The name of the user group", + "type": "string" + }, + "group_type": { + "description": "The group type, 1 for LDAP group, 2 for HTTP group, 3 for OIDC group.", + "type": "integer" + }, + "id": { + "description": "The ID of the user group", + "type": "integer" + } + } + }, + "UserProfile": { + "type": "object", + "properties": { + "comment": { + "type": "string" + }, + "email": { + "type": "string" + }, + "realname": { + "type": "string" + } + } + }, + "UserResp": { + "type": "object", + "properties": { + "admin_role_in_auth": { + "description": "indicate the admin privilege is grant by authenticator (LDAP), is always false unless it is the current login user", + "type": "boolean", + "x-omitempty": false + }, + "comment": { + "type": "string" + }, + "creation_time": { + "description": "The creation time of the user.", + "type": "string", + "format": "date-time" + }, + "email": { + "type": "string" + }, + "oidc_user_meta": { + "$ref": "#/definitions/OIDCUserInfo" + }, + "realname": { + "type": "string" + }, + "sysadmin_flag": { + "type": "boolean", + "x-omitempty": false + }, + "update_time": { + "description": "The update time of the user.", + "type": "string", + "format": "date-time" + }, + "user_id": { + "type": "integer", + "format": "int" + }, + "username": { + "type": "string" + } + } + }, + "UserSearch": { + "type": "object", + "properties": { + "user_id": { + "description": "The ID of the user.", + "type": "integer", + "format": "int" + }, + "username": { + "type": "string" + } + } + }, + "UserSearchRespItem": { + "type": "object", + "properties": { + "user_id": { + "description": "The ID of the user.", + "type": "integer", + "format": "int" + }, + "username": { + "type": "string" + } + } + }, + "UserSysAdminFlag": { + "type": "object", + "properties": { + "sysadmin_flag": { + "description": "true-admin, false-not admin.", + "type": "boolean" + } + } + }, + "VulnerabilitySummary": { + "description": "VulnerabilitySummary contains the total number of the foun d vulnerabilities number and numbers of each severity level.\n", + "type": "object", + "properties": { + "fixable": { + "description": "The number of the fixable vulnerabilities", + "type": "integer", + "format": "int", + "x-omitempty": false, + "example": 100 + }, + "summary": { + "description": "Numbers of the vulnerabilities with different severity", + "type": "object", + "additionalProperties": { + "type": "integer", + "format": "int", + "example": 10 + }, + "x-omitempty": false, + "example": { + "Critical": 5, + "High": 5 + } + }, + "total": { + "description": "The total number of the found vulnerabilities", + "type": "integer", + "format": "int", + "x-omitempty": false, + "example": 500 + } + } + }, + "WebhookJob": { + "description": "The webhook job.", + "type": "object", + "properties": { + "creation_time": { + "description": "The webhook job creation time.", + "type": "string", + "format": "date-time" + }, + "event_type": { + "description": "The webhook job event type.", + "type": "string" + }, + "id": { + "description": "The webhook job ID.", + "type": "integer", + "format": "int64" + }, + "job_detail": { + "description": "The webhook job notify detailed data.", + "type": "string" + }, + "notify_type": { + "description": "The webhook job notify type.", + "type": "string" + }, + "policy_id": { + "description": "The webhook policy ID.", + "type": "integer", + "format": "int64" + }, + "status": { + "description": "The webhook job status.", + "type": "string" + }, + "update_time": { + "description": "The webhook job update time.", + "type": "string", + "format": "date-time" + } + } + }, + "WebhookLastTrigger": { + "description": "The webhook policy and last trigger time group by event type.", + "type": "object", + "properties": { + "creation_time": { + "description": "The creation time of webhook policy.", + "type": "string", + "format": "date-time" + }, + "enabled": { + "description": "Whether or not the webhook policy enabled.", + "type": "boolean" + }, + "event_type": { + "description": "The webhook event type.", + "type": "string" + }, + "last_trigger_time": { + "description": "The last trigger time of webhook policy.", + "type": "string", + "format": "date-time" + }, + "policy_name": { + "description": "The webhook policy name.", + "type": "string" + } + } + }, + "WebhookPolicy": { + "description": "The webhook policy object", + "type": "object", + "properties": { + "creation_time": { + "description": "The create time of the webhook policy.", + "type": "string", + "format": "date-time" + }, + "creator": { + "description": "The creator of the webhook policy.", + "type": "string" + }, + "description": { + "description": "The description of webhook policy.", + "type": "string" + }, + "enabled": { + "description": "Whether the webhook policy is enabled or not.", + "type": "boolean", + "x-omitempty": false + }, + "event_types": { + "type": "array", + "items": { + "type": "string" + } + }, + "id": { + "description": "The webhook policy ID.", + "type": "integer", + "format": "int64" + }, + "name": { + "description": "The name of webhook policy.", + "type": "string" + }, + "project_id": { + "description": "The project ID of webhook policy.", + "type": "integer" + }, + "targets": { + "type": "array", + "items": { + "$ref": "#/definitions/WebhookTargetObject" + } + }, + "update_time": { + "description": "The update time of the webhook policy.", + "type": "string", + "format": "date-time" + } + } + }, + "WebhookTargetObject": { + "description": "The webhook policy target object.", + "type": "object", + "properties": { + "address": { + "description": "The webhook target address.", + "type": "string" + }, + "auth_header": { + "description": "The webhook auth header.", + "type": "string" + }, + "skip_cert_verify": { + "description": "Whether or not to skip cert verify.", + "type": "boolean" + }, + "type": { + "description": "The webhook target notify type.", + "type": "string" + } + } + }, + "Worker": { + "description": "worker in the pool", + "type": "object", + "properties": { + "check_in": { + "description": "the checkin of the running job in the worker", + "type": "string" + }, + "checkin_at": { + "description": "The checkin time of the worker", + "type": "string", + "format": "date-time", + "x-nullable": true, + "x-omitempty": true + }, + "id": { + "description": "the id of the worker", + "type": "string" + }, + "job_id": { + "description": "the id of the running job in the worker", + "type": "string" + }, + "job_name": { + "description": "the name of the running job in the worker", + "type": "string" + }, + "pool_id": { + "description": "the id of the worker pool", + "type": "string" + }, + "start_at": { + "description": "The start time of the worker", + "type": "string", + "format": "date-time", + "x-nullable": true, + "x-omitempty": true + } + } + }, + "WorkerPool": { + "description": "the worker pool of job service", + "type": "object", + "properties": { + "concurrency": { + "description": "The concurrency of the work pool", + "type": "integer" + }, + "heartbeat_at": { + "description": "The heartbeat time of the work pool", + "type": "string", + "format": "date-time" + }, + "host": { + "description": "The host of the work pool", + "type": "string" + }, + "pid": { + "description": "the process id of jobservice", + "type": "integer" + }, + "start_at": { + "description": "The start time of the work pool", + "type": "string", + "format": "date-time" + }, + "worker_pool_id": { + "description": "the id of the worker pool", + "type": "string" + } + } + } + }, + "parameters": { + "acceptVulnerabilities": { + "type": "string", + "default": "application/vnd.security.vulnerability.report; version=1.1, application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0", + "description": "A comma-separated lists of MIME types for the scan report or scan summary. The first mime type will be used when the report found for it.\nCurrently the mime type supports 'application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0' and 'application/vnd.security.vulnerability.report; version=1.1'", + "name": "X-Accept-Vulnerabilities", + "in": "header" + }, + "accessoryId": { + "type": "integer", + "format": "int64", + "description": "The ID of the accessory", + "name": "accessory_id", + "in": "path", + "required": true + }, + "digest": { + "type": "string", + "description": "The digest of the resource", + "name": "digest", + "in": "path", + "required": true + }, + "executionId": { + "type": "integer", + "description": "Execution ID", + "name": "execution_id", + "in": "path", + "required": true + }, + "gcId": { + "type": "integer", + "format": "int64", + "description": "The ID of the gc log", + "name": "gc_id", + "in": "path", + "required": true + }, + "immutableRuleId": { + "type": "integer", + "format": "int64", + "description": "The ID of the immutable rule", + "name": "immutable_rule_id", + "in": "path", + "required": true + }, + "instanceName": { + "type": "string", + "description": "Instance Name", + "name": "preheat_instance_name", + "in": "path", + "required": true + }, + "isResourceName": { + "type": "boolean", + "default": false, + "description": "The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.", + "name": "X-Is-Resource-Name", + "in": "header" + }, + "labelId": { + "type": "integer", + "format": "int64", + "description": "Label ID", + "name": "label_id", + "in": "path", + "required": true + }, + "page": { + "type": "integer", + "format": "int64", + "default": 1, + "description": "The page number", + "name": "page", + "in": "query" + }, + "pageSize": { + "maximum": 100, + "type": "integer", + "format": "int64", + "default": 10, + "description": "The size of per page", + "name": "page_size", + "in": "query" + }, + "preheatPolicyName": { + "type": "string", + "description": "Preheat Policy Name", + "name": "preheat_policy_name", + "in": "path", + "required": true + }, + "projectName": { + "type": "string", + "description": "The name of the project", + "name": "project_name", + "in": "path", + "required": true + }, + "projectNameOrId": { + "type": "string", + "description": "The name or id of the project", + "name": "project_name_or_id", + "in": "path", + "required": true + }, + "purgeId": { + "type": "integer", + "format": "int64", + "description": "The ID of the purge log", + "name": "purge_id", + "in": "path", + "required": true + }, + "query": { + "type": "string", + "description": "Query string to query resources. Supported query patterns are \"exact match(k=v)\", \"fuzzy match(k=~v)\", \"range(k=[min~max])\", \"list with union releationship(k={v1 v2 v3})\" and \"list with intersetion relationship(k=(v1 v2 v3))\". The value of range and list can be string(enclosed by \" or '), integer or time(in format \"2020-04-09 02:36:00\"). All of these query patterns should be put in the query string \"q=xxx\" and splitted by \",\". e.g. q=k1=v1,k2=~v2,k3=[min~max]", + "name": "q", + "in": "query" + }, + "reference": { + "type": "string", + "description": "The reference of the artifact, can be digest or tag", + "name": "reference", + "in": "path", + "required": true + }, + "repositoryName": { + "type": "string", + "description": "The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -\u003e a%252Fb", + "name": "repository_name", + "in": "path", + "required": true + }, + "requestId": { + "minLength": 1, + "type": "string", + "description": "An unique ID for the request", + "name": "X-Request-Id", + "in": "header" + }, + "resourceNameInLocation": { + "type": "boolean", + "default": false, + "description": "The flag to indicate whether to return the name of the resource in Location. When X-Resource-Name-In-Location is true, the Location will return the name of the resource.", + "name": "X-Resource-Name-In-Location", + "in": "header" + }, + "robotId": { + "type": "integer", + "description": "Robot ID", + "name": "robot_id", + "in": "path", + "required": true + }, + "scanDataType": { + "type": "string", + "description": "The type of scan data to export", + "name": "X-Scan-Data-Type", + "in": "header", + "required": true + }, + "sort": { + "type": "string", + "description": "Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with \"sort=field1,-field2\"", + "name": "sort", + "in": "query" + }, + "tagName": { + "type": "string", + "description": "The name of the tag", + "name": "tag_name", + "in": "path", + "required": true + }, + "taskId": { + "type": "integer", + "description": "Task ID", + "name": "task_id", + "in": "path", + "required": true + }, + "userName": { + "type": "string", + "description": "The name of the user", + "name": "user_name", + "in": "query", + "required": true + }, + "webhookPolicyId": { + "type": "integer", + "format": "int64", + "description": "The ID of the webhook policy", + "name": "webhook_policy_id", + "in": "path", + "required": true + } + }, + "responses": { + "200": { + "description": "Success", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "201": { + "description": "Created", + "headers": { + "Location": { + "type": "string", + "description": "The location of the resource" + }, + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "202": { + "description": "Accepted", + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "405": { + "description": "Method not allowed", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "409": { + "description": "Conflict", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "412": { + "description": "Precondition failed", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "415": { + "description": "Unsupported MediaType", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/Errors" + }, + "headers": { + "X-Request-Id": { + "type": "string", + "description": "The ID of the corresponding request for the response" + } + } + } + }, + "securityDefinitions": { + "basic": { + "type": "basic" + } + }, + "security": [ + { + "basic": [] + }, + {} + ] +}`)) +} diff --git a/src/server/v2.0/restapi/operations/artifact/add_label.go b/src/server/v2.0/restapi/operations/artifact/add_label.go new file mode 100644 index 000000000..5b58ee7bc --- /dev/null +++ b/src/server/v2.0/restapi/operations/artifact/add_label.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// AddLabelHandlerFunc turns a function with the right signature into a add label handler +type AddLabelHandlerFunc func(AddLabelParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn AddLabelHandlerFunc) Handle(params AddLabelParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// AddLabelHandler interface for that can handle valid add label params +type AddLabelHandler interface { + Handle(AddLabelParams, interface{}) middleware.Responder +} + +// NewAddLabel creates a new http.Handler for the add label operation +func NewAddLabel(ctx *middleware.Context, handler AddLabelHandler) *AddLabel { + return &AddLabel{Context: ctx, Handler: handler} +} + +/*AddLabel swagger:route POST /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/labels artifact addLabel + +Add label to artifact + +Add label to the specified artiact. + +*/ +type AddLabel struct { + Context *middleware.Context + Handler AddLabelHandler +} + +func (o *AddLabel) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewAddLabelParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/artifact/add_label_parameters.go b/src/server/v2.0/restapi/operations/artifact/add_label_parameters.go new file mode 100644 index 000000000..afb621d6c --- /dev/null +++ b/src/server/v2.0/restapi/operations/artifact/add_label_parameters.go @@ -0,0 +1,195 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewAddLabelParams creates a new AddLabelParams object +// no default values defined in spec. +func NewAddLabelParams() AddLabelParams { + + return AddLabelParams{} +} + +// AddLabelParams contains all the bound params for the add label operation +// typically these are obtained from a http.Request +// +// swagger:parameters addLabel +type AddLabelParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The label that added to the artifact. Only the ID property is needed. + Required: true + In: body + */ + Label *models.Label + /*The name of the project + Required: true + In: path + */ + ProjectName string + /*The reference of the artifact, can be digest or tag + Required: true + In: path + */ + Reference string + /*The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -> a%252Fb + Required: true + In: path + */ + RepositoryName string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewAddLabelParams() beforehand. +func (o *AddLabelParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Label + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("label", "body", "")) + } else { + res = append(res, errors.NewParseError("label", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Label = &body + } + } + } else { + res = append(res, errors.Required("label", "body", "")) + } + rProjectName, rhkProjectName, _ := route.Params.GetOK("project_name") + if err := o.bindProjectName(rProjectName, rhkProjectName, route.Formats); err != nil { + res = append(res, err) + } + + rReference, rhkReference, _ := route.Params.GetOK("reference") + if err := o.bindReference(rReference, rhkReference, route.Formats); err != nil { + res = append(res, err) + } + + rRepositoryName, rhkRepositoryName, _ := route.Params.GetOK("repository_name") + if err := o.bindRepositoryName(rRepositoryName, rhkRepositoryName, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *AddLabelParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *AddLabelParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindProjectName binds and validates parameter ProjectName from path. +func (o *AddLabelParams) bindProjectName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectName = raw + + return nil +} + +// bindReference binds and validates parameter Reference from path. +func (o *AddLabelParams) bindReference(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.Reference = raw + + return nil +} + +// bindRepositoryName binds and validates parameter RepositoryName from path. +func (o *AddLabelParams) bindRepositoryName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.RepositoryName = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/artifact/add_label_responses.go b/src/server/v2.0/restapi/operations/artifact/add_label_responses.go new file mode 100644 index 000000000..97965a466 --- /dev/null +++ b/src/server/v2.0/restapi/operations/artifact/add_label_responses.go @@ -0,0 +1,456 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// AddLabelOKCode is the HTTP code returned for type AddLabelOK +const AddLabelOKCode int = 200 + +/*AddLabelOK Success + +swagger:response addLabelOK +*/ +type AddLabelOK struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewAddLabelOK creates AddLabelOK with default headers values +func NewAddLabelOK() *AddLabelOK { + + return &AddLabelOK{} +} + +// WithXRequestID adds the xRequestId to the add label o k response +func (o *AddLabelOK) WithXRequestID(xRequestID string) *AddLabelOK { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the add label o k response +func (o *AddLabelOK) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *AddLabelOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// AddLabelBadRequestCode is the HTTP code returned for type AddLabelBadRequest +const AddLabelBadRequestCode int = 400 + +/*AddLabelBadRequest Bad request + +swagger:response addLabelBadRequest +*/ +type AddLabelBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewAddLabelBadRequest creates AddLabelBadRequest with default headers values +func NewAddLabelBadRequest() *AddLabelBadRequest { + + return &AddLabelBadRequest{} +} + +// WithXRequestID adds the xRequestId to the add label bad request response +func (o *AddLabelBadRequest) WithXRequestID(xRequestID string) *AddLabelBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the add label bad request response +func (o *AddLabelBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the add label bad request response +func (o *AddLabelBadRequest) WithPayload(payload *models.Errors) *AddLabelBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the add label bad request response +func (o *AddLabelBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *AddLabelBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// AddLabelUnauthorizedCode is the HTTP code returned for type AddLabelUnauthorized +const AddLabelUnauthorizedCode int = 401 + +/*AddLabelUnauthorized Unauthorized + +swagger:response addLabelUnauthorized +*/ +type AddLabelUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewAddLabelUnauthorized creates AddLabelUnauthorized with default headers values +func NewAddLabelUnauthorized() *AddLabelUnauthorized { + + return &AddLabelUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the add label unauthorized response +func (o *AddLabelUnauthorized) WithXRequestID(xRequestID string) *AddLabelUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the add label unauthorized response +func (o *AddLabelUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the add label unauthorized response +func (o *AddLabelUnauthorized) WithPayload(payload *models.Errors) *AddLabelUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the add label unauthorized response +func (o *AddLabelUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *AddLabelUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// AddLabelForbiddenCode is the HTTP code returned for type AddLabelForbidden +const AddLabelForbiddenCode int = 403 + +/*AddLabelForbidden Forbidden + +swagger:response addLabelForbidden +*/ +type AddLabelForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewAddLabelForbidden creates AddLabelForbidden with default headers values +func NewAddLabelForbidden() *AddLabelForbidden { + + return &AddLabelForbidden{} +} + +// WithXRequestID adds the xRequestId to the add label forbidden response +func (o *AddLabelForbidden) WithXRequestID(xRequestID string) *AddLabelForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the add label forbidden response +func (o *AddLabelForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the add label forbidden response +func (o *AddLabelForbidden) WithPayload(payload *models.Errors) *AddLabelForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the add label forbidden response +func (o *AddLabelForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *AddLabelForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// AddLabelNotFoundCode is the HTTP code returned for type AddLabelNotFound +const AddLabelNotFoundCode int = 404 + +/*AddLabelNotFound Not found + +swagger:response addLabelNotFound +*/ +type AddLabelNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewAddLabelNotFound creates AddLabelNotFound with default headers values +func NewAddLabelNotFound() *AddLabelNotFound { + + return &AddLabelNotFound{} +} + +// WithXRequestID adds the xRequestId to the add label not found response +func (o *AddLabelNotFound) WithXRequestID(xRequestID string) *AddLabelNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the add label not found response +func (o *AddLabelNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the add label not found response +func (o *AddLabelNotFound) WithPayload(payload *models.Errors) *AddLabelNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the add label not found response +func (o *AddLabelNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *AddLabelNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// AddLabelConflictCode is the HTTP code returned for type AddLabelConflict +const AddLabelConflictCode int = 409 + +/*AddLabelConflict Conflict + +swagger:response addLabelConflict +*/ +type AddLabelConflict struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewAddLabelConflict creates AddLabelConflict with default headers values +func NewAddLabelConflict() *AddLabelConflict { + + return &AddLabelConflict{} +} + +// WithXRequestID adds the xRequestId to the add label conflict response +func (o *AddLabelConflict) WithXRequestID(xRequestID string) *AddLabelConflict { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the add label conflict response +func (o *AddLabelConflict) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the add label conflict response +func (o *AddLabelConflict) WithPayload(payload *models.Errors) *AddLabelConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the add label conflict response +func (o *AddLabelConflict) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *AddLabelConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// AddLabelInternalServerErrorCode is the HTTP code returned for type AddLabelInternalServerError +const AddLabelInternalServerErrorCode int = 500 + +/*AddLabelInternalServerError Internal server error + +swagger:response addLabelInternalServerError +*/ +type AddLabelInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewAddLabelInternalServerError creates AddLabelInternalServerError with default headers values +func NewAddLabelInternalServerError() *AddLabelInternalServerError { + + return &AddLabelInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the add label internal server error response +func (o *AddLabelInternalServerError) WithXRequestID(xRequestID string) *AddLabelInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the add label internal server error response +func (o *AddLabelInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the add label internal server error response +func (o *AddLabelInternalServerError) WithPayload(payload *models.Errors) *AddLabelInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the add label internal server error response +func (o *AddLabelInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *AddLabelInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/artifact/add_label_urlbuilder.go b/src/server/v2.0/restapi/operations/artifact/add_label_urlbuilder.go new file mode 100644 index 000000000..935049be3 --- /dev/null +++ b/src/server/v2.0/restapi/operations/artifact/add_label_urlbuilder.go @@ -0,0 +1,115 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// AddLabelURL generates an URL for the add label operation +type AddLabelURL struct { + ProjectName string + Reference string + RepositoryName string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *AddLabelURL) WithBasePath(bp string) *AddLabelURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *AddLabelURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *AddLabelURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/labels" + + projectName := o.ProjectName + if projectName != "" { + _path = strings.Replace(_path, "{project_name}", projectName, -1) + } else { + return nil, errors.New("projectName is required on AddLabelURL") + } + + reference := o.Reference + if reference != "" { + _path = strings.Replace(_path, "{reference}", reference, -1) + } else { + return nil, errors.New("reference is required on AddLabelURL") + } + + repositoryName := o.RepositoryName + if repositoryName != "" { + _path = strings.Replace(_path, "{repository_name}", repositoryName, -1) + } else { + return nil, errors.New("repositoryName is required on AddLabelURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *AddLabelURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *AddLabelURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *AddLabelURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on AddLabelURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on AddLabelURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *AddLabelURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/artifact/copy_artifact.go b/src/server/v2.0/restapi/operations/artifact/copy_artifact.go new file mode 100644 index 000000000..1de7b06b9 --- /dev/null +++ b/src/server/v2.0/restapi/operations/artifact/copy_artifact.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CopyArtifactHandlerFunc turns a function with the right signature into a copy artifact handler +type CopyArtifactHandlerFunc func(CopyArtifactParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CopyArtifactHandlerFunc) Handle(params CopyArtifactParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CopyArtifactHandler interface for that can handle valid copy artifact params +type CopyArtifactHandler interface { + Handle(CopyArtifactParams, interface{}) middleware.Responder +} + +// NewCopyArtifact creates a new http.Handler for the copy artifact operation +func NewCopyArtifact(ctx *middleware.Context, handler CopyArtifactHandler) *CopyArtifact { + return &CopyArtifact{Context: ctx, Handler: handler} +} + +/*CopyArtifact swagger:route POST /projects/{project_name}/repositories/{repository_name}/artifacts artifact copyArtifact + +Copy artifact + +Copy the artifact specified in the "from" parameter to the repository. + +*/ +type CopyArtifact struct { + Context *middleware.Context + Handler CopyArtifactHandler +} + +func (o *CopyArtifact) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewCopyArtifactParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/artifact/copy_artifact_parameters.go b/src/server/v2.0/restapi/operations/artifact/copy_artifact_parameters.go new file mode 100644 index 000000000..b7593282d --- /dev/null +++ b/src/server/v2.0/restapi/operations/artifact/copy_artifact_parameters.go @@ -0,0 +1,173 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewCopyArtifactParams creates a new CopyArtifactParams object +// no default values defined in spec. +func NewCopyArtifactParams() CopyArtifactParams { + + return CopyArtifactParams{} +} + +// CopyArtifactParams contains all the bound params for the copy artifact operation +// typically these are obtained from a http.Request +// +// swagger:parameters CopyArtifact +type CopyArtifactParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The artifact from which the new artifact is copied from, the format should be "project/repository:tag" or "project/repository@digest". + Required: true + In: query + */ + From string + /*The name of the project + Required: true + In: path + */ + ProjectName string + /*The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -> a%252Fb + Required: true + In: path + */ + RepositoryName string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCopyArtifactParams() beforehand. +func (o *CopyArtifactParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + qFrom, qhkFrom, _ := qs.GetOK("from") + if err := o.bindFrom(qFrom, qhkFrom, route.Formats); err != nil { + res = append(res, err) + } + + rProjectName, rhkProjectName, _ := route.Params.GetOK("project_name") + if err := o.bindProjectName(rProjectName, rhkProjectName, route.Formats); err != nil { + res = append(res, err) + } + + rRepositoryName, rhkRepositoryName, _ := route.Params.GetOK("repository_name") + if err := o.bindRepositoryName(rRepositoryName, rhkRepositoryName, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *CopyArtifactParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *CopyArtifactParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindFrom binds and validates parameter From from query. +func (o *CopyArtifactParams) bindFrom(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("from", "query", rawData) + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // AllowEmptyValue: false + if err := validate.RequiredString("from", "query", raw); err != nil { + return err + } + + o.From = raw + + return nil +} + +// bindProjectName binds and validates parameter ProjectName from path. +func (o *CopyArtifactParams) bindProjectName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectName = raw + + return nil +} + +// bindRepositoryName binds and validates parameter RepositoryName from path. +func (o *CopyArtifactParams) bindRepositoryName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.RepositoryName = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/artifact/copy_artifact_responses.go b/src/server/v2.0/restapi/operations/artifact/copy_artifact_responses.go new file mode 100644 index 000000000..9d84368cd --- /dev/null +++ b/src/server/v2.0/restapi/operations/artifact/copy_artifact_responses.go @@ -0,0 +1,478 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// CopyArtifactCreatedCode is the HTTP code returned for type CopyArtifactCreated +const CopyArtifactCreatedCode int = 201 + +/*CopyArtifactCreated Created + +swagger:response copyArtifactCreated +*/ +type CopyArtifactCreated struct { + /*The location of the resource + + */ + Location string `json:"Location"` + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewCopyArtifactCreated creates CopyArtifactCreated with default headers values +func NewCopyArtifactCreated() *CopyArtifactCreated { + + return &CopyArtifactCreated{} +} + +// WithLocation adds the location to the copy artifact created response +func (o *CopyArtifactCreated) WithLocation(location string) *CopyArtifactCreated { + o.Location = location + return o +} + +// SetLocation sets the location to the copy artifact created response +func (o *CopyArtifactCreated) SetLocation(location string) { + o.Location = location +} + +// WithXRequestID adds the xRequestId to the copy artifact created response +func (o *CopyArtifactCreated) WithXRequestID(xRequestID string) *CopyArtifactCreated { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the copy artifact created response +func (o *CopyArtifactCreated) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *CopyArtifactCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Location + + location := o.Location + if location != "" { + rw.Header().Set("Location", location) + } + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(201) +} + +// CopyArtifactBadRequestCode is the HTTP code returned for type CopyArtifactBadRequest +const CopyArtifactBadRequestCode int = 400 + +/*CopyArtifactBadRequest Bad request + +swagger:response copyArtifactBadRequest +*/ +type CopyArtifactBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCopyArtifactBadRequest creates CopyArtifactBadRequest with default headers values +func NewCopyArtifactBadRequest() *CopyArtifactBadRequest { + + return &CopyArtifactBadRequest{} +} + +// WithXRequestID adds the xRequestId to the copy artifact bad request response +func (o *CopyArtifactBadRequest) WithXRequestID(xRequestID string) *CopyArtifactBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the copy artifact bad request response +func (o *CopyArtifactBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the copy artifact bad request response +func (o *CopyArtifactBadRequest) WithPayload(payload *models.Errors) *CopyArtifactBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the copy artifact bad request response +func (o *CopyArtifactBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CopyArtifactBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CopyArtifactUnauthorizedCode is the HTTP code returned for type CopyArtifactUnauthorized +const CopyArtifactUnauthorizedCode int = 401 + +/*CopyArtifactUnauthorized Unauthorized + +swagger:response copyArtifactUnauthorized +*/ +type CopyArtifactUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCopyArtifactUnauthorized creates CopyArtifactUnauthorized with default headers values +func NewCopyArtifactUnauthorized() *CopyArtifactUnauthorized { + + return &CopyArtifactUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the copy artifact unauthorized response +func (o *CopyArtifactUnauthorized) WithXRequestID(xRequestID string) *CopyArtifactUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the copy artifact unauthorized response +func (o *CopyArtifactUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the copy artifact unauthorized response +func (o *CopyArtifactUnauthorized) WithPayload(payload *models.Errors) *CopyArtifactUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the copy artifact unauthorized response +func (o *CopyArtifactUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CopyArtifactUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CopyArtifactForbiddenCode is the HTTP code returned for type CopyArtifactForbidden +const CopyArtifactForbiddenCode int = 403 + +/*CopyArtifactForbidden Forbidden + +swagger:response copyArtifactForbidden +*/ +type CopyArtifactForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCopyArtifactForbidden creates CopyArtifactForbidden with default headers values +func NewCopyArtifactForbidden() *CopyArtifactForbidden { + + return &CopyArtifactForbidden{} +} + +// WithXRequestID adds the xRequestId to the copy artifact forbidden response +func (o *CopyArtifactForbidden) WithXRequestID(xRequestID string) *CopyArtifactForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the copy artifact forbidden response +func (o *CopyArtifactForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the copy artifact forbidden response +func (o *CopyArtifactForbidden) WithPayload(payload *models.Errors) *CopyArtifactForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the copy artifact forbidden response +func (o *CopyArtifactForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CopyArtifactForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CopyArtifactNotFoundCode is the HTTP code returned for type CopyArtifactNotFound +const CopyArtifactNotFoundCode int = 404 + +/*CopyArtifactNotFound Not found + +swagger:response copyArtifactNotFound +*/ +type CopyArtifactNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCopyArtifactNotFound creates CopyArtifactNotFound with default headers values +func NewCopyArtifactNotFound() *CopyArtifactNotFound { + + return &CopyArtifactNotFound{} +} + +// WithXRequestID adds the xRequestId to the copy artifact not found response +func (o *CopyArtifactNotFound) WithXRequestID(xRequestID string) *CopyArtifactNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the copy artifact not found response +func (o *CopyArtifactNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the copy artifact not found response +func (o *CopyArtifactNotFound) WithPayload(payload *models.Errors) *CopyArtifactNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the copy artifact not found response +func (o *CopyArtifactNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CopyArtifactNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CopyArtifactMethodNotAllowedCode is the HTTP code returned for type CopyArtifactMethodNotAllowed +const CopyArtifactMethodNotAllowedCode int = 405 + +/*CopyArtifactMethodNotAllowed Method not allowed + +swagger:response copyArtifactMethodNotAllowed +*/ +type CopyArtifactMethodNotAllowed struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCopyArtifactMethodNotAllowed creates CopyArtifactMethodNotAllowed with default headers values +func NewCopyArtifactMethodNotAllowed() *CopyArtifactMethodNotAllowed { + + return &CopyArtifactMethodNotAllowed{} +} + +// WithXRequestID adds the xRequestId to the copy artifact method not allowed response +func (o *CopyArtifactMethodNotAllowed) WithXRequestID(xRequestID string) *CopyArtifactMethodNotAllowed { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the copy artifact method not allowed response +func (o *CopyArtifactMethodNotAllowed) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the copy artifact method not allowed response +func (o *CopyArtifactMethodNotAllowed) WithPayload(payload *models.Errors) *CopyArtifactMethodNotAllowed { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the copy artifact method not allowed response +func (o *CopyArtifactMethodNotAllowed) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CopyArtifactMethodNotAllowed) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(405) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CopyArtifactInternalServerErrorCode is the HTTP code returned for type CopyArtifactInternalServerError +const CopyArtifactInternalServerErrorCode int = 500 + +/*CopyArtifactInternalServerError Internal server error + +swagger:response copyArtifactInternalServerError +*/ +type CopyArtifactInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCopyArtifactInternalServerError creates CopyArtifactInternalServerError with default headers values +func NewCopyArtifactInternalServerError() *CopyArtifactInternalServerError { + + return &CopyArtifactInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the copy artifact internal server error response +func (o *CopyArtifactInternalServerError) WithXRequestID(xRequestID string) *CopyArtifactInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the copy artifact internal server error response +func (o *CopyArtifactInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the copy artifact internal server error response +func (o *CopyArtifactInternalServerError) WithPayload(payload *models.Errors) *CopyArtifactInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the copy artifact internal server error response +func (o *CopyArtifactInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CopyArtifactInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/artifact/copy_artifact_urlbuilder.go b/src/server/v2.0/restapi/operations/artifact/copy_artifact_urlbuilder.go new file mode 100644 index 000000000..d31c9ba7f --- /dev/null +++ b/src/server/v2.0/restapi/operations/artifact/copy_artifact_urlbuilder.go @@ -0,0 +1,118 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// CopyArtifactURL generates an URL for the copy artifact operation +type CopyArtifactURL struct { + ProjectName string + RepositoryName string + + From string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CopyArtifactURL) WithBasePath(bp string) *CopyArtifactURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CopyArtifactURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CopyArtifactURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name}/repositories/{repository_name}/artifacts" + + projectName := o.ProjectName + if projectName != "" { + _path = strings.Replace(_path, "{project_name}", projectName, -1) + } else { + return nil, errors.New("projectName is required on CopyArtifactURL") + } + + repositoryName := o.RepositoryName + if repositoryName != "" { + _path = strings.Replace(_path, "{repository_name}", repositoryName, -1) + } else { + return nil, errors.New("repositoryName is required on CopyArtifactURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + fromQ := o.From + if fromQ != "" { + qs.Set("from", fromQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CopyArtifactURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CopyArtifactURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CopyArtifactURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CopyArtifactURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CopyArtifactURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CopyArtifactURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/artifact/create_tag.go b/src/server/v2.0/restapi/operations/artifact/create_tag.go new file mode 100644 index 000000000..58c5322a6 --- /dev/null +++ b/src/server/v2.0/restapi/operations/artifact/create_tag.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateTagHandlerFunc turns a function with the right signature into a create tag handler +type CreateTagHandlerFunc func(CreateTagParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateTagHandlerFunc) Handle(params CreateTagParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateTagHandler interface for that can handle valid create tag params +type CreateTagHandler interface { + Handle(CreateTagParams, interface{}) middleware.Responder +} + +// NewCreateTag creates a new http.Handler for the create tag operation +func NewCreateTag(ctx *middleware.Context, handler CreateTagHandler) *CreateTag { + return &CreateTag{Context: ctx, Handler: handler} +} + +/*CreateTag swagger:route POST /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/tags artifact createTag + +Create tag + +Create a tag for the specified artifact + +*/ +type CreateTag struct { + Context *middleware.Context + Handler CreateTagHandler +} + +func (o *CreateTag) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewCreateTagParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/artifact/create_tag_parameters.go b/src/server/v2.0/restapi/operations/artifact/create_tag_parameters.go new file mode 100644 index 000000000..c75ab13cd --- /dev/null +++ b/src/server/v2.0/restapi/operations/artifact/create_tag_parameters.go @@ -0,0 +1,195 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewCreateTagParams creates a new CreateTagParams object +// no default values defined in spec. +func NewCreateTagParams() CreateTagParams { + + return CreateTagParams{} +} + +// CreateTagParams contains all the bound params for the create tag operation +// typically these are obtained from a http.Request +// +// swagger:parameters createTag +type CreateTagParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The name of the project + Required: true + In: path + */ + ProjectName string + /*The reference of the artifact, can be digest or tag + Required: true + In: path + */ + Reference string + /*The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -> a%252Fb + Required: true + In: path + */ + RepositoryName string + /*The JSON object of tag. + Required: true + In: body + */ + Tag *models.Tag +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateTagParams() beforehand. +func (o *CreateTagParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rProjectName, rhkProjectName, _ := route.Params.GetOK("project_name") + if err := o.bindProjectName(rProjectName, rhkProjectName, route.Formats); err != nil { + res = append(res, err) + } + + rReference, rhkReference, _ := route.Params.GetOK("reference") + if err := o.bindReference(rReference, rhkReference, route.Formats); err != nil { + res = append(res, err) + } + + rRepositoryName, rhkRepositoryName, _ := route.Params.GetOK("repository_name") + if err := o.bindRepositoryName(rRepositoryName, rhkRepositoryName, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Tag + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("tag", "body", "")) + } else { + res = append(res, errors.NewParseError("tag", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Tag = &body + } + } + } else { + res = append(res, errors.Required("tag", "body", "")) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *CreateTagParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *CreateTagParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindProjectName binds and validates parameter ProjectName from path. +func (o *CreateTagParams) bindProjectName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectName = raw + + return nil +} + +// bindReference binds and validates parameter Reference from path. +func (o *CreateTagParams) bindReference(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.Reference = raw + + return nil +} + +// bindRepositoryName binds and validates parameter RepositoryName from path. +func (o *CreateTagParams) bindRepositoryName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.RepositoryName = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/artifact/create_tag_responses.go b/src/server/v2.0/restapi/operations/artifact/create_tag_responses.go new file mode 100644 index 000000000..dbc4aff08 --- /dev/null +++ b/src/server/v2.0/restapi/operations/artifact/create_tag_responses.go @@ -0,0 +1,544 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// CreateTagCreatedCode is the HTTP code returned for type CreateTagCreated +const CreateTagCreatedCode int = 201 + +/*CreateTagCreated Created + +swagger:response createTagCreated +*/ +type CreateTagCreated struct { + /*The location of the resource + + */ + Location string `json:"Location"` + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewCreateTagCreated creates CreateTagCreated with default headers values +func NewCreateTagCreated() *CreateTagCreated { + + return &CreateTagCreated{} +} + +// WithLocation adds the location to the create tag created response +func (o *CreateTagCreated) WithLocation(location string) *CreateTagCreated { + o.Location = location + return o +} + +// SetLocation sets the location to the create tag created response +func (o *CreateTagCreated) SetLocation(location string) { + o.Location = location +} + +// WithXRequestID adds the xRequestId to the create tag created response +func (o *CreateTagCreated) WithXRequestID(xRequestID string) *CreateTagCreated { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create tag created response +func (o *CreateTagCreated) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *CreateTagCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Location + + location := o.Location + if location != "" { + rw.Header().Set("Location", location) + } + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(201) +} + +// CreateTagBadRequestCode is the HTTP code returned for type CreateTagBadRequest +const CreateTagBadRequestCode int = 400 + +/*CreateTagBadRequest Bad request + +swagger:response createTagBadRequest +*/ +type CreateTagBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateTagBadRequest creates CreateTagBadRequest with default headers values +func NewCreateTagBadRequest() *CreateTagBadRequest { + + return &CreateTagBadRequest{} +} + +// WithXRequestID adds the xRequestId to the create tag bad request response +func (o *CreateTagBadRequest) WithXRequestID(xRequestID string) *CreateTagBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create tag bad request response +func (o *CreateTagBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create tag bad request response +func (o *CreateTagBadRequest) WithPayload(payload *models.Errors) *CreateTagBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create tag bad request response +func (o *CreateTagBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTagBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateTagUnauthorizedCode is the HTTP code returned for type CreateTagUnauthorized +const CreateTagUnauthorizedCode int = 401 + +/*CreateTagUnauthorized Unauthorized + +swagger:response createTagUnauthorized +*/ +type CreateTagUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateTagUnauthorized creates CreateTagUnauthorized with default headers values +func NewCreateTagUnauthorized() *CreateTagUnauthorized { + + return &CreateTagUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the create tag unauthorized response +func (o *CreateTagUnauthorized) WithXRequestID(xRequestID string) *CreateTagUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create tag unauthorized response +func (o *CreateTagUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create tag unauthorized response +func (o *CreateTagUnauthorized) WithPayload(payload *models.Errors) *CreateTagUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create tag unauthorized response +func (o *CreateTagUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTagUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateTagForbiddenCode is the HTTP code returned for type CreateTagForbidden +const CreateTagForbiddenCode int = 403 + +/*CreateTagForbidden Forbidden + +swagger:response createTagForbidden +*/ +type CreateTagForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateTagForbidden creates CreateTagForbidden with default headers values +func NewCreateTagForbidden() *CreateTagForbidden { + + return &CreateTagForbidden{} +} + +// WithXRequestID adds the xRequestId to the create tag forbidden response +func (o *CreateTagForbidden) WithXRequestID(xRequestID string) *CreateTagForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create tag forbidden response +func (o *CreateTagForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create tag forbidden response +func (o *CreateTagForbidden) WithPayload(payload *models.Errors) *CreateTagForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create tag forbidden response +func (o *CreateTagForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTagForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateTagNotFoundCode is the HTTP code returned for type CreateTagNotFound +const CreateTagNotFoundCode int = 404 + +/*CreateTagNotFound Not found + +swagger:response createTagNotFound +*/ +type CreateTagNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateTagNotFound creates CreateTagNotFound with default headers values +func NewCreateTagNotFound() *CreateTagNotFound { + + return &CreateTagNotFound{} +} + +// WithXRequestID adds the xRequestId to the create tag not found response +func (o *CreateTagNotFound) WithXRequestID(xRequestID string) *CreateTagNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create tag not found response +func (o *CreateTagNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create tag not found response +func (o *CreateTagNotFound) WithPayload(payload *models.Errors) *CreateTagNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create tag not found response +func (o *CreateTagNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTagNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateTagMethodNotAllowedCode is the HTTP code returned for type CreateTagMethodNotAllowed +const CreateTagMethodNotAllowedCode int = 405 + +/*CreateTagMethodNotAllowed Method not allowed + +swagger:response createTagMethodNotAllowed +*/ +type CreateTagMethodNotAllowed struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateTagMethodNotAllowed creates CreateTagMethodNotAllowed with default headers values +func NewCreateTagMethodNotAllowed() *CreateTagMethodNotAllowed { + + return &CreateTagMethodNotAllowed{} +} + +// WithXRequestID adds the xRequestId to the create tag method not allowed response +func (o *CreateTagMethodNotAllowed) WithXRequestID(xRequestID string) *CreateTagMethodNotAllowed { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create tag method not allowed response +func (o *CreateTagMethodNotAllowed) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create tag method not allowed response +func (o *CreateTagMethodNotAllowed) WithPayload(payload *models.Errors) *CreateTagMethodNotAllowed { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create tag method not allowed response +func (o *CreateTagMethodNotAllowed) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTagMethodNotAllowed) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(405) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateTagConflictCode is the HTTP code returned for type CreateTagConflict +const CreateTagConflictCode int = 409 + +/*CreateTagConflict Conflict + +swagger:response createTagConflict +*/ +type CreateTagConflict struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateTagConflict creates CreateTagConflict with default headers values +func NewCreateTagConflict() *CreateTagConflict { + + return &CreateTagConflict{} +} + +// WithXRequestID adds the xRequestId to the create tag conflict response +func (o *CreateTagConflict) WithXRequestID(xRequestID string) *CreateTagConflict { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create tag conflict response +func (o *CreateTagConflict) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create tag conflict response +func (o *CreateTagConflict) WithPayload(payload *models.Errors) *CreateTagConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create tag conflict response +func (o *CreateTagConflict) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTagConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateTagInternalServerErrorCode is the HTTP code returned for type CreateTagInternalServerError +const CreateTagInternalServerErrorCode int = 500 + +/*CreateTagInternalServerError Internal server error + +swagger:response createTagInternalServerError +*/ +type CreateTagInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateTagInternalServerError creates CreateTagInternalServerError with default headers values +func NewCreateTagInternalServerError() *CreateTagInternalServerError { + + return &CreateTagInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the create tag internal server error response +func (o *CreateTagInternalServerError) WithXRequestID(xRequestID string) *CreateTagInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create tag internal server error response +func (o *CreateTagInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create tag internal server error response +func (o *CreateTagInternalServerError) WithPayload(payload *models.Errors) *CreateTagInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create tag internal server error response +func (o *CreateTagInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTagInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/artifact/create_tag_urlbuilder.go b/src/server/v2.0/restapi/operations/artifact/create_tag_urlbuilder.go new file mode 100644 index 000000000..2f2d66d4c --- /dev/null +++ b/src/server/v2.0/restapi/operations/artifact/create_tag_urlbuilder.go @@ -0,0 +1,115 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// CreateTagURL generates an URL for the create tag operation +type CreateTagURL struct { + ProjectName string + Reference string + RepositoryName string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateTagURL) WithBasePath(bp string) *CreateTagURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateTagURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateTagURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/tags" + + projectName := o.ProjectName + if projectName != "" { + _path = strings.Replace(_path, "{project_name}", projectName, -1) + } else { + return nil, errors.New("projectName is required on CreateTagURL") + } + + reference := o.Reference + if reference != "" { + _path = strings.Replace(_path, "{reference}", reference, -1) + } else { + return nil, errors.New("reference is required on CreateTagURL") + } + + repositoryName := o.RepositoryName + if repositoryName != "" { + _path = strings.Replace(_path, "{repository_name}", repositoryName, -1) + } else { + return nil, errors.New("repositoryName is required on CreateTagURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateTagURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateTagURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateTagURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateTagURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateTagURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateTagURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/artifact/delete_artifact.go b/src/server/v2.0/restapi/operations/artifact/delete_artifact.go new file mode 100644 index 000000000..44d873aed --- /dev/null +++ b/src/server/v2.0/restapi/operations/artifact/delete_artifact.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteArtifactHandlerFunc turns a function with the right signature into a delete artifact handler +type DeleteArtifactHandlerFunc func(DeleteArtifactParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteArtifactHandlerFunc) Handle(params DeleteArtifactParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteArtifactHandler interface for that can handle valid delete artifact params +type DeleteArtifactHandler interface { + Handle(DeleteArtifactParams, interface{}) middleware.Responder +} + +// NewDeleteArtifact creates a new http.Handler for the delete artifact operation +func NewDeleteArtifact(ctx *middleware.Context, handler DeleteArtifactHandler) *DeleteArtifact { + return &DeleteArtifact{Context: ctx, Handler: handler} +} + +/*DeleteArtifact swagger:route DELETE /projects/{project_name}/repositories/{repository_name}/artifacts/{reference} artifact deleteArtifact + +Delete the specific artifact + +Delete the artifact specified by the reference under the project and repository. The reference can be digest or tag + +*/ +type DeleteArtifact struct { + Context *middleware.Context + Handler DeleteArtifactHandler +} + +func (o *DeleteArtifact) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewDeleteArtifactParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/artifact/delete_artifact_parameters.go b/src/server/v2.0/restapi/operations/artifact/delete_artifact_parameters.go new file mode 100644 index 000000000..31aff99c5 --- /dev/null +++ b/src/server/v2.0/restapi/operations/artifact/delete_artifact_parameters.go @@ -0,0 +1,164 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewDeleteArtifactParams creates a new DeleteArtifactParams object +// no default values defined in spec. +func NewDeleteArtifactParams() DeleteArtifactParams { + + return DeleteArtifactParams{} +} + +// DeleteArtifactParams contains all the bound params for the delete artifact operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteArtifact +type DeleteArtifactParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The name of the project + Required: true + In: path + */ + ProjectName string + /*The reference of the artifact, can be digest or tag + Required: true + In: path + */ + Reference string + /*The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -> a%252Fb + Required: true + In: path + */ + RepositoryName string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteArtifactParams() beforehand. +func (o *DeleteArtifactParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rProjectName, rhkProjectName, _ := route.Params.GetOK("project_name") + if err := o.bindProjectName(rProjectName, rhkProjectName, route.Formats); err != nil { + res = append(res, err) + } + + rReference, rhkReference, _ := route.Params.GetOK("reference") + if err := o.bindReference(rReference, rhkReference, route.Formats); err != nil { + res = append(res, err) + } + + rRepositoryName, rhkRepositoryName, _ := route.Params.GetOK("repository_name") + if err := o.bindRepositoryName(rRepositoryName, rhkRepositoryName, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *DeleteArtifactParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *DeleteArtifactParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindProjectName binds and validates parameter ProjectName from path. +func (o *DeleteArtifactParams) bindProjectName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectName = raw + + return nil +} + +// bindReference binds and validates parameter Reference from path. +func (o *DeleteArtifactParams) bindReference(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.Reference = raw + + return nil +} + +// bindRepositoryName binds and validates parameter RepositoryName from path. +func (o *DeleteArtifactParams) bindRepositoryName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.RepositoryName = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/artifact/delete_artifact_responses.go b/src/server/v2.0/restapi/operations/artifact/delete_artifact_responses.go new file mode 100644 index 000000000..5f3e83da0 --- /dev/null +++ b/src/server/v2.0/restapi/operations/artifact/delete_artifact_responses.go @@ -0,0 +1,324 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// DeleteArtifactOKCode is the HTTP code returned for type DeleteArtifactOK +const DeleteArtifactOKCode int = 200 + +/*DeleteArtifactOK Success + +swagger:response deleteArtifactOK +*/ +type DeleteArtifactOK struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewDeleteArtifactOK creates DeleteArtifactOK with default headers values +func NewDeleteArtifactOK() *DeleteArtifactOK { + + return &DeleteArtifactOK{} +} + +// WithXRequestID adds the xRequestId to the delete artifact o k response +func (o *DeleteArtifactOK) WithXRequestID(xRequestID string) *DeleteArtifactOK { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete artifact o k response +func (o *DeleteArtifactOK) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *DeleteArtifactOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// DeleteArtifactUnauthorizedCode is the HTTP code returned for type DeleteArtifactUnauthorized +const DeleteArtifactUnauthorizedCode int = 401 + +/*DeleteArtifactUnauthorized Unauthorized + +swagger:response deleteArtifactUnauthorized +*/ +type DeleteArtifactUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteArtifactUnauthorized creates DeleteArtifactUnauthorized with default headers values +func NewDeleteArtifactUnauthorized() *DeleteArtifactUnauthorized { + + return &DeleteArtifactUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the delete artifact unauthorized response +func (o *DeleteArtifactUnauthorized) WithXRequestID(xRequestID string) *DeleteArtifactUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete artifact unauthorized response +func (o *DeleteArtifactUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete artifact unauthorized response +func (o *DeleteArtifactUnauthorized) WithPayload(payload *models.Errors) *DeleteArtifactUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete artifact unauthorized response +func (o *DeleteArtifactUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteArtifactUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteArtifactForbiddenCode is the HTTP code returned for type DeleteArtifactForbidden +const DeleteArtifactForbiddenCode int = 403 + +/*DeleteArtifactForbidden Forbidden + +swagger:response deleteArtifactForbidden +*/ +type DeleteArtifactForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteArtifactForbidden creates DeleteArtifactForbidden with default headers values +func NewDeleteArtifactForbidden() *DeleteArtifactForbidden { + + return &DeleteArtifactForbidden{} +} + +// WithXRequestID adds the xRequestId to the delete artifact forbidden response +func (o *DeleteArtifactForbidden) WithXRequestID(xRequestID string) *DeleteArtifactForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete artifact forbidden response +func (o *DeleteArtifactForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete artifact forbidden response +func (o *DeleteArtifactForbidden) WithPayload(payload *models.Errors) *DeleteArtifactForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete artifact forbidden response +func (o *DeleteArtifactForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteArtifactForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteArtifactNotFoundCode is the HTTP code returned for type DeleteArtifactNotFound +const DeleteArtifactNotFoundCode int = 404 + +/*DeleteArtifactNotFound Not found + +swagger:response deleteArtifactNotFound +*/ +type DeleteArtifactNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteArtifactNotFound creates DeleteArtifactNotFound with default headers values +func NewDeleteArtifactNotFound() *DeleteArtifactNotFound { + + return &DeleteArtifactNotFound{} +} + +// WithXRequestID adds the xRequestId to the delete artifact not found response +func (o *DeleteArtifactNotFound) WithXRequestID(xRequestID string) *DeleteArtifactNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete artifact not found response +func (o *DeleteArtifactNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete artifact not found response +func (o *DeleteArtifactNotFound) WithPayload(payload *models.Errors) *DeleteArtifactNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete artifact not found response +func (o *DeleteArtifactNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteArtifactNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteArtifactInternalServerErrorCode is the HTTP code returned for type DeleteArtifactInternalServerError +const DeleteArtifactInternalServerErrorCode int = 500 + +/*DeleteArtifactInternalServerError Internal server error + +swagger:response deleteArtifactInternalServerError +*/ +type DeleteArtifactInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteArtifactInternalServerError creates DeleteArtifactInternalServerError with default headers values +func NewDeleteArtifactInternalServerError() *DeleteArtifactInternalServerError { + + return &DeleteArtifactInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the delete artifact internal server error response +func (o *DeleteArtifactInternalServerError) WithXRequestID(xRequestID string) *DeleteArtifactInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete artifact internal server error response +func (o *DeleteArtifactInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete artifact internal server error response +func (o *DeleteArtifactInternalServerError) WithPayload(payload *models.Errors) *DeleteArtifactInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete artifact internal server error response +func (o *DeleteArtifactInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteArtifactInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/artifact/delete_artifact_urlbuilder.go b/src/server/v2.0/restapi/operations/artifact/delete_artifact_urlbuilder.go new file mode 100644 index 000000000..1ec56ccad --- /dev/null +++ b/src/server/v2.0/restapi/operations/artifact/delete_artifact_urlbuilder.go @@ -0,0 +1,115 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// DeleteArtifactURL generates an URL for the delete artifact operation +type DeleteArtifactURL struct { + ProjectName string + Reference string + RepositoryName string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteArtifactURL) WithBasePath(bp string) *DeleteArtifactURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteArtifactURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteArtifactURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}" + + projectName := o.ProjectName + if projectName != "" { + _path = strings.Replace(_path, "{project_name}", projectName, -1) + } else { + return nil, errors.New("projectName is required on DeleteArtifactURL") + } + + reference := o.Reference + if reference != "" { + _path = strings.Replace(_path, "{reference}", reference, -1) + } else { + return nil, errors.New("reference is required on DeleteArtifactURL") + } + + repositoryName := o.RepositoryName + if repositoryName != "" { + _path = strings.Replace(_path, "{repository_name}", repositoryName, -1) + } else { + return nil, errors.New("repositoryName is required on DeleteArtifactURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteArtifactURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteArtifactURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteArtifactURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteArtifactURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteArtifactURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteArtifactURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/artifact/delete_tag.go b/src/server/v2.0/restapi/operations/artifact/delete_tag.go new file mode 100644 index 000000000..6ce146c50 --- /dev/null +++ b/src/server/v2.0/restapi/operations/artifact/delete_tag.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteTagHandlerFunc turns a function with the right signature into a delete tag handler +type DeleteTagHandlerFunc func(DeleteTagParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteTagHandlerFunc) Handle(params DeleteTagParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteTagHandler interface for that can handle valid delete tag params +type DeleteTagHandler interface { + Handle(DeleteTagParams, interface{}) middleware.Responder +} + +// NewDeleteTag creates a new http.Handler for the delete tag operation +func NewDeleteTag(ctx *middleware.Context, handler DeleteTagHandler) *DeleteTag { + return &DeleteTag{Context: ctx, Handler: handler} +} + +/*DeleteTag swagger:route DELETE /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/tags/{tag_name} artifact deleteTag + +Delete tag + +Delete the tag of the specified artifact + +*/ +type DeleteTag struct { + Context *middleware.Context + Handler DeleteTagHandler +} + +func (o *DeleteTag) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewDeleteTagParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/artifact/delete_tag_parameters.go b/src/server/v2.0/restapi/operations/artifact/delete_tag_parameters.go new file mode 100644 index 000000000..01f9b1f83 --- /dev/null +++ b/src/server/v2.0/restapi/operations/artifact/delete_tag_parameters.go @@ -0,0 +1,189 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewDeleteTagParams creates a new DeleteTagParams object +// no default values defined in spec. +func NewDeleteTagParams() DeleteTagParams { + + return DeleteTagParams{} +} + +// DeleteTagParams contains all the bound params for the delete tag operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteTag +type DeleteTagParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The name of the project + Required: true + In: path + */ + ProjectName string + /*The reference of the artifact, can be digest or tag + Required: true + In: path + */ + Reference string + /*The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -> a%252Fb + Required: true + In: path + */ + RepositoryName string + /*The name of the tag + Required: true + In: path + */ + TagName string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteTagParams() beforehand. +func (o *DeleteTagParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rProjectName, rhkProjectName, _ := route.Params.GetOK("project_name") + if err := o.bindProjectName(rProjectName, rhkProjectName, route.Formats); err != nil { + res = append(res, err) + } + + rReference, rhkReference, _ := route.Params.GetOK("reference") + if err := o.bindReference(rReference, rhkReference, route.Formats); err != nil { + res = append(res, err) + } + + rRepositoryName, rhkRepositoryName, _ := route.Params.GetOK("repository_name") + if err := o.bindRepositoryName(rRepositoryName, rhkRepositoryName, route.Formats); err != nil { + res = append(res, err) + } + + rTagName, rhkTagName, _ := route.Params.GetOK("tag_name") + if err := o.bindTagName(rTagName, rhkTagName, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *DeleteTagParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *DeleteTagParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindProjectName binds and validates parameter ProjectName from path. +func (o *DeleteTagParams) bindProjectName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectName = raw + + return nil +} + +// bindReference binds and validates parameter Reference from path. +func (o *DeleteTagParams) bindReference(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.Reference = raw + + return nil +} + +// bindRepositoryName binds and validates parameter RepositoryName from path. +func (o *DeleteTagParams) bindRepositoryName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.RepositoryName = raw + + return nil +} + +// bindTagName binds and validates parameter TagName from path. +func (o *DeleteTagParams) bindTagName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.TagName = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/artifact/delete_tag_responses.go b/src/server/v2.0/restapi/operations/artifact/delete_tag_responses.go new file mode 100644 index 000000000..e26a15177 --- /dev/null +++ b/src/server/v2.0/restapi/operations/artifact/delete_tag_responses.go @@ -0,0 +1,324 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// DeleteTagOKCode is the HTTP code returned for type DeleteTagOK +const DeleteTagOKCode int = 200 + +/*DeleteTagOK Success + +swagger:response deleteTagOK +*/ +type DeleteTagOK struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewDeleteTagOK creates DeleteTagOK with default headers values +func NewDeleteTagOK() *DeleteTagOK { + + return &DeleteTagOK{} +} + +// WithXRequestID adds the xRequestId to the delete tag o k response +func (o *DeleteTagOK) WithXRequestID(xRequestID string) *DeleteTagOK { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete tag o k response +func (o *DeleteTagOK) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *DeleteTagOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// DeleteTagUnauthorizedCode is the HTTP code returned for type DeleteTagUnauthorized +const DeleteTagUnauthorizedCode int = 401 + +/*DeleteTagUnauthorized Unauthorized + +swagger:response deleteTagUnauthorized +*/ +type DeleteTagUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteTagUnauthorized creates DeleteTagUnauthorized with default headers values +func NewDeleteTagUnauthorized() *DeleteTagUnauthorized { + + return &DeleteTagUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the delete tag unauthorized response +func (o *DeleteTagUnauthorized) WithXRequestID(xRequestID string) *DeleteTagUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete tag unauthorized response +func (o *DeleteTagUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete tag unauthorized response +func (o *DeleteTagUnauthorized) WithPayload(payload *models.Errors) *DeleteTagUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete tag unauthorized response +func (o *DeleteTagUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteTagUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteTagForbiddenCode is the HTTP code returned for type DeleteTagForbidden +const DeleteTagForbiddenCode int = 403 + +/*DeleteTagForbidden Forbidden + +swagger:response deleteTagForbidden +*/ +type DeleteTagForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteTagForbidden creates DeleteTagForbidden with default headers values +func NewDeleteTagForbidden() *DeleteTagForbidden { + + return &DeleteTagForbidden{} +} + +// WithXRequestID adds the xRequestId to the delete tag forbidden response +func (o *DeleteTagForbidden) WithXRequestID(xRequestID string) *DeleteTagForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete tag forbidden response +func (o *DeleteTagForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete tag forbidden response +func (o *DeleteTagForbidden) WithPayload(payload *models.Errors) *DeleteTagForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete tag forbidden response +func (o *DeleteTagForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteTagForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteTagNotFoundCode is the HTTP code returned for type DeleteTagNotFound +const DeleteTagNotFoundCode int = 404 + +/*DeleteTagNotFound Not found + +swagger:response deleteTagNotFound +*/ +type DeleteTagNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteTagNotFound creates DeleteTagNotFound with default headers values +func NewDeleteTagNotFound() *DeleteTagNotFound { + + return &DeleteTagNotFound{} +} + +// WithXRequestID adds the xRequestId to the delete tag not found response +func (o *DeleteTagNotFound) WithXRequestID(xRequestID string) *DeleteTagNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete tag not found response +func (o *DeleteTagNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete tag not found response +func (o *DeleteTagNotFound) WithPayload(payload *models.Errors) *DeleteTagNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete tag not found response +func (o *DeleteTagNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteTagNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteTagInternalServerErrorCode is the HTTP code returned for type DeleteTagInternalServerError +const DeleteTagInternalServerErrorCode int = 500 + +/*DeleteTagInternalServerError Internal server error + +swagger:response deleteTagInternalServerError +*/ +type DeleteTagInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteTagInternalServerError creates DeleteTagInternalServerError with default headers values +func NewDeleteTagInternalServerError() *DeleteTagInternalServerError { + + return &DeleteTagInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the delete tag internal server error response +func (o *DeleteTagInternalServerError) WithXRequestID(xRequestID string) *DeleteTagInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete tag internal server error response +func (o *DeleteTagInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete tag internal server error response +func (o *DeleteTagInternalServerError) WithPayload(payload *models.Errors) *DeleteTagInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete tag internal server error response +func (o *DeleteTagInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteTagInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/artifact/delete_tag_urlbuilder.go b/src/server/v2.0/restapi/operations/artifact/delete_tag_urlbuilder.go new file mode 100644 index 000000000..0d44dd4b8 --- /dev/null +++ b/src/server/v2.0/restapi/operations/artifact/delete_tag_urlbuilder.go @@ -0,0 +1,123 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// DeleteTagURL generates an URL for the delete tag operation +type DeleteTagURL struct { + ProjectName string + Reference string + RepositoryName string + TagName string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteTagURL) WithBasePath(bp string) *DeleteTagURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteTagURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteTagURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/tags/{tag_name}" + + projectName := o.ProjectName + if projectName != "" { + _path = strings.Replace(_path, "{project_name}", projectName, -1) + } else { + return nil, errors.New("projectName is required on DeleteTagURL") + } + + reference := o.Reference + if reference != "" { + _path = strings.Replace(_path, "{reference}", reference, -1) + } else { + return nil, errors.New("reference is required on DeleteTagURL") + } + + repositoryName := o.RepositoryName + if repositoryName != "" { + _path = strings.Replace(_path, "{repository_name}", repositoryName, -1) + } else { + return nil, errors.New("repositoryName is required on DeleteTagURL") + } + + tagName := o.TagName + if tagName != "" { + _path = strings.Replace(_path, "{tag_name}", tagName, -1) + } else { + return nil, errors.New("tagName is required on DeleteTagURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteTagURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteTagURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteTagURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteTagURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteTagURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteTagURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/artifact/get_addition.go b/src/server/v2.0/restapi/operations/artifact/get_addition.go new file mode 100644 index 000000000..1c3885a8d --- /dev/null +++ b/src/server/v2.0/restapi/operations/artifact/get_addition.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAdditionHandlerFunc turns a function with the right signature into a get addition handler +type GetAdditionHandlerFunc func(GetAdditionParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAdditionHandlerFunc) Handle(params GetAdditionParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAdditionHandler interface for that can handle valid get addition params +type GetAdditionHandler interface { + Handle(GetAdditionParams, interface{}) middleware.Responder +} + +// NewGetAddition creates a new http.Handler for the get addition operation +func NewGetAddition(ctx *middleware.Context, handler GetAdditionHandler) *GetAddition { + return &GetAddition{Context: ctx, Handler: handler} +} + +/*GetAddition swagger:route GET /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/additions/{addition} artifact getAddition + +Get the addition of the specific artifact + +Get the addition of the artifact specified by the reference under the project and repository. + +*/ +type GetAddition struct { + Context *middleware.Context + Handler GetAdditionHandler +} + +func (o *GetAddition) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetAdditionParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/artifact/get_addition_parameters.go b/src/server/v2.0/restapi/operations/artifact/get_addition_parameters.go new file mode 100644 index 000000000..ec70445d7 --- /dev/null +++ b/src/server/v2.0/restapi/operations/artifact/get_addition_parameters.go @@ -0,0 +1,203 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewGetAdditionParams creates a new GetAdditionParams object +// no default values defined in spec. +func NewGetAdditionParams() GetAdditionParams { + + return GetAdditionParams{} +} + +// GetAdditionParams contains all the bound params for the get addition operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAddition +type GetAdditionParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The type of addition. + Required: true + In: path + */ + Addition string + /*The name of the project + Required: true + In: path + */ + ProjectName string + /*The reference of the artifact, can be digest or tag + Required: true + In: path + */ + Reference string + /*The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -> a%252Fb + Required: true + In: path + */ + RepositoryName string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAdditionParams() beforehand. +func (o *GetAdditionParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rAddition, rhkAddition, _ := route.Params.GetOK("addition") + if err := o.bindAddition(rAddition, rhkAddition, route.Formats); err != nil { + res = append(res, err) + } + + rProjectName, rhkProjectName, _ := route.Params.GetOK("project_name") + if err := o.bindProjectName(rProjectName, rhkProjectName, route.Formats); err != nil { + res = append(res, err) + } + + rReference, rhkReference, _ := route.Params.GetOK("reference") + if err := o.bindReference(rReference, rhkReference, route.Formats); err != nil { + res = append(res, err) + } + + rRepositoryName, rhkRepositoryName, _ := route.Params.GetOK("repository_name") + if err := o.bindRepositoryName(rRepositoryName, rhkRepositoryName, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetAdditionParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetAdditionParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindAddition binds and validates parameter Addition from path. +func (o *GetAdditionParams) bindAddition(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.Addition = raw + + if err := o.validateAddition(formats); err != nil { + return err + } + + return nil +} + +// validateAddition carries on validations for parameter Addition +func (o *GetAdditionParams) validateAddition(formats strfmt.Registry) error { + + if err := validate.EnumCase("addition", "path", o.Addition, []interface{}{"build_history", "values.yaml", "readme.md", "dependencies"}, true); err != nil { + return err + } + + return nil +} + +// bindProjectName binds and validates parameter ProjectName from path. +func (o *GetAdditionParams) bindProjectName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectName = raw + + return nil +} + +// bindReference binds and validates parameter Reference from path. +func (o *GetAdditionParams) bindReference(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.Reference = raw + + return nil +} + +// bindRepositoryName binds and validates parameter RepositoryName from path. +func (o *GetAdditionParams) bindRepositoryName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.RepositoryName = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/artifact/get_addition_responses.go b/src/server/v2.0/restapi/operations/artifact/get_addition_responses.go new file mode 100644 index 000000000..bb060ca58 --- /dev/null +++ b/src/server/v2.0/restapi/operations/artifact/get_addition_responses.go @@ -0,0 +1,408 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetAdditionOKCode is the HTTP code returned for type GetAdditionOK +const GetAdditionOKCode int = 200 + +/*GetAdditionOK Success + +swagger:response getAdditionOK +*/ +type GetAdditionOK struct { + /*The content type of the addition + + */ + ContentType string `json:"Content-Type"` + + /* + In: Body + */ + Payload string `json:"body,omitempty"` +} + +// NewGetAdditionOK creates GetAdditionOK with default headers values +func NewGetAdditionOK() *GetAdditionOK { + + return &GetAdditionOK{} +} + +// WithContentType adds the contentType to the get addition o k response +func (o *GetAdditionOK) WithContentType(contentType string) *GetAdditionOK { + o.ContentType = contentType + return o +} + +// SetContentType sets the contentType to the get addition o k response +func (o *GetAdditionOK) SetContentType(contentType string) { + o.ContentType = contentType +} + +// WithPayload adds the payload to the get addition o k response +func (o *GetAdditionOK) WithPayload(payload string) *GetAdditionOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get addition o k response +func (o *GetAdditionOK) SetPayload(payload string) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAdditionOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Content-Type + + contentType := o.ContentType + if contentType != "" { + rw.Header().Set("Content-Type", contentType) + } + + rw.WriteHeader(200) + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// GetAdditionBadRequestCode is the HTTP code returned for type GetAdditionBadRequest +const GetAdditionBadRequestCode int = 400 + +/*GetAdditionBadRequest Bad request + +swagger:response getAdditionBadRequest +*/ +type GetAdditionBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetAdditionBadRequest creates GetAdditionBadRequest with default headers values +func NewGetAdditionBadRequest() *GetAdditionBadRequest { + + return &GetAdditionBadRequest{} +} + +// WithXRequestID adds the xRequestId to the get addition bad request response +func (o *GetAdditionBadRequest) WithXRequestID(xRequestID string) *GetAdditionBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get addition bad request response +func (o *GetAdditionBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get addition bad request response +func (o *GetAdditionBadRequest) WithPayload(payload *models.Errors) *GetAdditionBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get addition bad request response +func (o *GetAdditionBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAdditionBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetAdditionUnauthorizedCode is the HTTP code returned for type GetAdditionUnauthorized +const GetAdditionUnauthorizedCode int = 401 + +/*GetAdditionUnauthorized Unauthorized + +swagger:response getAdditionUnauthorized +*/ +type GetAdditionUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetAdditionUnauthorized creates GetAdditionUnauthorized with default headers values +func NewGetAdditionUnauthorized() *GetAdditionUnauthorized { + + return &GetAdditionUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the get addition unauthorized response +func (o *GetAdditionUnauthorized) WithXRequestID(xRequestID string) *GetAdditionUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get addition unauthorized response +func (o *GetAdditionUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get addition unauthorized response +func (o *GetAdditionUnauthorized) WithPayload(payload *models.Errors) *GetAdditionUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get addition unauthorized response +func (o *GetAdditionUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAdditionUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetAdditionForbiddenCode is the HTTP code returned for type GetAdditionForbidden +const GetAdditionForbiddenCode int = 403 + +/*GetAdditionForbidden Forbidden + +swagger:response getAdditionForbidden +*/ +type GetAdditionForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetAdditionForbidden creates GetAdditionForbidden with default headers values +func NewGetAdditionForbidden() *GetAdditionForbidden { + + return &GetAdditionForbidden{} +} + +// WithXRequestID adds the xRequestId to the get addition forbidden response +func (o *GetAdditionForbidden) WithXRequestID(xRequestID string) *GetAdditionForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get addition forbidden response +func (o *GetAdditionForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get addition forbidden response +func (o *GetAdditionForbidden) WithPayload(payload *models.Errors) *GetAdditionForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get addition forbidden response +func (o *GetAdditionForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAdditionForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetAdditionNotFoundCode is the HTTP code returned for type GetAdditionNotFound +const GetAdditionNotFoundCode int = 404 + +/*GetAdditionNotFound Not found + +swagger:response getAdditionNotFound +*/ +type GetAdditionNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetAdditionNotFound creates GetAdditionNotFound with default headers values +func NewGetAdditionNotFound() *GetAdditionNotFound { + + return &GetAdditionNotFound{} +} + +// WithXRequestID adds the xRequestId to the get addition not found response +func (o *GetAdditionNotFound) WithXRequestID(xRequestID string) *GetAdditionNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get addition not found response +func (o *GetAdditionNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get addition not found response +func (o *GetAdditionNotFound) WithPayload(payload *models.Errors) *GetAdditionNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get addition not found response +func (o *GetAdditionNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAdditionNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetAdditionInternalServerErrorCode is the HTTP code returned for type GetAdditionInternalServerError +const GetAdditionInternalServerErrorCode int = 500 + +/*GetAdditionInternalServerError Internal server error + +swagger:response getAdditionInternalServerError +*/ +type GetAdditionInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetAdditionInternalServerError creates GetAdditionInternalServerError with default headers values +func NewGetAdditionInternalServerError() *GetAdditionInternalServerError { + + return &GetAdditionInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get addition internal server error response +func (o *GetAdditionInternalServerError) WithXRequestID(xRequestID string) *GetAdditionInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get addition internal server error response +func (o *GetAdditionInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get addition internal server error response +func (o *GetAdditionInternalServerError) WithPayload(payload *models.Errors) *GetAdditionInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get addition internal server error response +func (o *GetAdditionInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAdditionInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/artifact/get_addition_urlbuilder.go b/src/server/v2.0/restapi/operations/artifact/get_addition_urlbuilder.go new file mode 100644 index 000000000..18f81ff54 --- /dev/null +++ b/src/server/v2.0/restapi/operations/artifact/get_addition_urlbuilder.go @@ -0,0 +1,123 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetAdditionURL generates an URL for the get addition operation +type GetAdditionURL struct { + Addition string + ProjectName string + Reference string + RepositoryName string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAdditionURL) WithBasePath(bp string) *GetAdditionURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAdditionURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAdditionURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/additions/{addition}" + + addition := o.Addition + if addition != "" { + _path = strings.Replace(_path, "{addition}", addition, -1) + } else { + return nil, errors.New("addition is required on GetAdditionURL") + } + + projectName := o.ProjectName + if projectName != "" { + _path = strings.Replace(_path, "{project_name}", projectName, -1) + } else { + return nil, errors.New("projectName is required on GetAdditionURL") + } + + reference := o.Reference + if reference != "" { + _path = strings.Replace(_path, "{reference}", reference, -1) + } else { + return nil, errors.New("reference is required on GetAdditionURL") + } + + repositoryName := o.RepositoryName + if repositoryName != "" { + _path = strings.Replace(_path, "{repository_name}", repositoryName, -1) + } else { + return nil, errors.New("repositoryName is required on GetAdditionURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAdditionURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAdditionURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAdditionURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAdditionURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAdditionURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAdditionURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/artifact/get_artifact.go b/src/server/v2.0/restapi/operations/artifact/get_artifact.go new file mode 100644 index 000000000..aa8e4ca35 --- /dev/null +++ b/src/server/v2.0/restapi/operations/artifact/get_artifact.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetArtifactHandlerFunc turns a function with the right signature into a get artifact handler +type GetArtifactHandlerFunc func(GetArtifactParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetArtifactHandlerFunc) Handle(params GetArtifactParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetArtifactHandler interface for that can handle valid get artifact params +type GetArtifactHandler interface { + Handle(GetArtifactParams, interface{}) middleware.Responder +} + +// NewGetArtifact creates a new http.Handler for the get artifact operation +func NewGetArtifact(ctx *middleware.Context, handler GetArtifactHandler) *GetArtifact { + return &GetArtifact{Context: ctx, Handler: handler} +} + +/*GetArtifact swagger:route GET /projects/{project_name}/repositories/{repository_name}/artifacts/{reference} artifact getArtifact + +Get the specific artifact + +Get the artifact specified by the reference under the project and repository. The reference can be digest or tag. + +*/ +type GetArtifact struct { + Context *middleware.Context + Handler GetArtifactHandler +} + +func (o *GetArtifact) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetArtifactParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/artifact/get_artifact_parameters.go b/src/server/v2.0/restapi/operations/artifact/get_artifact_parameters.go new file mode 100644 index 000000000..25319ae93 --- /dev/null +++ b/src/server/v2.0/restapi/operations/artifact/get_artifact_parameters.go @@ -0,0 +1,510 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewGetArtifactParams creates a new GetArtifactParams object +// with the default values initialized. +func NewGetArtifactParams() GetArtifactParams { + + var ( + // initialize parameters with default values + + xAcceptVulnerabilitiesDefault = string("application/vnd.security.vulnerability.report; version=1.1, application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0") + + pageDefault = int64(1) + pageSizeDefault = int64(10) + + withAccessoryDefault = bool(false) + withImmutableStatusDefault = bool(false) + withLabelDefault = bool(false) + withScanOverviewDefault = bool(false) + withSignatureDefault = bool(false) + withTagDefault = bool(true) + ) + + return GetArtifactParams{ + XAcceptVulnerabilities: &xAcceptVulnerabilitiesDefault, + + Page: &pageDefault, + + PageSize: &pageSizeDefault, + + WithAccessory: &withAccessoryDefault, + + WithImmutableStatus: &withImmutableStatusDefault, + + WithLabel: &withLabelDefault, + + WithScanOverview: &withScanOverviewDefault, + + WithSignature: &withSignatureDefault, + + WithTag: &withTagDefault, + } +} + +// GetArtifactParams contains all the bound params for the get artifact operation +// typically these are obtained from a http.Request +// +// swagger:parameters getArtifact +type GetArtifactParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*A comma-separated lists of MIME types for the scan report or scan summary. The first mime type will be used when the report found for it. + Currently the mime type supports 'application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0' and 'application/vnd.security.vulnerability.report; version=1.1' + In: header + Default: "application/vnd.security.vulnerability.report; version=1.1, application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0" + */ + XAcceptVulnerabilities *string + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The page number + In: query + Default: 1 + */ + Page *int64 + /*The size of per page + Maximum: 100 + In: query + Default: 10 + */ + PageSize *int64 + /*The name of the project + Required: true + In: path + */ + ProjectName string + /*The reference of the artifact, can be digest or tag + Required: true + In: path + */ + Reference string + /*The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -> a%252Fb + Required: true + In: path + */ + RepositoryName string + /*Specify whether the accessories are included of the returning artifacts. + In: query + Default: false + */ + WithAccessory *bool + /*Specify whether the immutable status is inclued inside the tags of the returning artifacts. + In: query + Default: false + */ + WithImmutableStatus *bool + /*Specify whether the labels are inclued inside the returning artifacts + In: query + Default: false + */ + WithLabel *bool + /*Specify whether the scan overview is inclued inside the returning artifacts + In: query + Default: false + */ + WithScanOverview *bool + /*Specify whether the signature is inclued inside the returning artifacts + In: query + Default: false + */ + WithSignature *bool + /*Specify whether the tags are inclued inside the returning artifacts + In: query + Default: true + */ + WithTag *bool +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetArtifactParams() beforehand. +func (o *GetArtifactParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if err := o.bindXAcceptVulnerabilities(r.Header[http.CanonicalHeaderKey("X-Accept-Vulnerabilities")], true, route.Formats); err != nil { + res = append(res, err) + } + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + qPage, qhkPage, _ := qs.GetOK("page") + if err := o.bindPage(qPage, qhkPage, route.Formats); err != nil { + res = append(res, err) + } + + qPageSize, qhkPageSize, _ := qs.GetOK("page_size") + if err := o.bindPageSize(qPageSize, qhkPageSize, route.Formats); err != nil { + res = append(res, err) + } + + rProjectName, rhkProjectName, _ := route.Params.GetOK("project_name") + if err := o.bindProjectName(rProjectName, rhkProjectName, route.Formats); err != nil { + res = append(res, err) + } + + rReference, rhkReference, _ := route.Params.GetOK("reference") + if err := o.bindReference(rReference, rhkReference, route.Formats); err != nil { + res = append(res, err) + } + + rRepositoryName, rhkRepositoryName, _ := route.Params.GetOK("repository_name") + if err := o.bindRepositoryName(rRepositoryName, rhkRepositoryName, route.Formats); err != nil { + res = append(res, err) + } + + qWithAccessory, qhkWithAccessory, _ := qs.GetOK("with_accessory") + if err := o.bindWithAccessory(qWithAccessory, qhkWithAccessory, route.Formats); err != nil { + res = append(res, err) + } + + qWithImmutableStatus, qhkWithImmutableStatus, _ := qs.GetOK("with_immutable_status") + if err := o.bindWithImmutableStatus(qWithImmutableStatus, qhkWithImmutableStatus, route.Formats); err != nil { + res = append(res, err) + } + + qWithLabel, qhkWithLabel, _ := qs.GetOK("with_label") + if err := o.bindWithLabel(qWithLabel, qhkWithLabel, route.Formats); err != nil { + res = append(res, err) + } + + qWithScanOverview, qhkWithScanOverview, _ := qs.GetOK("with_scan_overview") + if err := o.bindWithScanOverview(qWithScanOverview, qhkWithScanOverview, route.Formats); err != nil { + res = append(res, err) + } + + qWithSignature, qhkWithSignature, _ := qs.GetOK("with_signature") + if err := o.bindWithSignature(qWithSignature, qhkWithSignature, route.Formats); err != nil { + res = append(res, err) + } + + qWithTag, qhkWithTag, _ := qs.GetOK("with_tag") + if err := o.bindWithTag(qWithTag, qhkWithTag, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXAcceptVulnerabilities binds and validates parameter XAcceptVulnerabilities from header. +func (o *GetArtifactParams) bindXAcceptVulnerabilities(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewGetArtifactParams() + return nil + } + + o.XAcceptVulnerabilities = &raw + + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetArtifactParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetArtifactParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindPage binds and validates parameter Page from query. +func (o *GetArtifactParams) bindPage(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewGetArtifactParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page", "query", "int64", raw) + } + o.Page = &value + + return nil +} + +// bindPageSize binds and validates parameter PageSize from query. +func (o *GetArtifactParams) bindPageSize(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewGetArtifactParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page_size", "query", "int64", raw) + } + o.PageSize = &value + + if err := o.validatePageSize(formats); err != nil { + return err + } + + return nil +} + +// validatePageSize carries on validations for parameter PageSize +func (o *GetArtifactParams) validatePageSize(formats strfmt.Registry) error { + + if err := validate.MaximumInt("page_size", "query", int64(*o.PageSize), 100, false); err != nil { + return err + } + + return nil +} + +// bindProjectName binds and validates parameter ProjectName from path. +func (o *GetArtifactParams) bindProjectName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectName = raw + + return nil +} + +// bindReference binds and validates parameter Reference from path. +func (o *GetArtifactParams) bindReference(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.Reference = raw + + return nil +} + +// bindRepositoryName binds and validates parameter RepositoryName from path. +func (o *GetArtifactParams) bindRepositoryName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.RepositoryName = raw + + return nil +} + +// bindWithAccessory binds and validates parameter WithAccessory from query. +func (o *GetArtifactParams) bindWithAccessory(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewGetArtifactParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("with_accessory", "query", "bool", raw) + } + o.WithAccessory = &value + + return nil +} + +// bindWithImmutableStatus binds and validates parameter WithImmutableStatus from query. +func (o *GetArtifactParams) bindWithImmutableStatus(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewGetArtifactParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("with_immutable_status", "query", "bool", raw) + } + o.WithImmutableStatus = &value + + return nil +} + +// bindWithLabel binds and validates parameter WithLabel from query. +func (o *GetArtifactParams) bindWithLabel(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewGetArtifactParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("with_label", "query", "bool", raw) + } + o.WithLabel = &value + + return nil +} + +// bindWithScanOverview binds and validates parameter WithScanOverview from query. +func (o *GetArtifactParams) bindWithScanOverview(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewGetArtifactParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("with_scan_overview", "query", "bool", raw) + } + o.WithScanOverview = &value + + return nil +} + +// bindWithSignature binds and validates parameter WithSignature from query. +func (o *GetArtifactParams) bindWithSignature(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewGetArtifactParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("with_signature", "query", "bool", raw) + } + o.WithSignature = &value + + return nil +} + +// bindWithTag binds and validates parameter WithTag from query. +func (o *GetArtifactParams) bindWithTag(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewGetArtifactParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("with_tag", "query", "bool", raw) + } + o.WithTag = &value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/artifact/get_artifact_responses.go b/src/server/v2.0/restapi/operations/artifact/get_artifact_responses.go new file mode 100644 index 000000000..3a3be6652 --- /dev/null +++ b/src/server/v2.0/restapi/operations/artifact/get_artifact_responses.go @@ -0,0 +1,388 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetArtifactOKCode is the HTTP code returned for type GetArtifactOK +const GetArtifactOKCode int = 200 + +/*GetArtifactOK Success + +swagger:response getArtifactOK +*/ +type GetArtifactOK struct { + + /* + In: Body + */ + Payload *models.Artifact `json:"body,omitempty"` +} + +// NewGetArtifactOK creates GetArtifactOK with default headers values +func NewGetArtifactOK() *GetArtifactOK { + + return &GetArtifactOK{} +} + +// WithPayload adds the payload to the get artifact o k response +func (o *GetArtifactOK) WithPayload(payload *models.Artifact) *GetArtifactOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get artifact o k response +func (o *GetArtifactOK) SetPayload(payload *models.Artifact) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetArtifactOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetArtifactBadRequestCode is the HTTP code returned for type GetArtifactBadRequest +const GetArtifactBadRequestCode int = 400 + +/*GetArtifactBadRequest Bad request + +swagger:response getArtifactBadRequest +*/ +type GetArtifactBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetArtifactBadRequest creates GetArtifactBadRequest with default headers values +func NewGetArtifactBadRequest() *GetArtifactBadRequest { + + return &GetArtifactBadRequest{} +} + +// WithXRequestID adds the xRequestId to the get artifact bad request response +func (o *GetArtifactBadRequest) WithXRequestID(xRequestID string) *GetArtifactBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get artifact bad request response +func (o *GetArtifactBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get artifact bad request response +func (o *GetArtifactBadRequest) WithPayload(payload *models.Errors) *GetArtifactBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get artifact bad request response +func (o *GetArtifactBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetArtifactBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetArtifactUnauthorizedCode is the HTTP code returned for type GetArtifactUnauthorized +const GetArtifactUnauthorizedCode int = 401 + +/*GetArtifactUnauthorized Unauthorized + +swagger:response getArtifactUnauthorized +*/ +type GetArtifactUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetArtifactUnauthorized creates GetArtifactUnauthorized with default headers values +func NewGetArtifactUnauthorized() *GetArtifactUnauthorized { + + return &GetArtifactUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the get artifact unauthorized response +func (o *GetArtifactUnauthorized) WithXRequestID(xRequestID string) *GetArtifactUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get artifact unauthorized response +func (o *GetArtifactUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get artifact unauthorized response +func (o *GetArtifactUnauthorized) WithPayload(payload *models.Errors) *GetArtifactUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get artifact unauthorized response +func (o *GetArtifactUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetArtifactUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetArtifactForbiddenCode is the HTTP code returned for type GetArtifactForbidden +const GetArtifactForbiddenCode int = 403 + +/*GetArtifactForbidden Forbidden + +swagger:response getArtifactForbidden +*/ +type GetArtifactForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetArtifactForbidden creates GetArtifactForbidden with default headers values +func NewGetArtifactForbidden() *GetArtifactForbidden { + + return &GetArtifactForbidden{} +} + +// WithXRequestID adds the xRequestId to the get artifact forbidden response +func (o *GetArtifactForbidden) WithXRequestID(xRequestID string) *GetArtifactForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get artifact forbidden response +func (o *GetArtifactForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get artifact forbidden response +func (o *GetArtifactForbidden) WithPayload(payload *models.Errors) *GetArtifactForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get artifact forbidden response +func (o *GetArtifactForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetArtifactForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetArtifactNotFoundCode is the HTTP code returned for type GetArtifactNotFound +const GetArtifactNotFoundCode int = 404 + +/*GetArtifactNotFound Not found + +swagger:response getArtifactNotFound +*/ +type GetArtifactNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetArtifactNotFound creates GetArtifactNotFound with default headers values +func NewGetArtifactNotFound() *GetArtifactNotFound { + + return &GetArtifactNotFound{} +} + +// WithXRequestID adds the xRequestId to the get artifact not found response +func (o *GetArtifactNotFound) WithXRequestID(xRequestID string) *GetArtifactNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get artifact not found response +func (o *GetArtifactNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get artifact not found response +func (o *GetArtifactNotFound) WithPayload(payload *models.Errors) *GetArtifactNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get artifact not found response +func (o *GetArtifactNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetArtifactNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetArtifactInternalServerErrorCode is the HTTP code returned for type GetArtifactInternalServerError +const GetArtifactInternalServerErrorCode int = 500 + +/*GetArtifactInternalServerError Internal server error + +swagger:response getArtifactInternalServerError +*/ +type GetArtifactInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetArtifactInternalServerError creates GetArtifactInternalServerError with default headers values +func NewGetArtifactInternalServerError() *GetArtifactInternalServerError { + + return &GetArtifactInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get artifact internal server error response +func (o *GetArtifactInternalServerError) WithXRequestID(xRequestID string) *GetArtifactInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get artifact internal server error response +func (o *GetArtifactInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get artifact internal server error response +func (o *GetArtifactInternalServerError) WithPayload(payload *models.Errors) *GetArtifactInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get artifact internal server error response +func (o *GetArtifactInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetArtifactInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/artifact/get_artifact_urlbuilder.go b/src/server/v2.0/restapi/operations/artifact/get_artifact_urlbuilder.go new file mode 100644 index 000000000..71fe781f5 --- /dev/null +++ b/src/server/v2.0/restapi/operations/artifact/get_artifact_urlbuilder.go @@ -0,0 +1,194 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetArtifactURL generates an URL for the get artifact operation +type GetArtifactURL struct { + ProjectName string + Reference string + RepositoryName string + + Page *int64 + PageSize *int64 + WithAccessory *bool + WithImmutableStatus *bool + WithLabel *bool + WithScanOverview *bool + WithSignature *bool + WithTag *bool + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetArtifactURL) WithBasePath(bp string) *GetArtifactURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetArtifactURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetArtifactURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}" + + projectName := o.ProjectName + if projectName != "" { + _path = strings.Replace(_path, "{project_name}", projectName, -1) + } else { + return nil, errors.New("projectName is required on GetArtifactURL") + } + + reference := o.Reference + if reference != "" { + _path = strings.Replace(_path, "{reference}", reference, -1) + } else { + return nil, errors.New("reference is required on GetArtifactURL") + } + + repositoryName := o.RepositoryName + if repositoryName != "" { + _path = strings.Replace(_path, "{repository_name}", repositoryName, -1) + } else { + return nil, errors.New("repositoryName is required on GetArtifactURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var pageQ string + if o.Page != nil { + pageQ = swag.FormatInt64(*o.Page) + } + if pageQ != "" { + qs.Set("page", pageQ) + } + + var pageSizeQ string + if o.PageSize != nil { + pageSizeQ = swag.FormatInt64(*o.PageSize) + } + if pageSizeQ != "" { + qs.Set("page_size", pageSizeQ) + } + + var withAccessoryQ string + if o.WithAccessory != nil { + withAccessoryQ = swag.FormatBool(*o.WithAccessory) + } + if withAccessoryQ != "" { + qs.Set("with_accessory", withAccessoryQ) + } + + var withImmutableStatusQ string + if o.WithImmutableStatus != nil { + withImmutableStatusQ = swag.FormatBool(*o.WithImmutableStatus) + } + if withImmutableStatusQ != "" { + qs.Set("with_immutable_status", withImmutableStatusQ) + } + + var withLabelQ string + if o.WithLabel != nil { + withLabelQ = swag.FormatBool(*o.WithLabel) + } + if withLabelQ != "" { + qs.Set("with_label", withLabelQ) + } + + var withScanOverviewQ string + if o.WithScanOverview != nil { + withScanOverviewQ = swag.FormatBool(*o.WithScanOverview) + } + if withScanOverviewQ != "" { + qs.Set("with_scan_overview", withScanOverviewQ) + } + + var withSignatureQ string + if o.WithSignature != nil { + withSignatureQ = swag.FormatBool(*o.WithSignature) + } + if withSignatureQ != "" { + qs.Set("with_signature", withSignatureQ) + } + + var withTagQ string + if o.WithTag != nil { + withTagQ = swag.FormatBool(*o.WithTag) + } + if withTagQ != "" { + qs.Set("with_tag", withTagQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetArtifactURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetArtifactURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetArtifactURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetArtifactURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetArtifactURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetArtifactURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/artifact/get_vulnerabilities_addition.go b/src/server/v2.0/restapi/operations/artifact/get_vulnerabilities_addition.go new file mode 100644 index 000000000..3688b12d8 --- /dev/null +++ b/src/server/v2.0/restapi/operations/artifact/get_vulnerabilities_addition.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetVulnerabilitiesAdditionHandlerFunc turns a function with the right signature into a get vulnerabilities addition handler +type GetVulnerabilitiesAdditionHandlerFunc func(GetVulnerabilitiesAdditionParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetVulnerabilitiesAdditionHandlerFunc) Handle(params GetVulnerabilitiesAdditionParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetVulnerabilitiesAdditionHandler interface for that can handle valid get vulnerabilities addition params +type GetVulnerabilitiesAdditionHandler interface { + Handle(GetVulnerabilitiesAdditionParams, interface{}) middleware.Responder +} + +// NewGetVulnerabilitiesAddition creates a new http.Handler for the get vulnerabilities addition operation +func NewGetVulnerabilitiesAddition(ctx *middleware.Context, handler GetVulnerabilitiesAdditionHandler) *GetVulnerabilitiesAddition { + return &GetVulnerabilitiesAddition{Context: ctx, Handler: handler} +} + +/*GetVulnerabilitiesAddition swagger:route GET /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/additions/vulnerabilities artifact getVulnerabilitiesAddition + +Get the vulnerabilities addition of the specific artifact + +Get the vulnerabilities addition of the artifact specified by the reference under the project and repository. + +*/ +type GetVulnerabilitiesAddition struct { + Context *middleware.Context + Handler GetVulnerabilitiesAdditionHandler +} + +func (o *GetVulnerabilitiesAddition) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetVulnerabilitiesAdditionParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/artifact/get_vulnerabilities_addition_parameters.go b/src/server/v2.0/restapi/operations/artifact/get_vulnerabilities_addition_parameters.go new file mode 100644 index 000000000..841c1da82 --- /dev/null +++ b/src/server/v2.0/restapi/operations/artifact/get_vulnerabilities_addition_parameters.go @@ -0,0 +1,201 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewGetVulnerabilitiesAdditionParams creates a new GetVulnerabilitiesAdditionParams object +// with the default values initialized. +func NewGetVulnerabilitiesAdditionParams() GetVulnerabilitiesAdditionParams { + + var ( + // initialize parameters with default values + + xAcceptVulnerabilitiesDefault = string("application/vnd.security.vulnerability.report; version=1.1, application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0") + ) + + return GetVulnerabilitiesAdditionParams{ + XAcceptVulnerabilities: &xAcceptVulnerabilitiesDefault, + } +} + +// GetVulnerabilitiesAdditionParams contains all the bound params for the get vulnerabilities addition operation +// typically these are obtained from a http.Request +// +// swagger:parameters getVulnerabilitiesAddition +type GetVulnerabilitiesAdditionParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*A comma-separated lists of MIME types for the scan report or scan summary. The first mime type will be used when the report found for it. + Currently the mime type supports 'application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0' and 'application/vnd.security.vulnerability.report; version=1.1' + In: header + Default: "application/vnd.security.vulnerability.report; version=1.1, application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0" + */ + XAcceptVulnerabilities *string + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The name of the project + Required: true + In: path + */ + ProjectName string + /*The reference of the artifact, can be digest or tag + Required: true + In: path + */ + Reference string + /*The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -> a%252Fb + Required: true + In: path + */ + RepositoryName string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetVulnerabilitiesAdditionParams() beforehand. +func (o *GetVulnerabilitiesAdditionParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXAcceptVulnerabilities(r.Header[http.CanonicalHeaderKey("X-Accept-Vulnerabilities")], true, route.Formats); err != nil { + res = append(res, err) + } + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rProjectName, rhkProjectName, _ := route.Params.GetOK("project_name") + if err := o.bindProjectName(rProjectName, rhkProjectName, route.Formats); err != nil { + res = append(res, err) + } + + rReference, rhkReference, _ := route.Params.GetOK("reference") + if err := o.bindReference(rReference, rhkReference, route.Formats); err != nil { + res = append(res, err) + } + + rRepositoryName, rhkRepositoryName, _ := route.Params.GetOK("repository_name") + if err := o.bindRepositoryName(rRepositoryName, rhkRepositoryName, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXAcceptVulnerabilities binds and validates parameter XAcceptVulnerabilities from header. +func (o *GetVulnerabilitiesAdditionParams) bindXAcceptVulnerabilities(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewGetVulnerabilitiesAdditionParams() + return nil + } + + o.XAcceptVulnerabilities = &raw + + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetVulnerabilitiesAdditionParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetVulnerabilitiesAdditionParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindProjectName binds and validates parameter ProjectName from path. +func (o *GetVulnerabilitiesAdditionParams) bindProjectName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectName = raw + + return nil +} + +// bindReference binds and validates parameter Reference from path. +func (o *GetVulnerabilitiesAdditionParams) bindReference(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.Reference = raw + + return nil +} + +// bindRepositoryName binds and validates parameter RepositoryName from path. +func (o *GetVulnerabilitiesAdditionParams) bindRepositoryName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.RepositoryName = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/artifact/get_vulnerabilities_addition_responses.go b/src/server/v2.0/restapi/operations/artifact/get_vulnerabilities_addition_responses.go new file mode 100644 index 000000000..87eb0b564 --- /dev/null +++ b/src/server/v2.0/restapi/operations/artifact/get_vulnerabilities_addition_responses.go @@ -0,0 +1,408 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetVulnerabilitiesAdditionOKCode is the HTTP code returned for type GetVulnerabilitiesAdditionOK +const GetVulnerabilitiesAdditionOKCode int = 200 + +/*GetVulnerabilitiesAdditionOK Success + +swagger:response getVulnerabilitiesAdditionOK +*/ +type GetVulnerabilitiesAdditionOK struct { + /*The content type of the vulnerabilities addition + + */ + ContentType string `json:"Content-Type"` + + /* + In: Body + */ + Payload string `json:"body,omitempty"` +} + +// NewGetVulnerabilitiesAdditionOK creates GetVulnerabilitiesAdditionOK with default headers values +func NewGetVulnerabilitiesAdditionOK() *GetVulnerabilitiesAdditionOK { + + return &GetVulnerabilitiesAdditionOK{} +} + +// WithContentType adds the contentType to the get vulnerabilities addition o k response +func (o *GetVulnerabilitiesAdditionOK) WithContentType(contentType string) *GetVulnerabilitiesAdditionOK { + o.ContentType = contentType + return o +} + +// SetContentType sets the contentType to the get vulnerabilities addition o k response +func (o *GetVulnerabilitiesAdditionOK) SetContentType(contentType string) { + o.ContentType = contentType +} + +// WithPayload adds the payload to the get vulnerabilities addition o k response +func (o *GetVulnerabilitiesAdditionOK) WithPayload(payload string) *GetVulnerabilitiesAdditionOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get vulnerabilities addition o k response +func (o *GetVulnerabilitiesAdditionOK) SetPayload(payload string) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetVulnerabilitiesAdditionOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Content-Type + + contentType := o.ContentType + if contentType != "" { + rw.Header().Set("Content-Type", contentType) + } + + rw.WriteHeader(200) + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// GetVulnerabilitiesAdditionBadRequestCode is the HTTP code returned for type GetVulnerabilitiesAdditionBadRequest +const GetVulnerabilitiesAdditionBadRequestCode int = 400 + +/*GetVulnerabilitiesAdditionBadRequest Bad request + +swagger:response getVulnerabilitiesAdditionBadRequest +*/ +type GetVulnerabilitiesAdditionBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetVulnerabilitiesAdditionBadRequest creates GetVulnerabilitiesAdditionBadRequest with default headers values +func NewGetVulnerabilitiesAdditionBadRequest() *GetVulnerabilitiesAdditionBadRequest { + + return &GetVulnerabilitiesAdditionBadRequest{} +} + +// WithXRequestID adds the xRequestId to the get vulnerabilities addition bad request response +func (o *GetVulnerabilitiesAdditionBadRequest) WithXRequestID(xRequestID string) *GetVulnerabilitiesAdditionBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get vulnerabilities addition bad request response +func (o *GetVulnerabilitiesAdditionBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get vulnerabilities addition bad request response +func (o *GetVulnerabilitiesAdditionBadRequest) WithPayload(payload *models.Errors) *GetVulnerabilitiesAdditionBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get vulnerabilities addition bad request response +func (o *GetVulnerabilitiesAdditionBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetVulnerabilitiesAdditionBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetVulnerabilitiesAdditionUnauthorizedCode is the HTTP code returned for type GetVulnerabilitiesAdditionUnauthorized +const GetVulnerabilitiesAdditionUnauthorizedCode int = 401 + +/*GetVulnerabilitiesAdditionUnauthorized Unauthorized + +swagger:response getVulnerabilitiesAdditionUnauthorized +*/ +type GetVulnerabilitiesAdditionUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetVulnerabilitiesAdditionUnauthorized creates GetVulnerabilitiesAdditionUnauthorized with default headers values +func NewGetVulnerabilitiesAdditionUnauthorized() *GetVulnerabilitiesAdditionUnauthorized { + + return &GetVulnerabilitiesAdditionUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the get vulnerabilities addition unauthorized response +func (o *GetVulnerabilitiesAdditionUnauthorized) WithXRequestID(xRequestID string) *GetVulnerabilitiesAdditionUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get vulnerabilities addition unauthorized response +func (o *GetVulnerabilitiesAdditionUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get vulnerabilities addition unauthorized response +func (o *GetVulnerabilitiesAdditionUnauthorized) WithPayload(payload *models.Errors) *GetVulnerabilitiesAdditionUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get vulnerabilities addition unauthorized response +func (o *GetVulnerabilitiesAdditionUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetVulnerabilitiesAdditionUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetVulnerabilitiesAdditionForbiddenCode is the HTTP code returned for type GetVulnerabilitiesAdditionForbidden +const GetVulnerabilitiesAdditionForbiddenCode int = 403 + +/*GetVulnerabilitiesAdditionForbidden Forbidden + +swagger:response getVulnerabilitiesAdditionForbidden +*/ +type GetVulnerabilitiesAdditionForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetVulnerabilitiesAdditionForbidden creates GetVulnerabilitiesAdditionForbidden with default headers values +func NewGetVulnerabilitiesAdditionForbidden() *GetVulnerabilitiesAdditionForbidden { + + return &GetVulnerabilitiesAdditionForbidden{} +} + +// WithXRequestID adds the xRequestId to the get vulnerabilities addition forbidden response +func (o *GetVulnerabilitiesAdditionForbidden) WithXRequestID(xRequestID string) *GetVulnerabilitiesAdditionForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get vulnerabilities addition forbidden response +func (o *GetVulnerabilitiesAdditionForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get vulnerabilities addition forbidden response +func (o *GetVulnerabilitiesAdditionForbidden) WithPayload(payload *models.Errors) *GetVulnerabilitiesAdditionForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get vulnerabilities addition forbidden response +func (o *GetVulnerabilitiesAdditionForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetVulnerabilitiesAdditionForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetVulnerabilitiesAdditionNotFoundCode is the HTTP code returned for type GetVulnerabilitiesAdditionNotFound +const GetVulnerabilitiesAdditionNotFoundCode int = 404 + +/*GetVulnerabilitiesAdditionNotFound Not found + +swagger:response getVulnerabilitiesAdditionNotFound +*/ +type GetVulnerabilitiesAdditionNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetVulnerabilitiesAdditionNotFound creates GetVulnerabilitiesAdditionNotFound with default headers values +func NewGetVulnerabilitiesAdditionNotFound() *GetVulnerabilitiesAdditionNotFound { + + return &GetVulnerabilitiesAdditionNotFound{} +} + +// WithXRequestID adds the xRequestId to the get vulnerabilities addition not found response +func (o *GetVulnerabilitiesAdditionNotFound) WithXRequestID(xRequestID string) *GetVulnerabilitiesAdditionNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get vulnerabilities addition not found response +func (o *GetVulnerabilitiesAdditionNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get vulnerabilities addition not found response +func (o *GetVulnerabilitiesAdditionNotFound) WithPayload(payload *models.Errors) *GetVulnerabilitiesAdditionNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get vulnerabilities addition not found response +func (o *GetVulnerabilitiesAdditionNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetVulnerabilitiesAdditionNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetVulnerabilitiesAdditionInternalServerErrorCode is the HTTP code returned for type GetVulnerabilitiesAdditionInternalServerError +const GetVulnerabilitiesAdditionInternalServerErrorCode int = 500 + +/*GetVulnerabilitiesAdditionInternalServerError Internal server error + +swagger:response getVulnerabilitiesAdditionInternalServerError +*/ +type GetVulnerabilitiesAdditionInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetVulnerabilitiesAdditionInternalServerError creates GetVulnerabilitiesAdditionInternalServerError with default headers values +func NewGetVulnerabilitiesAdditionInternalServerError() *GetVulnerabilitiesAdditionInternalServerError { + + return &GetVulnerabilitiesAdditionInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get vulnerabilities addition internal server error response +func (o *GetVulnerabilitiesAdditionInternalServerError) WithXRequestID(xRequestID string) *GetVulnerabilitiesAdditionInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get vulnerabilities addition internal server error response +func (o *GetVulnerabilitiesAdditionInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get vulnerabilities addition internal server error response +func (o *GetVulnerabilitiesAdditionInternalServerError) WithPayload(payload *models.Errors) *GetVulnerabilitiesAdditionInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get vulnerabilities addition internal server error response +func (o *GetVulnerabilitiesAdditionInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetVulnerabilitiesAdditionInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/artifact/get_vulnerabilities_addition_urlbuilder.go b/src/server/v2.0/restapi/operations/artifact/get_vulnerabilities_addition_urlbuilder.go new file mode 100644 index 000000000..c5af1eb52 --- /dev/null +++ b/src/server/v2.0/restapi/operations/artifact/get_vulnerabilities_addition_urlbuilder.go @@ -0,0 +1,115 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetVulnerabilitiesAdditionURL generates an URL for the get vulnerabilities addition operation +type GetVulnerabilitiesAdditionURL struct { + ProjectName string + Reference string + RepositoryName string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetVulnerabilitiesAdditionURL) WithBasePath(bp string) *GetVulnerabilitiesAdditionURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetVulnerabilitiesAdditionURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetVulnerabilitiesAdditionURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/additions/vulnerabilities" + + projectName := o.ProjectName + if projectName != "" { + _path = strings.Replace(_path, "{project_name}", projectName, -1) + } else { + return nil, errors.New("projectName is required on GetVulnerabilitiesAdditionURL") + } + + reference := o.Reference + if reference != "" { + _path = strings.Replace(_path, "{reference}", reference, -1) + } else { + return nil, errors.New("reference is required on GetVulnerabilitiesAdditionURL") + } + + repositoryName := o.RepositoryName + if repositoryName != "" { + _path = strings.Replace(_path, "{repository_name}", repositoryName, -1) + } else { + return nil, errors.New("repositoryName is required on GetVulnerabilitiesAdditionURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetVulnerabilitiesAdditionURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetVulnerabilitiesAdditionURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetVulnerabilitiesAdditionURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetVulnerabilitiesAdditionURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetVulnerabilitiesAdditionURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetVulnerabilitiesAdditionURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/artifact/list_accessories.go b/src/server/v2.0/restapi/operations/artifact/list_accessories.go new file mode 100644 index 000000000..9e2230e94 --- /dev/null +++ b/src/server/v2.0/restapi/operations/artifact/list_accessories.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ListAccessoriesHandlerFunc turns a function with the right signature into a list accessories handler +type ListAccessoriesHandlerFunc func(ListAccessoriesParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ListAccessoriesHandlerFunc) Handle(params ListAccessoriesParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ListAccessoriesHandler interface for that can handle valid list accessories params +type ListAccessoriesHandler interface { + Handle(ListAccessoriesParams, interface{}) middleware.Responder +} + +// NewListAccessories creates a new http.Handler for the list accessories operation +func NewListAccessories(ctx *middleware.Context, handler ListAccessoriesHandler) *ListAccessories { + return &ListAccessories{Context: ctx, Handler: handler} +} + +/*ListAccessories swagger:route GET /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/accessories artifact listAccessories + +List accessories + +List accessories of the specific artifact + +*/ +type ListAccessories struct { + Context *middleware.Context + Handler ListAccessoriesHandler +} + +func (o *ListAccessories) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewListAccessoriesParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/artifact/list_accessories_parameters.go b/src/server/v2.0/restapi/operations/artifact/list_accessories_parameters.go new file mode 100644 index 000000000..0ba1cf144 --- /dev/null +++ b/src/server/v2.0/restapi/operations/artifact/list_accessories_parameters.go @@ -0,0 +1,314 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewListAccessoriesParams creates a new ListAccessoriesParams object +// with the default values initialized. +func NewListAccessoriesParams() ListAccessoriesParams { + + var ( + // initialize parameters with default values + + pageDefault = int64(1) + pageSizeDefault = int64(10) + ) + + return ListAccessoriesParams{ + Page: &pageDefault, + + PageSize: &pageSizeDefault, + } +} + +// ListAccessoriesParams contains all the bound params for the list accessories operation +// typically these are obtained from a http.Request +// +// swagger:parameters listAccessories +type ListAccessoriesParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The page number + In: query + Default: 1 + */ + Page *int64 + /*The size of per page + Maximum: 100 + In: query + Default: 10 + */ + PageSize *int64 + /*The name of the project + Required: true + In: path + */ + ProjectName string + /*Query string to query resources. Supported query patterns are "exact match(k=v)", "fuzzy match(k=~v)", "range(k=[min~max])", "list with union releationship(k={v1 v2 v3})" and "list with intersetion relationship(k=(v1 v2 v3))". The value of range and list can be string(enclosed by " or '), integer or time(in format "2020-04-09 02:36:00"). All of these query patterns should be put in the query string "q=xxx" and splitted by ",". e.g. q=k1=v1,k2=~v2,k3=[min~max] + In: query + */ + Q *string + /*The reference of the artifact, can be digest or tag + Required: true + In: path + */ + Reference string + /*The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -> a%252Fb + Required: true + In: path + */ + RepositoryName string + /*Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + In: query + */ + Sort *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewListAccessoriesParams() beforehand. +func (o *ListAccessoriesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + qPage, qhkPage, _ := qs.GetOK("page") + if err := o.bindPage(qPage, qhkPage, route.Formats); err != nil { + res = append(res, err) + } + + qPageSize, qhkPageSize, _ := qs.GetOK("page_size") + if err := o.bindPageSize(qPageSize, qhkPageSize, route.Formats); err != nil { + res = append(res, err) + } + + rProjectName, rhkProjectName, _ := route.Params.GetOK("project_name") + if err := o.bindProjectName(rProjectName, rhkProjectName, route.Formats); err != nil { + res = append(res, err) + } + + qQ, qhkQ, _ := qs.GetOK("q") + if err := o.bindQ(qQ, qhkQ, route.Formats); err != nil { + res = append(res, err) + } + + rReference, rhkReference, _ := route.Params.GetOK("reference") + if err := o.bindReference(rReference, rhkReference, route.Formats); err != nil { + res = append(res, err) + } + + rRepositoryName, rhkRepositoryName, _ := route.Params.GetOK("repository_name") + if err := o.bindRepositoryName(rRepositoryName, rhkRepositoryName, route.Formats); err != nil { + res = append(res, err) + } + + qSort, qhkSort, _ := qs.GetOK("sort") + if err := o.bindSort(qSort, qhkSort, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *ListAccessoriesParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *ListAccessoriesParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindPage binds and validates parameter Page from query. +func (o *ListAccessoriesParams) bindPage(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListAccessoriesParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page", "query", "int64", raw) + } + o.Page = &value + + return nil +} + +// bindPageSize binds and validates parameter PageSize from query. +func (o *ListAccessoriesParams) bindPageSize(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListAccessoriesParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page_size", "query", "int64", raw) + } + o.PageSize = &value + + if err := o.validatePageSize(formats); err != nil { + return err + } + + return nil +} + +// validatePageSize carries on validations for parameter PageSize +func (o *ListAccessoriesParams) validatePageSize(formats strfmt.Registry) error { + + if err := validate.MaximumInt("page_size", "query", int64(*o.PageSize), 100, false); err != nil { + return err + } + + return nil +} + +// bindProjectName binds and validates parameter ProjectName from path. +func (o *ListAccessoriesParams) bindProjectName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectName = raw + + return nil +} + +// bindQ binds and validates parameter Q from query. +func (o *ListAccessoriesParams) bindQ(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Q = &raw + + return nil +} + +// bindReference binds and validates parameter Reference from path. +func (o *ListAccessoriesParams) bindReference(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.Reference = raw + + return nil +} + +// bindRepositoryName binds and validates parameter RepositoryName from path. +func (o *ListAccessoriesParams) bindRepositoryName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.RepositoryName = raw + + return nil +} + +// bindSort binds and validates parameter Sort from query. +func (o *ListAccessoriesParams) bindSort(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Sort = &raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/artifact/list_accessories_responses.go b/src/server/v2.0/restapi/operations/artifact/list_accessories_responses.go new file mode 100644 index 000000000..f53a97609 --- /dev/null +++ b/src/server/v2.0/restapi/operations/artifact/list_accessories_responses.go @@ -0,0 +1,436 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/swag" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// ListAccessoriesOKCode is the HTTP code returned for type ListAccessoriesOK +const ListAccessoriesOKCode int = 200 + +/*ListAccessoriesOK Success + +swagger:response listAccessoriesOK +*/ +type ListAccessoriesOK struct { + /*Link refers to the previous page and next page + + */ + Link string `json:"Link"` + /*The total count of accessories + + */ + XTotalCount int64 `json:"X-Total-Count"` + + /* + In: Body + */ + Payload []*models.Accessory `json:"body,omitempty"` +} + +// NewListAccessoriesOK creates ListAccessoriesOK with default headers values +func NewListAccessoriesOK() *ListAccessoriesOK { + + return &ListAccessoriesOK{} +} + +// WithLink adds the link to the list accessories o k response +func (o *ListAccessoriesOK) WithLink(link string) *ListAccessoriesOK { + o.Link = link + return o +} + +// SetLink sets the link to the list accessories o k response +func (o *ListAccessoriesOK) SetLink(link string) { + o.Link = link +} + +// WithXTotalCount adds the xTotalCount to the list accessories o k response +func (o *ListAccessoriesOK) WithXTotalCount(xTotalCount int64) *ListAccessoriesOK { + o.XTotalCount = xTotalCount + return o +} + +// SetXTotalCount sets the xTotalCount to the list accessories o k response +func (o *ListAccessoriesOK) SetXTotalCount(xTotalCount int64) { + o.XTotalCount = xTotalCount +} + +// WithPayload adds the payload to the list accessories o k response +func (o *ListAccessoriesOK) WithPayload(payload []*models.Accessory) *ListAccessoriesOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list accessories o k response +func (o *ListAccessoriesOK) SetPayload(payload []*models.Accessory) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListAccessoriesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Link + + link := o.Link + if link != "" { + rw.Header().Set("Link", link) + } + + // response header X-Total-Count + + xTotalCount := swag.FormatInt64(o.XTotalCount) + if xTotalCount != "" { + rw.Header().Set("X-Total-Count", xTotalCount) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = make([]*models.Accessory, 0, 50) + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ListAccessoriesBadRequestCode is the HTTP code returned for type ListAccessoriesBadRequest +const ListAccessoriesBadRequestCode int = 400 + +/*ListAccessoriesBadRequest Bad request + +swagger:response listAccessoriesBadRequest +*/ +type ListAccessoriesBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListAccessoriesBadRequest creates ListAccessoriesBadRequest with default headers values +func NewListAccessoriesBadRequest() *ListAccessoriesBadRequest { + + return &ListAccessoriesBadRequest{} +} + +// WithXRequestID adds the xRequestId to the list accessories bad request response +func (o *ListAccessoriesBadRequest) WithXRequestID(xRequestID string) *ListAccessoriesBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list accessories bad request response +func (o *ListAccessoriesBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list accessories bad request response +func (o *ListAccessoriesBadRequest) WithPayload(payload *models.Errors) *ListAccessoriesBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list accessories bad request response +func (o *ListAccessoriesBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListAccessoriesBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListAccessoriesUnauthorizedCode is the HTTP code returned for type ListAccessoriesUnauthorized +const ListAccessoriesUnauthorizedCode int = 401 + +/*ListAccessoriesUnauthorized Unauthorized + +swagger:response listAccessoriesUnauthorized +*/ +type ListAccessoriesUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListAccessoriesUnauthorized creates ListAccessoriesUnauthorized with default headers values +func NewListAccessoriesUnauthorized() *ListAccessoriesUnauthorized { + + return &ListAccessoriesUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the list accessories unauthorized response +func (o *ListAccessoriesUnauthorized) WithXRequestID(xRequestID string) *ListAccessoriesUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list accessories unauthorized response +func (o *ListAccessoriesUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list accessories unauthorized response +func (o *ListAccessoriesUnauthorized) WithPayload(payload *models.Errors) *ListAccessoriesUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list accessories unauthorized response +func (o *ListAccessoriesUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListAccessoriesUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListAccessoriesForbiddenCode is the HTTP code returned for type ListAccessoriesForbidden +const ListAccessoriesForbiddenCode int = 403 + +/*ListAccessoriesForbidden Forbidden + +swagger:response listAccessoriesForbidden +*/ +type ListAccessoriesForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListAccessoriesForbidden creates ListAccessoriesForbidden with default headers values +func NewListAccessoriesForbidden() *ListAccessoriesForbidden { + + return &ListAccessoriesForbidden{} +} + +// WithXRequestID adds the xRequestId to the list accessories forbidden response +func (o *ListAccessoriesForbidden) WithXRequestID(xRequestID string) *ListAccessoriesForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list accessories forbidden response +func (o *ListAccessoriesForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list accessories forbidden response +func (o *ListAccessoriesForbidden) WithPayload(payload *models.Errors) *ListAccessoriesForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list accessories forbidden response +func (o *ListAccessoriesForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListAccessoriesForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListAccessoriesNotFoundCode is the HTTP code returned for type ListAccessoriesNotFound +const ListAccessoriesNotFoundCode int = 404 + +/*ListAccessoriesNotFound Not found + +swagger:response listAccessoriesNotFound +*/ +type ListAccessoriesNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListAccessoriesNotFound creates ListAccessoriesNotFound with default headers values +func NewListAccessoriesNotFound() *ListAccessoriesNotFound { + + return &ListAccessoriesNotFound{} +} + +// WithXRequestID adds the xRequestId to the list accessories not found response +func (o *ListAccessoriesNotFound) WithXRequestID(xRequestID string) *ListAccessoriesNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list accessories not found response +func (o *ListAccessoriesNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list accessories not found response +func (o *ListAccessoriesNotFound) WithPayload(payload *models.Errors) *ListAccessoriesNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list accessories not found response +func (o *ListAccessoriesNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListAccessoriesNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListAccessoriesInternalServerErrorCode is the HTTP code returned for type ListAccessoriesInternalServerError +const ListAccessoriesInternalServerErrorCode int = 500 + +/*ListAccessoriesInternalServerError Internal server error + +swagger:response listAccessoriesInternalServerError +*/ +type ListAccessoriesInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListAccessoriesInternalServerError creates ListAccessoriesInternalServerError with default headers values +func NewListAccessoriesInternalServerError() *ListAccessoriesInternalServerError { + + return &ListAccessoriesInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the list accessories internal server error response +func (o *ListAccessoriesInternalServerError) WithXRequestID(xRequestID string) *ListAccessoriesInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list accessories internal server error response +func (o *ListAccessoriesInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list accessories internal server error response +func (o *ListAccessoriesInternalServerError) WithPayload(payload *models.Errors) *ListAccessoriesInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list accessories internal server error response +func (o *ListAccessoriesInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListAccessoriesInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/artifact/list_accessories_urlbuilder.go b/src/server/v2.0/restapi/operations/artifact/list_accessories_urlbuilder.go new file mode 100644 index 000000000..24f0ad0af --- /dev/null +++ b/src/server/v2.0/restapi/operations/artifact/list_accessories_urlbuilder.go @@ -0,0 +1,158 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ListAccessoriesURL generates an URL for the list accessories operation +type ListAccessoriesURL struct { + ProjectName string + Reference string + RepositoryName string + + Page *int64 + PageSize *int64 + Q *string + Sort *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListAccessoriesURL) WithBasePath(bp string) *ListAccessoriesURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListAccessoriesURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ListAccessoriesURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/accessories" + + projectName := o.ProjectName + if projectName != "" { + _path = strings.Replace(_path, "{project_name}", projectName, -1) + } else { + return nil, errors.New("projectName is required on ListAccessoriesURL") + } + + reference := o.Reference + if reference != "" { + _path = strings.Replace(_path, "{reference}", reference, -1) + } else { + return nil, errors.New("reference is required on ListAccessoriesURL") + } + + repositoryName := o.RepositoryName + if repositoryName != "" { + _path = strings.Replace(_path, "{repository_name}", repositoryName, -1) + } else { + return nil, errors.New("repositoryName is required on ListAccessoriesURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var pageQ string + if o.Page != nil { + pageQ = swag.FormatInt64(*o.Page) + } + if pageQ != "" { + qs.Set("page", pageQ) + } + + var pageSizeQ string + if o.PageSize != nil { + pageSizeQ = swag.FormatInt64(*o.PageSize) + } + if pageSizeQ != "" { + qs.Set("page_size", pageSizeQ) + } + + var qQ string + if o.Q != nil { + qQ = *o.Q + } + if qQ != "" { + qs.Set("q", qQ) + } + + var sortQ string + if o.Sort != nil { + sortQ = *o.Sort + } + if sortQ != "" { + qs.Set("sort", sortQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ListAccessoriesURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ListAccessoriesURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ListAccessoriesURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ListAccessoriesURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ListAccessoriesURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ListAccessoriesURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/artifact/list_artifacts.go b/src/server/v2.0/restapi/operations/artifact/list_artifacts.go new file mode 100644 index 000000000..e0aae4560 --- /dev/null +++ b/src/server/v2.0/restapi/operations/artifact/list_artifacts.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ListArtifactsHandlerFunc turns a function with the right signature into a list artifacts handler +type ListArtifactsHandlerFunc func(ListArtifactsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ListArtifactsHandlerFunc) Handle(params ListArtifactsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ListArtifactsHandler interface for that can handle valid list artifacts params +type ListArtifactsHandler interface { + Handle(ListArtifactsParams, interface{}) middleware.Responder +} + +// NewListArtifacts creates a new http.Handler for the list artifacts operation +func NewListArtifacts(ctx *middleware.Context, handler ListArtifactsHandler) *ListArtifacts { + return &ListArtifacts{Context: ctx, Handler: handler} +} + +/*ListArtifacts swagger:route GET /projects/{project_name}/repositories/{repository_name}/artifacts artifact listArtifacts + +List artifacts + +List artifacts under the specific project and repository. Except the basic properties, the other supported queries in "q" includes "tags=*" to list only tagged artifacts, "tags=nil" to list only untagged artifacts, "tags=~v" to list artifacts whose tag fuzzy matches "v", "tags=v" to list artifact whose tag exactly matches "v", "labels=(id1, id2)" to list artifacts that both labels with id1 and id2 are added to + +*/ +type ListArtifacts struct { + Context *middleware.Context + Handler ListArtifactsHandler +} + +func (o *ListArtifacts) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewListArtifactsParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/artifact/list_artifacts_parameters.go b/src/server/v2.0/restapi/operations/artifact/list_artifacts_parameters.go new file mode 100644 index 000000000..56cfd8564 --- /dev/null +++ b/src/server/v2.0/restapi/operations/artifact/list_artifacts_parameters.go @@ -0,0 +1,539 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewListArtifactsParams creates a new ListArtifactsParams object +// with the default values initialized. +func NewListArtifactsParams() ListArtifactsParams { + + var ( + // initialize parameters with default values + + xAcceptVulnerabilitiesDefault = string("application/vnd.security.vulnerability.report; version=1.1, application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0") + + pageDefault = int64(1) + pageSizeDefault = int64(10) + + withAccessoryDefault = bool(false) + withImmutableStatusDefault = bool(false) + withLabelDefault = bool(false) + withScanOverviewDefault = bool(false) + withSignatureDefault = bool(false) + withTagDefault = bool(true) + ) + + return ListArtifactsParams{ + XAcceptVulnerabilities: &xAcceptVulnerabilitiesDefault, + + Page: &pageDefault, + + PageSize: &pageSizeDefault, + + WithAccessory: &withAccessoryDefault, + + WithImmutableStatus: &withImmutableStatusDefault, + + WithLabel: &withLabelDefault, + + WithScanOverview: &withScanOverviewDefault, + + WithSignature: &withSignatureDefault, + + WithTag: &withTagDefault, + } +} + +// ListArtifactsParams contains all the bound params for the list artifacts operation +// typically these are obtained from a http.Request +// +// swagger:parameters listArtifacts +type ListArtifactsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*A comma-separated lists of MIME types for the scan report or scan summary. The first mime type will be used when the report found for it. + Currently the mime type supports 'application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0' and 'application/vnd.security.vulnerability.report; version=1.1' + In: header + Default: "application/vnd.security.vulnerability.report; version=1.1, application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0" + */ + XAcceptVulnerabilities *string + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The page number + In: query + Default: 1 + */ + Page *int64 + /*The size of per page + Maximum: 100 + In: query + Default: 10 + */ + PageSize *int64 + /*The name of the project + Required: true + In: path + */ + ProjectName string + /*Query string to query resources. Supported query patterns are "exact match(k=v)", "fuzzy match(k=~v)", "range(k=[min~max])", "list with union releationship(k={v1 v2 v3})" and "list with intersetion relationship(k=(v1 v2 v3))". The value of range and list can be string(enclosed by " or '), integer or time(in format "2020-04-09 02:36:00"). All of these query patterns should be put in the query string "q=xxx" and splitted by ",". e.g. q=k1=v1,k2=~v2,k3=[min~max] + In: query + */ + Q *string + /*The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -> a%252Fb + Required: true + In: path + */ + RepositoryName string + /*Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + In: query + */ + Sort *string + /*Specify whether the accessories are included of the returning artifacts. Only works when setting "with_accessory=true" + In: query + Default: false + */ + WithAccessory *bool + /*Specify whether the immutable status is included inside the tags of the returning artifacts. Only works when setting "with_immutable_status=true" + In: query + Default: false + */ + WithImmutableStatus *bool + /*Specify whether the labels are included inside the returning artifacts + In: query + Default: false + */ + WithLabel *bool + /*Specify whether the scan overview is included inside the returning artifacts + In: query + Default: false + */ + WithScanOverview *bool + /*Specify whether the signature is included inside the tags of the returning artifacts. Only works when setting "with_tag=true" + In: query + Default: false + */ + WithSignature *bool + /*Specify whether the tags are included inside the returning artifacts + In: query + Default: true + */ + WithTag *bool +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewListArtifactsParams() beforehand. +func (o *ListArtifactsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if err := o.bindXAcceptVulnerabilities(r.Header[http.CanonicalHeaderKey("X-Accept-Vulnerabilities")], true, route.Formats); err != nil { + res = append(res, err) + } + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + qPage, qhkPage, _ := qs.GetOK("page") + if err := o.bindPage(qPage, qhkPage, route.Formats); err != nil { + res = append(res, err) + } + + qPageSize, qhkPageSize, _ := qs.GetOK("page_size") + if err := o.bindPageSize(qPageSize, qhkPageSize, route.Formats); err != nil { + res = append(res, err) + } + + rProjectName, rhkProjectName, _ := route.Params.GetOK("project_name") + if err := o.bindProjectName(rProjectName, rhkProjectName, route.Formats); err != nil { + res = append(res, err) + } + + qQ, qhkQ, _ := qs.GetOK("q") + if err := o.bindQ(qQ, qhkQ, route.Formats); err != nil { + res = append(res, err) + } + + rRepositoryName, rhkRepositoryName, _ := route.Params.GetOK("repository_name") + if err := o.bindRepositoryName(rRepositoryName, rhkRepositoryName, route.Formats); err != nil { + res = append(res, err) + } + + qSort, qhkSort, _ := qs.GetOK("sort") + if err := o.bindSort(qSort, qhkSort, route.Formats); err != nil { + res = append(res, err) + } + + qWithAccessory, qhkWithAccessory, _ := qs.GetOK("with_accessory") + if err := o.bindWithAccessory(qWithAccessory, qhkWithAccessory, route.Formats); err != nil { + res = append(res, err) + } + + qWithImmutableStatus, qhkWithImmutableStatus, _ := qs.GetOK("with_immutable_status") + if err := o.bindWithImmutableStatus(qWithImmutableStatus, qhkWithImmutableStatus, route.Formats); err != nil { + res = append(res, err) + } + + qWithLabel, qhkWithLabel, _ := qs.GetOK("with_label") + if err := o.bindWithLabel(qWithLabel, qhkWithLabel, route.Formats); err != nil { + res = append(res, err) + } + + qWithScanOverview, qhkWithScanOverview, _ := qs.GetOK("with_scan_overview") + if err := o.bindWithScanOverview(qWithScanOverview, qhkWithScanOverview, route.Formats); err != nil { + res = append(res, err) + } + + qWithSignature, qhkWithSignature, _ := qs.GetOK("with_signature") + if err := o.bindWithSignature(qWithSignature, qhkWithSignature, route.Formats); err != nil { + res = append(res, err) + } + + qWithTag, qhkWithTag, _ := qs.GetOK("with_tag") + if err := o.bindWithTag(qWithTag, qhkWithTag, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXAcceptVulnerabilities binds and validates parameter XAcceptVulnerabilities from header. +func (o *ListArtifactsParams) bindXAcceptVulnerabilities(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListArtifactsParams() + return nil + } + + o.XAcceptVulnerabilities = &raw + + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *ListArtifactsParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *ListArtifactsParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindPage binds and validates parameter Page from query. +func (o *ListArtifactsParams) bindPage(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListArtifactsParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page", "query", "int64", raw) + } + o.Page = &value + + return nil +} + +// bindPageSize binds and validates parameter PageSize from query. +func (o *ListArtifactsParams) bindPageSize(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListArtifactsParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page_size", "query", "int64", raw) + } + o.PageSize = &value + + if err := o.validatePageSize(formats); err != nil { + return err + } + + return nil +} + +// validatePageSize carries on validations for parameter PageSize +func (o *ListArtifactsParams) validatePageSize(formats strfmt.Registry) error { + + if err := validate.MaximumInt("page_size", "query", int64(*o.PageSize), 100, false); err != nil { + return err + } + + return nil +} + +// bindProjectName binds and validates parameter ProjectName from path. +func (o *ListArtifactsParams) bindProjectName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectName = raw + + return nil +} + +// bindQ binds and validates parameter Q from query. +func (o *ListArtifactsParams) bindQ(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Q = &raw + + return nil +} + +// bindRepositoryName binds and validates parameter RepositoryName from path. +func (o *ListArtifactsParams) bindRepositoryName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.RepositoryName = raw + + return nil +} + +// bindSort binds and validates parameter Sort from query. +func (o *ListArtifactsParams) bindSort(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Sort = &raw + + return nil +} + +// bindWithAccessory binds and validates parameter WithAccessory from query. +func (o *ListArtifactsParams) bindWithAccessory(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListArtifactsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("with_accessory", "query", "bool", raw) + } + o.WithAccessory = &value + + return nil +} + +// bindWithImmutableStatus binds and validates parameter WithImmutableStatus from query. +func (o *ListArtifactsParams) bindWithImmutableStatus(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListArtifactsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("with_immutable_status", "query", "bool", raw) + } + o.WithImmutableStatus = &value + + return nil +} + +// bindWithLabel binds and validates parameter WithLabel from query. +func (o *ListArtifactsParams) bindWithLabel(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListArtifactsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("with_label", "query", "bool", raw) + } + o.WithLabel = &value + + return nil +} + +// bindWithScanOverview binds and validates parameter WithScanOverview from query. +func (o *ListArtifactsParams) bindWithScanOverview(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListArtifactsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("with_scan_overview", "query", "bool", raw) + } + o.WithScanOverview = &value + + return nil +} + +// bindWithSignature binds and validates parameter WithSignature from query. +func (o *ListArtifactsParams) bindWithSignature(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListArtifactsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("with_signature", "query", "bool", raw) + } + o.WithSignature = &value + + return nil +} + +// bindWithTag binds and validates parameter WithTag from query. +func (o *ListArtifactsParams) bindWithTag(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListArtifactsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("with_tag", "query", "bool", raw) + } + o.WithTag = &value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/artifact/list_artifacts_responses.go b/src/server/v2.0/restapi/operations/artifact/list_artifacts_responses.go new file mode 100644 index 000000000..c04d094eb --- /dev/null +++ b/src/server/v2.0/restapi/operations/artifact/list_artifacts_responses.go @@ -0,0 +1,436 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/swag" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// ListArtifactsOKCode is the HTTP code returned for type ListArtifactsOK +const ListArtifactsOKCode int = 200 + +/*ListArtifactsOK Success + +swagger:response listArtifactsOK +*/ +type ListArtifactsOK struct { + /*Link refers to the previous page and next page + + */ + Link string `json:"Link"` + /*The total count of artifacts + + */ + XTotalCount int64 `json:"X-Total-Count"` + + /* + In: Body + */ + Payload []*models.Artifact `json:"body,omitempty"` +} + +// NewListArtifactsOK creates ListArtifactsOK with default headers values +func NewListArtifactsOK() *ListArtifactsOK { + + return &ListArtifactsOK{} +} + +// WithLink adds the link to the list artifacts o k response +func (o *ListArtifactsOK) WithLink(link string) *ListArtifactsOK { + o.Link = link + return o +} + +// SetLink sets the link to the list artifacts o k response +func (o *ListArtifactsOK) SetLink(link string) { + o.Link = link +} + +// WithXTotalCount adds the xTotalCount to the list artifacts o k response +func (o *ListArtifactsOK) WithXTotalCount(xTotalCount int64) *ListArtifactsOK { + o.XTotalCount = xTotalCount + return o +} + +// SetXTotalCount sets the xTotalCount to the list artifacts o k response +func (o *ListArtifactsOK) SetXTotalCount(xTotalCount int64) { + o.XTotalCount = xTotalCount +} + +// WithPayload adds the payload to the list artifacts o k response +func (o *ListArtifactsOK) WithPayload(payload []*models.Artifact) *ListArtifactsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list artifacts o k response +func (o *ListArtifactsOK) SetPayload(payload []*models.Artifact) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListArtifactsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Link + + link := o.Link + if link != "" { + rw.Header().Set("Link", link) + } + + // response header X-Total-Count + + xTotalCount := swag.FormatInt64(o.XTotalCount) + if xTotalCount != "" { + rw.Header().Set("X-Total-Count", xTotalCount) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = make([]*models.Artifact, 0, 50) + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ListArtifactsBadRequestCode is the HTTP code returned for type ListArtifactsBadRequest +const ListArtifactsBadRequestCode int = 400 + +/*ListArtifactsBadRequest Bad request + +swagger:response listArtifactsBadRequest +*/ +type ListArtifactsBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListArtifactsBadRequest creates ListArtifactsBadRequest with default headers values +func NewListArtifactsBadRequest() *ListArtifactsBadRequest { + + return &ListArtifactsBadRequest{} +} + +// WithXRequestID adds the xRequestId to the list artifacts bad request response +func (o *ListArtifactsBadRequest) WithXRequestID(xRequestID string) *ListArtifactsBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list artifacts bad request response +func (o *ListArtifactsBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list artifacts bad request response +func (o *ListArtifactsBadRequest) WithPayload(payload *models.Errors) *ListArtifactsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list artifacts bad request response +func (o *ListArtifactsBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListArtifactsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListArtifactsUnauthorizedCode is the HTTP code returned for type ListArtifactsUnauthorized +const ListArtifactsUnauthorizedCode int = 401 + +/*ListArtifactsUnauthorized Unauthorized + +swagger:response listArtifactsUnauthorized +*/ +type ListArtifactsUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListArtifactsUnauthorized creates ListArtifactsUnauthorized with default headers values +func NewListArtifactsUnauthorized() *ListArtifactsUnauthorized { + + return &ListArtifactsUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the list artifacts unauthorized response +func (o *ListArtifactsUnauthorized) WithXRequestID(xRequestID string) *ListArtifactsUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list artifacts unauthorized response +func (o *ListArtifactsUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list artifacts unauthorized response +func (o *ListArtifactsUnauthorized) WithPayload(payload *models.Errors) *ListArtifactsUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list artifacts unauthorized response +func (o *ListArtifactsUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListArtifactsUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListArtifactsForbiddenCode is the HTTP code returned for type ListArtifactsForbidden +const ListArtifactsForbiddenCode int = 403 + +/*ListArtifactsForbidden Forbidden + +swagger:response listArtifactsForbidden +*/ +type ListArtifactsForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListArtifactsForbidden creates ListArtifactsForbidden with default headers values +func NewListArtifactsForbidden() *ListArtifactsForbidden { + + return &ListArtifactsForbidden{} +} + +// WithXRequestID adds the xRequestId to the list artifacts forbidden response +func (o *ListArtifactsForbidden) WithXRequestID(xRequestID string) *ListArtifactsForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list artifacts forbidden response +func (o *ListArtifactsForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list artifacts forbidden response +func (o *ListArtifactsForbidden) WithPayload(payload *models.Errors) *ListArtifactsForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list artifacts forbidden response +func (o *ListArtifactsForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListArtifactsForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListArtifactsNotFoundCode is the HTTP code returned for type ListArtifactsNotFound +const ListArtifactsNotFoundCode int = 404 + +/*ListArtifactsNotFound Not found + +swagger:response listArtifactsNotFound +*/ +type ListArtifactsNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListArtifactsNotFound creates ListArtifactsNotFound with default headers values +func NewListArtifactsNotFound() *ListArtifactsNotFound { + + return &ListArtifactsNotFound{} +} + +// WithXRequestID adds the xRequestId to the list artifacts not found response +func (o *ListArtifactsNotFound) WithXRequestID(xRequestID string) *ListArtifactsNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list artifacts not found response +func (o *ListArtifactsNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list artifacts not found response +func (o *ListArtifactsNotFound) WithPayload(payload *models.Errors) *ListArtifactsNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list artifacts not found response +func (o *ListArtifactsNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListArtifactsNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListArtifactsInternalServerErrorCode is the HTTP code returned for type ListArtifactsInternalServerError +const ListArtifactsInternalServerErrorCode int = 500 + +/*ListArtifactsInternalServerError Internal server error + +swagger:response listArtifactsInternalServerError +*/ +type ListArtifactsInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListArtifactsInternalServerError creates ListArtifactsInternalServerError with default headers values +func NewListArtifactsInternalServerError() *ListArtifactsInternalServerError { + + return &ListArtifactsInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the list artifacts internal server error response +func (o *ListArtifactsInternalServerError) WithXRequestID(xRequestID string) *ListArtifactsInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list artifacts internal server error response +func (o *ListArtifactsInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list artifacts internal server error response +func (o *ListArtifactsInternalServerError) WithPayload(payload *models.Errors) *ListArtifactsInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list artifacts internal server error response +func (o *ListArtifactsInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListArtifactsInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/artifact/list_artifacts_urlbuilder.go b/src/server/v2.0/restapi/operations/artifact/list_artifacts_urlbuilder.go new file mode 100644 index 000000000..9eee7f6ff --- /dev/null +++ b/src/server/v2.0/restapi/operations/artifact/list_artifacts_urlbuilder.go @@ -0,0 +1,204 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ListArtifactsURL generates an URL for the list artifacts operation +type ListArtifactsURL struct { + ProjectName string + RepositoryName string + + Page *int64 + PageSize *int64 + Q *string + Sort *string + WithAccessory *bool + WithImmutableStatus *bool + WithLabel *bool + WithScanOverview *bool + WithSignature *bool + WithTag *bool + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListArtifactsURL) WithBasePath(bp string) *ListArtifactsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListArtifactsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ListArtifactsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name}/repositories/{repository_name}/artifacts" + + projectName := o.ProjectName + if projectName != "" { + _path = strings.Replace(_path, "{project_name}", projectName, -1) + } else { + return nil, errors.New("projectName is required on ListArtifactsURL") + } + + repositoryName := o.RepositoryName + if repositoryName != "" { + _path = strings.Replace(_path, "{repository_name}", repositoryName, -1) + } else { + return nil, errors.New("repositoryName is required on ListArtifactsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var pageQ string + if o.Page != nil { + pageQ = swag.FormatInt64(*o.Page) + } + if pageQ != "" { + qs.Set("page", pageQ) + } + + var pageSizeQ string + if o.PageSize != nil { + pageSizeQ = swag.FormatInt64(*o.PageSize) + } + if pageSizeQ != "" { + qs.Set("page_size", pageSizeQ) + } + + var qQ string + if o.Q != nil { + qQ = *o.Q + } + if qQ != "" { + qs.Set("q", qQ) + } + + var sortQ string + if o.Sort != nil { + sortQ = *o.Sort + } + if sortQ != "" { + qs.Set("sort", sortQ) + } + + var withAccessoryQ string + if o.WithAccessory != nil { + withAccessoryQ = swag.FormatBool(*o.WithAccessory) + } + if withAccessoryQ != "" { + qs.Set("with_accessory", withAccessoryQ) + } + + var withImmutableStatusQ string + if o.WithImmutableStatus != nil { + withImmutableStatusQ = swag.FormatBool(*o.WithImmutableStatus) + } + if withImmutableStatusQ != "" { + qs.Set("with_immutable_status", withImmutableStatusQ) + } + + var withLabelQ string + if o.WithLabel != nil { + withLabelQ = swag.FormatBool(*o.WithLabel) + } + if withLabelQ != "" { + qs.Set("with_label", withLabelQ) + } + + var withScanOverviewQ string + if o.WithScanOverview != nil { + withScanOverviewQ = swag.FormatBool(*o.WithScanOverview) + } + if withScanOverviewQ != "" { + qs.Set("with_scan_overview", withScanOverviewQ) + } + + var withSignatureQ string + if o.WithSignature != nil { + withSignatureQ = swag.FormatBool(*o.WithSignature) + } + if withSignatureQ != "" { + qs.Set("with_signature", withSignatureQ) + } + + var withTagQ string + if o.WithTag != nil { + withTagQ = swag.FormatBool(*o.WithTag) + } + if withTagQ != "" { + qs.Set("with_tag", withTagQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ListArtifactsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ListArtifactsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ListArtifactsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ListArtifactsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ListArtifactsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ListArtifactsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/artifact/list_tags.go b/src/server/v2.0/restapi/operations/artifact/list_tags.go new file mode 100644 index 000000000..295fc129e --- /dev/null +++ b/src/server/v2.0/restapi/operations/artifact/list_tags.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ListTagsHandlerFunc turns a function with the right signature into a list tags handler +type ListTagsHandlerFunc func(ListTagsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ListTagsHandlerFunc) Handle(params ListTagsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ListTagsHandler interface for that can handle valid list tags params +type ListTagsHandler interface { + Handle(ListTagsParams, interface{}) middleware.Responder +} + +// NewListTags creates a new http.Handler for the list tags operation +func NewListTags(ctx *middleware.Context, handler ListTagsHandler) *ListTags { + return &ListTags{Context: ctx, Handler: handler} +} + +/*ListTags swagger:route GET /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/tags artifact listTags + +List tags + +List tags of the specific artifact + +*/ +type ListTags struct { + Context *middleware.Context + Handler ListTagsHandler +} + +func (o *ListTags) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewListTagsParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/artifact/list_tags_parameters.go b/src/server/v2.0/restapi/operations/artifact/list_tags_parameters.go new file mode 100644 index 000000000..881908ad6 --- /dev/null +++ b/src/server/v2.0/restapi/operations/artifact/list_tags_parameters.go @@ -0,0 +1,387 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewListTagsParams creates a new ListTagsParams object +// with the default values initialized. +func NewListTagsParams() ListTagsParams { + + var ( + // initialize parameters with default values + + pageDefault = int64(1) + pageSizeDefault = int64(10) + + withImmutableStatusDefault = bool(false) + withSignatureDefault = bool(false) + ) + + return ListTagsParams{ + Page: &pageDefault, + + PageSize: &pageSizeDefault, + + WithImmutableStatus: &withImmutableStatusDefault, + + WithSignature: &withSignatureDefault, + } +} + +// ListTagsParams contains all the bound params for the list tags operation +// typically these are obtained from a http.Request +// +// swagger:parameters listTags +type ListTagsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The page number + In: query + Default: 1 + */ + Page *int64 + /*The size of per page + Maximum: 100 + In: query + Default: 10 + */ + PageSize *int64 + /*The name of the project + Required: true + In: path + */ + ProjectName string + /*Query string to query resources. Supported query patterns are "exact match(k=v)", "fuzzy match(k=~v)", "range(k=[min~max])", "list with union releationship(k={v1 v2 v3})" and "list with intersetion relationship(k=(v1 v2 v3))". The value of range and list can be string(enclosed by " or '), integer or time(in format "2020-04-09 02:36:00"). All of these query patterns should be put in the query string "q=xxx" and splitted by ",". e.g. q=k1=v1,k2=~v2,k3=[min~max] + In: query + */ + Q *string + /*The reference of the artifact, can be digest or tag + Required: true + In: path + */ + Reference string + /*The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -> a%252Fb + Required: true + In: path + */ + RepositoryName string + /*Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + In: query + */ + Sort *string + /*Specify whether the immutable status is included inside the returning tags + In: query + Default: false + */ + WithImmutableStatus *bool + /*Specify whether the signature is included inside the returning tags + In: query + Default: false + */ + WithSignature *bool +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewListTagsParams() beforehand. +func (o *ListTagsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + qPage, qhkPage, _ := qs.GetOK("page") + if err := o.bindPage(qPage, qhkPage, route.Formats); err != nil { + res = append(res, err) + } + + qPageSize, qhkPageSize, _ := qs.GetOK("page_size") + if err := o.bindPageSize(qPageSize, qhkPageSize, route.Formats); err != nil { + res = append(res, err) + } + + rProjectName, rhkProjectName, _ := route.Params.GetOK("project_name") + if err := o.bindProjectName(rProjectName, rhkProjectName, route.Formats); err != nil { + res = append(res, err) + } + + qQ, qhkQ, _ := qs.GetOK("q") + if err := o.bindQ(qQ, qhkQ, route.Formats); err != nil { + res = append(res, err) + } + + rReference, rhkReference, _ := route.Params.GetOK("reference") + if err := o.bindReference(rReference, rhkReference, route.Formats); err != nil { + res = append(res, err) + } + + rRepositoryName, rhkRepositoryName, _ := route.Params.GetOK("repository_name") + if err := o.bindRepositoryName(rRepositoryName, rhkRepositoryName, route.Formats); err != nil { + res = append(res, err) + } + + qSort, qhkSort, _ := qs.GetOK("sort") + if err := o.bindSort(qSort, qhkSort, route.Formats); err != nil { + res = append(res, err) + } + + qWithImmutableStatus, qhkWithImmutableStatus, _ := qs.GetOK("with_immutable_status") + if err := o.bindWithImmutableStatus(qWithImmutableStatus, qhkWithImmutableStatus, route.Formats); err != nil { + res = append(res, err) + } + + qWithSignature, qhkWithSignature, _ := qs.GetOK("with_signature") + if err := o.bindWithSignature(qWithSignature, qhkWithSignature, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *ListTagsParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *ListTagsParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindPage binds and validates parameter Page from query. +func (o *ListTagsParams) bindPage(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListTagsParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page", "query", "int64", raw) + } + o.Page = &value + + return nil +} + +// bindPageSize binds and validates parameter PageSize from query. +func (o *ListTagsParams) bindPageSize(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListTagsParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page_size", "query", "int64", raw) + } + o.PageSize = &value + + if err := o.validatePageSize(formats); err != nil { + return err + } + + return nil +} + +// validatePageSize carries on validations for parameter PageSize +func (o *ListTagsParams) validatePageSize(formats strfmt.Registry) error { + + if err := validate.MaximumInt("page_size", "query", int64(*o.PageSize), 100, false); err != nil { + return err + } + + return nil +} + +// bindProjectName binds and validates parameter ProjectName from path. +func (o *ListTagsParams) bindProjectName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectName = raw + + return nil +} + +// bindQ binds and validates parameter Q from query. +func (o *ListTagsParams) bindQ(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Q = &raw + + return nil +} + +// bindReference binds and validates parameter Reference from path. +func (o *ListTagsParams) bindReference(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.Reference = raw + + return nil +} + +// bindRepositoryName binds and validates parameter RepositoryName from path. +func (o *ListTagsParams) bindRepositoryName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.RepositoryName = raw + + return nil +} + +// bindSort binds and validates parameter Sort from query. +func (o *ListTagsParams) bindSort(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Sort = &raw + + return nil +} + +// bindWithImmutableStatus binds and validates parameter WithImmutableStatus from query. +func (o *ListTagsParams) bindWithImmutableStatus(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListTagsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("with_immutable_status", "query", "bool", raw) + } + o.WithImmutableStatus = &value + + return nil +} + +// bindWithSignature binds and validates parameter WithSignature from query. +func (o *ListTagsParams) bindWithSignature(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListTagsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("with_signature", "query", "bool", raw) + } + o.WithSignature = &value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/artifact/list_tags_responses.go b/src/server/v2.0/restapi/operations/artifact/list_tags_responses.go new file mode 100644 index 000000000..419c7cc74 --- /dev/null +++ b/src/server/v2.0/restapi/operations/artifact/list_tags_responses.go @@ -0,0 +1,436 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/swag" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// ListTagsOKCode is the HTTP code returned for type ListTagsOK +const ListTagsOKCode int = 200 + +/*ListTagsOK Success + +swagger:response listTagsOK +*/ +type ListTagsOK struct { + /*Link refers to the previous page and next page + + */ + Link string `json:"Link"` + /*The total count of tags + + */ + XTotalCount int64 `json:"X-Total-Count"` + + /* + In: Body + */ + Payload []*models.Tag `json:"body,omitempty"` +} + +// NewListTagsOK creates ListTagsOK with default headers values +func NewListTagsOK() *ListTagsOK { + + return &ListTagsOK{} +} + +// WithLink adds the link to the list tags o k response +func (o *ListTagsOK) WithLink(link string) *ListTagsOK { + o.Link = link + return o +} + +// SetLink sets the link to the list tags o k response +func (o *ListTagsOK) SetLink(link string) { + o.Link = link +} + +// WithXTotalCount adds the xTotalCount to the list tags o k response +func (o *ListTagsOK) WithXTotalCount(xTotalCount int64) *ListTagsOK { + o.XTotalCount = xTotalCount + return o +} + +// SetXTotalCount sets the xTotalCount to the list tags o k response +func (o *ListTagsOK) SetXTotalCount(xTotalCount int64) { + o.XTotalCount = xTotalCount +} + +// WithPayload adds the payload to the list tags o k response +func (o *ListTagsOK) WithPayload(payload []*models.Tag) *ListTagsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list tags o k response +func (o *ListTagsOK) SetPayload(payload []*models.Tag) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListTagsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Link + + link := o.Link + if link != "" { + rw.Header().Set("Link", link) + } + + // response header X-Total-Count + + xTotalCount := swag.FormatInt64(o.XTotalCount) + if xTotalCount != "" { + rw.Header().Set("X-Total-Count", xTotalCount) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = make([]*models.Tag, 0, 50) + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ListTagsBadRequestCode is the HTTP code returned for type ListTagsBadRequest +const ListTagsBadRequestCode int = 400 + +/*ListTagsBadRequest Bad request + +swagger:response listTagsBadRequest +*/ +type ListTagsBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListTagsBadRequest creates ListTagsBadRequest with default headers values +func NewListTagsBadRequest() *ListTagsBadRequest { + + return &ListTagsBadRequest{} +} + +// WithXRequestID adds the xRequestId to the list tags bad request response +func (o *ListTagsBadRequest) WithXRequestID(xRequestID string) *ListTagsBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list tags bad request response +func (o *ListTagsBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list tags bad request response +func (o *ListTagsBadRequest) WithPayload(payload *models.Errors) *ListTagsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list tags bad request response +func (o *ListTagsBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListTagsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListTagsUnauthorizedCode is the HTTP code returned for type ListTagsUnauthorized +const ListTagsUnauthorizedCode int = 401 + +/*ListTagsUnauthorized Unauthorized + +swagger:response listTagsUnauthorized +*/ +type ListTagsUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListTagsUnauthorized creates ListTagsUnauthorized with default headers values +func NewListTagsUnauthorized() *ListTagsUnauthorized { + + return &ListTagsUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the list tags unauthorized response +func (o *ListTagsUnauthorized) WithXRequestID(xRequestID string) *ListTagsUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list tags unauthorized response +func (o *ListTagsUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list tags unauthorized response +func (o *ListTagsUnauthorized) WithPayload(payload *models.Errors) *ListTagsUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list tags unauthorized response +func (o *ListTagsUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListTagsUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListTagsForbiddenCode is the HTTP code returned for type ListTagsForbidden +const ListTagsForbiddenCode int = 403 + +/*ListTagsForbidden Forbidden + +swagger:response listTagsForbidden +*/ +type ListTagsForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListTagsForbidden creates ListTagsForbidden with default headers values +func NewListTagsForbidden() *ListTagsForbidden { + + return &ListTagsForbidden{} +} + +// WithXRequestID adds the xRequestId to the list tags forbidden response +func (o *ListTagsForbidden) WithXRequestID(xRequestID string) *ListTagsForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list tags forbidden response +func (o *ListTagsForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list tags forbidden response +func (o *ListTagsForbidden) WithPayload(payload *models.Errors) *ListTagsForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list tags forbidden response +func (o *ListTagsForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListTagsForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListTagsNotFoundCode is the HTTP code returned for type ListTagsNotFound +const ListTagsNotFoundCode int = 404 + +/*ListTagsNotFound Not found + +swagger:response listTagsNotFound +*/ +type ListTagsNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListTagsNotFound creates ListTagsNotFound with default headers values +func NewListTagsNotFound() *ListTagsNotFound { + + return &ListTagsNotFound{} +} + +// WithXRequestID adds the xRequestId to the list tags not found response +func (o *ListTagsNotFound) WithXRequestID(xRequestID string) *ListTagsNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list tags not found response +func (o *ListTagsNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list tags not found response +func (o *ListTagsNotFound) WithPayload(payload *models.Errors) *ListTagsNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list tags not found response +func (o *ListTagsNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListTagsNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListTagsInternalServerErrorCode is the HTTP code returned for type ListTagsInternalServerError +const ListTagsInternalServerErrorCode int = 500 + +/*ListTagsInternalServerError Internal server error + +swagger:response listTagsInternalServerError +*/ +type ListTagsInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListTagsInternalServerError creates ListTagsInternalServerError with default headers values +func NewListTagsInternalServerError() *ListTagsInternalServerError { + + return &ListTagsInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the list tags internal server error response +func (o *ListTagsInternalServerError) WithXRequestID(xRequestID string) *ListTagsInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list tags internal server error response +func (o *ListTagsInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list tags internal server error response +func (o *ListTagsInternalServerError) WithPayload(payload *models.Errors) *ListTagsInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list tags internal server error response +func (o *ListTagsInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListTagsInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/artifact/list_tags_urlbuilder.go b/src/server/v2.0/restapi/operations/artifact/list_tags_urlbuilder.go new file mode 100644 index 000000000..806bd266f --- /dev/null +++ b/src/server/v2.0/restapi/operations/artifact/list_tags_urlbuilder.go @@ -0,0 +1,176 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ListTagsURL generates an URL for the list tags operation +type ListTagsURL struct { + ProjectName string + Reference string + RepositoryName string + + Page *int64 + PageSize *int64 + Q *string + Sort *string + WithImmutableStatus *bool + WithSignature *bool + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListTagsURL) WithBasePath(bp string) *ListTagsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListTagsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ListTagsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/tags" + + projectName := o.ProjectName + if projectName != "" { + _path = strings.Replace(_path, "{project_name}", projectName, -1) + } else { + return nil, errors.New("projectName is required on ListTagsURL") + } + + reference := o.Reference + if reference != "" { + _path = strings.Replace(_path, "{reference}", reference, -1) + } else { + return nil, errors.New("reference is required on ListTagsURL") + } + + repositoryName := o.RepositoryName + if repositoryName != "" { + _path = strings.Replace(_path, "{repository_name}", repositoryName, -1) + } else { + return nil, errors.New("repositoryName is required on ListTagsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var pageQ string + if o.Page != nil { + pageQ = swag.FormatInt64(*o.Page) + } + if pageQ != "" { + qs.Set("page", pageQ) + } + + var pageSizeQ string + if o.PageSize != nil { + pageSizeQ = swag.FormatInt64(*o.PageSize) + } + if pageSizeQ != "" { + qs.Set("page_size", pageSizeQ) + } + + var qQ string + if o.Q != nil { + qQ = *o.Q + } + if qQ != "" { + qs.Set("q", qQ) + } + + var sortQ string + if o.Sort != nil { + sortQ = *o.Sort + } + if sortQ != "" { + qs.Set("sort", sortQ) + } + + var withImmutableStatusQ string + if o.WithImmutableStatus != nil { + withImmutableStatusQ = swag.FormatBool(*o.WithImmutableStatus) + } + if withImmutableStatusQ != "" { + qs.Set("with_immutable_status", withImmutableStatusQ) + } + + var withSignatureQ string + if o.WithSignature != nil { + withSignatureQ = swag.FormatBool(*o.WithSignature) + } + if withSignatureQ != "" { + qs.Set("with_signature", withSignatureQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ListTagsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ListTagsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ListTagsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ListTagsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ListTagsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ListTagsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/artifact/remove_label.go b/src/server/v2.0/restapi/operations/artifact/remove_label.go new file mode 100644 index 000000000..6527bff09 --- /dev/null +++ b/src/server/v2.0/restapi/operations/artifact/remove_label.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// RemoveLabelHandlerFunc turns a function with the right signature into a remove label handler +type RemoveLabelHandlerFunc func(RemoveLabelParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn RemoveLabelHandlerFunc) Handle(params RemoveLabelParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// RemoveLabelHandler interface for that can handle valid remove label params +type RemoveLabelHandler interface { + Handle(RemoveLabelParams, interface{}) middleware.Responder +} + +// NewRemoveLabel creates a new http.Handler for the remove label operation +func NewRemoveLabel(ctx *middleware.Context, handler RemoveLabelHandler) *RemoveLabel { + return &RemoveLabel{Context: ctx, Handler: handler} +} + +/*RemoveLabel swagger:route DELETE /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/labels/{label_id} artifact removeLabel + +Remove label from artifact + +Remove the label from the specified artiact. + +*/ +type RemoveLabel struct { + Context *middleware.Context + Handler RemoveLabelHandler +} + +func (o *RemoveLabel) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewRemoveLabelParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/artifact/remove_label_parameters.go b/src/server/v2.0/restapi/operations/artifact/remove_label_parameters.go new file mode 100644 index 000000000..be594b469 --- /dev/null +++ b/src/server/v2.0/restapi/operations/artifact/remove_label_parameters.go @@ -0,0 +1,194 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewRemoveLabelParams creates a new RemoveLabelParams object +// no default values defined in spec. +func NewRemoveLabelParams() RemoveLabelParams { + + return RemoveLabelParams{} +} + +// RemoveLabelParams contains all the bound params for the remove label operation +// typically these are obtained from a http.Request +// +// swagger:parameters removeLabel +type RemoveLabelParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The ID of the label that removed from the artifact. + Required: true + In: path + */ + LabelID int64 + /*The name of the project + Required: true + In: path + */ + ProjectName string + /*The reference of the artifact, can be digest or tag + Required: true + In: path + */ + Reference string + /*The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -> a%252Fb + Required: true + In: path + */ + RepositoryName string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewRemoveLabelParams() beforehand. +func (o *RemoveLabelParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rLabelID, rhkLabelID, _ := route.Params.GetOK("label_id") + if err := o.bindLabelID(rLabelID, rhkLabelID, route.Formats); err != nil { + res = append(res, err) + } + + rProjectName, rhkProjectName, _ := route.Params.GetOK("project_name") + if err := o.bindProjectName(rProjectName, rhkProjectName, route.Formats); err != nil { + res = append(res, err) + } + + rReference, rhkReference, _ := route.Params.GetOK("reference") + if err := o.bindReference(rReference, rhkReference, route.Formats); err != nil { + res = append(res, err) + } + + rRepositoryName, rhkRepositoryName, _ := route.Params.GetOK("repository_name") + if err := o.bindRepositoryName(rRepositoryName, rhkRepositoryName, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *RemoveLabelParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *RemoveLabelParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindLabelID binds and validates parameter LabelID from path. +func (o *RemoveLabelParams) bindLabelID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("label_id", "path", "int64", raw) + } + o.LabelID = value + + return nil +} + +// bindProjectName binds and validates parameter ProjectName from path. +func (o *RemoveLabelParams) bindProjectName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectName = raw + + return nil +} + +// bindReference binds and validates parameter Reference from path. +func (o *RemoveLabelParams) bindReference(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.Reference = raw + + return nil +} + +// bindRepositoryName binds and validates parameter RepositoryName from path. +func (o *RemoveLabelParams) bindRepositoryName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.RepositoryName = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/artifact/remove_label_responses.go b/src/server/v2.0/restapi/operations/artifact/remove_label_responses.go new file mode 100644 index 000000000..72d2d9276 --- /dev/null +++ b/src/server/v2.0/restapi/operations/artifact/remove_label_responses.go @@ -0,0 +1,390 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// RemoveLabelOKCode is the HTTP code returned for type RemoveLabelOK +const RemoveLabelOKCode int = 200 + +/*RemoveLabelOK Success + +swagger:response removeLabelOK +*/ +type RemoveLabelOK struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewRemoveLabelOK creates RemoveLabelOK with default headers values +func NewRemoveLabelOK() *RemoveLabelOK { + + return &RemoveLabelOK{} +} + +// WithXRequestID adds the xRequestId to the remove label o k response +func (o *RemoveLabelOK) WithXRequestID(xRequestID string) *RemoveLabelOK { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the remove label o k response +func (o *RemoveLabelOK) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *RemoveLabelOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// RemoveLabelUnauthorizedCode is the HTTP code returned for type RemoveLabelUnauthorized +const RemoveLabelUnauthorizedCode int = 401 + +/*RemoveLabelUnauthorized Unauthorized + +swagger:response removeLabelUnauthorized +*/ +type RemoveLabelUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewRemoveLabelUnauthorized creates RemoveLabelUnauthorized with default headers values +func NewRemoveLabelUnauthorized() *RemoveLabelUnauthorized { + + return &RemoveLabelUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the remove label unauthorized response +func (o *RemoveLabelUnauthorized) WithXRequestID(xRequestID string) *RemoveLabelUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the remove label unauthorized response +func (o *RemoveLabelUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the remove label unauthorized response +func (o *RemoveLabelUnauthorized) WithPayload(payload *models.Errors) *RemoveLabelUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the remove label unauthorized response +func (o *RemoveLabelUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *RemoveLabelUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// RemoveLabelForbiddenCode is the HTTP code returned for type RemoveLabelForbidden +const RemoveLabelForbiddenCode int = 403 + +/*RemoveLabelForbidden Forbidden + +swagger:response removeLabelForbidden +*/ +type RemoveLabelForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewRemoveLabelForbidden creates RemoveLabelForbidden with default headers values +func NewRemoveLabelForbidden() *RemoveLabelForbidden { + + return &RemoveLabelForbidden{} +} + +// WithXRequestID adds the xRequestId to the remove label forbidden response +func (o *RemoveLabelForbidden) WithXRequestID(xRequestID string) *RemoveLabelForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the remove label forbidden response +func (o *RemoveLabelForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the remove label forbidden response +func (o *RemoveLabelForbidden) WithPayload(payload *models.Errors) *RemoveLabelForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the remove label forbidden response +func (o *RemoveLabelForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *RemoveLabelForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// RemoveLabelNotFoundCode is the HTTP code returned for type RemoveLabelNotFound +const RemoveLabelNotFoundCode int = 404 + +/*RemoveLabelNotFound Not found + +swagger:response removeLabelNotFound +*/ +type RemoveLabelNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewRemoveLabelNotFound creates RemoveLabelNotFound with default headers values +func NewRemoveLabelNotFound() *RemoveLabelNotFound { + + return &RemoveLabelNotFound{} +} + +// WithXRequestID adds the xRequestId to the remove label not found response +func (o *RemoveLabelNotFound) WithXRequestID(xRequestID string) *RemoveLabelNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the remove label not found response +func (o *RemoveLabelNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the remove label not found response +func (o *RemoveLabelNotFound) WithPayload(payload *models.Errors) *RemoveLabelNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the remove label not found response +func (o *RemoveLabelNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *RemoveLabelNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// RemoveLabelConflictCode is the HTTP code returned for type RemoveLabelConflict +const RemoveLabelConflictCode int = 409 + +/*RemoveLabelConflict Conflict + +swagger:response removeLabelConflict +*/ +type RemoveLabelConflict struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewRemoveLabelConflict creates RemoveLabelConflict with default headers values +func NewRemoveLabelConflict() *RemoveLabelConflict { + + return &RemoveLabelConflict{} +} + +// WithXRequestID adds the xRequestId to the remove label conflict response +func (o *RemoveLabelConflict) WithXRequestID(xRequestID string) *RemoveLabelConflict { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the remove label conflict response +func (o *RemoveLabelConflict) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the remove label conflict response +func (o *RemoveLabelConflict) WithPayload(payload *models.Errors) *RemoveLabelConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the remove label conflict response +func (o *RemoveLabelConflict) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *RemoveLabelConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// RemoveLabelInternalServerErrorCode is the HTTP code returned for type RemoveLabelInternalServerError +const RemoveLabelInternalServerErrorCode int = 500 + +/*RemoveLabelInternalServerError Internal server error + +swagger:response removeLabelInternalServerError +*/ +type RemoveLabelInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewRemoveLabelInternalServerError creates RemoveLabelInternalServerError with default headers values +func NewRemoveLabelInternalServerError() *RemoveLabelInternalServerError { + + return &RemoveLabelInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the remove label internal server error response +func (o *RemoveLabelInternalServerError) WithXRequestID(xRequestID string) *RemoveLabelInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the remove label internal server error response +func (o *RemoveLabelInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the remove label internal server error response +func (o *RemoveLabelInternalServerError) WithPayload(payload *models.Errors) *RemoveLabelInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the remove label internal server error response +func (o *RemoveLabelInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *RemoveLabelInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/artifact/remove_label_urlbuilder.go b/src/server/v2.0/restapi/operations/artifact/remove_label_urlbuilder.go new file mode 100644 index 000000000..ded88cd5c --- /dev/null +++ b/src/server/v2.0/restapi/operations/artifact/remove_label_urlbuilder.go @@ -0,0 +1,125 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// RemoveLabelURL generates an URL for the remove label operation +type RemoveLabelURL struct { + LabelID int64 + ProjectName string + Reference string + RepositoryName string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *RemoveLabelURL) WithBasePath(bp string) *RemoveLabelURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *RemoveLabelURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *RemoveLabelURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/labels/{label_id}" + + labelID := swag.FormatInt64(o.LabelID) + if labelID != "" { + _path = strings.Replace(_path, "{label_id}", labelID, -1) + } else { + return nil, errors.New("labelId is required on RemoveLabelURL") + } + + projectName := o.ProjectName + if projectName != "" { + _path = strings.Replace(_path, "{project_name}", projectName, -1) + } else { + return nil, errors.New("projectName is required on RemoveLabelURL") + } + + reference := o.Reference + if reference != "" { + _path = strings.Replace(_path, "{reference}", reference, -1) + } else { + return nil, errors.New("reference is required on RemoveLabelURL") + } + + repositoryName := o.RepositoryName + if repositoryName != "" { + _path = strings.Replace(_path, "{repository_name}", repositoryName, -1) + } else { + return nil, errors.New("repositoryName is required on RemoveLabelURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *RemoveLabelURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *RemoveLabelURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *RemoveLabelURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on RemoveLabelURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on RemoveLabelURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *RemoveLabelURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/auditlog/list_audit_logs.go b/src/server/v2.0/restapi/operations/auditlog/list_audit_logs.go new file mode 100644 index 000000000..551851e2c --- /dev/null +++ b/src/server/v2.0/restapi/operations/auditlog/list_audit_logs.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package auditlog + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ListAuditLogsHandlerFunc turns a function with the right signature into a list audit logs handler +type ListAuditLogsHandlerFunc func(ListAuditLogsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ListAuditLogsHandlerFunc) Handle(params ListAuditLogsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ListAuditLogsHandler interface for that can handle valid list audit logs params +type ListAuditLogsHandler interface { + Handle(ListAuditLogsParams, interface{}) middleware.Responder +} + +// NewListAuditLogs creates a new http.Handler for the list audit logs operation +func NewListAuditLogs(ctx *middleware.Context, handler ListAuditLogsHandler) *ListAuditLogs { + return &ListAuditLogs{Context: ctx, Handler: handler} +} + +/*ListAuditLogs swagger:route GET /audit-logs auditlog listAuditLogs + +Get recent logs of the projects which the user is a member of + +This endpoint let user see the recent operation logs of the projects which he is member of + + +*/ +type ListAuditLogs struct { + Context *middleware.Context + Handler ListAuditLogsHandler +} + +func (o *ListAuditLogs) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewListAuditLogsParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/auditlog/list_audit_logs_parameters.go b/src/server/v2.0/restapi/operations/auditlog/list_audit_logs_parameters.go new file mode 100644 index 000000000..473a4126f --- /dev/null +++ b/src/server/v2.0/restapi/operations/auditlog/list_audit_logs_parameters.go @@ -0,0 +1,239 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package auditlog + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewListAuditLogsParams creates a new ListAuditLogsParams object +// with the default values initialized. +func NewListAuditLogsParams() ListAuditLogsParams { + + var ( + // initialize parameters with default values + + pageDefault = int64(1) + pageSizeDefault = int64(10) + ) + + return ListAuditLogsParams{ + Page: &pageDefault, + + PageSize: &pageSizeDefault, + } +} + +// ListAuditLogsParams contains all the bound params for the list audit logs operation +// typically these are obtained from a http.Request +// +// swagger:parameters listAuditLogs +type ListAuditLogsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The page number + In: query + Default: 1 + */ + Page *int64 + /*The size of per page + Maximum: 100 + In: query + Default: 10 + */ + PageSize *int64 + /*Query string to query resources. Supported query patterns are "exact match(k=v)", "fuzzy match(k=~v)", "range(k=[min~max])", "list with union releationship(k={v1 v2 v3})" and "list with intersetion relationship(k=(v1 v2 v3))". The value of range and list can be string(enclosed by " or '), integer or time(in format "2020-04-09 02:36:00"). All of these query patterns should be put in the query string "q=xxx" and splitted by ",". e.g. q=k1=v1,k2=~v2,k3=[min~max] + In: query + */ + Q *string + /*Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + In: query + */ + Sort *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewListAuditLogsParams() beforehand. +func (o *ListAuditLogsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + qPage, qhkPage, _ := qs.GetOK("page") + if err := o.bindPage(qPage, qhkPage, route.Formats); err != nil { + res = append(res, err) + } + + qPageSize, qhkPageSize, _ := qs.GetOK("page_size") + if err := o.bindPageSize(qPageSize, qhkPageSize, route.Formats); err != nil { + res = append(res, err) + } + + qQ, qhkQ, _ := qs.GetOK("q") + if err := o.bindQ(qQ, qhkQ, route.Formats); err != nil { + res = append(res, err) + } + + qSort, qhkSort, _ := qs.GetOK("sort") + if err := o.bindSort(qSort, qhkSort, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *ListAuditLogsParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *ListAuditLogsParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindPage binds and validates parameter Page from query. +func (o *ListAuditLogsParams) bindPage(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListAuditLogsParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page", "query", "int64", raw) + } + o.Page = &value + + return nil +} + +// bindPageSize binds and validates parameter PageSize from query. +func (o *ListAuditLogsParams) bindPageSize(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListAuditLogsParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page_size", "query", "int64", raw) + } + o.PageSize = &value + + if err := o.validatePageSize(formats); err != nil { + return err + } + + return nil +} + +// validatePageSize carries on validations for parameter PageSize +func (o *ListAuditLogsParams) validatePageSize(formats strfmt.Registry) error { + + if err := validate.MaximumInt("page_size", "query", int64(*o.PageSize), 100, false); err != nil { + return err + } + + return nil +} + +// bindQ binds and validates parameter Q from query. +func (o *ListAuditLogsParams) bindQ(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Q = &raw + + return nil +} + +// bindSort binds and validates parameter Sort from query. +func (o *ListAuditLogsParams) bindSort(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Sort = &raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/auditlog/list_audit_logs_responses.go b/src/server/v2.0/restapi/operations/auditlog/list_audit_logs_responses.go new file mode 100644 index 000000000..cab9c5fa3 --- /dev/null +++ b/src/server/v2.0/restapi/operations/auditlog/list_audit_logs_responses.go @@ -0,0 +1,304 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package auditlog + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/swag" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// ListAuditLogsOKCode is the HTTP code returned for type ListAuditLogsOK +const ListAuditLogsOKCode int = 200 + +/*ListAuditLogsOK Success + +swagger:response listAuditLogsOK +*/ +type ListAuditLogsOK struct { + /*Link refers to the previous page and next page + + */ + Link string `json:"Link"` + /*The total count of auditlogs + + */ + XTotalCount int64 `json:"X-Total-Count"` + + /* + In: Body + */ + Payload []*models.AuditLog `json:"body,omitempty"` +} + +// NewListAuditLogsOK creates ListAuditLogsOK with default headers values +func NewListAuditLogsOK() *ListAuditLogsOK { + + return &ListAuditLogsOK{} +} + +// WithLink adds the link to the list audit logs o k response +func (o *ListAuditLogsOK) WithLink(link string) *ListAuditLogsOK { + o.Link = link + return o +} + +// SetLink sets the link to the list audit logs o k response +func (o *ListAuditLogsOK) SetLink(link string) { + o.Link = link +} + +// WithXTotalCount adds the xTotalCount to the list audit logs o k response +func (o *ListAuditLogsOK) WithXTotalCount(xTotalCount int64) *ListAuditLogsOK { + o.XTotalCount = xTotalCount + return o +} + +// SetXTotalCount sets the xTotalCount to the list audit logs o k response +func (o *ListAuditLogsOK) SetXTotalCount(xTotalCount int64) { + o.XTotalCount = xTotalCount +} + +// WithPayload adds the payload to the list audit logs o k response +func (o *ListAuditLogsOK) WithPayload(payload []*models.AuditLog) *ListAuditLogsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list audit logs o k response +func (o *ListAuditLogsOK) SetPayload(payload []*models.AuditLog) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListAuditLogsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Link + + link := o.Link + if link != "" { + rw.Header().Set("Link", link) + } + + // response header X-Total-Count + + xTotalCount := swag.FormatInt64(o.XTotalCount) + if xTotalCount != "" { + rw.Header().Set("X-Total-Count", xTotalCount) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = make([]*models.AuditLog, 0, 50) + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ListAuditLogsBadRequestCode is the HTTP code returned for type ListAuditLogsBadRequest +const ListAuditLogsBadRequestCode int = 400 + +/*ListAuditLogsBadRequest Bad request + +swagger:response listAuditLogsBadRequest +*/ +type ListAuditLogsBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListAuditLogsBadRequest creates ListAuditLogsBadRequest with default headers values +func NewListAuditLogsBadRequest() *ListAuditLogsBadRequest { + + return &ListAuditLogsBadRequest{} +} + +// WithXRequestID adds the xRequestId to the list audit logs bad request response +func (o *ListAuditLogsBadRequest) WithXRequestID(xRequestID string) *ListAuditLogsBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list audit logs bad request response +func (o *ListAuditLogsBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list audit logs bad request response +func (o *ListAuditLogsBadRequest) WithPayload(payload *models.Errors) *ListAuditLogsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list audit logs bad request response +func (o *ListAuditLogsBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListAuditLogsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListAuditLogsUnauthorizedCode is the HTTP code returned for type ListAuditLogsUnauthorized +const ListAuditLogsUnauthorizedCode int = 401 + +/*ListAuditLogsUnauthorized Unauthorized + +swagger:response listAuditLogsUnauthorized +*/ +type ListAuditLogsUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListAuditLogsUnauthorized creates ListAuditLogsUnauthorized with default headers values +func NewListAuditLogsUnauthorized() *ListAuditLogsUnauthorized { + + return &ListAuditLogsUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the list audit logs unauthorized response +func (o *ListAuditLogsUnauthorized) WithXRequestID(xRequestID string) *ListAuditLogsUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list audit logs unauthorized response +func (o *ListAuditLogsUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list audit logs unauthorized response +func (o *ListAuditLogsUnauthorized) WithPayload(payload *models.Errors) *ListAuditLogsUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list audit logs unauthorized response +func (o *ListAuditLogsUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListAuditLogsUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListAuditLogsInternalServerErrorCode is the HTTP code returned for type ListAuditLogsInternalServerError +const ListAuditLogsInternalServerErrorCode int = 500 + +/*ListAuditLogsInternalServerError Internal server error + +swagger:response listAuditLogsInternalServerError +*/ +type ListAuditLogsInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListAuditLogsInternalServerError creates ListAuditLogsInternalServerError with default headers values +func NewListAuditLogsInternalServerError() *ListAuditLogsInternalServerError { + + return &ListAuditLogsInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the list audit logs internal server error response +func (o *ListAuditLogsInternalServerError) WithXRequestID(xRequestID string) *ListAuditLogsInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list audit logs internal server error response +func (o *ListAuditLogsInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list audit logs internal server error response +func (o *ListAuditLogsInternalServerError) WithPayload(payload *models.Errors) *ListAuditLogsInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list audit logs internal server error response +func (o *ListAuditLogsInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListAuditLogsInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/auditlog/list_audit_logs_urlbuilder.go b/src/server/v2.0/restapi/operations/auditlog/list_audit_logs_urlbuilder.go new file mode 100644 index 000000000..a2f3bdb9f --- /dev/null +++ b/src/server/v2.0/restapi/operations/auditlog/list_audit_logs_urlbuilder.go @@ -0,0 +1,132 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package auditlog + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// ListAuditLogsURL generates an URL for the list audit logs operation +type ListAuditLogsURL struct { + Page *int64 + PageSize *int64 + Q *string + Sort *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListAuditLogsURL) WithBasePath(bp string) *ListAuditLogsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListAuditLogsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ListAuditLogsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/audit-logs" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var pageQ string + if o.Page != nil { + pageQ = swag.FormatInt64(*o.Page) + } + if pageQ != "" { + qs.Set("page", pageQ) + } + + var pageSizeQ string + if o.PageSize != nil { + pageSizeQ = swag.FormatInt64(*o.PageSize) + } + if pageSizeQ != "" { + qs.Set("page_size", pageSizeQ) + } + + var qQ string + if o.Q != nil { + qQ = *o.Q + } + if qQ != "" { + qs.Set("q", qQ) + } + + var sortQ string + if o.Sort != nil { + sortQ = *o.Sort + } + if sortQ != "" { + qs.Set("sort", sortQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ListAuditLogsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ListAuditLogsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ListAuditLogsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ListAuditLogsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ListAuditLogsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ListAuditLogsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/configure/get_configurations.go b/src/server/v2.0/restapi/operations/configure/get_configurations.go new file mode 100644 index 000000000..61c88127f --- /dev/null +++ b/src/server/v2.0/restapi/operations/configure/get_configurations.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package configure + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetConfigurationsHandlerFunc turns a function with the right signature into a get configurations handler +type GetConfigurationsHandlerFunc func(GetConfigurationsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetConfigurationsHandlerFunc) Handle(params GetConfigurationsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetConfigurationsHandler interface for that can handle valid get configurations params +type GetConfigurationsHandler interface { + Handle(GetConfigurationsParams, interface{}) middleware.Responder +} + +// NewGetConfigurations creates a new http.Handler for the get configurations operation +func NewGetConfigurations(ctx *middleware.Context, handler GetConfigurationsHandler) *GetConfigurations { + return &GetConfigurations{Context: ctx, Handler: handler} +} + +/*GetConfigurations swagger:route GET /configurations configure getConfigurations + +Get system configurations. + +This endpoint is for retrieving system configurations that only provides for admin user. + + +*/ +type GetConfigurations struct { + Context *middleware.Context + Handler GetConfigurationsHandler +} + +func (o *GetConfigurations) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetConfigurationsParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/configure/get_configurations_parameters.go b/src/server/v2.0/restapi/operations/configure/get_configurations_parameters.go new file mode 100644 index 000000000..cfcad310a --- /dev/null +++ b/src/server/v2.0/restapi/operations/configure/get_configurations_parameters.go @@ -0,0 +1,89 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package configure + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewGetConfigurationsParams creates a new GetConfigurationsParams object +// no default values defined in spec. +func NewGetConfigurationsParams() GetConfigurationsParams { + + return GetConfigurationsParams{} +} + +// GetConfigurationsParams contains all the bound params for the get configurations operation +// typically these are obtained from a http.Request +// +// swagger:parameters getConfigurations +type GetConfigurationsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetConfigurationsParams() beforehand. +func (o *GetConfigurationsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetConfigurationsParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetConfigurationsParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} diff --git a/src/server/v2.0/restapi/operations/configure/get_configurations_responses.go b/src/server/v2.0/restapi/operations/configure/get_configurations_responses.go new file mode 100644 index 000000000..4335db32d --- /dev/null +++ b/src/server/v2.0/restapi/operations/configure/get_configurations_responses.go @@ -0,0 +1,130 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package configure + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetConfigurationsOKCode is the HTTP code returned for type GetConfigurationsOK +const GetConfigurationsOKCode int = 200 + +/*GetConfigurationsOK Get system configurations successfully. The response body is a map. + +swagger:response getConfigurationsOK +*/ +type GetConfigurationsOK struct { + + /* + In: Body + */ + Payload *models.ConfigurationsResponse `json:"body,omitempty"` +} + +// NewGetConfigurationsOK creates GetConfigurationsOK with default headers values +func NewGetConfigurationsOK() *GetConfigurationsOK { + + return &GetConfigurationsOK{} +} + +// WithPayload adds the payload to the get configurations o k response +func (o *GetConfigurationsOK) WithPayload(payload *models.ConfigurationsResponse) *GetConfigurationsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get configurations o k response +func (o *GetConfigurationsOK) SetPayload(payload *models.ConfigurationsResponse) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetConfigurationsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetConfigurationsUnauthorizedCode is the HTTP code returned for type GetConfigurationsUnauthorized +const GetConfigurationsUnauthorizedCode int = 401 + +/*GetConfigurationsUnauthorized User need to log in first.ß + +swagger:response getConfigurationsUnauthorized +*/ +type GetConfigurationsUnauthorized struct { +} + +// NewGetConfigurationsUnauthorized creates GetConfigurationsUnauthorized with default headers values +func NewGetConfigurationsUnauthorized() *GetConfigurationsUnauthorized { + + return &GetConfigurationsUnauthorized{} +} + +// WriteResponse to the client +func (o *GetConfigurationsUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(401) +} + +// GetConfigurationsForbiddenCode is the HTTP code returned for type GetConfigurationsForbidden +const GetConfigurationsForbiddenCode int = 403 + +/*GetConfigurationsForbidden User does not have permission of admin role. + +swagger:response getConfigurationsForbidden +*/ +type GetConfigurationsForbidden struct { +} + +// NewGetConfigurationsForbidden creates GetConfigurationsForbidden with default headers values +func NewGetConfigurationsForbidden() *GetConfigurationsForbidden { + + return &GetConfigurationsForbidden{} +} + +// WriteResponse to the client +func (o *GetConfigurationsForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(403) +} + +// GetConfigurationsInternalServerErrorCode is the HTTP code returned for type GetConfigurationsInternalServerError +const GetConfigurationsInternalServerErrorCode int = 500 + +/*GetConfigurationsInternalServerError Unexpected internal errors. + +swagger:response getConfigurationsInternalServerError +*/ +type GetConfigurationsInternalServerError struct { +} + +// NewGetConfigurationsInternalServerError creates GetConfigurationsInternalServerError with default headers values +func NewGetConfigurationsInternalServerError() *GetConfigurationsInternalServerError { + + return &GetConfigurationsInternalServerError{} +} + +// WriteResponse to the client +func (o *GetConfigurationsInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(500) +} diff --git a/src/server/v2.0/restapi/operations/configure/get_configurations_urlbuilder.go b/src/server/v2.0/restapi/operations/configure/get_configurations_urlbuilder.go new file mode 100644 index 000000000..fcbb01175 --- /dev/null +++ b/src/server/v2.0/restapi/operations/configure/get_configurations_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package configure + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetConfigurationsURL generates an URL for the get configurations operation +type GetConfigurationsURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetConfigurationsURL) WithBasePath(bp string) *GetConfigurationsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetConfigurationsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetConfigurationsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/configurations" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetConfigurationsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetConfigurationsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetConfigurationsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetConfigurationsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetConfigurationsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetConfigurationsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/configure/get_internalconfig.go b/src/server/v2.0/restapi/operations/configure/get_internalconfig.go new file mode 100644 index 000000000..014ec4e34 --- /dev/null +++ b/src/server/v2.0/restapi/operations/configure/get_internalconfig.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package configure + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetInternalconfigHandlerFunc turns a function with the right signature into a get internalconfig handler +type GetInternalconfigHandlerFunc func(GetInternalconfigParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetInternalconfigHandlerFunc) Handle(params GetInternalconfigParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetInternalconfigHandler interface for that can handle valid get internalconfig params +type GetInternalconfigHandler interface { + Handle(GetInternalconfigParams, interface{}) middleware.Responder +} + +// NewGetInternalconfig creates a new http.Handler for the get internalconfig operation +func NewGetInternalconfig(ctx *middleware.Context, handler GetInternalconfigHandler) *GetInternalconfig { + return &GetInternalconfig{Context: ctx, Handler: handler} +} + +/*GetInternalconfig swagger:route GET /internalconfig configure getInternalconfig + +Get internal configurations. + +This endpoint is for retrieving system configurations that only provides for internal api call. + + +*/ +type GetInternalconfig struct { + Context *middleware.Context + Handler GetInternalconfigHandler +} + +func (o *GetInternalconfig) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetInternalconfigParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/configure/get_internalconfig_parameters.go b/src/server/v2.0/restapi/operations/configure/get_internalconfig_parameters.go new file mode 100644 index 000000000..1721af9a5 --- /dev/null +++ b/src/server/v2.0/restapi/operations/configure/get_internalconfig_parameters.go @@ -0,0 +1,89 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package configure + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewGetInternalconfigParams creates a new GetInternalconfigParams object +// no default values defined in spec. +func NewGetInternalconfigParams() GetInternalconfigParams { + + return GetInternalconfigParams{} +} + +// GetInternalconfigParams contains all the bound params for the get internalconfig operation +// typically these are obtained from a http.Request +// +// swagger:parameters getInternalconfig +type GetInternalconfigParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetInternalconfigParams() beforehand. +func (o *GetInternalconfigParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetInternalconfigParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetInternalconfigParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} diff --git a/src/server/v2.0/restapi/operations/configure/get_internalconfig_responses.go b/src/server/v2.0/restapi/operations/configure/get_internalconfig_responses.go new file mode 100644 index 000000000..14489d1e1 --- /dev/null +++ b/src/server/v2.0/restapi/operations/configure/get_internalconfig_responses.go @@ -0,0 +1,133 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package configure + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetInternalconfigOKCode is the HTTP code returned for type GetInternalconfigOK +const GetInternalconfigOKCode int = 200 + +/*GetInternalconfigOK Get system configurations successfully. The response body is a map. + +swagger:response getInternalconfigOK +*/ +type GetInternalconfigOK struct { + + /* + In: Body + */ + Payload models.InternalConfigurationsResponse `json:"body,omitempty"` +} + +// NewGetInternalconfigOK creates GetInternalconfigOK with default headers values +func NewGetInternalconfigOK() *GetInternalconfigOK { + + return &GetInternalconfigOK{} +} + +// WithPayload adds the payload to the get internalconfig o k response +func (o *GetInternalconfigOK) WithPayload(payload models.InternalConfigurationsResponse) *GetInternalconfigOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get internalconfig o k response +func (o *GetInternalconfigOK) SetPayload(payload models.InternalConfigurationsResponse) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetInternalconfigOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty map + payload = models.InternalConfigurationsResponse{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// GetInternalconfigUnauthorizedCode is the HTTP code returned for type GetInternalconfigUnauthorized +const GetInternalconfigUnauthorizedCode int = 401 + +/*GetInternalconfigUnauthorized User need to log in first. + +swagger:response getInternalconfigUnauthorized +*/ +type GetInternalconfigUnauthorized struct { +} + +// NewGetInternalconfigUnauthorized creates GetInternalconfigUnauthorized with default headers values +func NewGetInternalconfigUnauthorized() *GetInternalconfigUnauthorized { + + return &GetInternalconfigUnauthorized{} +} + +// WriteResponse to the client +func (o *GetInternalconfigUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(401) +} + +// GetInternalconfigForbiddenCode is the HTTP code returned for type GetInternalconfigForbidden +const GetInternalconfigForbiddenCode int = 403 + +/*GetInternalconfigForbidden User does not have permission of admin role. + +swagger:response getInternalconfigForbidden +*/ +type GetInternalconfigForbidden struct { +} + +// NewGetInternalconfigForbidden creates GetInternalconfigForbidden with default headers values +func NewGetInternalconfigForbidden() *GetInternalconfigForbidden { + + return &GetInternalconfigForbidden{} +} + +// WriteResponse to the client +func (o *GetInternalconfigForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(403) +} + +// GetInternalconfigInternalServerErrorCode is the HTTP code returned for type GetInternalconfigInternalServerError +const GetInternalconfigInternalServerErrorCode int = 500 + +/*GetInternalconfigInternalServerError Unexpected internal errors. + +swagger:response getInternalconfigInternalServerError +*/ +type GetInternalconfigInternalServerError struct { +} + +// NewGetInternalconfigInternalServerError creates GetInternalconfigInternalServerError with default headers values +func NewGetInternalconfigInternalServerError() *GetInternalconfigInternalServerError { + + return &GetInternalconfigInternalServerError{} +} + +// WriteResponse to the client +func (o *GetInternalconfigInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(500) +} diff --git a/src/server/v2.0/restapi/operations/configure/get_internalconfig_urlbuilder.go b/src/server/v2.0/restapi/operations/configure/get_internalconfig_urlbuilder.go new file mode 100644 index 000000000..dfff7e3bc --- /dev/null +++ b/src/server/v2.0/restapi/operations/configure/get_internalconfig_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package configure + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetInternalconfigURL generates an URL for the get internalconfig operation +type GetInternalconfigURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetInternalconfigURL) WithBasePath(bp string) *GetInternalconfigURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetInternalconfigURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetInternalconfigURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/internalconfig" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetInternalconfigURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetInternalconfigURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetInternalconfigURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetInternalconfigURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetInternalconfigURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetInternalconfigURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/configure/update_configurations.go b/src/server/v2.0/restapi/operations/configure/update_configurations.go new file mode 100644 index 000000000..10eae8ea8 --- /dev/null +++ b/src/server/v2.0/restapi/operations/configure/update_configurations.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package configure + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// UpdateConfigurationsHandlerFunc turns a function with the right signature into a update configurations handler +type UpdateConfigurationsHandlerFunc func(UpdateConfigurationsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn UpdateConfigurationsHandlerFunc) Handle(params UpdateConfigurationsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// UpdateConfigurationsHandler interface for that can handle valid update configurations params +type UpdateConfigurationsHandler interface { + Handle(UpdateConfigurationsParams, interface{}) middleware.Responder +} + +// NewUpdateConfigurations creates a new http.Handler for the update configurations operation +func NewUpdateConfigurations(ctx *middleware.Context, handler UpdateConfigurationsHandler) *UpdateConfigurations { + return &UpdateConfigurations{Context: ctx, Handler: handler} +} + +/*UpdateConfigurations swagger:route PUT /configurations configure updateConfigurations + +Modify system configurations. + +This endpoint is for modifying system configurations that only provides for admin user. + + +*/ +type UpdateConfigurations struct { + Context *middleware.Context + Handler UpdateConfigurationsHandler +} + +func (o *UpdateConfigurations) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewUpdateConfigurationsParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/configure/update_configurations_parameters.go b/src/server/v2.0/restapi/operations/configure/update_configurations_parameters.go new file mode 100644 index 000000000..ee10f031c --- /dev/null +++ b/src/server/v2.0/restapi/operations/configure/update_configurations_parameters.go @@ -0,0 +1,120 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package configure + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewUpdateConfigurationsParams creates a new UpdateConfigurationsParams object +// no default values defined in spec. +func NewUpdateConfigurationsParams() UpdateConfigurationsParams { + + return UpdateConfigurationsParams{} +} + +// UpdateConfigurationsParams contains all the bound params for the update configurations operation +// typically these are obtained from a http.Request +// +// swagger:parameters updateConfigurations +type UpdateConfigurationsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The configuration map can contain a subset of the attributes of the schema, which are to be updated. + Required: true + In: body + */ + Configurations *models.Configurations +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewUpdateConfigurationsParams() beforehand. +func (o *UpdateConfigurationsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Configurations + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("configurations", "body", "")) + } else { + res = append(res, errors.NewParseError("configurations", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Configurations = &body + } + } + } else { + res = append(res, errors.Required("configurations", "body", "")) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *UpdateConfigurationsParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *UpdateConfigurationsParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} diff --git a/src/server/v2.0/restapi/operations/configure/update_configurations_responses.go b/src/server/v2.0/restapi/operations/configure/update_configurations_responses.go new file mode 100644 index 000000000..84606dfd2 --- /dev/null +++ b/src/server/v2.0/restapi/operations/configure/update_configurations_responses.go @@ -0,0 +1,108 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package configure + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" +) + +// UpdateConfigurationsOKCode is the HTTP code returned for type UpdateConfigurationsOK +const UpdateConfigurationsOKCode int = 200 + +/*UpdateConfigurationsOK Modify system configurations successfully. + +swagger:response updateConfigurationsOK +*/ +type UpdateConfigurationsOK struct { +} + +// NewUpdateConfigurationsOK creates UpdateConfigurationsOK with default headers values +func NewUpdateConfigurationsOK() *UpdateConfigurationsOK { + + return &UpdateConfigurationsOK{} +} + +// WriteResponse to the client +func (o *UpdateConfigurationsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// UpdateConfigurationsUnauthorizedCode is the HTTP code returned for type UpdateConfigurationsUnauthorized +const UpdateConfigurationsUnauthorizedCode int = 401 + +/*UpdateConfigurationsUnauthorized User need to log in first. + +swagger:response updateConfigurationsUnauthorized +*/ +type UpdateConfigurationsUnauthorized struct { +} + +// NewUpdateConfigurationsUnauthorized creates UpdateConfigurationsUnauthorized with default headers values +func NewUpdateConfigurationsUnauthorized() *UpdateConfigurationsUnauthorized { + + return &UpdateConfigurationsUnauthorized{} +} + +// WriteResponse to the client +func (o *UpdateConfigurationsUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(401) +} + +// UpdateConfigurationsForbiddenCode is the HTTP code returned for type UpdateConfigurationsForbidden +const UpdateConfigurationsForbiddenCode int = 403 + +/*UpdateConfigurationsForbidden User does not have permission of admin role. + +swagger:response updateConfigurationsForbidden +*/ +type UpdateConfigurationsForbidden struct { +} + +// NewUpdateConfigurationsForbidden creates UpdateConfigurationsForbidden with default headers values +func NewUpdateConfigurationsForbidden() *UpdateConfigurationsForbidden { + + return &UpdateConfigurationsForbidden{} +} + +// WriteResponse to the client +func (o *UpdateConfigurationsForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(403) +} + +// UpdateConfigurationsInternalServerErrorCode is the HTTP code returned for type UpdateConfigurationsInternalServerError +const UpdateConfigurationsInternalServerErrorCode int = 500 + +/*UpdateConfigurationsInternalServerError Unexpected internal errors. + +swagger:response updateConfigurationsInternalServerError +*/ +type UpdateConfigurationsInternalServerError struct { +} + +// NewUpdateConfigurationsInternalServerError creates UpdateConfigurationsInternalServerError with default headers values +func NewUpdateConfigurationsInternalServerError() *UpdateConfigurationsInternalServerError { + + return &UpdateConfigurationsInternalServerError{} +} + +// WriteResponse to the client +func (o *UpdateConfigurationsInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(500) +} diff --git a/src/server/v2.0/restapi/operations/configure/update_configurations_urlbuilder.go b/src/server/v2.0/restapi/operations/configure/update_configurations_urlbuilder.go new file mode 100644 index 000000000..d9e7d3b3e --- /dev/null +++ b/src/server/v2.0/restapi/operations/configure/update_configurations_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package configure + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// UpdateConfigurationsURL generates an URL for the update configurations operation +type UpdateConfigurationsURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdateConfigurationsURL) WithBasePath(bp string) *UpdateConfigurationsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdateConfigurationsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *UpdateConfigurationsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/configurations" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *UpdateConfigurationsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *UpdateConfigurationsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *UpdateConfigurationsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on UpdateConfigurationsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on UpdateConfigurationsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *UpdateConfigurationsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/gc/create_gc_schedule.go b/src/server/v2.0/restapi/operations/gc/create_gc_schedule.go new file mode 100644 index 000000000..8e7ce808e --- /dev/null +++ b/src/server/v2.0/restapi/operations/gc/create_gc_schedule.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package gc + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateGCScheduleHandlerFunc turns a function with the right signature into a create GC schedule handler +type CreateGCScheduleHandlerFunc func(CreateGCScheduleParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateGCScheduleHandlerFunc) Handle(params CreateGCScheduleParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateGCScheduleHandler interface for that can handle valid create GC schedule params +type CreateGCScheduleHandler interface { + Handle(CreateGCScheduleParams, interface{}) middleware.Responder +} + +// NewCreateGCSchedule creates a new http.Handler for the create GC schedule operation +func NewCreateGCSchedule(ctx *middleware.Context, handler CreateGCScheduleHandler) *CreateGCSchedule { + return &CreateGCSchedule{Context: ctx, Handler: handler} +} + +/*CreateGCSchedule swagger:route POST /system/gc/schedule gc createGcSchedule + +Create a gc schedule. + +This endpoint is for update gc schedule. + + +*/ +type CreateGCSchedule struct { + Context *middleware.Context + Handler CreateGCScheduleHandler +} + +func (o *CreateGCSchedule) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewCreateGCScheduleParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/gc/create_gc_schedule_parameters.go b/src/server/v2.0/restapi/operations/gc/create_gc_schedule_parameters.go new file mode 100644 index 000000000..ca410a8eb --- /dev/null +++ b/src/server/v2.0/restapi/operations/gc/create_gc_schedule_parameters.go @@ -0,0 +1,120 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package gc + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewCreateGCScheduleParams creates a new CreateGCScheduleParams object +// no default values defined in spec. +func NewCreateGCScheduleParams() CreateGCScheduleParams { + + return CreateGCScheduleParams{} +} + +// CreateGCScheduleParams contains all the bound params for the create GC schedule operation +// typically these are obtained from a http.Request +// +// swagger:parameters createGCSchedule +type CreateGCScheduleParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*Updates of gc's schedule. + Required: true + In: body + */ + Schedule *models.Schedule +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateGCScheduleParams() beforehand. +func (o *CreateGCScheduleParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Schedule + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("schedule", "body", "")) + } else { + res = append(res, errors.NewParseError("schedule", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Schedule = &body + } + } + } else { + res = append(res, errors.Required("schedule", "body", "")) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *CreateGCScheduleParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *CreateGCScheduleParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} diff --git a/src/server/v2.0/restapi/operations/gc/create_gc_schedule_responses.go b/src/server/v2.0/restapi/operations/gc/create_gc_schedule_responses.go new file mode 100644 index 000000000..82f0e87d6 --- /dev/null +++ b/src/server/v2.0/restapi/operations/gc/create_gc_schedule_responses.go @@ -0,0 +1,412 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package gc + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// CreateGCScheduleCreatedCode is the HTTP code returned for type CreateGCScheduleCreated +const CreateGCScheduleCreatedCode int = 201 + +/*CreateGCScheduleCreated Created + +swagger:response createGcScheduleCreated +*/ +type CreateGCScheduleCreated struct { + /*The location of the resource + + */ + Location string `json:"Location"` + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewCreateGCScheduleCreated creates CreateGCScheduleCreated with default headers values +func NewCreateGCScheduleCreated() *CreateGCScheduleCreated { + + return &CreateGCScheduleCreated{} +} + +// WithLocation adds the location to the create Gc schedule created response +func (o *CreateGCScheduleCreated) WithLocation(location string) *CreateGCScheduleCreated { + o.Location = location + return o +} + +// SetLocation sets the location to the create Gc schedule created response +func (o *CreateGCScheduleCreated) SetLocation(location string) { + o.Location = location +} + +// WithXRequestID adds the xRequestId to the create Gc schedule created response +func (o *CreateGCScheduleCreated) WithXRequestID(xRequestID string) *CreateGCScheduleCreated { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create Gc schedule created response +func (o *CreateGCScheduleCreated) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *CreateGCScheduleCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Location + + location := o.Location + if location != "" { + rw.Header().Set("Location", location) + } + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(201) +} + +// CreateGCScheduleBadRequestCode is the HTTP code returned for type CreateGCScheduleBadRequest +const CreateGCScheduleBadRequestCode int = 400 + +/*CreateGCScheduleBadRequest Bad request + +swagger:response createGcScheduleBadRequest +*/ +type CreateGCScheduleBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateGCScheduleBadRequest creates CreateGCScheduleBadRequest with default headers values +func NewCreateGCScheduleBadRequest() *CreateGCScheduleBadRequest { + + return &CreateGCScheduleBadRequest{} +} + +// WithXRequestID adds the xRequestId to the create Gc schedule bad request response +func (o *CreateGCScheduleBadRequest) WithXRequestID(xRequestID string) *CreateGCScheduleBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create Gc schedule bad request response +func (o *CreateGCScheduleBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create Gc schedule bad request response +func (o *CreateGCScheduleBadRequest) WithPayload(payload *models.Errors) *CreateGCScheduleBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Gc schedule bad request response +func (o *CreateGCScheduleBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateGCScheduleBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateGCScheduleUnauthorizedCode is the HTTP code returned for type CreateGCScheduleUnauthorized +const CreateGCScheduleUnauthorizedCode int = 401 + +/*CreateGCScheduleUnauthorized Unauthorized + +swagger:response createGcScheduleUnauthorized +*/ +type CreateGCScheduleUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateGCScheduleUnauthorized creates CreateGCScheduleUnauthorized with default headers values +func NewCreateGCScheduleUnauthorized() *CreateGCScheduleUnauthorized { + + return &CreateGCScheduleUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the create Gc schedule unauthorized response +func (o *CreateGCScheduleUnauthorized) WithXRequestID(xRequestID string) *CreateGCScheduleUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create Gc schedule unauthorized response +func (o *CreateGCScheduleUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create Gc schedule unauthorized response +func (o *CreateGCScheduleUnauthorized) WithPayload(payload *models.Errors) *CreateGCScheduleUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Gc schedule unauthorized response +func (o *CreateGCScheduleUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateGCScheduleUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateGCScheduleForbiddenCode is the HTTP code returned for type CreateGCScheduleForbidden +const CreateGCScheduleForbiddenCode int = 403 + +/*CreateGCScheduleForbidden Forbidden + +swagger:response createGcScheduleForbidden +*/ +type CreateGCScheduleForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateGCScheduleForbidden creates CreateGCScheduleForbidden with default headers values +func NewCreateGCScheduleForbidden() *CreateGCScheduleForbidden { + + return &CreateGCScheduleForbidden{} +} + +// WithXRequestID adds the xRequestId to the create Gc schedule forbidden response +func (o *CreateGCScheduleForbidden) WithXRequestID(xRequestID string) *CreateGCScheduleForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create Gc schedule forbidden response +func (o *CreateGCScheduleForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create Gc schedule forbidden response +func (o *CreateGCScheduleForbidden) WithPayload(payload *models.Errors) *CreateGCScheduleForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Gc schedule forbidden response +func (o *CreateGCScheduleForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateGCScheduleForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateGCScheduleConflictCode is the HTTP code returned for type CreateGCScheduleConflict +const CreateGCScheduleConflictCode int = 409 + +/*CreateGCScheduleConflict Conflict + +swagger:response createGcScheduleConflict +*/ +type CreateGCScheduleConflict struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateGCScheduleConflict creates CreateGCScheduleConflict with default headers values +func NewCreateGCScheduleConflict() *CreateGCScheduleConflict { + + return &CreateGCScheduleConflict{} +} + +// WithXRequestID adds the xRequestId to the create Gc schedule conflict response +func (o *CreateGCScheduleConflict) WithXRequestID(xRequestID string) *CreateGCScheduleConflict { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create Gc schedule conflict response +func (o *CreateGCScheduleConflict) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create Gc schedule conflict response +func (o *CreateGCScheduleConflict) WithPayload(payload *models.Errors) *CreateGCScheduleConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Gc schedule conflict response +func (o *CreateGCScheduleConflict) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateGCScheduleConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateGCScheduleInternalServerErrorCode is the HTTP code returned for type CreateGCScheduleInternalServerError +const CreateGCScheduleInternalServerErrorCode int = 500 + +/*CreateGCScheduleInternalServerError Internal server error + +swagger:response createGcScheduleInternalServerError +*/ +type CreateGCScheduleInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateGCScheduleInternalServerError creates CreateGCScheduleInternalServerError with default headers values +func NewCreateGCScheduleInternalServerError() *CreateGCScheduleInternalServerError { + + return &CreateGCScheduleInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the create Gc schedule internal server error response +func (o *CreateGCScheduleInternalServerError) WithXRequestID(xRequestID string) *CreateGCScheduleInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create Gc schedule internal server error response +func (o *CreateGCScheduleInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create Gc schedule internal server error response +func (o *CreateGCScheduleInternalServerError) WithPayload(payload *models.Errors) *CreateGCScheduleInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Gc schedule internal server error response +func (o *CreateGCScheduleInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateGCScheduleInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/gc/create_gc_schedule_urlbuilder.go b/src/server/v2.0/restapi/operations/gc/create_gc_schedule_urlbuilder.go new file mode 100644 index 000000000..1056355e7 --- /dev/null +++ b/src/server/v2.0/restapi/operations/gc/create_gc_schedule_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package gc + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// CreateGCScheduleURL generates an URL for the create GC schedule operation +type CreateGCScheduleURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateGCScheduleURL) WithBasePath(bp string) *CreateGCScheduleURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateGCScheduleURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateGCScheduleURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/system/gc/schedule" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateGCScheduleURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateGCScheduleURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateGCScheduleURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateGCScheduleURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateGCScheduleURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateGCScheduleURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/gc/get_gc.go b/src/server/v2.0/restapi/operations/gc/get_gc.go new file mode 100644 index 000000000..8c1477058 --- /dev/null +++ b/src/server/v2.0/restapi/operations/gc/get_gc.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package gc + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetGCHandlerFunc turns a function with the right signature into a get GC handler +type GetGCHandlerFunc func(GetGCParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetGCHandlerFunc) Handle(params GetGCParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetGCHandler interface for that can handle valid get GC params +type GetGCHandler interface { + Handle(GetGCParams, interface{}) middleware.Responder +} + +// NewGetGC creates a new http.Handler for the get GC operation +func NewGetGC(ctx *middleware.Context, handler GetGCHandler) *GetGC { + return &GetGC{Context: ctx, Handler: handler} +} + +/*GetGC swagger:route GET /system/gc/{gc_id} gc getGc + +Get gc status. + +This endpoint let user get gc status filtered by specific ID. + +*/ +type GetGC struct { + Context *middleware.Context + Handler GetGCHandler +} + +func (o *GetGC) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetGCParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/gc/get_gc_history.go b/src/server/v2.0/restapi/operations/gc/get_gc_history.go new file mode 100644 index 000000000..e9da29dab --- /dev/null +++ b/src/server/v2.0/restapi/operations/gc/get_gc_history.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package gc + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetGCHistoryHandlerFunc turns a function with the right signature into a get GC history handler +type GetGCHistoryHandlerFunc func(GetGCHistoryParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetGCHistoryHandlerFunc) Handle(params GetGCHistoryParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetGCHistoryHandler interface for that can handle valid get GC history params +type GetGCHistoryHandler interface { + Handle(GetGCHistoryParams, interface{}) middleware.Responder +} + +// NewGetGCHistory creates a new http.Handler for the get GC history operation +func NewGetGCHistory(ctx *middleware.Context, handler GetGCHistoryHandler) *GetGCHistory { + return &GetGCHistory{Context: ctx, Handler: handler} +} + +/*GetGCHistory swagger:route GET /system/gc gc getGcHistory + +Get gc results. + +This endpoint let user get gc execution history. + +*/ +type GetGCHistory struct { + Context *middleware.Context + Handler GetGCHistoryHandler +} + +func (o *GetGCHistory) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetGCHistoryParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/gc/get_gc_history_parameters.go b/src/server/v2.0/restapi/operations/gc/get_gc_history_parameters.go new file mode 100644 index 000000000..ac17e0a7f --- /dev/null +++ b/src/server/v2.0/restapi/operations/gc/get_gc_history_parameters.go @@ -0,0 +1,239 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package gc + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewGetGCHistoryParams creates a new GetGCHistoryParams object +// with the default values initialized. +func NewGetGCHistoryParams() GetGCHistoryParams { + + var ( + // initialize parameters with default values + + pageDefault = int64(1) + pageSizeDefault = int64(10) + ) + + return GetGCHistoryParams{ + Page: &pageDefault, + + PageSize: &pageSizeDefault, + } +} + +// GetGCHistoryParams contains all the bound params for the get GC history operation +// typically these are obtained from a http.Request +// +// swagger:parameters getGCHistory +type GetGCHistoryParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The page number + In: query + Default: 1 + */ + Page *int64 + /*The size of per page + Maximum: 100 + In: query + Default: 10 + */ + PageSize *int64 + /*Query string to query resources. Supported query patterns are "exact match(k=v)", "fuzzy match(k=~v)", "range(k=[min~max])", "list with union releationship(k={v1 v2 v3})" and "list with intersetion relationship(k=(v1 v2 v3))". The value of range and list can be string(enclosed by " or '), integer or time(in format "2020-04-09 02:36:00"). All of these query patterns should be put in the query string "q=xxx" and splitted by ",". e.g. q=k1=v1,k2=~v2,k3=[min~max] + In: query + */ + Q *string + /*Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + In: query + */ + Sort *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetGCHistoryParams() beforehand. +func (o *GetGCHistoryParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + qPage, qhkPage, _ := qs.GetOK("page") + if err := o.bindPage(qPage, qhkPage, route.Formats); err != nil { + res = append(res, err) + } + + qPageSize, qhkPageSize, _ := qs.GetOK("page_size") + if err := o.bindPageSize(qPageSize, qhkPageSize, route.Formats); err != nil { + res = append(res, err) + } + + qQ, qhkQ, _ := qs.GetOK("q") + if err := o.bindQ(qQ, qhkQ, route.Formats); err != nil { + res = append(res, err) + } + + qSort, qhkSort, _ := qs.GetOK("sort") + if err := o.bindSort(qSort, qhkSort, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetGCHistoryParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetGCHistoryParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindPage binds and validates parameter Page from query. +func (o *GetGCHistoryParams) bindPage(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewGetGCHistoryParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page", "query", "int64", raw) + } + o.Page = &value + + return nil +} + +// bindPageSize binds and validates parameter PageSize from query. +func (o *GetGCHistoryParams) bindPageSize(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewGetGCHistoryParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page_size", "query", "int64", raw) + } + o.PageSize = &value + + if err := o.validatePageSize(formats); err != nil { + return err + } + + return nil +} + +// validatePageSize carries on validations for parameter PageSize +func (o *GetGCHistoryParams) validatePageSize(formats strfmt.Registry) error { + + if err := validate.MaximumInt("page_size", "query", int64(*o.PageSize), 100, false); err != nil { + return err + } + + return nil +} + +// bindQ binds and validates parameter Q from query. +func (o *GetGCHistoryParams) bindQ(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Q = &raw + + return nil +} + +// bindSort binds and validates parameter Sort from query. +func (o *GetGCHistoryParams) bindSort(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Sort = &raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/gc/get_gc_history_responses.go b/src/server/v2.0/restapi/operations/gc/get_gc_history_responses.go new file mode 100644 index 000000000..ea55e8b88 --- /dev/null +++ b/src/server/v2.0/restapi/operations/gc/get_gc_history_responses.go @@ -0,0 +1,304 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package gc + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/swag" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetGCHistoryOKCode is the HTTP code returned for type GetGCHistoryOK +const GetGCHistoryOKCode int = 200 + +/*GetGCHistoryOK Get gc results successfully. + +swagger:response getGcHistoryOK +*/ +type GetGCHistoryOK struct { + /*Link refers to the previous page and next page + + */ + Link string `json:"Link"` + /*The total count of history + + */ + XTotalCount int64 `json:"X-Total-Count"` + + /* + In: Body + */ + Payload []*models.GCHistory `json:"body,omitempty"` +} + +// NewGetGCHistoryOK creates GetGCHistoryOK with default headers values +func NewGetGCHistoryOK() *GetGCHistoryOK { + + return &GetGCHistoryOK{} +} + +// WithLink adds the link to the get Gc history o k response +func (o *GetGCHistoryOK) WithLink(link string) *GetGCHistoryOK { + o.Link = link + return o +} + +// SetLink sets the link to the get Gc history o k response +func (o *GetGCHistoryOK) SetLink(link string) { + o.Link = link +} + +// WithXTotalCount adds the xTotalCount to the get Gc history o k response +func (o *GetGCHistoryOK) WithXTotalCount(xTotalCount int64) *GetGCHistoryOK { + o.XTotalCount = xTotalCount + return o +} + +// SetXTotalCount sets the xTotalCount to the get Gc history o k response +func (o *GetGCHistoryOK) SetXTotalCount(xTotalCount int64) { + o.XTotalCount = xTotalCount +} + +// WithPayload adds the payload to the get Gc history o k response +func (o *GetGCHistoryOK) WithPayload(payload []*models.GCHistory) *GetGCHistoryOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Gc history o k response +func (o *GetGCHistoryOK) SetPayload(payload []*models.GCHistory) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetGCHistoryOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Link + + link := o.Link + if link != "" { + rw.Header().Set("Link", link) + } + + // response header X-Total-Count + + xTotalCount := swag.FormatInt64(o.XTotalCount) + if xTotalCount != "" { + rw.Header().Set("X-Total-Count", xTotalCount) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = make([]*models.GCHistory, 0, 50) + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// GetGCHistoryUnauthorizedCode is the HTTP code returned for type GetGCHistoryUnauthorized +const GetGCHistoryUnauthorizedCode int = 401 + +/*GetGCHistoryUnauthorized Unauthorized + +swagger:response getGcHistoryUnauthorized +*/ +type GetGCHistoryUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetGCHistoryUnauthorized creates GetGCHistoryUnauthorized with default headers values +func NewGetGCHistoryUnauthorized() *GetGCHistoryUnauthorized { + + return &GetGCHistoryUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the get Gc history unauthorized response +func (o *GetGCHistoryUnauthorized) WithXRequestID(xRequestID string) *GetGCHistoryUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get Gc history unauthorized response +func (o *GetGCHistoryUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get Gc history unauthorized response +func (o *GetGCHistoryUnauthorized) WithPayload(payload *models.Errors) *GetGCHistoryUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Gc history unauthorized response +func (o *GetGCHistoryUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetGCHistoryUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetGCHistoryForbiddenCode is the HTTP code returned for type GetGCHistoryForbidden +const GetGCHistoryForbiddenCode int = 403 + +/*GetGCHistoryForbidden Forbidden + +swagger:response getGcHistoryForbidden +*/ +type GetGCHistoryForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetGCHistoryForbidden creates GetGCHistoryForbidden with default headers values +func NewGetGCHistoryForbidden() *GetGCHistoryForbidden { + + return &GetGCHistoryForbidden{} +} + +// WithXRequestID adds the xRequestId to the get Gc history forbidden response +func (o *GetGCHistoryForbidden) WithXRequestID(xRequestID string) *GetGCHistoryForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get Gc history forbidden response +func (o *GetGCHistoryForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get Gc history forbidden response +func (o *GetGCHistoryForbidden) WithPayload(payload *models.Errors) *GetGCHistoryForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Gc history forbidden response +func (o *GetGCHistoryForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetGCHistoryForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetGCHistoryInternalServerErrorCode is the HTTP code returned for type GetGCHistoryInternalServerError +const GetGCHistoryInternalServerErrorCode int = 500 + +/*GetGCHistoryInternalServerError Internal server error + +swagger:response getGcHistoryInternalServerError +*/ +type GetGCHistoryInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetGCHistoryInternalServerError creates GetGCHistoryInternalServerError with default headers values +func NewGetGCHistoryInternalServerError() *GetGCHistoryInternalServerError { + + return &GetGCHistoryInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get Gc history internal server error response +func (o *GetGCHistoryInternalServerError) WithXRequestID(xRequestID string) *GetGCHistoryInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get Gc history internal server error response +func (o *GetGCHistoryInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get Gc history internal server error response +func (o *GetGCHistoryInternalServerError) WithPayload(payload *models.Errors) *GetGCHistoryInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Gc history internal server error response +func (o *GetGCHistoryInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetGCHistoryInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/gc/get_gc_history_urlbuilder.go b/src/server/v2.0/restapi/operations/gc/get_gc_history_urlbuilder.go new file mode 100644 index 000000000..cd3612579 --- /dev/null +++ b/src/server/v2.0/restapi/operations/gc/get_gc_history_urlbuilder.go @@ -0,0 +1,132 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package gc + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// GetGCHistoryURL generates an URL for the get GC history operation +type GetGCHistoryURL struct { + Page *int64 + PageSize *int64 + Q *string + Sort *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetGCHistoryURL) WithBasePath(bp string) *GetGCHistoryURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetGCHistoryURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetGCHistoryURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/system/gc" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var pageQ string + if o.Page != nil { + pageQ = swag.FormatInt64(*o.Page) + } + if pageQ != "" { + qs.Set("page", pageQ) + } + + var pageSizeQ string + if o.PageSize != nil { + pageSizeQ = swag.FormatInt64(*o.PageSize) + } + if pageSizeQ != "" { + qs.Set("page_size", pageSizeQ) + } + + var qQ string + if o.Q != nil { + qQ = *o.Q + } + if qQ != "" { + qs.Set("q", qQ) + } + + var sortQ string + if o.Sort != nil { + sortQ = *o.Sort + } + if sortQ != "" { + qs.Set("sort", sortQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetGCHistoryURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetGCHistoryURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetGCHistoryURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetGCHistoryURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetGCHistoryURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetGCHistoryURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/gc/get_gc_log.go b/src/server/v2.0/restapi/operations/gc/get_gc_log.go new file mode 100644 index 000000000..0a520ec9f --- /dev/null +++ b/src/server/v2.0/restapi/operations/gc/get_gc_log.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package gc + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetGCLogHandlerFunc turns a function with the right signature into a get GC log handler +type GetGCLogHandlerFunc func(GetGCLogParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetGCLogHandlerFunc) Handle(params GetGCLogParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetGCLogHandler interface for that can handle valid get GC log params +type GetGCLogHandler interface { + Handle(GetGCLogParams, interface{}) middleware.Responder +} + +// NewGetGCLog creates a new http.Handler for the get GC log operation +func NewGetGCLog(ctx *middleware.Context, handler GetGCLogHandler) *GetGCLog { + return &GetGCLog{Context: ctx, Handler: handler} +} + +/*GetGCLog swagger:route GET /system/gc/{gc_id}/log gc getGcLog + +Get gc job log. + +This endpoint let user get gc job logs filtered by specific ID. + +*/ +type GetGCLog struct { + Context *middleware.Context + Handler GetGCLogHandler +} + +func (o *GetGCLog) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetGCLogParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/gc/get_gc_log_parameters.go b/src/server/v2.0/restapi/operations/gc/get_gc_log_parameters.go new file mode 100644 index 000000000..6c3caef63 --- /dev/null +++ b/src/server/v2.0/restapi/operations/gc/get_gc_log_parameters.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package gc + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewGetGCLogParams creates a new GetGCLogParams object +// no default values defined in spec. +func NewGetGCLogParams() GetGCLogParams { + + return GetGCLogParams{} +} + +// GetGCLogParams contains all the bound params for the get GC log operation +// typically these are obtained from a http.Request +// +// swagger:parameters getGCLog +type GetGCLogParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The ID of the gc log + Required: true + In: path + */ + GCID int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetGCLogParams() beforehand. +func (o *GetGCLogParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rGCID, rhkGCID, _ := route.Params.GetOK("gc_id") + if err := o.bindGCID(rGCID, rhkGCID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetGCLogParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetGCLogParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindGCID binds and validates parameter GCID from path. +func (o *GetGCLogParams) bindGCID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("gc_id", "path", "int64", raw) + } + o.GCID = value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/gc/get_gc_log_responses.go b/src/server/v2.0/restapi/operations/gc/get_gc_log_responses.go new file mode 100644 index 000000000..b387cd033 --- /dev/null +++ b/src/server/v2.0/restapi/operations/gc/get_gc_log_responses.go @@ -0,0 +1,386 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package gc + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetGCLogOKCode is the HTTP code returned for type GetGCLogOK +const GetGCLogOKCode int = 200 + +/*GetGCLogOK Get successfully. + +swagger:response getGcLogOK +*/ +type GetGCLogOK struct { + + /* + In: Body + */ + Payload string `json:"body,omitempty"` +} + +// NewGetGCLogOK creates GetGCLogOK with default headers values +func NewGetGCLogOK() *GetGCLogOK { + + return &GetGCLogOK{} +} + +// WithPayload adds the payload to the get Gc log o k response +func (o *GetGCLogOK) WithPayload(payload string) *GetGCLogOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Gc log o k response +func (o *GetGCLogOK) SetPayload(payload string) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetGCLogOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// GetGCLogBadRequestCode is the HTTP code returned for type GetGCLogBadRequest +const GetGCLogBadRequestCode int = 400 + +/*GetGCLogBadRequest Bad request + +swagger:response getGcLogBadRequest +*/ +type GetGCLogBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetGCLogBadRequest creates GetGCLogBadRequest with default headers values +func NewGetGCLogBadRequest() *GetGCLogBadRequest { + + return &GetGCLogBadRequest{} +} + +// WithXRequestID adds the xRequestId to the get Gc log bad request response +func (o *GetGCLogBadRequest) WithXRequestID(xRequestID string) *GetGCLogBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get Gc log bad request response +func (o *GetGCLogBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get Gc log bad request response +func (o *GetGCLogBadRequest) WithPayload(payload *models.Errors) *GetGCLogBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Gc log bad request response +func (o *GetGCLogBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetGCLogBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetGCLogUnauthorizedCode is the HTTP code returned for type GetGCLogUnauthorized +const GetGCLogUnauthorizedCode int = 401 + +/*GetGCLogUnauthorized Unauthorized + +swagger:response getGcLogUnauthorized +*/ +type GetGCLogUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetGCLogUnauthorized creates GetGCLogUnauthorized with default headers values +func NewGetGCLogUnauthorized() *GetGCLogUnauthorized { + + return &GetGCLogUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the get Gc log unauthorized response +func (o *GetGCLogUnauthorized) WithXRequestID(xRequestID string) *GetGCLogUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get Gc log unauthorized response +func (o *GetGCLogUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get Gc log unauthorized response +func (o *GetGCLogUnauthorized) WithPayload(payload *models.Errors) *GetGCLogUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Gc log unauthorized response +func (o *GetGCLogUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetGCLogUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetGCLogForbiddenCode is the HTTP code returned for type GetGCLogForbidden +const GetGCLogForbiddenCode int = 403 + +/*GetGCLogForbidden Forbidden + +swagger:response getGcLogForbidden +*/ +type GetGCLogForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetGCLogForbidden creates GetGCLogForbidden with default headers values +func NewGetGCLogForbidden() *GetGCLogForbidden { + + return &GetGCLogForbidden{} +} + +// WithXRequestID adds the xRequestId to the get Gc log forbidden response +func (o *GetGCLogForbidden) WithXRequestID(xRequestID string) *GetGCLogForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get Gc log forbidden response +func (o *GetGCLogForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get Gc log forbidden response +func (o *GetGCLogForbidden) WithPayload(payload *models.Errors) *GetGCLogForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Gc log forbidden response +func (o *GetGCLogForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetGCLogForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetGCLogNotFoundCode is the HTTP code returned for type GetGCLogNotFound +const GetGCLogNotFoundCode int = 404 + +/*GetGCLogNotFound Not found + +swagger:response getGcLogNotFound +*/ +type GetGCLogNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetGCLogNotFound creates GetGCLogNotFound with default headers values +func NewGetGCLogNotFound() *GetGCLogNotFound { + + return &GetGCLogNotFound{} +} + +// WithXRequestID adds the xRequestId to the get Gc log not found response +func (o *GetGCLogNotFound) WithXRequestID(xRequestID string) *GetGCLogNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get Gc log not found response +func (o *GetGCLogNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get Gc log not found response +func (o *GetGCLogNotFound) WithPayload(payload *models.Errors) *GetGCLogNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Gc log not found response +func (o *GetGCLogNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetGCLogNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetGCLogInternalServerErrorCode is the HTTP code returned for type GetGCLogInternalServerError +const GetGCLogInternalServerErrorCode int = 500 + +/*GetGCLogInternalServerError Internal server error + +swagger:response getGcLogInternalServerError +*/ +type GetGCLogInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetGCLogInternalServerError creates GetGCLogInternalServerError with default headers values +func NewGetGCLogInternalServerError() *GetGCLogInternalServerError { + + return &GetGCLogInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get Gc log internal server error response +func (o *GetGCLogInternalServerError) WithXRequestID(xRequestID string) *GetGCLogInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get Gc log internal server error response +func (o *GetGCLogInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get Gc log internal server error response +func (o *GetGCLogInternalServerError) WithPayload(payload *models.Errors) *GetGCLogInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Gc log internal server error response +func (o *GetGCLogInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetGCLogInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/gc/get_gc_log_urlbuilder.go b/src/server/v2.0/restapi/operations/gc/get_gc_log_urlbuilder.go new file mode 100644 index 000000000..7b0382e96 --- /dev/null +++ b/src/server/v2.0/restapi/operations/gc/get_gc_log_urlbuilder.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package gc + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetGCLogURL generates an URL for the get GC log operation +type GetGCLogURL struct { + GCID int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetGCLogURL) WithBasePath(bp string) *GetGCLogURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetGCLogURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetGCLogURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/system/gc/{gc_id}/log" + + gCID := swag.FormatInt64(o.GCID) + if gCID != "" { + _path = strings.Replace(_path, "{gc_id}", gCID, -1) + } else { + return nil, errors.New("gcId is required on GetGCLogURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetGCLogURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetGCLogURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetGCLogURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetGCLogURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetGCLogURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetGCLogURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/gc/get_gc_parameters.go b/src/server/v2.0/restapi/operations/gc/get_gc_parameters.go new file mode 100644 index 000000000..aecfd96ab --- /dev/null +++ b/src/server/v2.0/restapi/operations/gc/get_gc_parameters.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package gc + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewGetGCParams creates a new GetGCParams object +// no default values defined in spec. +func NewGetGCParams() GetGCParams { + + return GetGCParams{} +} + +// GetGCParams contains all the bound params for the get GC operation +// typically these are obtained from a http.Request +// +// swagger:parameters getGC +type GetGCParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The ID of the gc log + Required: true + In: path + */ + GCID int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetGCParams() beforehand. +func (o *GetGCParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rGCID, rhkGCID, _ := route.Params.GetOK("gc_id") + if err := o.bindGCID(rGCID, rhkGCID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetGCParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetGCParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindGCID binds and validates parameter GCID from path. +func (o *GetGCParams) bindGCID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("gc_id", "path", "int64", raw) + } + o.GCID = value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/gc/get_gc_responses.go b/src/server/v2.0/restapi/operations/gc/get_gc_responses.go new file mode 100644 index 000000000..22487ea78 --- /dev/null +++ b/src/server/v2.0/restapi/operations/gc/get_gc_responses.go @@ -0,0 +1,322 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package gc + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetGCOKCode is the HTTP code returned for type GetGCOK +const GetGCOKCode int = 200 + +/*GetGCOK Get gc results successfully. + +swagger:response getGcOK +*/ +type GetGCOK struct { + + /* + In: Body + */ + Payload *models.GCHistory `json:"body,omitempty"` +} + +// NewGetGCOK creates GetGCOK with default headers values +func NewGetGCOK() *GetGCOK { + + return &GetGCOK{} +} + +// WithPayload adds the payload to the get Gc o k response +func (o *GetGCOK) WithPayload(payload *models.GCHistory) *GetGCOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Gc o k response +func (o *GetGCOK) SetPayload(payload *models.GCHistory) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetGCOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetGCUnauthorizedCode is the HTTP code returned for type GetGCUnauthorized +const GetGCUnauthorizedCode int = 401 + +/*GetGCUnauthorized Unauthorized + +swagger:response getGcUnauthorized +*/ +type GetGCUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetGCUnauthorized creates GetGCUnauthorized with default headers values +func NewGetGCUnauthorized() *GetGCUnauthorized { + + return &GetGCUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the get Gc unauthorized response +func (o *GetGCUnauthorized) WithXRequestID(xRequestID string) *GetGCUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get Gc unauthorized response +func (o *GetGCUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get Gc unauthorized response +func (o *GetGCUnauthorized) WithPayload(payload *models.Errors) *GetGCUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Gc unauthorized response +func (o *GetGCUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetGCUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetGCForbiddenCode is the HTTP code returned for type GetGCForbidden +const GetGCForbiddenCode int = 403 + +/*GetGCForbidden Forbidden + +swagger:response getGcForbidden +*/ +type GetGCForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetGCForbidden creates GetGCForbidden with default headers values +func NewGetGCForbidden() *GetGCForbidden { + + return &GetGCForbidden{} +} + +// WithXRequestID adds the xRequestId to the get Gc forbidden response +func (o *GetGCForbidden) WithXRequestID(xRequestID string) *GetGCForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get Gc forbidden response +func (o *GetGCForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get Gc forbidden response +func (o *GetGCForbidden) WithPayload(payload *models.Errors) *GetGCForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Gc forbidden response +func (o *GetGCForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetGCForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetGCNotFoundCode is the HTTP code returned for type GetGCNotFound +const GetGCNotFoundCode int = 404 + +/*GetGCNotFound Not found + +swagger:response getGcNotFound +*/ +type GetGCNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetGCNotFound creates GetGCNotFound with default headers values +func NewGetGCNotFound() *GetGCNotFound { + + return &GetGCNotFound{} +} + +// WithXRequestID adds the xRequestId to the get Gc not found response +func (o *GetGCNotFound) WithXRequestID(xRequestID string) *GetGCNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get Gc not found response +func (o *GetGCNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get Gc not found response +func (o *GetGCNotFound) WithPayload(payload *models.Errors) *GetGCNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Gc not found response +func (o *GetGCNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetGCNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetGCInternalServerErrorCode is the HTTP code returned for type GetGCInternalServerError +const GetGCInternalServerErrorCode int = 500 + +/*GetGCInternalServerError Internal server error + +swagger:response getGcInternalServerError +*/ +type GetGCInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetGCInternalServerError creates GetGCInternalServerError with default headers values +func NewGetGCInternalServerError() *GetGCInternalServerError { + + return &GetGCInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get Gc internal server error response +func (o *GetGCInternalServerError) WithXRequestID(xRequestID string) *GetGCInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get Gc internal server error response +func (o *GetGCInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get Gc internal server error response +func (o *GetGCInternalServerError) WithPayload(payload *models.Errors) *GetGCInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Gc internal server error response +func (o *GetGCInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetGCInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/gc/get_gc_schedule.go b/src/server/v2.0/restapi/operations/gc/get_gc_schedule.go new file mode 100644 index 000000000..843698ca6 --- /dev/null +++ b/src/server/v2.0/restapi/operations/gc/get_gc_schedule.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package gc + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetGCScheduleHandlerFunc turns a function with the right signature into a get GC schedule handler +type GetGCScheduleHandlerFunc func(GetGCScheduleParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetGCScheduleHandlerFunc) Handle(params GetGCScheduleParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetGCScheduleHandler interface for that can handle valid get GC schedule params +type GetGCScheduleHandler interface { + Handle(GetGCScheduleParams, interface{}) middleware.Responder +} + +// NewGetGCSchedule creates a new http.Handler for the get GC schedule operation +func NewGetGCSchedule(ctx *middleware.Context, handler GetGCScheduleHandler) *GetGCSchedule { + return &GetGCSchedule{Context: ctx, Handler: handler} +} + +/*GetGCSchedule swagger:route GET /system/gc/schedule gc getGcSchedule + +Get gc's schedule. + +This endpoint is for get schedule of gc job. + +*/ +type GetGCSchedule struct { + Context *middleware.Context + Handler GetGCScheduleHandler +} + +func (o *GetGCSchedule) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetGCScheduleParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/gc/get_gc_schedule_parameters.go b/src/server/v2.0/restapi/operations/gc/get_gc_schedule_parameters.go new file mode 100644 index 000000000..bae85a04c --- /dev/null +++ b/src/server/v2.0/restapi/operations/gc/get_gc_schedule_parameters.go @@ -0,0 +1,89 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package gc + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewGetGCScheduleParams creates a new GetGCScheduleParams object +// no default values defined in spec. +func NewGetGCScheduleParams() GetGCScheduleParams { + + return GetGCScheduleParams{} +} + +// GetGCScheduleParams contains all the bound params for the get GC schedule operation +// typically these are obtained from a http.Request +// +// swagger:parameters getGCSchedule +type GetGCScheduleParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetGCScheduleParams() beforehand. +func (o *GetGCScheduleParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetGCScheduleParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetGCScheduleParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} diff --git a/src/server/v2.0/restapi/operations/gc/get_gc_schedule_responses.go b/src/server/v2.0/restapi/operations/gc/get_gc_schedule_responses.go new file mode 100644 index 000000000..5f69e6cd9 --- /dev/null +++ b/src/server/v2.0/restapi/operations/gc/get_gc_schedule_responses.go @@ -0,0 +1,256 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package gc + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetGCScheduleOKCode is the HTTP code returned for type GetGCScheduleOK +const GetGCScheduleOKCode int = 200 + +/*GetGCScheduleOK Get gc's schedule. + +swagger:response getGcScheduleOK +*/ +type GetGCScheduleOK struct { + + /* + In: Body + */ + Payload *models.GCHistory `json:"body,omitempty"` +} + +// NewGetGCScheduleOK creates GetGCScheduleOK with default headers values +func NewGetGCScheduleOK() *GetGCScheduleOK { + + return &GetGCScheduleOK{} +} + +// WithPayload adds the payload to the get Gc schedule o k response +func (o *GetGCScheduleOK) WithPayload(payload *models.GCHistory) *GetGCScheduleOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Gc schedule o k response +func (o *GetGCScheduleOK) SetPayload(payload *models.GCHistory) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetGCScheduleOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetGCScheduleUnauthorizedCode is the HTTP code returned for type GetGCScheduleUnauthorized +const GetGCScheduleUnauthorizedCode int = 401 + +/*GetGCScheduleUnauthorized Unauthorized + +swagger:response getGcScheduleUnauthorized +*/ +type GetGCScheduleUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetGCScheduleUnauthorized creates GetGCScheduleUnauthorized with default headers values +func NewGetGCScheduleUnauthorized() *GetGCScheduleUnauthorized { + + return &GetGCScheduleUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the get Gc schedule unauthorized response +func (o *GetGCScheduleUnauthorized) WithXRequestID(xRequestID string) *GetGCScheduleUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get Gc schedule unauthorized response +func (o *GetGCScheduleUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get Gc schedule unauthorized response +func (o *GetGCScheduleUnauthorized) WithPayload(payload *models.Errors) *GetGCScheduleUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Gc schedule unauthorized response +func (o *GetGCScheduleUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetGCScheduleUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetGCScheduleForbiddenCode is the HTTP code returned for type GetGCScheduleForbidden +const GetGCScheduleForbiddenCode int = 403 + +/*GetGCScheduleForbidden Forbidden + +swagger:response getGcScheduleForbidden +*/ +type GetGCScheduleForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetGCScheduleForbidden creates GetGCScheduleForbidden with default headers values +func NewGetGCScheduleForbidden() *GetGCScheduleForbidden { + + return &GetGCScheduleForbidden{} +} + +// WithXRequestID adds the xRequestId to the get Gc schedule forbidden response +func (o *GetGCScheduleForbidden) WithXRequestID(xRequestID string) *GetGCScheduleForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get Gc schedule forbidden response +func (o *GetGCScheduleForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get Gc schedule forbidden response +func (o *GetGCScheduleForbidden) WithPayload(payload *models.Errors) *GetGCScheduleForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Gc schedule forbidden response +func (o *GetGCScheduleForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetGCScheduleForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetGCScheduleInternalServerErrorCode is the HTTP code returned for type GetGCScheduleInternalServerError +const GetGCScheduleInternalServerErrorCode int = 500 + +/*GetGCScheduleInternalServerError Internal server error + +swagger:response getGcScheduleInternalServerError +*/ +type GetGCScheduleInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetGCScheduleInternalServerError creates GetGCScheduleInternalServerError with default headers values +func NewGetGCScheduleInternalServerError() *GetGCScheduleInternalServerError { + + return &GetGCScheduleInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get Gc schedule internal server error response +func (o *GetGCScheduleInternalServerError) WithXRequestID(xRequestID string) *GetGCScheduleInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get Gc schedule internal server error response +func (o *GetGCScheduleInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get Gc schedule internal server error response +func (o *GetGCScheduleInternalServerError) WithPayload(payload *models.Errors) *GetGCScheduleInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Gc schedule internal server error response +func (o *GetGCScheduleInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetGCScheduleInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/gc/get_gc_schedule_urlbuilder.go b/src/server/v2.0/restapi/operations/gc/get_gc_schedule_urlbuilder.go new file mode 100644 index 000000000..bf83d8f00 --- /dev/null +++ b/src/server/v2.0/restapi/operations/gc/get_gc_schedule_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package gc + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetGCScheduleURL generates an URL for the get GC schedule operation +type GetGCScheduleURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetGCScheduleURL) WithBasePath(bp string) *GetGCScheduleURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetGCScheduleURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetGCScheduleURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/system/gc/schedule" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetGCScheduleURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetGCScheduleURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetGCScheduleURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetGCScheduleURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetGCScheduleURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetGCScheduleURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/gc/get_gc_urlbuilder.go b/src/server/v2.0/restapi/operations/gc/get_gc_urlbuilder.go new file mode 100644 index 000000000..add9da9ca --- /dev/null +++ b/src/server/v2.0/restapi/operations/gc/get_gc_urlbuilder.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package gc + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetGCURL generates an URL for the get GC operation +type GetGCURL struct { + GCID int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetGCURL) WithBasePath(bp string) *GetGCURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetGCURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetGCURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/system/gc/{gc_id}" + + gCID := swag.FormatInt64(o.GCID) + if gCID != "" { + _path = strings.Replace(_path, "{gc_id}", gCID, -1) + } else { + return nil, errors.New("gcId is required on GetGCURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetGCURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetGCURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetGCURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetGCURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetGCURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetGCURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/gc/stop_gc.go b/src/server/v2.0/restapi/operations/gc/stop_gc.go new file mode 100644 index 000000000..ebf6b2c83 --- /dev/null +++ b/src/server/v2.0/restapi/operations/gc/stop_gc.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package gc + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// StopGCHandlerFunc turns a function with the right signature into a stop GC handler +type StopGCHandlerFunc func(StopGCParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn StopGCHandlerFunc) Handle(params StopGCParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// StopGCHandler interface for that can handle valid stop GC params +type StopGCHandler interface { + Handle(StopGCParams, interface{}) middleware.Responder +} + +// NewStopGC creates a new http.Handler for the stop GC operation +func NewStopGC(ctx *middleware.Context, handler StopGCHandler) *StopGC { + return &StopGC{Context: ctx, Handler: handler} +} + +/*StopGC swagger:route PUT /system/gc/{gc_id} gc stopGc + +Stop the specific GC execution + +Stop the GC execution specified by ID + +*/ +type StopGC struct { + Context *middleware.Context + Handler StopGCHandler +} + +func (o *StopGC) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewStopGCParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/gc/stop_gc_parameters.go b/src/server/v2.0/restapi/operations/gc/stop_gc_parameters.go new file mode 100644 index 000000000..4a7a71cb8 --- /dev/null +++ b/src/server/v2.0/restapi/operations/gc/stop_gc_parameters.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package gc + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewStopGCParams creates a new StopGCParams object +// no default values defined in spec. +func NewStopGCParams() StopGCParams { + + return StopGCParams{} +} + +// StopGCParams contains all the bound params for the stop GC operation +// typically these are obtained from a http.Request +// +// swagger:parameters stopGC +type StopGCParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The ID of the gc log + Required: true + In: path + */ + GCID int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewStopGCParams() beforehand. +func (o *StopGCParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rGCID, rhkGCID, _ := route.Params.GetOK("gc_id") + if err := o.bindGCID(rGCID, rhkGCID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *StopGCParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *StopGCParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindGCID binds and validates parameter GCID from path. +func (o *StopGCParams) bindGCID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("gc_id", "path", "int64", raw) + } + o.GCID = value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/gc/stop_gc_responses.go b/src/server/v2.0/restapi/operations/gc/stop_gc_responses.go new file mode 100644 index 000000000..22b993e6b --- /dev/null +++ b/src/server/v2.0/restapi/operations/gc/stop_gc_responses.go @@ -0,0 +1,324 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package gc + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// StopGCOKCode is the HTTP code returned for type StopGCOK +const StopGCOKCode int = 200 + +/*StopGCOK Success + +swagger:response stopGcOK +*/ +type StopGCOK struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewStopGCOK creates StopGCOK with default headers values +func NewStopGCOK() *StopGCOK { + + return &StopGCOK{} +} + +// WithXRequestID adds the xRequestId to the stop Gc o k response +func (o *StopGCOK) WithXRequestID(xRequestID string) *StopGCOK { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the stop Gc o k response +func (o *StopGCOK) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *StopGCOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// StopGCUnauthorizedCode is the HTTP code returned for type StopGCUnauthorized +const StopGCUnauthorizedCode int = 401 + +/*StopGCUnauthorized Unauthorized + +swagger:response stopGcUnauthorized +*/ +type StopGCUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewStopGCUnauthorized creates StopGCUnauthorized with default headers values +func NewStopGCUnauthorized() *StopGCUnauthorized { + + return &StopGCUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the stop Gc unauthorized response +func (o *StopGCUnauthorized) WithXRequestID(xRequestID string) *StopGCUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the stop Gc unauthorized response +func (o *StopGCUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the stop Gc unauthorized response +func (o *StopGCUnauthorized) WithPayload(payload *models.Errors) *StopGCUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the stop Gc unauthorized response +func (o *StopGCUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *StopGCUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// StopGCForbiddenCode is the HTTP code returned for type StopGCForbidden +const StopGCForbiddenCode int = 403 + +/*StopGCForbidden Forbidden + +swagger:response stopGcForbidden +*/ +type StopGCForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewStopGCForbidden creates StopGCForbidden with default headers values +func NewStopGCForbidden() *StopGCForbidden { + + return &StopGCForbidden{} +} + +// WithXRequestID adds the xRequestId to the stop Gc forbidden response +func (o *StopGCForbidden) WithXRequestID(xRequestID string) *StopGCForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the stop Gc forbidden response +func (o *StopGCForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the stop Gc forbidden response +func (o *StopGCForbidden) WithPayload(payload *models.Errors) *StopGCForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the stop Gc forbidden response +func (o *StopGCForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *StopGCForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// StopGCNotFoundCode is the HTTP code returned for type StopGCNotFound +const StopGCNotFoundCode int = 404 + +/*StopGCNotFound Not found + +swagger:response stopGcNotFound +*/ +type StopGCNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewStopGCNotFound creates StopGCNotFound with default headers values +func NewStopGCNotFound() *StopGCNotFound { + + return &StopGCNotFound{} +} + +// WithXRequestID adds the xRequestId to the stop Gc not found response +func (o *StopGCNotFound) WithXRequestID(xRequestID string) *StopGCNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the stop Gc not found response +func (o *StopGCNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the stop Gc not found response +func (o *StopGCNotFound) WithPayload(payload *models.Errors) *StopGCNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the stop Gc not found response +func (o *StopGCNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *StopGCNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// StopGCInternalServerErrorCode is the HTTP code returned for type StopGCInternalServerError +const StopGCInternalServerErrorCode int = 500 + +/*StopGCInternalServerError Internal server error + +swagger:response stopGcInternalServerError +*/ +type StopGCInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewStopGCInternalServerError creates StopGCInternalServerError with default headers values +func NewStopGCInternalServerError() *StopGCInternalServerError { + + return &StopGCInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the stop Gc internal server error response +func (o *StopGCInternalServerError) WithXRequestID(xRequestID string) *StopGCInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the stop Gc internal server error response +func (o *StopGCInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the stop Gc internal server error response +func (o *StopGCInternalServerError) WithPayload(payload *models.Errors) *StopGCInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the stop Gc internal server error response +func (o *StopGCInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *StopGCInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/gc/stop_gc_urlbuilder.go b/src/server/v2.0/restapi/operations/gc/stop_gc_urlbuilder.go new file mode 100644 index 000000000..07edd455e --- /dev/null +++ b/src/server/v2.0/restapi/operations/gc/stop_gc_urlbuilder.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package gc + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// StopGCURL generates an URL for the stop GC operation +type StopGCURL struct { + GCID int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *StopGCURL) WithBasePath(bp string) *StopGCURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *StopGCURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *StopGCURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/system/gc/{gc_id}" + + gCID := swag.FormatInt64(o.GCID) + if gCID != "" { + _path = strings.Replace(_path, "{gc_id}", gCID, -1) + } else { + return nil, errors.New("gcId is required on StopGCURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *StopGCURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *StopGCURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *StopGCURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on StopGCURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on StopGCURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *StopGCURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/gc/update_gc_schedule.go b/src/server/v2.0/restapi/operations/gc/update_gc_schedule.go new file mode 100644 index 000000000..6624e3f5a --- /dev/null +++ b/src/server/v2.0/restapi/operations/gc/update_gc_schedule.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package gc + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// UpdateGCScheduleHandlerFunc turns a function with the right signature into a update GC schedule handler +type UpdateGCScheduleHandlerFunc func(UpdateGCScheduleParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn UpdateGCScheduleHandlerFunc) Handle(params UpdateGCScheduleParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// UpdateGCScheduleHandler interface for that can handle valid update GC schedule params +type UpdateGCScheduleHandler interface { + Handle(UpdateGCScheduleParams, interface{}) middleware.Responder +} + +// NewUpdateGCSchedule creates a new http.Handler for the update GC schedule operation +func NewUpdateGCSchedule(ctx *middleware.Context, handler UpdateGCScheduleHandler) *UpdateGCSchedule { + return &UpdateGCSchedule{Context: ctx, Handler: handler} +} + +/*UpdateGCSchedule swagger:route PUT /system/gc/schedule gc updateGcSchedule + +Update gc's schedule. + +This endpoint is for update gc schedule. + + +*/ +type UpdateGCSchedule struct { + Context *middleware.Context + Handler UpdateGCScheduleHandler +} + +func (o *UpdateGCSchedule) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewUpdateGCScheduleParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/gc/update_gc_schedule_parameters.go b/src/server/v2.0/restapi/operations/gc/update_gc_schedule_parameters.go new file mode 100644 index 000000000..d7bf322e0 --- /dev/null +++ b/src/server/v2.0/restapi/operations/gc/update_gc_schedule_parameters.go @@ -0,0 +1,120 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package gc + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewUpdateGCScheduleParams creates a new UpdateGCScheduleParams object +// no default values defined in spec. +func NewUpdateGCScheduleParams() UpdateGCScheduleParams { + + return UpdateGCScheduleParams{} +} + +// UpdateGCScheduleParams contains all the bound params for the update GC schedule operation +// typically these are obtained from a http.Request +// +// swagger:parameters updateGCSchedule +type UpdateGCScheduleParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*Updates of gc's schedule. + Required: true + In: body + */ + Schedule *models.Schedule +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewUpdateGCScheduleParams() beforehand. +func (o *UpdateGCScheduleParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Schedule + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("schedule", "body", "")) + } else { + res = append(res, errors.NewParseError("schedule", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Schedule = &body + } + } + } else { + res = append(res, errors.Required("schedule", "body", "")) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *UpdateGCScheduleParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *UpdateGCScheduleParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} diff --git a/src/server/v2.0/restapi/operations/gc/update_gc_schedule_responses.go b/src/server/v2.0/restapi/operations/gc/update_gc_schedule_responses.go new file mode 100644 index 000000000..efdf9961a --- /dev/null +++ b/src/server/v2.0/restapi/operations/gc/update_gc_schedule_responses.go @@ -0,0 +1,302 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package gc + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// UpdateGCScheduleOKCode is the HTTP code returned for type UpdateGCScheduleOK +const UpdateGCScheduleOKCode int = 200 + +/*UpdateGCScheduleOK Updated gc's schedule successfully. + +swagger:response updateGcScheduleOK +*/ +type UpdateGCScheduleOK struct { +} + +// NewUpdateGCScheduleOK creates UpdateGCScheduleOK with default headers values +func NewUpdateGCScheduleOK() *UpdateGCScheduleOK { + + return &UpdateGCScheduleOK{} +} + +// WriteResponse to the client +func (o *UpdateGCScheduleOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// UpdateGCScheduleBadRequestCode is the HTTP code returned for type UpdateGCScheduleBadRequest +const UpdateGCScheduleBadRequestCode int = 400 + +/*UpdateGCScheduleBadRequest Bad request + +swagger:response updateGcScheduleBadRequest +*/ +type UpdateGCScheduleBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateGCScheduleBadRequest creates UpdateGCScheduleBadRequest with default headers values +func NewUpdateGCScheduleBadRequest() *UpdateGCScheduleBadRequest { + + return &UpdateGCScheduleBadRequest{} +} + +// WithXRequestID adds the xRequestId to the update Gc schedule bad request response +func (o *UpdateGCScheduleBadRequest) WithXRequestID(xRequestID string) *UpdateGCScheduleBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update Gc schedule bad request response +func (o *UpdateGCScheduleBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update Gc schedule bad request response +func (o *UpdateGCScheduleBadRequest) WithPayload(payload *models.Errors) *UpdateGCScheduleBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update Gc schedule bad request response +func (o *UpdateGCScheduleBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateGCScheduleBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateGCScheduleUnauthorizedCode is the HTTP code returned for type UpdateGCScheduleUnauthorized +const UpdateGCScheduleUnauthorizedCode int = 401 + +/*UpdateGCScheduleUnauthorized Unauthorized + +swagger:response updateGcScheduleUnauthorized +*/ +type UpdateGCScheduleUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateGCScheduleUnauthorized creates UpdateGCScheduleUnauthorized with default headers values +func NewUpdateGCScheduleUnauthorized() *UpdateGCScheduleUnauthorized { + + return &UpdateGCScheduleUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the update Gc schedule unauthorized response +func (o *UpdateGCScheduleUnauthorized) WithXRequestID(xRequestID string) *UpdateGCScheduleUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update Gc schedule unauthorized response +func (o *UpdateGCScheduleUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update Gc schedule unauthorized response +func (o *UpdateGCScheduleUnauthorized) WithPayload(payload *models.Errors) *UpdateGCScheduleUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update Gc schedule unauthorized response +func (o *UpdateGCScheduleUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateGCScheduleUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateGCScheduleForbiddenCode is the HTTP code returned for type UpdateGCScheduleForbidden +const UpdateGCScheduleForbiddenCode int = 403 + +/*UpdateGCScheduleForbidden Forbidden + +swagger:response updateGcScheduleForbidden +*/ +type UpdateGCScheduleForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateGCScheduleForbidden creates UpdateGCScheduleForbidden with default headers values +func NewUpdateGCScheduleForbidden() *UpdateGCScheduleForbidden { + + return &UpdateGCScheduleForbidden{} +} + +// WithXRequestID adds the xRequestId to the update Gc schedule forbidden response +func (o *UpdateGCScheduleForbidden) WithXRequestID(xRequestID string) *UpdateGCScheduleForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update Gc schedule forbidden response +func (o *UpdateGCScheduleForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update Gc schedule forbidden response +func (o *UpdateGCScheduleForbidden) WithPayload(payload *models.Errors) *UpdateGCScheduleForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update Gc schedule forbidden response +func (o *UpdateGCScheduleForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateGCScheduleForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateGCScheduleInternalServerErrorCode is the HTTP code returned for type UpdateGCScheduleInternalServerError +const UpdateGCScheduleInternalServerErrorCode int = 500 + +/*UpdateGCScheduleInternalServerError Internal server error + +swagger:response updateGcScheduleInternalServerError +*/ +type UpdateGCScheduleInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateGCScheduleInternalServerError creates UpdateGCScheduleInternalServerError with default headers values +func NewUpdateGCScheduleInternalServerError() *UpdateGCScheduleInternalServerError { + + return &UpdateGCScheduleInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the update Gc schedule internal server error response +func (o *UpdateGCScheduleInternalServerError) WithXRequestID(xRequestID string) *UpdateGCScheduleInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update Gc schedule internal server error response +func (o *UpdateGCScheduleInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update Gc schedule internal server error response +func (o *UpdateGCScheduleInternalServerError) WithPayload(payload *models.Errors) *UpdateGCScheduleInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update Gc schedule internal server error response +func (o *UpdateGCScheduleInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateGCScheduleInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/gc/update_gc_schedule_urlbuilder.go b/src/server/v2.0/restapi/operations/gc/update_gc_schedule_urlbuilder.go new file mode 100644 index 000000000..44af1a3c4 --- /dev/null +++ b/src/server/v2.0/restapi/operations/gc/update_gc_schedule_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package gc + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// UpdateGCScheduleURL generates an URL for the update GC schedule operation +type UpdateGCScheduleURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdateGCScheduleURL) WithBasePath(bp string) *UpdateGCScheduleURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdateGCScheduleURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *UpdateGCScheduleURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/system/gc/schedule" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *UpdateGCScheduleURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *UpdateGCScheduleURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *UpdateGCScheduleURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on UpdateGCScheduleURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on UpdateGCScheduleURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *UpdateGCScheduleURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/harbor_api.go b/src/server/v2.0/restapi/operations/harbor_api.go new file mode 100644 index 000000000..42cdf53fa --- /dev/null +++ b/src/server/v2.0/restapi/operations/harbor_api.go @@ -0,0 +1,2768 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "fmt" + "io" + "net/http" + "strings" + + "github.com/go-openapi/errors" + "github.com/go-openapi/loads" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/runtime/security" + "github.com/go-openapi/spec" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/artifact" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/auditlog" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/configure" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/gc" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/health" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/icon" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/immutable" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/jobservice" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/label" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/ldap" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/member" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/oidc" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/ping" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/preheat" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/project" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/project_metadata" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/purge" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/quota" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/registry" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/replication" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/repository" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/retention" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/robot" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/robotv1" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/scan" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/scan_all" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/scan_data_export" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/scanner" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/schedule" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/search" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/statistic" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/system_cve_allowlist" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/systeminfo" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/user" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/usergroup" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/webhook" + "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/webhookjob" +) + +// NewHarborAPI creates a new Harbor instance +func NewHarborAPI(spec *loads.Document) *HarborAPI { + return &HarborAPI{ + handlers: make(map[string]map[string]http.Handler), + formats: strfmt.Default, + defaultConsumes: "application/json", + defaultProduces: "application/json", + customConsumers: make(map[string]runtime.Consumer), + customProducers: make(map[string]runtime.Producer), + operationMiddlewares: make(map[string]middleware.Builder), + PreServerShutdown: func() {}, + ServerShutdown: func() {}, + spec: spec, + useSwaggerUI: false, + ServeError: errors.ServeError, + BasicAuthenticator: security.BasicAuth, + APIKeyAuthenticator: security.APIKeyAuth, + BearerAuthenticator: security.BearerAuth, + + JSONConsumer: runtime.JSONConsumer(), + + BinProducer: runtime.ByteStreamProducer(), + CsvProducer: runtime.ProducerFunc(func(w io.Writer, data interface{}) error { + return errors.NotImplemented("csv producer has not yet been implemented") + }), + JSONProducer: runtime.JSONProducer(), + TxtProducer: runtime.TextProducer(), + + ArtifactCopyArtifactHandler: artifact.CopyArtifactHandlerFunc(func(params artifact.CopyArtifactParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation artifact.CopyArtifact has not yet been implemented") + }), + ImmutableCreateImmuRuleHandler: immutable.CreateImmuRuleHandlerFunc(func(params immutable.CreateImmuRuleParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation immutable.CreateImmuRule has not yet been implemented") + }), + PreheatCreateInstanceHandler: preheat.CreateInstanceHandlerFunc(func(params preheat.CreateInstanceParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation preheat.CreateInstance has not yet been implemented") + }), + LabelCreateLabelHandler: label.CreateLabelHandlerFunc(func(params label.CreateLabelParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation label.CreateLabel has not yet been implemented") + }), + PreheatCreatePolicyHandler: preheat.CreatePolicyHandlerFunc(func(params preheat.CreatePolicyParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation preheat.CreatePolicy has not yet been implemented") + }), + RobotCreateRobotHandler: robot.CreateRobotHandlerFunc(func(params robot.CreateRobotParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation robot.CreateRobot has not yet been implemented") + }), + Robotv1CreateRobotV1Handler: robotv1.CreateRobotV1HandlerFunc(func(params robotv1.CreateRobotV1Params, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation robotv1.CreateRobotV1 has not yet been implemented") + }), + WebhookCreateWebhookPolicyOfProjectHandler: webhook.CreateWebhookPolicyOfProjectHandlerFunc(func(params webhook.CreateWebhookPolicyOfProjectParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation webhook.CreateWebhookPolicyOfProject has not yet been implemented") + }), + ImmutableDeleteImmuRuleHandler: immutable.DeleteImmuRuleHandlerFunc(func(params immutable.DeleteImmuRuleParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation immutable.DeleteImmuRule has not yet been implemented") + }), + PreheatDeleteInstanceHandler: preheat.DeleteInstanceHandlerFunc(func(params preheat.DeleteInstanceParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation preheat.DeleteInstance has not yet been implemented") + }), + LabelDeleteLabelHandler: label.DeleteLabelHandlerFunc(func(params label.DeleteLabelParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation label.DeleteLabel has not yet been implemented") + }), + PreheatDeletePolicyHandler: preheat.DeletePolicyHandlerFunc(func(params preheat.DeletePolicyParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation preheat.DeletePolicy has not yet been implemented") + }), + RobotDeleteRobotHandler: robot.DeleteRobotHandlerFunc(func(params robot.DeleteRobotParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation robot.DeleteRobot has not yet been implemented") + }), + Robotv1DeleteRobotV1Handler: robotv1.DeleteRobotV1HandlerFunc(func(params robotv1.DeleteRobotV1Params, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation robotv1.DeleteRobotV1 has not yet been implemented") + }), + WebhookDeleteWebhookPolicyOfProjectHandler: webhook.DeleteWebhookPolicyOfProjectHandlerFunc(func(params webhook.DeleteWebhookPolicyOfProjectParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation webhook.DeleteWebhookPolicyOfProject has not yet been implemented") + }), + PreheatGetExecutionHandler: preheat.GetExecutionHandlerFunc(func(params preheat.GetExecutionParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation preheat.GetExecution has not yet been implemented") + }), + PreheatGetInstanceHandler: preheat.GetInstanceHandlerFunc(func(params preheat.GetInstanceParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation preheat.GetInstance has not yet been implemented") + }), + LabelGetLabelByIDHandler: label.GetLabelByIDHandlerFunc(func(params label.GetLabelByIDParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation label.GetLabelByID has not yet been implemented") + }), + PreheatGetPolicyHandler: preheat.GetPolicyHandlerFunc(func(params preheat.GetPolicyParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation preheat.GetPolicy has not yet been implemented") + }), + PreheatGetPreheatLogHandler: preheat.GetPreheatLogHandlerFunc(func(params preheat.GetPreheatLogParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation preheat.GetPreheatLog has not yet been implemented") + }), + RobotGetRobotByIDHandler: robot.GetRobotByIDHandlerFunc(func(params robot.GetRobotByIDParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation robot.GetRobotByID has not yet been implemented") + }), + Robotv1GetRobotByIDV1Handler: robotv1.GetRobotByIDV1HandlerFunc(func(params robotv1.GetRobotByIDV1Params, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation robotv1.GetRobotByIDV1 has not yet been implemented") + }), + WebhookGetSupportedEventTypesHandler: webhook.GetSupportedEventTypesHandlerFunc(func(params webhook.GetSupportedEventTypesParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation webhook.GetSupportedEventTypes has not yet been implemented") + }), + WebhookGetWebhookPolicyOfProjectHandler: webhook.GetWebhookPolicyOfProjectHandlerFunc(func(params webhook.GetWebhookPolicyOfProjectParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation webhook.GetWebhookPolicyOfProject has not yet been implemented") + }), + WebhookLastTriggerHandler: webhook.LastTriggerHandlerFunc(func(params webhook.LastTriggerParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation webhook.LastTrigger has not yet been implemented") + }), + PreheatListExecutionsHandler: preheat.ListExecutionsHandlerFunc(func(params preheat.ListExecutionsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation preheat.ListExecutions has not yet been implemented") + }), + ImmutableListImmuRulesHandler: immutable.ListImmuRulesHandlerFunc(func(params immutable.ListImmuRulesParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation immutable.ListImmuRules has not yet been implemented") + }), + PreheatListInstancesHandler: preheat.ListInstancesHandlerFunc(func(params preheat.ListInstancesParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation preheat.ListInstances has not yet been implemented") + }), + LabelListLabelsHandler: label.ListLabelsHandlerFunc(func(params label.ListLabelsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation label.ListLabels has not yet been implemented") + }), + PreheatListPoliciesHandler: preheat.ListPoliciesHandlerFunc(func(params preheat.ListPoliciesParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation preheat.ListPolicies has not yet been implemented") + }), + PreheatListProvidersHandler: preheat.ListProvidersHandlerFunc(func(params preheat.ListProvidersParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation preheat.ListProviders has not yet been implemented") + }), + PreheatListProvidersUnderProjectHandler: preheat.ListProvidersUnderProjectHandlerFunc(func(params preheat.ListProvidersUnderProjectParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation preheat.ListProvidersUnderProject has not yet been implemented") + }), + RobotListRobotHandler: robot.ListRobotHandlerFunc(func(params robot.ListRobotParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation robot.ListRobot has not yet been implemented") + }), + Robotv1ListRobotV1Handler: robotv1.ListRobotV1HandlerFunc(func(params robotv1.ListRobotV1Params, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation robotv1.ListRobotV1 has not yet been implemented") + }), + PreheatListTasksHandler: preheat.ListTasksHandlerFunc(func(params preheat.ListTasksParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation preheat.ListTasks has not yet been implemented") + }), + WebhookjobListWebhookJobsHandler: webhookjob.ListWebhookJobsHandlerFunc(func(params webhookjob.ListWebhookJobsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation webhookjob.ListWebhookJobs has not yet been implemented") + }), + WebhookListWebhookPoliciesOfProjectHandler: webhook.ListWebhookPoliciesOfProjectHandlerFunc(func(params webhook.ListWebhookPoliciesOfProjectParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation webhook.ListWebhookPoliciesOfProject has not yet been implemented") + }), + PreheatManualPreheatHandler: preheat.ManualPreheatHandlerFunc(func(params preheat.ManualPreheatParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation preheat.ManualPreheat has not yet been implemented") + }), + PreheatPingInstancesHandler: preheat.PingInstancesHandlerFunc(func(params preheat.PingInstancesParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation preheat.PingInstances has not yet been implemented") + }), + RobotRefreshSecHandler: robot.RefreshSecHandlerFunc(func(params robot.RefreshSecParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation robot.RefreshSec has not yet been implemented") + }), + PreheatStopExecutionHandler: preheat.StopExecutionHandlerFunc(func(params preheat.StopExecutionParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation preheat.StopExecution has not yet been implemented") + }), + ImmutableUpdateImmuRuleHandler: immutable.UpdateImmuRuleHandlerFunc(func(params immutable.UpdateImmuRuleParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation immutable.UpdateImmuRule has not yet been implemented") + }), + PreheatUpdateInstanceHandler: preheat.UpdateInstanceHandlerFunc(func(params preheat.UpdateInstanceParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation preheat.UpdateInstance has not yet been implemented") + }), + LabelUpdateLabelHandler: label.UpdateLabelHandlerFunc(func(params label.UpdateLabelParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation label.UpdateLabel has not yet been implemented") + }), + PreheatUpdatePolicyHandler: preheat.UpdatePolicyHandlerFunc(func(params preheat.UpdatePolicyParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation preheat.UpdatePolicy has not yet been implemented") + }), + RobotUpdateRobotHandler: robot.UpdateRobotHandlerFunc(func(params robot.UpdateRobotParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation robot.UpdateRobot has not yet been implemented") + }), + Robotv1UpdateRobotV1Handler: robotv1.UpdateRobotV1HandlerFunc(func(params robotv1.UpdateRobotV1Params, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation robotv1.UpdateRobotV1 has not yet been implemented") + }), + WebhookUpdateWebhookPolicyOfProjectHandler: webhook.UpdateWebhookPolicyOfProjectHandlerFunc(func(params webhook.UpdateWebhookPolicyOfProjectParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation webhook.UpdateWebhookPolicyOfProject has not yet been implemented") + }), + JobserviceActionPendingJobsHandler: jobservice.ActionPendingJobsHandlerFunc(func(params jobservice.ActionPendingJobsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation jobservice.ActionPendingJobs has not yet been implemented") + }), + ArtifactAddLabelHandler: artifact.AddLabelHandlerFunc(func(params artifact.AddLabelParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation artifact.AddLabel has not yet been implemented") + }), + ProjectMetadataAddProjectMetadatasHandler: project_metadata.AddProjectMetadatasHandlerFunc(func(params project_metadata.AddProjectMetadatasParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation project_metadata.AddProjectMetadatas has not yet been implemented") + }), + GCCreateGCScheduleHandler: gc.CreateGCScheduleHandlerFunc(func(params gc.CreateGCScheduleParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation gc.CreateGCSchedule has not yet been implemented") + }), + ProjectCreateProjectHandler: project.CreateProjectHandlerFunc(func(params project.CreateProjectParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation project.CreateProject has not yet been implemented") + }), + MemberCreateProjectMemberHandler: member.CreateProjectMemberHandlerFunc(func(params member.CreateProjectMemberParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation member.CreateProjectMember has not yet been implemented") + }), + PurgeCreatePurgeScheduleHandler: purge.CreatePurgeScheduleHandlerFunc(func(params purge.CreatePurgeScheduleParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation purge.CreatePurgeSchedule has not yet been implemented") + }), + RegistryCreateRegistryHandler: registry.CreateRegistryHandlerFunc(func(params registry.CreateRegistryParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation registry.CreateRegistry has not yet been implemented") + }), + ReplicationCreateReplicationPolicyHandler: replication.CreateReplicationPolicyHandlerFunc(func(params replication.CreateReplicationPolicyParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation replication.CreateReplicationPolicy has not yet been implemented") + }), + RetentionCreateRetentionHandler: retention.CreateRetentionHandlerFunc(func(params retention.CreateRetentionParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation retention.CreateRetention has not yet been implemented") + }), + ScanAllCreateScanAllScheduleHandler: scan_all.CreateScanAllScheduleHandlerFunc(func(params scan_all.CreateScanAllScheduleParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation scan_all.CreateScanAllSchedule has not yet been implemented") + }), + ScannerCreateScannerHandler: scanner.CreateScannerHandlerFunc(func(params scanner.CreateScannerParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation scanner.CreateScanner has not yet been implemented") + }), + ArtifactCreateTagHandler: artifact.CreateTagHandlerFunc(func(params artifact.CreateTagParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation artifact.CreateTag has not yet been implemented") + }), + UserCreateUserHandler: user.CreateUserHandlerFunc(func(params user.CreateUserParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation user.CreateUser has not yet been implemented") + }), + UsergroupCreateUserGroupHandler: usergroup.CreateUserGroupHandlerFunc(func(params usergroup.CreateUserGroupParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation usergroup.CreateUserGroup has not yet been implemented") + }), + ArtifactDeleteArtifactHandler: artifact.DeleteArtifactHandlerFunc(func(params artifact.DeleteArtifactParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation artifact.DeleteArtifact has not yet been implemented") + }), + ProjectDeleteProjectHandler: project.DeleteProjectHandlerFunc(func(params project.DeleteProjectParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation project.DeleteProject has not yet been implemented") + }), + MemberDeleteProjectMemberHandler: member.DeleteProjectMemberHandlerFunc(func(params member.DeleteProjectMemberParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation member.DeleteProjectMember has not yet been implemented") + }), + ProjectMetadataDeleteProjectMetadataHandler: project_metadata.DeleteProjectMetadataHandlerFunc(func(params project_metadata.DeleteProjectMetadataParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation project_metadata.DeleteProjectMetadata has not yet been implemented") + }), + RegistryDeleteRegistryHandler: registry.DeleteRegistryHandlerFunc(func(params registry.DeleteRegistryParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation registry.DeleteRegistry has not yet been implemented") + }), + ReplicationDeleteReplicationPolicyHandler: replication.DeleteReplicationPolicyHandlerFunc(func(params replication.DeleteReplicationPolicyParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation replication.DeleteReplicationPolicy has not yet been implemented") + }), + RepositoryDeleteRepositoryHandler: repository.DeleteRepositoryHandlerFunc(func(params repository.DeleteRepositoryParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation repository.DeleteRepository has not yet been implemented") + }), + RetentionDeleteRetentionHandler: retention.DeleteRetentionHandlerFunc(func(params retention.DeleteRetentionParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation retention.DeleteRetention has not yet been implemented") + }), + ScannerDeleteScannerHandler: scanner.DeleteScannerHandlerFunc(func(params scanner.DeleteScannerParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation scanner.DeleteScanner has not yet been implemented") + }), + ArtifactDeleteTagHandler: artifact.DeleteTagHandlerFunc(func(params artifact.DeleteTagParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation artifact.DeleteTag has not yet been implemented") + }), + UserDeleteUserHandler: user.DeleteUserHandlerFunc(func(params user.DeleteUserParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation user.DeleteUser has not yet been implemented") + }), + UsergroupDeleteUserGroupHandler: usergroup.DeleteUserGroupHandlerFunc(func(params usergroup.DeleteUserGroupParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation usergroup.DeleteUserGroup has not yet been implemented") + }), + ScanDataExportDownloadScanDataHandler: scan_data_export.DownloadScanDataHandlerFunc(func(params scan_data_export.DownloadScanDataParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation scan_data_export.DownloadScanData has not yet been implemented") + }), + ScanDataExportExportScanDataHandler: scan_data_export.ExportScanDataHandlerFunc(func(params scan_data_export.ExportScanDataParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation scan_data_export.ExportScanData has not yet been implemented") + }), + ArtifactGetAdditionHandler: artifact.GetAdditionHandlerFunc(func(params artifact.GetAdditionParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation artifact.GetAddition has not yet been implemented") + }), + ArtifactGetArtifactHandler: artifact.GetArtifactHandlerFunc(func(params artifact.GetArtifactParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation artifact.GetArtifact has not yet been implemented") + }), + SysteminfoGetCertHandler: systeminfo.GetCertHandlerFunc(func(params systeminfo.GetCertParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation systeminfo.GetCert has not yet been implemented") + }), + ConfigureGetConfigurationsHandler: configure.GetConfigurationsHandlerFunc(func(params configure.GetConfigurationsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation configure.GetConfigurations has not yet been implemented") + }), + UserGetCurrentUserInfoHandler: user.GetCurrentUserInfoHandlerFunc(func(params user.GetCurrentUserInfoParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation user.GetCurrentUserInfo has not yet been implemented") + }), + UserGetCurrentUserPermissionsHandler: user.GetCurrentUserPermissionsHandlerFunc(func(params user.GetCurrentUserPermissionsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation user.GetCurrentUserPermissions has not yet been implemented") + }), + GCGetGCHandler: gc.GetGCHandlerFunc(func(params gc.GetGCParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation gc.GetGC has not yet been implemented") + }), + GCGetGCHistoryHandler: gc.GetGCHistoryHandlerFunc(func(params gc.GetGCHistoryParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation gc.GetGCHistory has not yet been implemented") + }), + GCGetGCLogHandler: gc.GetGCLogHandlerFunc(func(params gc.GetGCLogParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation gc.GetGCLog has not yet been implemented") + }), + GCGetGCScheduleHandler: gc.GetGCScheduleHandlerFunc(func(params gc.GetGCScheduleParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation gc.GetGCSchedule has not yet been implemented") + }), + HealthGetHealthHandler: health.GetHealthHandlerFunc(func(params health.GetHealthParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation health.GetHealth has not yet been implemented") + }), + IconGetIconHandler: icon.GetIconHandlerFunc(func(params icon.GetIconParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation icon.GetIcon has not yet been implemented") + }), + ConfigureGetInternalconfigHandler: configure.GetInternalconfigHandlerFunc(func(params configure.GetInternalconfigParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation configure.GetInternalconfig has not yet been implemented") + }), + ScanAllGetLatestScanAllMetricsHandler: scan_all.GetLatestScanAllMetricsHandlerFunc(func(params scan_all.GetLatestScanAllMetricsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation scan_all.GetLatestScanAllMetrics has not yet been implemented") + }), + ScanAllGetLatestScheduledScanAllMetricsHandler: scan_all.GetLatestScheduledScanAllMetricsHandlerFunc(func(params scan_all.GetLatestScheduledScanAllMetricsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation scan_all.GetLatestScheduledScanAllMetrics has not yet been implemented") + }), + ProjectGetLogsHandler: project.GetLogsHandlerFunc(func(params project.GetLogsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation project.GetLogs has not yet been implemented") + }), + PingGetPingHandler: ping.GetPingHandlerFunc(func(params ping.GetPingParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation ping.GetPing has not yet been implemented") + }), + ProjectGetProjectHandler: project.GetProjectHandlerFunc(func(params project.GetProjectParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation project.GetProject has not yet been implemented") + }), + ProjectGetProjectDeletableHandler: project.GetProjectDeletableHandlerFunc(func(params project.GetProjectDeletableParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation project.GetProjectDeletable has not yet been implemented") + }), + MemberGetProjectMemberHandler: member.GetProjectMemberHandlerFunc(func(params member.GetProjectMemberParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation member.GetProjectMember has not yet been implemented") + }), + ProjectMetadataGetProjectMetadataHandler: project_metadata.GetProjectMetadataHandlerFunc(func(params project_metadata.GetProjectMetadataParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation project_metadata.GetProjectMetadata has not yet been implemented") + }), + ProjectGetProjectSummaryHandler: project.GetProjectSummaryHandlerFunc(func(params project.GetProjectSummaryParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation project.GetProjectSummary has not yet been implemented") + }), + PurgeGetPurgeHistoryHandler: purge.GetPurgeHistoryHandlerFunc(func(params purge.GetPurgeHistoryParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation purge.GetPurgeHistory has not yet been implemented") + }), + PurgeGetPurgeJobHandler: purge.GetPurgeJobHandlerFunc(func(params purge.GetPurgeJobParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation purge.GetPurgeJob has not yet been implemented") + }), + PurgeGetPurgeJobLogHandler: purge.GetPurgeJobLogHandlerFunc(func(params purge.GetPurgeJobLogParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation purge.GetPurgeJobLog has not yet been implemented") + }), + PurgeGetPurgeScheduleHandler: purge.GetPurgeScheduleHandlerFunc(func(params purge.GetPurgeScheduleParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation purge.GetPurgeSchedule has not yet been implemented") + }), + QuotaGetQuotaHandler: quota.GetQuotaHandlerFunc(func(params quota.GetQuotaParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation quota.GetQuota has not yet been implemented") + }), + RegistryGetRegistryHandler: registry.GetRegistryHandlerFunc(func(params registry.GetRegistryParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation registry.GetRegistry has not yet been implemented") + }), + RegistryGetRegistryInfoHandler: registry.GetRegistryInfoHandlerFunc(func(params registry.GetRegistryInfoParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation registry.GetRegistryInfo has not yet been implemented") + }), + RetentionGetRentenitionMetadataHandler: retention.GetRentenitionMetadataHandlerFunc(func(params retention.GetRentenitionMetadataParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation retention.GetRentenitionMetadata has not yet been implemented") + }), + ReplicationGetReplicationExecutionHandler: replication.GetReplicationExecutionHandlerFunc(func(params replication.GetReplicationExecutionParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation replication.GetReplicationExecution has not yet been implemented") + }), + ReplicationGetReplicationLogHandler: replication.GetReplicationLogHandlerFunc(func(params replication.GetReplicationLogParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation replication.GetReplicationLog has not yet been implemented") + }), + ReplicationGetReplicationPolicyHandler: replication.GetReplicationPolicyHandlerFunc(func(params replication.GetReplicationPolicyParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation replication.GetReplicationPolicy has not yet been implemented") + }), + ScanGetReportLogHandler: scan.GetReportLogHandlerFunc(func(params scan.GetReportLogParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation scan.GetReportLog has not yet been implemented") + }), + RepositoryGetRepositoryHandler: repository.GetRepositoryHandlerFunc(func(params repository.GetRepositoryParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation repository.GetRepository has not yet been implemented") + }), + RetentionGetRetentionHandler: retention.GetRetentionHandlerFunc(func(params retention.GetRetentionParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation retention.GetRetention has not yet been implemented") + }), + RetentionGetRetentionTaskLogHandler: retention.GetRetentionTaskLogHandlerFunc(func(params retention.GetRetentionTaskLogParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation retention.GetRetentionTaskLog has not yet been implemented") + }), + ScanAllGetScanAllScheduleHandler: scan_all.GetScanAllScheduleHandlerFunc(func(params scan_all.GetScanAllScheduleParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation scan_all.GetScanAllSchedule has not yet been implemented") + }), + ScanDataExportGetScanDataExportExecutionHandler: scan_data_export.GetScanDataExportExecutionHandlerFunc(func(params scan_data_export.GetScanDataExportExecutionParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation scan_data_export.GetScanDataExportExecution has not yet been implemented") + }), + ScanDataExportGetScanDataExportExecutionListHandler: scan_data_export.GetScanDataExportExecutionListHandlerFunc(func(params scan_data_export.GetScanDataExportExecutionListParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation scan_data_export.GetScanDataExportExecutionList has not yet been implemented") + }), + ScannerGetScannerHandler: scanner.GetScannerHandlerFunc(func(params scanner.GetScannerParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation scanner.GetScanner has not yet been implemented") + }), + ScannerGetScannerMetadataHandler: scanner.GetScannerMetadataHandlerFunc(func(params scanner.GetScannerMetadataParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation scanner.GetScannerMetadata has not yet been implemented") + }), + ProjectGetScannerOfProjectHandler: project.GetScannerOfProjectHandlerFunc(func(params project.GetScannerOfProjectParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation project.GetScannerOfProject has not yet been implemented") + }), + ScheduleGetSchedulePausedHandler: schedule.GetSchedulePausedHandlerFunc(func(params schedule.GetSchedulePausedParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation schedule.GetSchedulePaused has not yet been implemented") + }), + StatisticGetStatisticHandler: statistic.GetStatisticHandlerFunc(func(params statistic.GetStatisticParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation statistic.GetStatistic has not yet been implemented") + }), + SystemCVEAllowlistGetSystemCVEAllowlistHandler: system_cve_allowlist.GetSystemCVEAllowlistHandlerFunc(func(params system_cve_allowlist.GetSystemCVEAllowlistParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation system_cve_allowlist.GetSystemCVEAllowlist has not yet been implemented") + }), + SysteminfoGetSystemInfoHandler: systeminfo.GetSystemInfoHandlerFunc(func(params systeminfo.GetSystemInfoParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation systeminfo.GetSystemInfo has not yet been implemented") + }), + UserGetUserHandler: user.GetUserHandlerFunc(func(params user.GetUserParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation user.GetUser has not yet been implemented") + }), + UsergroupGetUserGroupHandler: usergroup.GetUserGroupHandlerFunc(func(params usergroup.GetUserGroupParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation usergroup.GetUserGroup has not yet been implemented") + }), + SysteminfoGetVolumesHandler: systeminfo.GetVolumesHandlerFunc(func(params systeminfo.GetVolumesParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation systeminfo.GetVolumes has not yet been implemented") + }), + ArtifactGetVulnerabilitiesAdditionHandler: artifact.GetVulnerabilitiesAdditionHandlerFunc(func(params artifact.GetVulnerabilitiesAdditionParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation artifact.GetVulnerabilitiesAddition has not yet been implemented") + }), + JobserviceGetWorkerPoolsHandler: jobservice.GetWorkerPoolsHandlerFunc(func(params jobservice.GetWorkerPoolsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation jobservice.GetWorkerPools has not yet been implemented") + }), + JobserviceGetWorkersHandler: jobservice.GetWorkersHandlerFunc(func(params jobservice.GetWorkersParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation jobservice.GetWorkers has not yet been implemented") + }), + ProjectHeadProjectHandler: project.HeadProjectHandlerFunc(func(params project.HeadProjectParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation project.HeadProject has not yet been implemented") + }), + LdapImportLdapUserHandler: ldap.ImportLdapUserHandlerFunc(func(params ldap.ImportLdapUserParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation ldap.ImportLdapUser has not yet been implemented") + }), + ArtifactListAccessoriesHandler: artifact.ListAccessoriesHandlerFunc(func(params artifact.ListAccessoriesParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation artifact.ListAccessories has not yet been implemented") + }), + RepositoryListAllRepositoriesHandler: repository.ListAllRepositoriesHandlerFunc(func(params repository.ListAllRepositoriesParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation repository.ListAllRepositories has not yet been implemented") + }), + ArtifactListArtifactsHandler: artifact.ListArtifactsHandlerFunc(func(params artifact.ListArtifactsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation artifact.ListArtifacts has not yet been implemented") + }), + AuditlogListAuditLogsHandler: auditlog.ListAuditLogsHandlerFunc(func(params auditlog.ListAuditLogsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation auditlog.ListAuditLogs has not yet been implemented") + }), + JobserviceListJobQueuesHandler: jobservice.ListJobQueuesHandlerFunc(func(params jobservice.ListJobQueuesParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation jobservice.ListJobQueues has not yet been implemented") + }), + MemberListProjectMembersHandler: member.ListProjectMembersHandlerFunc(func(params member.ListProjectMembersParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation member.ListProjectMembers has not yet been implemented") + }), + ProjectMetadataListProjectMetadatasHandler: project_metadata.ListProjectMetadatasHandlerFunc(func(params project_metadata.ListProjectMetadatasParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation project_metadata.ListProjectMetadatas has not yet been implemented") + }), + ProjectListProjectsHandler: project.ListProjectsHandlerFunc(func(params project.ListProjectsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation project.ListProjects has not yet been implemented") + }), + QuotaListQuotasHandler: quota.ListQuotasHandlerFunc(func(params quota.ListQuotasParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation quota.ListQuotas has not yet been implemented") + }), + RegistryListRegistriesHandler: registry.ListRegistriesHandlerFunc(func(params registry.ListRegistriesParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation registry.ListRegistries has not yet been implemented") + }), + RegistryListRegistryProviderInfosHandler: registry.ListRegistryProviderInfosHandlerFunc(func(params registry.ListRegistryProviderInfosParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation registry.ListRegistryProviderInfos has not yet been implemented") + }), + RegistryListRegistryProviderTypesHandler: registry.ListRegistryProviderTypesHandlerFunc(func(params registry.ListRegistryProviderTypesParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation registry.ListRegistryProviderTypes has not yet been implemented") + }), + ReplicationListReplicationExecutionsHandler: replication.ListReplicationExecutionsHandlerFunc(func(params replication.ListReplicationExecutionsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation replication.ListReplicationExecutions has not yet been implemented") + }), + ReplicationListReplicationPoliciesHandler: replication.ListReplicationPoliciesHandlerFunc(func(params replication.ListReplicationPoliciesParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation replication.ListReplicationPolicies has not yet been implemented") + }), + ReplicationListReplicationTasksHandler: replication.ListReplicationTasksHandlerFunc(func(params replication.ListReplicationTasksParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation replication.ListReplicationTasks has not yet been implemented") + }), + RepositoryListRepositoriesHandler: repository.ListRepositoriesHandlerFunc(func(params repository.ListRepositoriesParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation repository.ListRepositories has not yet been implemented") + }), + RetentionListRetentionExecutionsHandler: retention.ListRetentionExecutionsHandlerFunc(func(params retention.ListRetentionExecutionsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation retention.ListRetentionExecutions has not yet been implemented") + }), + RetentionListRetentionTasksHandler: retention.ListRetentionTasksHandlerFunc(func(params retention.ListRetentionTasksParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation retention.ListRetentionTasks has not yet been implemented") + }), + ProjectListScannerCandidatesOfProjectHandler: project.ListScannerCandidatesOfProjectHandlerFunc(func(params project.ListScannerCandidatesOfProjectParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation project.ListScannerCandidatesOfProject has not yet been implemented") + }), + ScannerListScannersHandler: scanner.ListScannersHandlerFunc(func(params scanner.ListScannersParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation scanner.ListScanners has not yet been implemented") + }), + ScheduleListSchedulesHandler: schedule.ListSchedulesHandlerFunc(func(params schedule.ListSchedulesParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation schedule.ListSchedules has not yet been implemented") + }), + ArtifactListTagsHandler: artifact.ListTagsHandlerFunc(func(params artifact.ListTagsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation artifact.ListTags has not yet been implemented") + }), + UsergroupListUserGroupsHandler: usergroup.ListUserGroupsHandlerFunc(func(params usergroup.ListUserGroupsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation usergroup.ListUserGroups has not yet been implemented") + }), + UserListUsersHandler: user.ListUsersHandlerFunc(func(params user.ListUsersParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation user.ListUsers has not yet been implemented") + }), + RetentionOperateRetentionExecutionHandler: retention.OperateRetentionExecutionHandlerFunc(func(params retention.OperateRetentionExecutionParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation retention.OperateRetentionExecution has not yet been implemented") + }), + LdapPingLdapHandler: ldap.PingLdapHandlerFunc(func(params ldap.PingLdapParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation ldap.PingLdap has not yet been implemented") + }), + OIDCPingOIDCHandler: oidc.PingOIDCHandlerFunc(func(params oidc.PingOIDCParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation oidc.PingOIDC has not yet been implemented") + }), + RegistryPingRegistryHandler: registry.PingRegistryHandlerFunc(func(params registry.PingRegistryParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation registry.PingRegistry has not yet been implemented") + }), + ScannerPingScannerHandler: scanner.PingScannerHandlerFunc(func(params scanner.PingScannerParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation scanner.PingScanner has not yet been implemented") + }), + SystemCVEAllowlistPutSystemCVEAllowlistHandler: system_cve_allowlist.PutSystemCVEAllowlistHandlerFunc(func(params system_cve_allowlist.PutSystemCVEAllowlistParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation system_cve_allowlist.PutSystemCVEAllowlist has not yet been implemented") + }), + ArtifactRemoveLabelHandler: artifact.RemoveLabelHandlerFunc(func(params artifact.RemoveLabelParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation artifact.RemoveLabel has not yet been implemented") + }), + ScanScanArtifactHandler: scan.ScanArtifactHandlerFunc(func(params scan.ScanArtifactParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation scan.ScanArtifact has not yet been implemented") + }), + SearchSearchHandler: search.SearchHandlerFunc(func(params search.SearchParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation search.Search has not yet been implemented") + }), + LdapSearchLdapGroupHandler: ldap.SearchLdapGroupHandlerFunc(func(params ldap.SearchLdapGroupParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation ldap.SearchLdapGroup has not yet been implemented") + }), + LdapSearchLdapUserHandler: ldap.SearchLdapUserHandlerFunc(func(params ldap.SearchLdapUserParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation ldap.SearchLdapUser has not yet been implemented") + }), + UsergroupSearchUserGroupsHandler: usergroup.SearchUserGroupsHandlerFunc(func(params usergroup.SearchUserGroupsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation usergroup.SearchUserGroups has not yet been implemented") + }), + UserSearchUsersHandler: user.SearchUsersHandlerFunc(func(params user.SearchUsersParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation user.SearchUsers has not yet been implemented") + }), + UserSetCliSecretHandler: user.SetCliSecretHandlerFunc(func(params user.SetCliSecretParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation user.SetCliSecret has not yet been implemented") + }), + ScannerSetScannerAsDefaultHandler: scanner.SetScannerAsDefaultHandlerFunc(func(params scanner.SetScannerAsDefaultParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation scanner.SetScannerAsDefault has not yet been implemented") + }), + ProjectSetScannerOfProjectHandler: project.SetScannerOfProjectHandlerFunc(func(params project.SetScannerOfProjectParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation project.SetScannerOfProject has not yet been implemented") + }), + UserSetUserSysAdminHandler: user.SetUserSysAdminHandlerFunc(func(params user.SetUserSysAdminParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation user.SetUserSysAdmin has not yet been implemented") + }), + ReplicationStartReplicationHandler: replication.StartReplicationHandlerFunc(func(params replication.StartReplicationParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation replication.StartReplication has not yet been implemented") + }), + GCStopGCHandler: gc.StopGCHandlerFunc(func(params gc.StopGCParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation gc.StopGC has not yet been implemented") + }), + PurgeStopPurgeHandler: purge.StopPurgeHandlerFunc(func(params purge.StopPurgeParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation purge.StopPurge has not yet been implemented") + }), + ReplicationStopReplicationHandler: replication.StopReplicationHandlerFunc(func(params replication.StopReplicationParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation replication.StopReplication has not yet been implemented") + }), + JobserviceStopRunningJobHandler: jobservice.StopRunningJobHandlerFunc(func(params jobservice.StopRunningJobParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation jobservice.StopRunningJob has not yet been implemented") + }), + ScanAllStopScanAllHandler: scan_all.StopScanAllHandlerFunc(func(params scan_all.StopScanAllParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation scan_all.StopScanAll has not yet been implemented") + }), + ScanStopScanArtifactHandler: scan.StopScanArtifactHandlerFunc(func(params scan.StopScanArtifactParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation scan.StopScanArtifact has not yet been implemented") + }), + RetentionTriggerRetentionExecutionHandler: retention.TriggerRetentionExecutionHandlerFunc(func(params retention.TriggerRetentionExecutionParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation retention.TriggerRetentionExecution has not yet been implemented") + }), + ConfigureUpdateConfigurationsHandler: configure.UpdateConfigurationsHandlerFunc(func(params configure.UpdateConfigurationsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation configure.UpdateConfigurations has not yet been implemented") + }), + GCUpdateGCScheduleHandler: gc.UpdateGCScheduleHandlerFunc(func(params gc.UpdateGCScheduleParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation gc.UpdateGCSchedule has not yet been implemented") + }), + ProjectUpdateProjectHandler: project.UpdateProjectHandlerFunc(func(params project.UpdateProjectParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation project.UpdateProject has not yet been implemented") + }), + MemberUpdateProjectMemberHandler: member.UpdateProjectMemberHandlerFunc(func(params member.UpdateProjectMemberParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation member.UpdateProjectMember has not yet been implemented") + }), + ProjectMetadataUpdateProjectMetadataHandler: project_metadata.UpdateProjectMetadataHandlerFunc(func(params project_metadata.UpdateProjectMetadataParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation project_metadata.UpdateProjectMetadata has not yet been implemented") + }), + PurgeUpdatePurgeScheduleHandler: purge.UpdatePurgeScheduleHandlerFunc(func(params purge.UpdatePurgeScheduleParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation purge.UpdatePurgeSchedule has not yet been implemented") + }), + QuotaUpdateQuotaHandler: quota.UpdateQuotaHandlerFunc(func(params quota.UpdateQuotaParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation quota.UpdateQuota has not yet been implemented") + }), + RegistryUpdateRegistryHandler: registry.UpdateRegistryHandlerFunc(func(params registry.UpdateRegistryParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation registry.UpdateRegistry has not yet been implemented") + }), + ReplicationUpdateReplicationPolicyHandler: replication.UpdateReplicationPolicyHandlerFunc(func(params replication.UpdateReplicationPolicyParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation replication.UpdateReplicationPolicy has not yet been implemented") + }), + RepositoryUpdateRepositoryHandler: repository.UpdateRepositoryHandlerFunc(func(params repository.UpdateRepositoryParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation repository.UpdateRepository has not yet been implemented") + }), + RetentionUpdateRetentionHandler: retention.UpdateRetentionHandlerFunc(func(params retention.UpdateRetentionParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation retention.UpdateRetention has not yet been implemented") + }), + ScanAllUpdateScanAllScheduleHandler: scan_all.UpdateScanAllScheduleHandlerFunc(func(params scan_all.UpdateScanAllScheduleParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation scan_all.UpdateScanAllSchedule has not yet been implemented") + }), + ScannerUpdateScannerHandler: scanner.UpdateScannerHandlerFunc(func(params scanner.UpdateScannerParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation scanner.UpdateScanner has not yet been implemented") + }), + UsergroupUpdateUserGroupHandler: usergroup.UpdateUserGroupHandlerFunc(func(params usergroup.UpdateUserGroupParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation usergroup.UpdateUserGroup has not yet been implemented") + }), + UserUpdateUserPasswordHandler: user.UpdateUserPasswordHandlerFunc(func(params user.UpdateUserPasswordParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation user.UpdateUserPassword has not yet been implemented") + }), + UserUpdateUserProfileHandler: user.UpdateUserProfileHandlerFunc(func(params user.UpdateUserProfileParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation user.UpdateUserProfile has not yet been implemented") + }), + + // Applies when the Authorization header is set with the Basic scheme + BasicAuth: func(user string, pass string) (interface{}, error) { + return nil, errors.NotImplemented("basic auth (basic) has not yet been implemented") + }, + // default authorizer is authorized meaning no requests are blocked + APIAuthorizer: security.Authorized(), + } +} + +/*HarborAPI These APIs provide services for manipulating Harbor project. */ +type HarborAPI struct { + spec *loads.Document + context *middleware.Context + handlers map[string]map[string]http.Handler + formats strfmt.Registry + customConsumers map[string]runtime.Consumer + customProducers map[string]runtime.Producer + defaultConsumes string + defaultProduces string + Middleware func(middleware.Builder) http.Handler + useSwaggerUI bool + + // operationMiddlewares middleware for operations + operationMiddlewares map[string]middleware.Builder + + // BeforePrepare is called before the Prepare of the operation + BeforePrepare func(context.Context, string, interface{}) middleware.Responder + + // BasicAuthenticator generates a runtime.Authenticator from the supplied basic auth function. + // It has a default implementation in the security package, however you can replace it for your particular usage. + BasicAuthenticator func(security.UserPassAuthentication) runtime.Authenticator + // APIKeyAuthenticator generates a runtime.Authenticator from the supplied token auth function. + // It has a default implementation in the security package, however you can replace it for your particular usage. + APIKeyAuthenticator func(string, string, security.TokenAuthentication) runtime.Authenticator + // BearerAuthenticator generates a runtime.Authenticator from the supplied bearer token auth function. + // It has a default implementation in the security package, however you can replace it for your particular usage. + BearerAuthenticator func(string, security.ScopedTokenAuthentication) runtime.Authenticator + + // JSONConsumer registers a consumer for the following mime types: + // - application/json + JSONConsumer runtime.Consumer + + // BinProducer registers a producer for the following mime types: + // - application/octet-stream + BinProducer runtime.Producer + // CsvProducer registers a producer for the following mime types: + // - text/csv + CsvProducer runtime.Producer + // JSONProducer registers a producer for the following mime types: + // - application/json + JSONProducer runtime.Producer + // TxtProducer registers a producer for the following mime types: + // - text/plain + TxtProducer runtime.Producer + + // BasicAuth registers a function that takes username and password and returns a principal + // it performs authentication with basic auth + BasicAuth func(string, string) (interface{}, error) + + // APIAuthorizer provides access control (ACL/RBAC/ABAC) by providing access to the request and authenticated principal + APIAuthorizer runtime.Authorizer + + // ArtifactCopyArtifactHandler sets the operation handler for the copy artifact operation + ArtifactCopyArtifactHandler artifact.CopyArtifactHandler + // ImmutableCreateImmuRuleHandler sets the operation handler for the create immu rule operation + ImmutableCreateImmuRuleHandler immutable.CreateImmuRuleHandler + // PreheatCreateInstanceHandler sets the operation handler for the create instance operation + PreheatCreateInstanceHandler preheat.CreateInstanceHandler + // LabelCreateLabelHandler sets the operation handler for the create label operation + LabelCreateLabelHandler label.CreateLabelHandler + // PreheatCreatePolicyHandler sets the operation handler for the create policy operation + PreheatCreatePolicyHandler preheat.CreatePolicyHandler + // RobotCreateRobotHandler sets the operation handler for the create robot operation + RobotCreateRobotHandler robot.CreateRobotHandler + // Robotv1CreateRobotV1Handler sets the operation handler for the create robot v1 operation + Robotv1CreateRobotV1Handler robotv1.CreateRobotV1Handler + // WebhookCreateWebhookPolicyOfProjectHandler sets the operation handler for the create webhook policy of project operation + WebhookCreateWebhookPolicyOfProjectHandler webhook.CreateWebhookPolicyOfProjectHandler + // ImmutableDeleteImmuRuleHandler sets the operation handler for the delete immu rule operation + ImmutableDeleteImmuRuleHandler immutable.DeleteImmuRuleHandler + // PreheatDeleteInstanceHandler sets the operation handler for the delete instance operation + PreheatDeleteInstanceHandler preheat.DeleteInstanceHandler + // LabelDeleteLabelHandler sets the operation handler for the delete label operation + LabelDeleteLabelHandler label.DeleteLabelHandler + // PreheatDeletePolicyHandler sets the operation handler for the delete policy operation + PreheatDeletePolicyHandler preheat.DeletePolicyHandler + // RobotDeleteRobotHandler sets the operation handler for the delete robot operation + RobotDeleteRobotHandler robot.DeleteRobotHandler + // Robotv1DeleteRobotV1Handler sets the operation handler for the delete robot v1 operation + Robotv1DeleteRobotV1Handler robotv1.DeleteRobotV1Handler + // WebhookDeleteWebhookPolicyOfProjectHandler sets the operation handler for the delete webhook policy of project operation + WebhookDeleteWebhookPolicyOfProjectHandler webhook.DeleteWebhookPolicyOfProjectHandler + // PreheatGetExecutionHandler sets the operation handler for the get execution operation + PreheatGetExecutionHandler preheat.GetExecutionHandler + // PreheatGetInstanceHandler sets the operation handler for the get instance operation + PreheatGetInstanceHandler preheat.GetInstanceHandler + // LabelGetLabelByIDHandler sets the operation handler for the get label by ID operation + LabelGetLabelByIDHandler label.GetLabelByIDHandler + // PreheatGetPolicyHandler sets the operation handler for the get policy operation + PreheatGetPolicyHandler preheat.GetPolicyHandler + // PreheatGetPreheatLogHandler sets the operation handler for the get preheat log operation + PreheatGetPreheatLogHandler preheat.GetPreheatLogHandler + // RobotGetRobotByIDHandler sets the operation handler for the get robot by ID operation + RobotGetRobotByIDHandler robot.GetRobotByIDHandler + // Robotv1GetRobotByIDV1Handler sets the operation handler for the get robot by ID v1 operation + Robotv1GetRobotByIDV1Handler robotv1.GetRobotByIDV1Handler + // WebhookGetSupportedEventTypesHandler sets the operation handler for the get supported event types operation + WebhookGetSupportedEventTypesHandler webhook.GetSupportedEventTypesHandler + // WebhookGetWebhookPolicyOfProjectHandler sets the operation handler for the get webhook policy of project operation + WebhookGetWebhookPolicyOfProjectHandler webhook.GetWebhookPolicyOfProjectHandler + // WebhookLastTriggerHandler sets the operation handler for the last trigger operation + WebhookLastTriggerHandler webhook.LastTriggerHandler + // PreheatListExecutionsHandler sets the operation handler for the list executions operation + PreheatListExecutionsHandler preheat.ListExecutionsHandler + // ImmutableListImmuRulesHandler sets the operation handler for the list immu rules operation + ImmutableListImmuRulesHandler immutable.ListImmuRulesHandler + // PreheatListInstancesHandler sets the operation handler for the list instances operation + PreheatListInstancesHandler preheat.ListInstancesHandler + // LabelListLabelsHandler sets the operation handler for the list labels operation + LabelListLabelsHandler label.ListLabelsHandler + // PreheatListPoliciesHandler sets the operation handler for the list policies operation + PreheatListPoliciesHandler preheat.ListPoliciesHandler + // PreheatListProvidersHandler sets the operation handler for the list providers operation + PreheatListProvidersHandler preheat.ListProvidersHandler + // PreheatListProvidersUnderProjectHandler sets the operation handler for the list providers under project operation + PreheatListProvidersUnderProjectHandler preheat.ListProvidersUnderProjectHandler + // RobotListRobotHandler sets the operation handler for the list robot operation + RobotListRobotHandler robot.ListRobotHandler + // Robotv1ListRobotV1Handler sets the operation handler for the list robot v1 operation + Robotv1ListRobotV1Handler robotv1.ListRobotV1Handler + // PreheatListTasksHandler sets the operation handler for the list tasks operation + PreheatListTasksHandler preheat.ListTasksHandler + // WebhookjobListWebhookJobsHandler sets the operation handler for the list webhook jobs operation + WebhookjobListWebhookJobsHandler webhookjob.ListWebhookJobsHandler + // WebhookListWebhookPoliciesOfProjectHandler sets the operation handler for the list webhook policies of project operation + WebhookListWebhookPoliciesOfProjectHandler webhook.ListWebhookPoliciesOfProjectHandler + // PreheatManualPreheatHandler sets the operation handler for the manual preheat operation + PreheatManualPreheatHandler preheat.ManualPreheatHandler + // PreheatPingInstancesHandler sets the operation handler for the ping instances operation + PreheatPingInstancesHandler preheat.PingInstancesHandler + // RobotRefreshSecHandler sets the operation handler for the refresh sec operation + RobotRefreshSecHandler robot.RefreshSecHandler + // PreheatStopExecutionHandler sets the operation handler for the stop execution operation + PreheatStopExecutionHandler preheat.StopExecutionHandler + // ImmutableUpdateImmuRuleHandler sets the operation handler for the update immu rule operation + ImmutableUpdateImmuRuleHandler immutable.UpdateImmuRuleHandler + // PreheatUpdateInstanceHandler sets the operation handler for the update instance operation + PreheatUpdateInstanceHandler preheat.UpdateInstanceHandler + // LabelUpdateLabelHandler sets the operation handler for the update label operation + LabelUpdateLabelHandler label.UpdateLabelHandler + // PreheatUpdatePolicyHandler sets the operation handler for the update policy operation + PreheatUpdatePolicyHandler preheat.UpdatePolicyHandler + // RobotUpdateRobotHandler sets the operation handler for the update robot operation + RobotUpdateRobotHandler robot.UpdateRobotHandler + // Robotv1UpdateRobotV1Handler sets the operation handler for the update robot v1 operation + Robotv1UpdateRobotV1Handler robotv1.UpdateRobotV1Handler + // WebhookUpdateWebhookPolicyOfProjectHandler sets the operation handler for the update webhook policy of project operation + WebhookUpdateWebhookPolicyOfProjectHandler webhook.UpdateWebhookPolicyOfProjectHandler + // JobserviceActionPendingJobsHandler sets the operation handler for the action pending jobs operation + JobserviceActionPendingJobsHandler jobservice.ActionPendingJobsHandler + // ArtifactAddLabelHandler sets the operation handler for the add label operation + ArtifactAddLabelHandler artifact.AddLabelHandler + // ProjectMetadataAddProjectMetadatasHandler sets the operation handler for the add project metadatas operation + ProjectMetadataAddProjectMetadatasHandler project_metadata.AddProjectMetadatasHandler + // GCCreateGCScheduleHandler sets the operation handler for the create GC schedule operation + GCCreateGCScheduleHandler gc.CreateGCScheduleHandler + // ProjectCreateProjectHandler sets the operation handler for the create project operation + ProjectCreateProjectHandler project.CreateProjectHandler + // MemberCreateProjectMemberHandler sets the operation handler for the create project member operation + MemberCreateProjectMemberHandler member.CreateProjectMemberHandler + // PurgeCreatePurgeScheduleHandler sets the operation handler for the create purge schedule operation + PurgeCreatePurgeScheduleHandler purge.CreatePurgeScheduleHandler + // RegistryCreateRegistryHandler sets the operation handler for the create registry operation + RegistryCreateRegistryHandler registry.CreateRegistryHandler + // ReplicationCreateReplicationPolicyHandler sets the operation handler for the create replication policy operation + ReplicationCreateReplicationPolicyHandler replication.CreateReplicationPolicyHandler + // RetentionCreateRetentionHandler sets the operation handler for the create retention operation + RetentionCreateRetentionHandler retention.CreateRetentionHandler + // ScanAllCreateScanAllScheduleHandler sets the operation handler for the create scan all schedule operation + ScanAllCreateScanAllScheduleHandler scan_all.CreateScanAllScheduleHandler + // ScannerCreateScannerHandler sets the operation handler for the create scanner operation + ScannerCreateScannerHandler scanner.CreateScannerHandler + // ArtifactCreateTagHandler sets the operation handler for the create tag operation + ArtifactCreateTagHandler artifact.CreateTagHandler + // UserCreateUserHandler sets the operation handler for the create user operation + UserCreateUserHandler user.CreateUserHandler + // UsergroupCreateUserGroupHandler sets the operation handler for the create user group operation + UsergroupCreateUserGroupHandler usergroup.CreateUserGroupHandler + // ArtifactDeleteArtifactHandler sets the operation handler for the delete artifact operation + ArtifactDeleteArtifactHandler artifact.DeleteArtifactHandler + // ProjectDeleteProjectHandler sets the operation handler for the delete project operation + ProjectDeleteProjectHandler project.DeleteProjectHandler + // MemberDeleteProjectMemberHandler sets the operation handler for the delete project member operation + MemberDeleteProjectMemberHandler member.DeleteProjectMemberHandler + // ProjectMetadataDeleteProjectMetadataHandler sets the operation handler for the delete project metadata operation + ProjectMetadataDeleteProjectMetadataHandler project_metadata.DeleteProjectMetadataHandler + // RegistryDeleteRegistryHandler sets the operation handler for the delete registry operation + RegistryDeleteRegistryHandler registry.DeleteRegistryHandler + // ReplicationDeleteReplicationPolicyHandler sets the operation handler for the delete replication policy operation + ReplicationDeleteReplicationPolicyHandler replication.DeleteReplicationPolicyHandler + // RepositoryDeleteRepositoryHandler sets the operation handler for the delete repository operation + RepositoryDeleteRepositoryHandler repository.DeleteRepositoryHandler + // RetentionDeleteRetentionHandler sets the operation handler for the delete retention operation + RetentionDeleteRetentionHandler retention.DeleteRetentionHandler + // ScannerDeleteScannerHandler sets the operation handler for the delete scanner operation + ScannerDeleteScannerHandler scanner.DeleteScannerHandler + // ArtifactDeleteTagHandler sets the operation handler for the delete tag operation + ArtifactDeleteTagHandler artifact.DeleteTagHandler + // UserDeleteUserHandler sets the operation handler for the delete user operation + UserDeleteUserHandler user.DeleteUserHandler + // UsergroupDeleteUserGroupHandler sets the operation handler for the delete user group operation + UsergroupDeleteUserGroupHandler usergroup.DeleteUserGroupHandler + // ScanDataExportDownloadScanDataHandler sets the operation handler for the download scan data operation + ScanDataExportDownloadScanDataHandler scan_data_export.DownloadScanDataHandler + // ScanDataExportExportScanDataHandler sets the operation handler for the export scan data operation + ScanDataExportExportScanDataHandler scan_data_export.ExportScanDataHandler + // ArtifactGetAdditionHandler sets the operation handler for the get addition operation + ArtifactGetAdditionHandler artifact.GetAdditionHandler + // ArtifactGetArtifactHandler sets the operation handler for the get artifact operation + ArtifactGetArtifactHandler artifact.GetArtifactHandler + // SysteminfoGetCertHandler sets the operation handler for the get cert operation + SysteminfoGetCertHandler systeminfo.GetCertHandler + // ConfigureGetConfigurationsHandler sets the operation handler for the get configurations operation + ConfigureGetConfigurationsHandler configure.GetConfigurationsHandler + // UserGetCurrentUserInfoHandler sets the operation handler for the get current user info operation + UserGetCurrentUserInfoHandler user.GetCurrentUserInfoHandler + // UserGetCurrentUserPermissionsHandler sets the operation handler for the get current user permissions operation + UserGetCurrentUserPermissionsHandler user.GetCurrentUserPermissionsHandler + // GCGetGCHandler sets the operation handler for the get GC operation + GCGetGCHandler gc.GetGCHandler + // GCGetGCHistoryHandler sets the operation handler for the get GC history operation + GCGetGCHistoryHandler gc.GetGCHistoryHandler + // GCGetGCLogHandler sets the operation handler for the get GC log operation + GCGetGCLogHandler gc.GetGCLogHandler + // GCGetGCScheduleHandler sets the operation handler for the get GC schedule operation + GCGetGCScheduleHandler gc.GetGCScheduleHandler + // HealthGetHealthHandler sets the operation handler for the get health operation + HealthGetHealthHandler health.GetHealthHandler + // IconGetIconHandler sets the operation handler for the get icon operation + IconGetIconHandler icon.GetIconHandler + // ConfigureGetInternalconfigHandler sets the operation handler for the get internalconfig operation + ConfigureGetInternalconfigHandler configure.GetInternalconfigHandler + // ScanAllGetLatestScanAllMetricsHandler sets the operation handler for the get latest scan all metrics operation + ScanAllGetLatestScanAllMetricsHandler scan_all.GetLatestScanAllMetricsHandler + // ScanAllGetLatestScheduledScanAllMetricsHandler sets the operation handler for the get latest scheduled scan all metrics operation + ScanAllGetLatestScheduledScanAllMetricsHandler scan_all.GetLatestScheduledScanAllMetricsHandler + // ProjectGetLogsHandler sets the operation handler for the get logs operation + ProjectGetLogsHandler project.GetLogsHandler + // PingGetPingHandler sets the operation handler for the get ping operation + PingGetPingHandler ping.GetPingHandler + // ProjectGetProjectHandler sets the operation handler for the get project operation + ProjectGetProjectHandler project.GetProjectHandler + // ProjectGetProjectDeletableHandler sets the operation handler for the get project deletable operation + ProjectGetProjectDeletableHandler project.GetProjectDeletableHandler + // MemberGetProjectMemberHandler sets the operation handler for the get project member operation + MemberGetProjectMemberHandler member.GetProjectMemberHandler + // ProjectMetadataGetProjectMetadataHandler sets the operation handler for the get project metadata operation + ProjectMetadataGetProjectMetadataHandler project_metadata.GetProjectMetadataHandler + // ProjectGetProjectSummaryHandler sets the operation handler for the get project summary operation + ProjectGetProjectSummaryHandler project.GetProjectSummaryHandler + // PurgeGetPurgeHistoryHandler sets the operation handler for the get purge history operation + PurgeGetPurgeHistoryHandler purge.GetPurgeHistoryHandler + // PurgeGetPurgeJobHandler sets the operation handler for the get purge job operation + PurgeGetPurgeJobHandler purge.GetPurgeJobHandler + // PurgeGetPurgeJobLogHandler sets the operation handler for the get purge job log operation + PurgeGetPurgeJobLogHandler purge.GetPurgeJobLogHandler + // PurgeGetPurgeScheduleHandler sets the operation handler for the get purge schedule operation + PurgeGetPurgeScheduleHandler purge.GetPurgeScheduleHandler + // QuotaGetQuotaHandler sets the operation handler for the get quota operation + QuotaGetQuotaHandler quota.GetQuotaHandler + // RegistryGetRegistryHandler sets the operation handler for the get registry operation + RegistryGetRegistryHandler registry.GetRegistryHandler + // RegistryGetRegistryInfoHandler sets the operation handler for the get registry info operation + RegistryGetRegistryInfoHandler registry.GetRegistryInfoHandler + // RetentionGetRentenitionMetadataHandler sets the operation handler for the get rentenition metadata operation + RetentionGetRentenitionMetadataHandler retention.GetRentenitionMetadataHandler + // ReplicationGetReplicationExecutionHandler sets the operation handler for the get replication execution operation + ReplicationGetReplicationExecutionHandler replication.GetReplicationExecutionHandler + // ReplicationGetReplicationLogHandler sets the operation handler for the get replication log operation + ReplicationGetReplicationLogHandler replication.GetReplicationLogHandler + // ReplicationGetReplicationPolicyHandler sets the operation handler for the get replication policy operation + ReplicationGetReplicationPolicyHandler replication.GetReplicationPolicyHandler + // ScanGetReportLogHandler sets the operation handler for the get report log operation + ScanGetReportLogHandler scan.GetReportLogHandler + // RepositoryGetRepositoryHandler sets the operation handler for the get repository operation + RepositoryGetRepositoryHandler repository.GetRepositoryHandler + // RetentionGetRetentionHandler sets the operation handler for the get retention operation + RetentionGetRetentionHandler retention.GetRetentionHandler + // RetentionGetRetentionTaskLogHandler sets the operation handler for the get retention task log operation + RetentionGetRetentionTaskLogHandler retention.GetRetentionTaskLogHandler + // ScanAllGetScanAllScheduleHandler sets the operation handler for the get scan all schedule operation + ScanAllGetScanAllScheduleHandler scan_all.GetScanAllScheduleHandler + // ScanDataExportGetScanDataExportExecutionHandler sets the operation handler for the get scan data export execution operation + ScanDataExportGetScanDataExportExecutionHandler scan_data_export.GetScanDataExportExecutionHandler + // ScanDataExportGetScanDataExportExecutionListHandler sets the operation handler for the get scan data export execution list operation + ScanDataExportGetScanDataExportExecutionListHandler scan_data_export.GetScanDataExportExecutionListHandler + // ScannerGetScannerHandler sets the operation handler for the get scanner operation + ScannerGetScannerHandler scanner.GetScannerHandler + // ScannerGetScannerMetadataHandler sets the operation handler for the get scanner metadata operation + ScannerGetScannerMetadataHandler scanner.GetScannerMetadataHandler + // ProjectGetScannerOfProjectHandler sets the operation handler for the get scanner of project operation + ProjectGetScannerOfProjectHandler project.GetScannerOfProjectHandler + // ScheduleGetSchedulePausedHandler sets the operation handler for the get schedule paused operation + ScheduleGetSchedulePausedHandler schedule.GetSchedulePausedHandler + // StatisticGetStatisticHandler sets the operation handler for the get statistic operation + StatisticGetStatisticHandler statistic.GetStatisticHandler + // SystemCVEAllowlistGetSystemCVEAllowlistHandler sets the operation handler for the get system CVE allowlist operation + SystemCVEAllowlistGetSystemCVEAllowlistHandler system_cve_allowlist.GetSystemCVEAllowlistHandler + // SysteminfoGetSystemInfoHandler sets the operation handler for the get system info operation + SysteminfoGetSystemInfoHandler systeminfo.GetSystemInfoHandler + // UserGetUserHandler sets the operation handler for the get user operation + UserGetUserHandler user.GetUserHandler + // UsergroupGetUserGroupHandler sets the operation handler for the get user group operation + UsergroupGetUserGroupHandler usergroup.GetUserGroupHandler + // SysteminfoGetVolumesHandler sets the operation handler for the get volumes operation + SysteminfoGetVolumesHandler systeminfo.GetVolumesHandler + // ArtifactGetVulnerabilitiesAdditionHandler sets the operation handler for the get vulnerabilities addition operation + ArtifactGetVulnerabilitiesAdditionHandler artifact.GetVulnerabilitiesAdditionHandler + // JobserviceGetWorkerPoolsHandler sets the operation handler for the get worker pools operation + JobserviceGetWorkerPoolsHandler jobservice.GetWorkerPoolsHandler + // JobserviceGetWorkersHandler sets the operation handler for the get workers operation + JobserviceGetWorkersHandler jobservice.GetWorkersHandler + // ProjectHeadProjectHandler sets the operation handler for the head project operation + ProjectHeadProjectHandler project.HeadProjectHandler + // LdapImportLdapUserHandler sets the operation handler for the import ldap user operation + LdapImportLdapUserHandler ldap.ImportLdapUserHandler + // ArtifactListAccessoriesHandler sets the operation handler for the list accessories operation + ArtifactListAccessoriesHandler artifact.ListAccessoriesHandler + // RepositoryListAllRepositoriesHandler sets the operation handler for the list all repositories operation + RepositoryListAllRepositoriesHandler repository.ListAllRepositoriesHandler + // ArtifactListArtifactsHandler sets the operation handler for the list artifacts operation + ArtifactListArtifactsHandler artifact.ListArtifactsHandler + // AuditlogListAuditLogsHandler sets the operation handler for the list audit logs operation + AuditlogListAuditLogsHandler auditlog.ListAuditLogsHandler + // JobserviceListJobQueuesHandler sets the operation handler for the list job queues operation + JobserviceListJobQueuesHandler jobservice.ListJobQueuesHandler + // MemberListProjectMembersHandler sets the operation handler for the list project members operation + MemberListProjectMembersHandler member.ListProjectMembersHandler + // ProjectMetadataListProjectMetadatasHandler sets the operation handler for the list project metadatas operation + ProjectMetadataListProjectMetadatasHandler project_metadata.ListProjectMetadatasHandler + // ProjectListProjectsHandler sets the operation handler for the list projects operation + ProjectListProjectsHandler project.ListProjectsHandler + // QuotaListQuotasHandler sets the operation handler for the list quotas operation + QuotaListQuotasHandler quota.ListQuotasHandler + // RegistryListRegistriesHandler sets the operation handler for the list registries operation + RegistryListRegistriesHandler registry.ListRegistriesHandler + // RegistryListRegistryProviderInfosHandler sets the operation handler for the list registry provider infos operation + RegistryListRegistryProviderInfosHandler registry.ListRegistryProviderInfosHandler + // RegistryListRegistryProviderTypesHandler sets the operation handler for the list registry provider types operation + RegistryListRegistryProviderTypesHandler registry.ListRegistryProviderTypesHandler + // ReplicationListReplicationExecutionsHandler sets the operation handler for the list replication executions operation + ReplicationListReplicationExecutionsHandler replication.ListReplicationExecutionsHandler + // ReplicationListReplicationPoliciesHandler sets the operation handler for the list replication policies operation + ReplicationListReplicationPoliciesHandler replication.ListReplicationPoliciesHandler + // ReplicationListReplicationTasksHandler sets the operation handler for the list replication tasks operation + ReplicationListReplicationTasksHandler replication.ListReplicationTasksHandler + // RepositoryListRepositoriesHandler sets the operation handler for the list repositories operation + RepositoryListRepositoriesHandler repository.ListRepositoriesHandler + // RetentionListRetentionExecutionsHandler sets the operation handler for the list retention executions operation + RetentionListRetentionExecutionsHandler retention.ListRetentionExecutionsHandler + // RetentionListRetentionTasksHandler sets the operation handler for the list retention tasks operation + RetentionListRetentionTasksHandler retention.ListRetentionTasksHandler + // ProjectListScannerCandidatesOfProjectHandler sets the operation handler for the list scanner candidates of project operation + ProjectListScannerCandidatesOfProjectHandler project.ListScannerCandidatesOfProjectHandler + // ScannerListScannersHandler sets the operation handler for the list scanners operation + ScannerListScannersHandler scanner.ListScannersHandler + // ScheduleListSchedulesHandler sets the operation handler for the list schedules operation + ScheduleListSchedulesHandler schedule.ListSchedulesHandler + // ArtifactListTagsHandler sets the operation handler for the list tags operation + ArtifactListTagsHandler artifact.ListTagsHandler + // UsergroupListUserGroupsHandler sets the operation handler for the list user groups operation + UsergroupListUserGroupsHandler usergroup.ListUserGroupsHandler + // UserListUsersHandler sets the operation handler for the list users operation + UserListUsersHandler user.ListUsersHandler + // RetentionOperateRetentionExecutionHandler sets the operation handler for the operate retention execution operation + RetentionOperateRetentionExecutionHandler retention.OperateRetentionExecutionHandler + // LdapPingLdapHandler sets the operation handler for the ping ldap operation + LdapPingLdapHandler ldap.PingLdapHandler + // OIDCPingOIDCHandler sets the operation handler for the ping OIDC operation + OIDCPingOIDCHandler oidc.PingOIDCHandler + // RegistryPingRegistryHandler sets the operation handler for the ping registry operation + RegistryPingRegistryHandler registry.PingRegistryHandler + // ScannerPingScannerHandler sets the operation handler for the ping scanner operation + ScannerPingScannerHandler scanner.PingScannerHandler + // SystemCVEAllowlistPutSystemCVEAllowlistHandler sets the operation handler for the put system CVE allowlist operation + SystemCVEAllowlistPutSystemCVEAllowlistHandler system_cve_allowlist.PutSystemCVEAllowlistHandler + // ArtifactRemoveLabelHandler sets the operation handler for the remove label operation + ArtifactRemoveLabelHandler artifact.RemoveLabelHandler + // ScanScanArtifactHandler sets the operation handler for the scan artifact operation + ScanScanArtifactHandler scan.ScanArtifactHandler + // SearchSearchHandler sets the operation handler for the search operation + SearchSearchHandler search.SearchHandler + // LdapSearchLdapGroupHandler sets the operation handler for the search ldap group operation + LdapSearchLdapGroupHandler ldap.SearchLdapGroupHandler + // LdapSearchLdapUserHandler sets the operation handler for the search ldap user operation + LdapSearchLdapUserHandler ldap.SearchLdapUserHandler + // UsergroupSearchUserGroupsHandler sets the operation handler for the search user groups operation + UsergroupSearchUserGroupsHandler usergroup.SearchUserGroupsHandler + // UserSearchUsersHandler sets the operation handler for the search users operation + UserSearchUsersHandler user.SearchUsersHandler + // UserSetCliSecretHandler sets the operation handler for the set cli secret operation + UserSetCliSecretHandler user.SetCliSecretHandler + // ScannerSetScannerAsDefaultHandler sets the operation handler for the set scanner as default operation + ScannerSetScannerAsDefaultHandler scanner.SetScannerAsDefaultHandler + // ProjectSetScannerOfProjectHandler sets the operation handler for the set scanner of project operation + ProjectSetScannerOfProjectHandler project.SetScannerOfProjectHandler + // UserSetUserSysAdminHandler sets the operation handler for the set user sys admin operation + UserSetUserSysAdminHandler user.SetUserSysAdminHandler + // ReplicationStartReplicationHandler sets the operation handler for the start replication operation + ReplicationStartReplicationHandler replication.StartReplicationHandler + // GCStopGCHandler sets the operation handler for the stop GC operation + GCStopGCHandler gc.StopGCHandler + // PurgeStopPurgeHandler sets the operation handler for the stop purge operation + PurgeStopPurgeHandler purge.StopPurgeHandler + // ReplicationStopReplicationHandler sets the operation handler for the stop replication operation + ReplicationStopReplicationHandler replication.StopReplicationHandler + // JobserviceStopRunningJobHandler sets the operation handler for the stop running job operation + JobserviceStopRunningJobHandler jobservice.StopRunningJobHandler + // ScanAllStopScanAllHandler sets the operation handler for the stop scan all operation + ScanAllStopScanAllHandler scan_all.StopScanAllHandler + // ScanStopScanArtifactHandler sets the operation handler for the stop scan artifact operation + ScanStopScanArtifactHandler scan.StopScanArtifactHandler + // RetentionTriggerRetentionExecutionHandler sets the operation handler for the trigger retention execution operation + RetentionTriggerRetentionExecutionHandler retention.TriggerRetentionExecutionHandler + // ConfigureUpdateConfigurationsHandler sets the operation handler for the update configurations operation + ConfigureUpdateConfigurationsHandler configure.UpdateConfigurationsHandler + // GCUpdateGCScheduleHandler sets the operation handler for the update GC schedule operation + GCUpdateGCScheduleHandler gc.UpdateGCScheduleHandler + // ProjectUpdateProjectHandler sets the operation handler for the update project operation + ProjectUpdateProjectHandler project.UpdateProjectHandler + // MemberUpdateProjectMemberHandler sets the operation handler for the update project member operation + MemberUpdateProjectMemberHandler member.UpdateProjectMemberHandler + // ProjectMetadataUpdateProjectMetadataHandler sets the operation handler for the update project metadata operation + ProjectMetadataUpdateProjectMetadataHandler project_metadata.UpdateProjectMetadataHandler + // PurgeUpdatePurgeScheduleHandler sets the operation handler for the update purge schedule operation + PurgeUpdatePurgeScheduleHandler purge.UpdatePurgeScheduleHandler + // QuotaUpdateQuotaHandler sets the operation handler for the update quota operation + QuotaUpdateQuotaHandler quota.UpdateQuotaHandler + // RegistryUpdateRegistryHandler sets the operation handler for the update registry operation + RegistryUpdateRegistryHandler registry.UpdateRegistryHandler + // ReplicationUpdateReplicationPolicyHandler sets the operation handler for the update replication policy operation + ReplicationUpdateReplicationPolicyHandler replication.UpdateReplicationPolicyHandler + // RepositoryUpdateRepositoryHandler sets the operation handler for the update repository operation + RepositoryUpdateRepositoryHandler repository.UpdateRepositoryHandler + // RetentionUpdateRetentionHandler sets the operation handler for the update retention operation + RetentionUpdateRetentionHandler retention.UpdateRetentionHandler + // ScanAllUpdateScanAllScheduleHandler sets the operation handler for the update scan all schedule operation + ScanAllUpdateScanAllScheduleHandler scan_all.UpdateScanAllScheduleHandler + // ScannerUpdateScannerHandler sets the operation handler for the update scanner operation + ScannerUpdateScannerHandler scanner.UpdateScannerHandler + // UsergroupUpdateUserGroupHandler sets the operation handler for the update user group operation + UsergroupUpdateUserGroupHandler usergroup.UpdateUserGroupHandler + // UserUpdateUserPasswordHandler sets the operation handler for the update user password operation + UserUpdateUserPasswordHandler user.UpdateUserPasswordHandler + // UserUpdateUserProfileHandler sets the operation handler for the update user profile operation + UserUpdateUserProfileHandler user.UpdateUserProfileHandler + // ServeError is called when an error is received, there is a default handler + // but you can set your own with this + ServeError func(http.ResponseWriter, *http.Request, error) + + // PreServerShutdown is called before the HTTP(S) server is shutdown + // This allows for custom functions to get executed before the HTTP(S) server stops accepting traffic + PreServerShutdown func() + + // ServerShutdown is called when the HTTP(S) server is shut down and done + // handling all active connections and does not accept connections any more + ServerShutdown func() + + // Custom command line argument groups with their descriptions + CommandLineOptionsGroups []swag.CommandLineOptionsGroup + + // User defined logger function. + Logger func(string, ...interface{}) +} + +// UseRedoc for documentation at /docs +func (o *HarborAPI) UseRedoc() { + o.useSwaggerUI = false +} + +// UseSwaggerUI for documentation at /docs +func (o *HarborAPI) UseSwaggerUI() { + o.useSwaggerUI = true +} + +// SetDefaultProduces sets the default produces media type +func (o *HarborAPI) SetDefaultProduces(mediaType string) { + o.defaultProduces = mediaType +} + +// SetDefaultConsumes returns the default consumes media type +func (o *HarborAPI) SetDefaultConsumes(mediaType string) { + o.defaultConsumes = mediaType +} + +// SetSpec sets a spec that will be served for the clients. +func (o *HarborAPI) SetSpec(spec *loads.Document) { + o.spec = spec +} + +// DefaultProduces returns the default produces media type +func (o *HarborAPI) DefaultProduces() string { + return o.defaultProduces +} + +// DefaultConsumes returns the default consumes media type +func (o *HarborAPI) DefaultConsumes() string { + return o.defaultConsumes +} + +// Formats returns the registered string formats +func (o *HarborAPI) Formats() strfmt.Registry { + return o.formats +} + +// RegisterFormat registers a custom format validator +func (o *HarborAPI) RegisterFormat(name string, format strfmt.Format, validator strfmt.Validator) { + o.formats.Add(name, format, validator) +} + +// Validate validates the registrations in the HarborAPI +func (o *HarborAPI) Validate() error { + var unregistered []string + + if o.JSONConsumer == nil { + unregistered = append(unregistered, "JSONConsumer") + } + + if o.BinProducer == nil { + unregistered = append(unregistered, "BinProducer") + } + if o.CsvProducer == nil { + unregistered = append(unregistered, "CsvProducer") + } + if o.JSONProducer == nil { + unregistered = append(unregistered, "JSONProducer") + } + if o.TxtProducer == nil { + unregistered = append(unregistered, "TxtProducer") + } + + if o.BasicAuth == nil { + unregistered = append(unregistered, "BasicAuth") + } + + if o.ArtifactCopyArtifactHandler == nil { + unregistered = append(unregistered, "artifact.CopyArtifactHandler") + } + if o.ImmutableCreateImmuRuleHandler == nil { + unregistered = append(unregistered, "immutable.CreateImmuRuleHandler") + } + if o.PreheatCreateInstanceHandler == nil { + unregistered = append(unregistered, "preheat.CreateInstanceHandler") + } + if o.LabelCreateLabelHandler == nil { + unregistered = append(unregistered, "label.CreateLabelHandler") + } + if o.PreheatCreatePolicyHandler == nil { + unregistered = append(unregistered, "preheat.CreatePolicyHandler") + } + if o.RobotCreateRobotHandler == nil { + unregistered = append(unregistered, "robot.CreateRobotHandler") + } + if o.Robotv1CreateRobotV1Handler == nil { + unregistered = append(unregistered, "robotv1.CreateRobotV1Handler") + } + if o.WebhookCreateWebhookPolicyOfProjectHandler == nil { + unregistered = append(unregistered, "webhook.CreateWebhookPolicyOfProjectHandler") + } + if o.ImmutableDeleteImmuRuleHandler == nil { + unregistered = append(unregistered, "immutable.DeleteImmuRuleHandler") + } + if o.PreheatDeleteInstanceHandler == nil { + unregistered = append(unregistered, "preheat.DeleteInstanceHandler") + } + if o.LabelDeleteLabelHandler == nil { + unregistered = append(unregistered, "label.DeleteLabelHandler") + } + if o.PreheatDeletePolicyHandler == nil { + unregistered = append(unregistered, "preheat.DeletePolicyHandler") + } + if o.RobotDeleteRobotHandler == nil { + unregistered = append(unregistered, "robot.DeleteRobotHandler") + } + if o.Robotv1DeleteRobotV1Handler == nil { + unregistered = append(unregistered, "robotv1.DeleteRobotV1Handler") + } + if o.WebhookDeleteWebhookPolicyOfProjectHandler == nil { + unregistered = append(unregistered, "webhook.DeleteWebhookPolicyOfProjectHandler") + } + if o.PreheatGetExecutionHandler == nil { + unregistered = append(unregistered, "preheat.GetExecutionHandler") + } + if o.PreheatGetInstanceHandler == nil { + unregistered = append(unregistered, "preheat.GetInstanceHandler") + } + if o.LabelGetLabelByIDHandler == nil { + unregistered = append(unregistered, "label.GetLabelByIDHandler") + } + if o.PreheatGetPolicyHandler == nil { + unregistered = append(unregistered, "preheat.GetPolicyHandler") + } + if o.PreheatGetPreheatLogHandler == nil { + unregistered = append(unregistered, "preheat.GetPreheatLogHandler") + } + if o.RobotGetRobotByIDHandler == nil { + unregistered = append(unregistered, "robot.GetRobotByIDHandler") + } + if o.Robotv1GetRobotByIDV1Handler == nil { + unregistered = append(unregistered, "robotv1.GetRobotByIDV1Handler") + } + if o.WebhookGetSupportedEventTypesHandler == nil { + unregistered = append(unregistered, "webhook.GetSupportedEventTypesHandler") + } + if o.WebhookGetWebhookPolicyOfProjectHandler == nil { + unregistered = append(unregistered, "webhook.GetWebhookPolicyOfProjectHandler") + } + if o.WebhookLastTriggerHandler == nil { + unregistered = append(unregistered, "webhook.LastTriggerHandler") + } + if o.PreheatListExecutionsHandler == nil { + unregistered = append(unregistered, "preheat.ListExecutionsHandler") + } + if o.ImmutableListImmuRulesHandler == nil { + unregistered = append(unregistered, "immutable.ListImmuRulesHandler") + } + if o.PreheatListInstancesHandler == nil { + unregistered = append(unregistered, "preheat.ListInstancesHandler") + } + if o.LabelListLabelsHandler == nil { + unregistered = append(unregistered, "label.ListLabelsHandler") + } + if o.PreheatListPoliciesHandler == nil { + unregistered = append(unregistered, "preheat.ListPoliciesHandler") + } + if o.PreheatListProvidersHandler == nil { + unregistered = append(unregistered, "preheat.ListProvidersHandler") + } + if o.PreheatListProvidersUnderProjectHandler == nil { + unregistered = append(unregistered, "preheat.ListProvidersUnderProjectHandler") + } + if o.RobotListRobotHandler == nil { + unregistered = append(unregistered, "robot.ListRobotHandler") + } + if o.Robotv1ListRobotV1Handler == nil { + unregistered = append(unregistered, "robotv1.ListRobotV1Handler") + } + if o.PreheatListTasksHandler == nil { + unregistered = append(unregistered, "preheat.ListTasksHandler") + } + if o.WebhookjobListWebhookJobsHandler == nil { + unregistered = append(unregistered, "webhookjob.ListWebhookJobsHandler") + } + if o.WebhookListWebhookPoliciesOfProjectHandler == nil { + unregistered = append(unregistered, "webhook.ListWebhookPoliciesOfProjectHandler") + } + if o.PreheatManualPreheatHandler == nil { + unregistered = append(unregistered, "preheat.ManualPreheatHandler") + } + if o.PreheatPingInstancesHandler == nil { + unregistered = append(unregistered, "preheat.PingInstancesHandler") + } + if o.RobotRefreshSecHandler == nil { + unregistered = append(unregistered, "robot.RefreshSecHandler") + } + if o.PreheatStopExecutionHandler == nil { + unregistered = append(unregistered, "preheat.StopExecutionHandler") + } + if o.ImmutableUpdateImmuRuleHandler == nil { + unregistered = append(unregistered, "immutable.UpdateImmuRuleHandler") + } + if o.PreheatUpdateInstanceHandler == nil { + unregistered = append(unregistered, "preheat.UpdateInstanceHandler") + } + if o.LabelUpdateLabelHandler == nil { + unregistered = append(unregistered, "label.UpdateLabelHandler") + } + if o.PreheatUpdatePolicyHandler == nil { + unregistered = append(unregistered, "preheat.UpdatePolicyHandler") + } + if o.RobotUpdateRobotHandler == nil { + unregistered = append(unregistered, "robot.UpdateRobotHandler") + } + if o.Robotv1UpdateRobotV1Handler == nil { + unregistered = append(unregistered, "robotv1.UpdateRobotV1Handler") + } + if o.WebhookUpdateWebhookPolicyOfProjectHandler == nil { + unregistered = append(unregistered, "webhook.UpdateWebhookPolicyOfProjectHandler") + } + if o.JobserviceActionPendingJobsHandler == nil { + unregistered = append(unregistered, "jobservice.ActionPendingJobsHandler") + } + if o.ArtifactAddLabelHandler == nil { + unregistered = append(unregistered, "artifact.AddLabelHandler") + } + if o.ProjectMetadataAddProjectMetadatasHandler == nil { + unregistered = append(unregistered, "project_metadata.AddProjectMetadatasHandler") + } + if o.GCCreateGCScheduleHandler == nil { + unregistered = append(unregistered, "gc.CreateGCScheduleHandler") + } + if o.ProjectCreateProjectHandler == nil { + unregistered = append(unregistered, "project.CreateProjectHandler") + } + if o.MemberCreateProjectMemberHandler == nil { + unregistered = append(unregistered, "member.CreateProjectMemberHandler") + } + if o.PurgeCreatePurgeScheduleHandler == nil { + unregistered = append(unregistered, "purge.CreatePurgeScheduleHandler") + } + if o.RegistryCreateRegistryHandler == nil { + unregistered = append(unregistered, "registry.CreateRegistryHandler") + } + if o.ReplicationCreateReplicationPolicyHandler == nil { + unregistered = append(unregistered, "replication.CreateReplicationPolicyHandler") + } + if o.RetentionCreateRetentionHandler == nil { + unregistered = append(unregistered, "retention.CreateRetentionHandler") + } + if o.ScanAllCreateScanAllScheduleHandler == nil { + unregistered = append(unregistered, "scan_all.CreateScanAllScheduleHandler") + } + if o.ScannerCreateScannerHandler == nil { + unregistered = append(unregistered, "scanner.CreateScannerHandler") + } + if o.ArtifactCreateTagHandler == nil { + unregistered = append(unregistered, "artifact.CreateTagHandler") + } + if o.UserCreateUserHandler == nil { + unregistered = append(unregistered, "user.CreateUserHandler") + } + if o.UsergroupCreateUserGroupHandler == nil { + unregistered = append(unregistered, "usergroup.CreateUserGroupHandler") + } + if o.ArtifactDeleteArtifactHandler == nil { + unregistered = append(unregistered, "artifact.DeleteArtifactHandler") + } + if o.ProjectDeleteProjectHandler == nil { + unregistered = append(unregistered, "project.DeleteProjectHandler") + } + if o.MemberDeleteProjectMemberHandler == nil { + unregistered = append(unregistered, "member.DeleteProjectMemberHandler") + } + if o.ProjectMetadataDeleteProjectMetadataHandler == nil { + unregistered = append(unregistered, "project_metadata.DeleteProjectMetadataHandler") + } + if o.RegistryDeleteRegistryHandler == nil { + unregistered = append(unregistered, "registry.DeleteRegistryHandler") + } + if o.ReplicationDeleteReplicationPolicyHandler == nil { + unregistered = append(unregistered, "replication.DeleteReplicationPolicyHandler") + } + if o.RepositoryDeleteRepositoryHandler == nil { + unregistered = append(unregistered, "repository.DeleteRepositoryHandler") + } + if o.RetentionDeleteRetentionHandler == nil { + unregistered = append(unregistered, "retention.DeleteRetentionHandler") + } + if o.ScannerDeleteScannerHandler == nil { + unregistered = append(unregistered, "scanner.DeleteScannerHandler") + } + if o.ArtifactDeleteTagHandler == nil { + unregistered = append(unregistered, "artifact.DeleteTagHandler") + } + if o.UserDeleteUserHandler == nil { + unregistered = append(unregistered, "user.DeleteUserHandler") + } + if o.UsergroupDeleteUserGroupHandler == nil { + unregistered = append(unregistered, "usergroup.DeleteUserGroupHandler") + } + if o.ScanDataExportDownloadScanDataHandler == nil { + unregistered = append(unregistered, "scan_data_export.DownloadScanDataHandler") + } + if o.ScanDataExportExportScanDataHandler == nil { + unregistered = append(unregistered, "scan_data_export.ExportScanDataHandler") + } + if o.ArtifactGetAdditionHandler == nil { + unregistered = append(unregistered, "artifact.GetAdditionHandler") + } + if o.ArtifactGetArtifactHandler == nil { + unregistered = append(unregistered, "artifact.GetArtifactHandler") + } + if o.SysteminfoGetCertHandler == nil { + unregistered = append(unregistered, "systeminfo.GetCertHandler") + } + if o.ConfigureGetConfigurationsHandler == nil { + unregistered = append(unregistered, "configure.GetConfigurationsHandler") + } + if o.UserGetCurrentUserInfoHandler == nil { + unregistered = append(unregistered, "user.GetCurrentUserInfoHandler") + } + if o.UserGetCurrentUserPermissionsHandler == nil { + unregistered = append(unregistered, "user.GetCurrentUserPermissionsHandler") + } + if o.GCGetGCHandler == nil { + unregistered = append(unregistered, "gc.GetGCHandler") + } + if o.GCGetGCHistoryHandler == nil { + unregistered = append(unregistered, "gc.GetGCHistoryHandler") + } + if o.GCGetGCLogHandler == nil { + unregistered = append(unregistered, "gc.GetGCLogHandler") + } + if o.GCGetGCScheduleHandler == nil { + unregistered = append(unregistered, "gc.GetGCScheduleHandler") + } + if o.HealthGetHealthHandler == nil { + unregistered = append(unregistered, "health.GetHealthHandler") + } + if o.IconGetIconHandler == nil { + unregistered = append(unregistered, "icon.GetIconHandler") + } + if o.ConfigureGetInternalconfigHandler == nil { + unregistered = append(unregistered, "configure.GetInternalconfigHandler") + } + if o.ScanAllGetLatestScanAllMetricsHandler == nil { + unregistered = append(unregistered, "scan_all.GetLatestScanAllMetricsHandler") + } + if o.ScanAllGetLatestScheduledScanAllMetricsHandler == nil { + unregistered = append(unregistered, "scan_all.GetLatestScheduledScanAllMetricsHandler") + } + if o.ProjectGetLogsHandler == nil { + unregistered = append(unregistered, "project.GetLogsHandler") + } + if o.PingGetPingHandler == nil { + unregistered = append(unregistered, "ping.GetPingHandler") + } + if o.ProjectGetProjectHandler == nil { + unregistered = append(unregistered, "project.GetProjectHandler") + } + if o.ProjectGetProjectDeletableHandler == nil { + unregistered = append(unregistered, "project.GetProjectDeletableHandler") + } + if o.MemberGetProjectMemberHandler == nil { + unregistered = append(unregistered, "member.GetProjectMemberHandler") + } + if o.ProjectMetadataGetProjectMetadataHandler == nil { + unregistered = append(unregistered, "project_metadata.GetProjectMetadataHandler") + } + if o.ProjectGetProjectSummaryHandler == nil { + unregistered = append(unregistered, "project.GetProjectSummaryHandler") + } + if o.PurgeGetPurgeHistoryHandler == nil { + unregistered = append(unregistered, "purge.GetPurgeHistoryHandler") + } + if o.PurgeGetPurgeJobHandler == nil { + unregistered = append(unregistered, "purge.GetPurgeJobHandler") + } + if o.PurgeGetPurgeJobLogHandler == nil { + unregistered = append(unregistered, "purge.GetPurgeJobLogHandler") + } + if o.PurgeGetPurgeScheduleHandler == nil { + unregistered = append(unregistered, "purge.GetPurgeScheduleHandler") + } + if o.QuotaGetQuotaHandler == nil { + unregistered = append(unregistered, "quota.GetQuotaHandler") + } + if o.RegistryGetRegistryHandler == nil { + unregistered = append(unregistered, "registry.GetRegistryHandler") + } + if o.RegistryGetRegistryInfoHandler == nil { + unregistered = append(unregistered, "registry.GetRegistryInfoHandler") + } + if o.RetentionGetRentenitionMetadataHandler == nil { + unregistered = append(unregistered, "retention.GetRentenitionMetadataHandler") + } + if o.ReplicationGetReplicationExecutionHandler == nil { + unregistered = append(unregistered, "replication.GetReplicationExecutionHandler") + } + if o.ReplicationGetReplicationLogHandler == nil { + unregistered = append(unregistered, "replication.GetReplicationLogHandler") + } + if o.ReplicationGetReplicationPolicyHandler == nil { + unregistered = append(unregistered, "replication.GetReplicationPolicyHandler") + } + if o.ScanGetReportLogHandler == nil { + unregistered = append(unregistered, "scan.GetReportLogHandler") + } + if o.RepositoryGetRepositoryHandler == nil { + unregistered = append(unregistered, "repository.GetRepositoryHandler") + } + if o.RetentionGetRetentionHandler == nil { + unregistered = append(unregistered, "retention.GetRetentionHandler") + } + if o.RetentionGetRetentionTaskLogHandler == nil { + unregistered = append(unregistered, "retention.GetRetentionTaskLogHandler") + } + if o.ScanAllGetScanAllScheduleHandler == nil { + unregistered = append(unregistered, "scan_all.GetScanAllScheduleHandler") + } + if o.ScanDataExportGetScanDataExportExecutionHandler == nil { + unregistered = append(unregistered, "scan_data_export.GetScanDataExportExecutionHandler") + } + if o.ScanDataExportGetScanDataExportExecutionListHandler == nil { + unregistered = append(unregistered, "scan_data_export.GetScanDataExportExecutionListHandler") + } + if o.ScannerGetScannerHandler == nil { + unregistered = append(unregistered, "scanner.GetScannerHandler") + } + if o.ScannerGetScannerMetadataHandler == nil { + unregistered = append(unregistered, "scanner.GetScannerMetadataHandler") + } + if o.ProjectGetScannerOfProjectHandler == nil { + unregistered = append(unregistered, "project.GetScannerOfProjectHandler") + } + if o.ScheduleGetSchedulePausedHandler == nil { + unregistered = append(unregistered, "schedule.GetSchedulePausedHandler") + } + if o.StatisticGetStatisticHandler == nil { + unregistered = append(unregistered, "statistic.GetStatisticHandler") + } + if o.SystemCVEAllowlistGetSystemCVEAllowlistHandler == nil { + unregistered = append(unregistered, "system_cve_allowlist.GetSystemCVEAllowlistHandler") + } + if o.SysteminfoGetSystemInfoHandler == nil { + unregistered = append(unregistered, "systeminfo.GetSystemInfoHandler") + } + if o.UserGetUserHandler == nil { + unregistered = append(unregistered, "user.GetUserHandler") + } + if o.UsergroupGetUserGroupHandler == nil { + unregistered = append(unregistered, "usergroup.GetUserGroupHandler") + } + if o.SysteminfoGetVolumesHandler == nil { + unregistered = append(unregistered, "systeminfo.GetVolumesHandler") + } + if o.ArtifactGetVulnerabilitiesAdditionHandler == nil { + unregistered = append(unregistered, "artifact.GetVulnerabilitiesAdditionHandler") + } + if o.JobserviceGetWorkerPoolsHandler == nil { + unregistered = append(unregistered, "jobservice.GetWorkerPoolsHandler") + } + if o.JobserviceGetWorkersHandler == nil { + unregistered = append(unregistered, "jobservice.GetWorkersHandler") + } + if o.ProjectHeadProjectHandler == nil { + unregistered = append(unregistered, "project.HeadProjectHandler") + } + if o.LdapImportLdapUserHandler == nil { + unregistered = append(unregistered, "ldap.ImportLdapUserHandler") + } + if o.ArtifactListAccessoriesHandler == nil { + unregistered = append(unregistered, "artifact.ListAccessoriesHandler") + } + if o.RepositoryListAllRepositoriesHandler == nil { + unregistered = append(unregistered, "repository.ListAllRepositoriesHandler") + } + if o.ArtifactListArtifactsHandler == nil { + unregistered = append(unregistered, "artifact.ListArtifactsHandler") + } + if o.AuditlogListAuditLogsHandler == nil { + unregistered = append(unregistered, "auditlog.ListAuditLogsHandler") + } + if o.JobserviceListJobQueuesHandler == nil { + unregistered = append(unregistered, "jobservice.ListJobQueuesHandler") + } + if o.MemberListProjectMembersHandler == nil { + unregistered = append(unregistered, "member.ListProjectMembersHandler") + } + if o.ProjectMetadataListProjectMetadatasHandler == nil { + unregistered = append(unregistered, "project_metadata.ListProjectMetadatasHandler") + } + if o.ProjectListProjectsHandler == nil { + unregistered = append(unregistered, "project.ListProjectsHandler") + } + if o.QuotaListQuotasHandler == nil { + unregistered = append(unregistered, "quota.ListQuotasHandler") + } + if o.RegistryListRegistriesHandler == nil { + unregistered = append(unregistered, "registry.ListRegistriesHandler") + } + if o.RegistryListRegistryProviderInfosHandler == nil { + unregistered = append(unregistered, "registry.ListRegistryProviderInfosHandler") + } + if o.RegistryListRegistryProviderTypesHandler == nil { + unregistered = append(unregistered, "registry.ListRegistryProviderTypesHandler") + } + if o.ReplicationListReplicationExecutionsHandler == nil { + unregistered = append(unregistered, "replication.ListReplicationExecutionsHandler") + } + if o.ReplicationListReplicationPoliciesHandler == nil { + unregistered = append(unregistered, "replication.ListReplicationPoliciesHandler") + } + if o.ReplicationListReplicationTasksHandler == nil { + unregistered = append(unregistered, "replication.ListReplicationTasksHandler") + } + if o.RepositoryListRepositoriesHandler == nil { + unregistered = append(unregistered, "repository.ListRepositoriesHandler") + } + if o.RetentionListRetentionExecutionsHandler == nil { + unregistered = append(unregistered, "retention.ListRetentionExecutionsHandler") + } + if o.RetentionListRetentionTasksHandler == nil { + unregistered = append(unregistered, "retention.ListRetentionTasksHandler") + } + if o.ProjectListScannerCandidatesOfProjectHandler == nil { + unregistered = append(unregistered, "project.ListScannerCandidatesOfProjectHandler") + } + if o.ScannerListScannersHandler == nil { + unregistered = append(unregistered, "scanner.ListScannersHandler") + } + if o.ScheduleListSchedulesHandler == nil { + unregistered = append(unregistered, "schedule.ListSchedulesHandler") + } + if o.ArtifactListTagsHandler == nil { + unregistered = append(unregistered, "artifact.ListTagsHandler") + } + if o.UsergroupListUserGroupsHandler == nil { + unregistered = append(unregistered, "usergroup.ListUserGroupsHandler") + } + if o.UserListUsersHandler == nil { + unregistered = append(unregistered, "user.ListUsersHandler") + } + if o.RetentionOperateRetentionExecutionHandler == nil { + unregistered = append(unregistered, "retention.OperateRetentionExecutionHandler") + } + if o.LdapPingLdapHandler == nil { + unregistered = append(unregistered, "ldap.PingLdapHandler") + } + if o.OIDCPingOIDCHandler == nil { + unregistered = append(unregistered, "oidc.PingOIDCHandler") + } + if o.RegistryPingRegistryHandler == nil { + unregistered = append(unregistered, "registry.PingRegistryHandler") + } + if o.ScannerPingScannerHandler == nil { + unregistered = append(unregistered, "scanner.PingScannerHandler") + } + if o.SystemCVEAllowlistPutSystemCVEAllowlistHandler == nil { + unregistered = append(unregistered, "system_cve_allowlist.PutSystemCVEAllowlistHandler") + } + if o.ArtifactRemoveLabelHandler == nil { + unregistered = append(unregistered, "artifact.RemoveLabelHandler") + } + if o.ScanScanArtifactHandler == nil { + unregistered = append(unregistered, "scan.ScanArtifactHandler") + } + if o.SearchSearchHandler == nil { + unregistered = append(unregistered, "search.SearchHandler") + } + if o.LdapSearchLdapGroupHandler == nil { + unregistered = append(unregistered, "ldap.SearchLdapGroupHandler") + } + if o.LdapSearchLdapUserHandler == nil { + unregistered = append(unregistered, "ldap.SearchLdapUserHandler") + } + if o.UsergroupSearchUserGroupsHandler == nil { + unregistered = append(unregistered, "usergroup.SearchUserGroupsHandler") + } + if o.UserSearchUsersHandler == nil { + unregistered = append(unregistered, "user.SearchUsersHandler") + } + if o.UserSetCliSecretHandler == nil { + unregistered = append(unregistered, "user.SetCliSecretHandler") + } + if o.ScannerSetScannerAsDefaultHandler == nil { + unregistered = append(unregistered, "scanner.SetScannerAsDefaultHandler") + } + if o.ProjectSetScannerOfProjectHandler == nil { + unregistered = append(unregistered, "project.SetScannerOfProjectHandler") + } + if o.UserSetUserSysAdminHandler == nil { + unregistered = append(unregistered, "user.SetUserSysAdminHandler") + } + if o.ReplicationStartReplicationHandler == nil { + unregistered = append(unregistered, "replication.StartReplicationHandler") + } + if o.GCStopGCHandler == nil { + unregistered = append(unregistered, "gc.StopGCHandler") + } + if o.PurgeStopPurgeHandler == nil { + unregistered = append(unregistered, "purge.StopPurgeHandler") + } + if o.ReplicationStopReplicationHandler == nil { + unregistered = append(unregistered, "replication.StopReplicationHandler") + } + if o.JobserviceStopRunningJobHandler == nil { + unregistered = append(unregistered, "jobservice.StopRunningJobHandler") + } + if o.ScanAllStopScanAllHandler == nil { + unregistered = append(unregistered, "scan_all.StopScanAllHandler") + } + if o.ScanStopScanArtifactHandler == nil { + unregistered = append(unregistered, "scan.StopScanArtifactHandler") + } + if o.RetentionTriggerRetentionExecutionHandler == nil { + unregistered = append(unregistered, "retention.TriggerRetentionExecutionHandler") + } + if o.ConfigureUpdateConfigurationsHandler == nil { + unregistered = append(unregistered, "configure.UpdateConfigurationsHandler") + } + if o.GCUpdateGCScheduleHandler == nil { + unregistered = append(unregistered, "gc.UpdateGCScheduleHandler") + } + if o.ProjectUpdateProjectHandler == nil { + unregistered = append(unregistered, "project.UpdateProjectHandler") + } + if o.MemberUpdateProjectMemberHandler == nil { + unregistered = append(unregistered, "member.UpdateProjectMemberHandler") + } + if o.ProjectMetadataUpdateProjectMetadataHandler == nil { + unregistered = append(unregistered, "project_metadata.UpdateProjectMetadataHandler") + } + if o.PurgeUpdatePurgeScheduleHandler == nil { + unregistered = append(unregistered, "purge.UpdatePurgeScheduleHandler") + } + if o.QuotaUpdateQuotaHandler == nil { + unregistered = append(unregistered, "quota.UpdateQuotaHandler") + } + if o.RegistryUpdateRegistryHandler == nil { + unregistered = append(unregistered, "registry.UpdateRegistryHandler") + } + if o.ReplicationUpdateReplicationPolicyHandler == nil { + unregistered = append(unregistered, "replication.UpdateReplicationPolicyHandler") + } + if o.RepositoryUpdateRepositoryHandler == nil { + unregistered = append(unregistered, "repository.UpdateRepositoryHandler") + } + if o.RetentionUpdateRetentionHandler == nil { + unregistered = append(unregistered, "retention.UpdateRetentionHandler") + } + if o.ScanAllUpdateScanAllScheduleHandler == nil { + unregistered = append(unregistered, "scan_all.UpdateScanAllScheduleHandler") + } + if o.ScannerUpdateScannerHandler == nil { + unregistered = append(unregistered, "scanner.UpdateScannerHandler") + } + if o.UsergroupUpdateUserGroupHandler == nil { + unregistered = append(unregistered, "usergroup.UpdateUserGroupHandler") + } + if o.UserUpdateUserPasswordHandler == nil { + unregistered = append(unregistered, "user.UpdateUserPasswordHandler") + } + if o.UserUpdateUserProfileHandler == nil { + unregistered = append(unregistered, "user.UpdateUserProfileHandler") + } + + if len(unregistered) > 0 { + return fmt.Errorf("missing registration: %s", strings.Join(unregistered, ", ")) + } + + return nil +} + +// ServeErrorFor gets a error handler for a given operation id +func (o *HarborAPI) ServeErrorFor(operationID string) func(http.ResponseWriter, *http.Request, error) { + return o.ServeError +} + +// AuthenticatorsFor gets the authenticators for the specified security schemes +func (o *HarborAPI) AuthenticatorsFor(schemes map[string]spec.SecurityScheme) map[string]runtime.Authenticator { + result := make(map[string]runtime.Authenticator) + for name := range schemes { + switch name { + case "basic": + result[name] = o.BasicAuthenticator(o.BasicAuth) + + } + } + return result +} + +// Authorizer returns the registered authorizer +func (o *HarborAPI) Authorizer() runtime.Authorizer { + return o.APIAuthorizer +} + +// ConsumersFor gets the consumers for the specified media types. +// MIME type parameters are ignored here. +func (o *HarborAPI) ConsumersFor(mediaTypes []string) map[string]runtime.Consumer { + result := make(map[string]runtime.Consumer, len(mediaTypes)) + for _, mt := range mediaTypes { + switch mt { + case "application/json": + result["application/json"] = o.JSONConsumer + } + + if c, ok := o.customConsumers[mt]; ok { + result[mt] = c + } + } + return result +} + +// ProducersFor gets the producers for the specified media types. +// MIME type parameters are ignored here. +func (o *HarborAPI) ProducersFor(mediaTypes []string) map[string]runtime.Producer { + result := make(map[string]runtime.Producer, len(mediaTypes)) + for _, mt := range mediaTypes { + switch mt { + case "application/octet-stream": + result["application/octet-stream"] = o.BinProducer + case "text/csv": + result["text/csv"] = o.CsvProducer + case "application/json": + result["application/json"] = o.JSONProducer + case "text/plain": + result["text/plain"] = o.TxtProducer + } + + if p, ok := o.customProducers[mt]; ok { + result[mt] = p + } + } + return result +} + +// HandlerFor gets a http.Handler for the provided operation method and path +func (o *HarborAPI) HandlerFor(method, path string) (http.Handler, bool) { + if o.handlers == nil { + return nil, false + } + um := strings.ToUpper(method) + if _, ok := o.handlers[um]; !ok { + return nil, false + } + if path == "/" { + path = "" + } + h, ok := o.handlers[um][path] + return h, ok +} + +// Context returns the middleware context for the harbor API +func (o *HarborAPI) Context() *middleware.Context { + if o.context == nil { + o.context = middleware.NewRoutableContext(o.spec, o, nil) + } + + return o.context +} + +func (o *HarborAPI) handler(operation string, next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + h := next + if b, ok := o.operationMiddlewares[operation]; ok { + h = b(h) + } + + h.ServeHTTP(w, r) + }) +} + +func (o *HarborAPI) initHandlerCache() { + o.Context() // don't care about the result, just that the initialization happened + if o.handlers == nil { + o.handlers = make(map[string]map[string]http.Handler) + } + + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/projects/{project_name}/repositories/{repository_name}/artifacts"] = o.handler("CopyArtifact", artifact.NewCopyArtifact(o.context, o.ArtifactCopyArtifactHandler)) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/projects/{project_name_or_id}/immutabletagrules"] = o.handler("CreateImmuRule", immutable.NewCreateImmuRule(o.context, o.ImmutableCreateImmuRuleHandler)) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/p2p/preheat/instances"] = o.handler("CreateInstance", preheat.NewCreateInstance(o.context, o.PreheatCreateInstanceHandler)) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/labels"] = o.handler("CreateLabel", label.NewCreateLabel(o.context, o.LabelCreateLabelHandler)) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/projects/{project_name}/preheat/policies"] = o.handler("CreatePolicy", preheat.NewCreatePolicy(o.context, o.PreheatCreatePolicyHandler)) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/robots"] = o.handler("CreateRobot", robot.NewCreateRobot(o.context, o.RobotCreateRobotHandler)) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/projects/{project_name_or_id}/robots"] = o.handler("CreateRobotV1", robotv1.NewCreateRobotV1(o.context, o.Robotv1CreateRobotV1Handler)) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/projects/{project_name_or_id}/webhook/policies"] = o.handler("CreateWebhookPolicyOfProject", webhook.NewCreateWebhookPolicyOfProject(o.context, o.WebhookCreateWebhookPolicyOfProjectHandler)) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/projects/{project_name_or_id}/immutabletagrules/{immutable_rule_id}"] = o.handler("DeleteImmuRule", immutable.NewDeleteImmuRule(o.context, o.ImmutableDeleteImmuRuleHandler)) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/p2p/preheat/instances/{preheat_instance_name}"] = o.handler("DeleteInstance", preheat.NewDeleteInstance(o.context, o.PreheatDeleteInstanceHandler)) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/labels/{label_id}"] = o.handler("DeleteLabel", label.NewDeleteLabel(o.context, o.LabelDeleteLabelHandler)) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/projects/{project_name}/preheat/policies/{preheat_policy_name}"] = o.handler("DeletePolicy", preheat.NewDeletePolicy(o.context, o.PreheatDeletePolicyHandler)) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/robots/{robot_id}"] = o.handler("DeleteRobot", robot.NewDeleteRobot(o.context, o.RobotDeleteRobotHandler)) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/projects/{project_name_or_id}/robots/{robot_id}"] = o.handler("DeleteRobotV1", robotv1.NewDeleteRobotV1(o.context, o.Robotv1DeleteRobotV1Handler)) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}"] = o.handler("DeleteWebhookPolicyOfProject", webhook.NewDeleteWebhookPolicyOfProject(o.context, o.WebhookDeleteWebhookPolicyOfProjectHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/projects/{project_name}/preheat/policies/{preheat_policy_name}/executions/{execution_id}"] = o.handler("GetExecution", preheat.NewGetExecution(o.context, o.PreheatGetExecutionHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/p2p/preheat/instances/{preheat_instance_name}"] = o.handler("GetInstance", preheat.NewGetInstance(o.context, o.PreheatGetInstanceHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/labels/{label_id}"] = o.handler("GetLabelByID", label.NewGetLabelByID(o.context, o.LabelGetLabelByIDHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/projects/{project_name}/preheat/policies/{preheat_policy_name}"] = o.handler("GetPolicy", preheat.NewGetPolicy(o.context, o.PreheatGetPolicyHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/projects/{project_name}/preheat/policies/{preheat_policy_name}/executions/{execution_id}/tasks/{task_id}/logs"] = o.handler("GetPreheatLog", preheat.NewGetPreheatLog(o.context, o.PreheatGetPreheatLogHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/robots/{robot_id}"] = o.handler("GetRobotByID", robot.NewGetRobotByID(o.context, o.RobotGetRobotByIDHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/projects/{project_name_or_id}/robots/{robot_id}"] = o.handler("GetRobotByIDV1", robotv1.NewGetRobotByIDV1(o.context, o.Robotv1GetRobotByIDV1Handler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/projects/{project_name_or_id}/webhook/events"] = o.handler("GetSupportedEventTypes", webhook.NewGetSupportedEventTypes(o.context, o.WebhookGetSupportedEventTypesHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}"] = o.handler("GetWebhookPolicyOfProject", webhook.NewGetWebhookPolicyOfProject(o.context, o.WebhookGetWebhookPolicyOfProjectHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/projects/{project_name_or_id}/webhook/lasttrigger"] = o.handler("LastTrigger", webhook.NewLastTrigger(o.context, o.WebhookLastTriggerHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/projects/{project_name}/preheat/policies/{preheat_policy_name}/executions"] = o.handler("ListExecutions", preheat.NewListExecutions(o.context, o.PreheatListExecutionsHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/projects/{project_name_or_id}/immutabletagrules"] = o.handler("ListImmuRules", immutable.NewListImmuRules(o.context, o.ImmutableListImmuRulesHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/p2p/preheat/instances"] = o.handler("ListInstances", preheat.NewListInstances(o.context, o.PreheatListInstancesHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/labels"] = o.handler("ListLabels", label.NewListLabels(o.context, o.LabelListLabelsHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/projects/{project_name}/preheat/policies"] = o.handler("ListPolicies", preheat.NewListPolicies(o.context, o.PreheatListPoliciesHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/p2p/preheat/providers"] = o.handler("ListProviders", preheat.NewListProviders(o.context, o.PreheatListProvidersHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/projects/{project_name}/preheat/providers"] = o.handler("ListProvidersUnderProject", preheat.NewListProvidersUnderProject(o.context, o.PreheatListProvidersUnderProjectHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/robots"] = o.handler("ListRobot", robot.NewListRobot(o.context, o.RobotListRobotHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/projects/{project_name_or_id}/robots"] = o.handler("ListRobotV1", robotv1.NewListRobotV1(o.context, o.Robotv1ListRobotV1Handler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/projects/{project_name}/preheat/policies/{preheat_policy_name}/executions/{execution_id}/tasks"] = o.handler("ListTasks", preheat.NewListTasks(o.context, o.PreheatListTasksHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/projects/{project_name_or_id}/webhook/jobs"] = o.handler("ListWebhookJobs", webhookjob.NewListWebhookJobs(o.context, o.WebhookjobListWebhookJobsHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/projects/{project_name_or_id}/webhook/policies"] = o.handler("ListWebhookPoliciesOfProject", webhook.NewListWebhookPoliciesOfProject(o.context, o.WebhookListWebhookPoliciesOfProjectHandler)) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/projects/{project_name}/preheat/policies/{preheat_policy_name}"] = o.handler("ManualPreheat", preheat.NewManualPreheat(o.context, o.PreheatManualPreheatHandler)) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/p2p/preheat/instances/ping"] = o.handler("PingInstances", preheat.NewPingInstances(o.context, o.PreheatPingInstancesHandler)) + if o.handlers["PATCH"] == nil { + o.handlers["PATCH"] = make(map[string]http.Handler) + } + o.handlers["PATCH"]["/robots/{robot_id}"] = o.handler("RefreshSec", robot.NewRefreshSec(o.context, o.RobotRefreshSecHandler)) + if o.handlers["PATCH"] == nil { + o.handlers["PATCH"] = make(map[string]http.Handler) + } + o.handlers["PATCH"]["/projects/{project_name}/preheat/policies/{preheat_policy_name}/executions/{execution_id}"] = o.handler("StopExecution", preheat.NewStopExecution(o.context, o.PreheatStopExecutionHandler)) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) + } + o.handlers["PUT"]["/projects/{project_name_or_id}/immutabletagrules/{immutable_rule_id}"] = o.handler("UpdateImmuRule", immutable.NewUpdateImmuRule(o.context, o.ImmutableUpdateImmuRuleHandler)) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) + } + o.handlers["PUT"]["/p2p/preheat/instances/{preheat_instance_name}"] = o.handler("UpdateInstance", preheat.NewUpdateInstance(o.context, o.PreheatUpdateInstanceHandler)) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) + } + o.handlers["PUT"]["/labels/{label_id}"] = o.handler("UpdateLabel", label.NewUpdateLabel(o.context, o.LabelUpdateLabelHandler)) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) + } + o.handlers["PUT"]["/projects/{project_name}/preheat/policies/{preheat_policy_name}"] = o.handler("UpdatePolicy", preheat.NewUpdatePolicy(o.context, o.PreheatUpdatePolicyHandler)) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) + } + o.handlers["PUT"]["/robots/{robot_id}"] = o.handler("UpdateRobot", robot.NewUpdateRobot(o.context, o.RobotUpdateRobotHandler)) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) + } + o.handlers["PUT"]["/projects/{project_name_or_id}/robots/{robot_id}"] = o.handler("UpdateRobotV1", robotv1.NewUpdateRobotV1(o.context, o.Robotv1UpdateRobotV1Handler)) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) + } + o.handlers["PUT"]["/projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}"] = o.handler("UpdateWebhookPolicyOfProject", webhook.NewUpdateWebhookPolicyOfProject(o.context, o.WebhookUpdateWebhookPolicyOfProjectHandler)) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) + } + o.handlers["PUT"]["/jobservice/queues/{job_type}"] = o.handler("ActionPendingJobs", jobservice.NewActionPendingJobs(o.context, o.JobserviceActionPendingJobsHandler)) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/labels"] = o.handler("AddLabel", artifact.NewAddLabel(o.context, o.ArtifactAddLabelHandler)) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/projects/{project_name_or_id}/metadatas"] = o.handler("AddProjectMetadatas", project_metadata.NewAddProjectMetadatas(o.context, o.ProjectMetadataAddProjectMetadatasHandler)) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/system/gc/schedule"] = o.handler("CreateGCSchedule", gc.NewCreateGCSchedule(o.context, o.GCCreateGCScheduleHandler)) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/projects"] = o.handler("CreateProject", project.NewCreateProject(o.context, o.ProjectCreateProjectHandler)) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/projects/{project_name_or_id}/members"] = o.handler("CreateProjectMember", member.NewCreateProjectMember(o.context, o.MemberCreateProjectMemberHandler)) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/system/purgeaudit/schedule"] = o.handler("CreatePurgeSchedule", purge.NewCreatePurgeSchedule(o.context, o.PurgeCreatePurgeScheduleHandler)) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/registries"] = o.handler("CreateRegistry", registry.NewCreateRegistry(o.context, o.RegistryCreateRegistryHandler)) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/replication/policies"] = o.handler("CreateReplicationPolicy", replication.NewCreateReplicationPolicy(o.context, o.ReplicationCreateReplicationPolicyHandler)) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/retentions"] = o.handler("CreateRetention", retention.NewCreateRetention(o.context, o.RetentionCreateRetentionHandler)) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/system/scanAll/schedule"] = o.handler("CreateScanAllSchedule", scan_all.NewCreateScanAllSchedule(o.context, o.ScanAllCreateScanAllScheduleHandler)) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/scanners"] = o.handler("CreateScanner", scanner.NewCreateScanner(o.context, o.ScannerCreateScannerHandler)) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/tags"] = o.handler("CreateTag", artifact.NewCreateTag(o.context, o.ArtifactCreateTagHandler)) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/users"] = o.handler("CreateUser", user.NewCreateUser(o.context, o.UserCreateUserHandler)) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/usergroups"] = o.handler("CreateUserGroup", usergroup.NewCreateUserGroup(o.context, o.UsergroupCreateUserGroupHandler)) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}"] = o.handler("DeleteArtifact", artifact.NewDeleteArtifact(o.context, o.ArtifactDeleteArtifactHandler)) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/projects/{project_name_or_id}"] = o.handler("DeleteProject", project.NewDeleteProject(o.context, o.ProjectDeleteProjectHandler)) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/projects/{project_name_or_id}/members/{mid}"] = o.handler("DeleteProjectMember", member.NewDeleteProjectMember(o.context, o.MemberDeleteProjectMemberHandler)) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/projects/{project_name_or_id}/metadatas/{meta_name}"] = o.handler("DeleteProjectMetadata", project_metadata.NewDeleteProjectMetadata(o.context, o.ProjectMetadataDeleteProjectMetadataHandler)) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/registries/{id}"] = o.handler("DeleteRegistry", registry.NewDeleteRegistry(o.context, o.RegistryDeleteRegistryHandler)) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/replication/policies/{id}"] = o.handler("DeleteReplicationPolicy", replication.NewDeleteReplicationPolicy(o.context, o.ReplicationDeleteReplicationPolicyHandler)) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/projects/{project_name}/repositories/{repository_name}"] = o.handler("DeleteRepository", repository.NewDeleteRepository(o.context, o.RepositoryDeleteRepositoryHandler)) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/retentions/{id}"] = o.handler("DeleteRetention", retention.NewDeleteRetention(o.context, o.RetentionDeleteRetentionHandler)) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/scanners/{registration_id}"] = o.handler("DeleteScanner", scanner.NewDeleteScanner(o.context, o.ScannerDeleteScannerHandler)) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/tags/{tag_name}"] = o.handler("DeleteTag", artifact.NewDeleteTag(o.context, o.ArtifactDeleteTagHandler)) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/users/{user_id}"] = o.handler("DeleteUser", user.NewDeleteUser(o.context, o.UserDeleteUserHandler)) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/usergroups/{group_id}"] = o.handler("DeleteUserGroup", usergroup.NewDeleteUserGroup(o.context, o.UsergroupDeleteUserGroupHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/export/cve/download/{execution_id}"] = o.handler("DownloadScanData", scan_data_export.NewDownloadScanData(o.context, o.ScanDataExportDownloadScanDataHandler)) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/export/cve"] = o.handler("ExportScanData", scan_data_export.NewExportScanData(o.context, o.ScanDataExportExportScanDataHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/additions/{addition}"] = o.handler("GetAddition", artifact.NewGetAddition(o.context, o.ArtifactGetAdditionHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}"] = o.handler("GetArtifact", artifact.NewGetArtifact(o.context, o.ArtifactGetArtifactHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/systeminfo/getcert"] = o.handler("GetCert", systeminfo.NewGetCert(o.context, o.SysteminfoGetCertHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/configurations"] = o.handler("GetConfigurations", configure.NewGetConfigurations(o.context, o.ConfigureGetConfigurationsHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/users/current"] = o.handler("GetCurrentUserInfo", user.NewGetCurrentUserInfo(o.context, o.UserGetCurrentUserInfoHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/users/current/permissions"] = o.handler("GetCurrentUserPermissions", user.NewGetCurrentUserPermissions(o.context, o.UserGetCurrentUserPermissionsHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/system/gc/{gc_id}"] = o.handler("GetGC", gc.NewGetGC(o.context, o.GCGetGCHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/system/gc"] = o.handler("GetGCHistory", gc.NewGetGCHistory(o.context, o.GCGetGCHistoryHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/system/gc/{gc_id}/log"] = o.handler("GetGCLog", gc.NewGetGCLog(o.context, o.GCGetGCLogHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/system/gc/schedule"] = o.handler("GetGCSchedule", gc.NewGetGCSchedule(o.context, o.GCGetGCScheduleHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/health"] = o.handler("GetHealth", health.NewGetHealth(o.context, o.HealthGetHealthHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/icons/{digest}"] = o.handler("GetIcon", icon.NewGetIcon(o.context, o.IconGetIconHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/internalconfig"] = o.handler("GetInternalconfig", configure.NewGetInternalconfig(o.context, o.ConfigureGetInternalconfigHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/scans/all/metrics"] = o.handler("GetLatestScanAllMetrics", scan_all.NewGetLatestScanAllMetrics(o.context, o.ScanAllGetLatestScanAllMetricsHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/scans/schedule/metrics"] = o.handler("GetLatestScheduledScanAllMetrics", scan_all.NewGetLatestScheduledScanAllMetrics(o.context, o.ScanAllGetLatestScheduledScanAllMetricsHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/projects/{project_name}/logs"] = o.handler("GetLogs", project.NewGetLogs(o.context, o.ProjectGetLogsHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/ping"] = o.handler("GetPing", ping.NewGetPing(o.context, o.PingGetPingHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/projects/{project_name_or_id}"] = o.handler("GetProject", project.NewGetProject(o.context, o.ProjectGetProjectHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/projects/{project_name_or_id}/_deletable"] = o.handler("GetProjectDeletable", project.NewGetProjectDeletable(o.context, o.ProjectGetProjectDeletableHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/projects/{project_name_or_id}/members/{mid}"] = o.handler("GetProjectMember", member.NewGetProjectMember(o.context, o.MemberGetProjectMemberHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/projects/{project_name_or_id}/metadatas/{meta_name}"] = o.handler("GetProjectMetadata", project_metadata.NewGetProjectMetadata(o.context, o.ProjectMetadataGetProjectMetadataHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/projects/{project_name_or_id}/summary"] = o.handler("GetProjectSummary", project.NewGetProjectSummary(o.context, o.ProjectGetProjectSummaryHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/system/purgeaudit"] = o.handler("GetPurgeHistory", purge.NewGetPurgeHistory(o.context, o.PurgeGetPurgeHistoryHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/system/purgeaudit/{purge_id}"] = o.handler("GetPurgeJob", purge.NewGetPurgeJob(o.context, o.PurgeGetPurgeJobHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/system/purgeaudit/{purge_id}/log"] = o.handler("GetPurgeJobLog", purge.NewGetPurgeJobLog(o.context, o.PurgeGetPurgeJobLogHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/system/purgeaudit/schedule"] = o.handler("GetPurgeSchedule", purge.NewGetPurgeSchedule(o.context, o.PurgeGetPurgeScheduleHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/quotas/{id}"] = o.handler("GetQuota", quota.NewGetQuota(o.context, o.QuotaGetQuotaHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/registries/{id}"] = o.handler("GetRegistry", registry.NewGetRegistry(o.context, o.RegistryGetRegistryHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/registries/{id}/info"] = o.handler("GetRegistryInfo", registry.NewGetRegistryInfo(o.context, o.RegistryGetRegistryInfoHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/retentions/metadatas"] = o.handler("GetRentenitionMetadata", retention.NewGetRentenitionMetadata(o.context, o.RetentionGetRentenitionMetadataHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/replication/executions/{id}"] = o.handler("GetReplicationExecution", replication.NewGetReplicationExecution(o.context, o.ReplicationGetReplicationExecutionHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/replication/executions/{id}/tasks/{task_id}/log"] = o.handler("GetReplicationLog", replication.NewGetReplicationLog(o.context, o.ReplicationGetReplicationLogHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/replication/policies/{id}"] = o.handler("GetReplicationPolicy", replication.NewGetReplicationPolicy(o.context, o.ReplicationGetReplicationPolicyHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/scan/{report_id}/log"] = o.handler("GetReportLog", scan.NewGetReportLog(o.context, o.ScanGetReportLogHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/projects/{project_name}/repositories/{repository_name}"] = o.handler("GetRepository", repository.NewGetRepository(o.context, o.RepositoryGetRepositoryHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/retentions/{id}"] = o.handler("GetRetention", retention.NewGetRetention(o.context, o.RetentionGetRetentionHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/retentions/{id}/executions/{eid}/tasks/{tid}"] = o.handler("GetRetentionTaskLog", retention.NewGetRetentionTaskLog(o.context, o.RetentionGetRetentionTaskLogHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/system/scanAll/schedule"] = o.handler("GetScanAllSchedule", scan_all.NewGetScanAllSchedule(o.context, o.ScanAllGetScanAllScheduleHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/export/cve/execution/{execution_id}"] = o.handler("GetScanDataExportExecution", scan_data_export.NewGetScanDataExportExecution(o.context, o.ScanDataExportGetScanDataExportExecutionHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/export/cve/executions"] = o.handler("GetScanDataExportExecutionList", scan_data_export.NewGetScanDataExportExecutionList(o.context, o.ScanDataExportGetScanDataExportExecutionListHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/scanners/{registration_id}"] = o.handler("GetScanner", scanner.NewGetScanner(o.context, o.ScannerGetScannerHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/scanners/{registration_id}/metadata"] = o.handler("GetScannerMetadata", scanner.NewGetScannerMetadata(o.context, o.ScannerGetScannerMetadataHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/projects/{project_name_or_id}/scanner"] = o.handler("GetScannerOfProject", project.NewGetScannerOfProject(o.context, o.ProjectGetScannerOfProjectHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/schedules/{job_type}/paused"] = o.handler("GetSchedulePaused", schedule.NewGetSchedulePaused(o.context, o.ScheduleGetSchedulePausedHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/statistics"] = o.handler("GetStatistic", statistic.NewGetStatistic(o.context, o.StatisticGetStatisticHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/system/CVEAllowlist"] = o.handler("GetSystemCVEAllowlist", system_cve_allowlist.NewGetSystemCVEAllowlist(o.context, o.SystemCVEAllowlistGetSystemCVEAllowlistHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/systeminfo"] = o.handler("GetSystemInfo", systeminfo.NewGetSystemInfo(o.context, o.SysteminfoGetSystemInfoHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/users/{user_id}"] = o.handler("GetUser", user.NewGetUser(o.context, o.UserGetUserHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/usergroups/{group_id}"] = o.handler("GetUserGroup", usergroup.NewGetUserGroup(o.context, o.UsergroupGetUserGroupHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/systeminfo/volumes"] = o.handler("GetVolumes", systeminfo.NewGetVolumes(o.context, o.SysteminfoGetVolumesHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/additions/vulnerabilities"] = o.handler("GetVulnerabilitiesAddition", artifact.NewGetVulnerabilitiesAddition(o.context, o.ArtifactGetVulnerabilitiesAdditionHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/jobservice/pools"] = o.handler("GetWorkerPools", jobservice.NewGetWorkerPools(o.context, o.JobserviceGetWorkerPoolsHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/jobservice/pools/{pool_id}/workers"] = o.handler("GetWorkers", jobservice.NewGetWorkers(o.context, o.JobserviceGetWorkersHandler)) + if o.handlers["HEAD"] == nil { + o.handlers["HEAD"] = make(map[string]http.Handler) + } + o.handlers["HEAD"]["/projects"] = o.handler("HeadProject", project.NewHeadProject(o.context, o.ProjectHeadProjectHandler)) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/ldap/users/import"] = o.handler("ImportLdapUser", ldap.NewImportLdapUser(o.context, o.LdapImportLdapUserHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/accessories"] = o.handler("ListAccessories", artifact.NewListAccessories(o.context, o.ArtifactListAccessoriesHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/repositories"] = o.handler("ListAllRepositories", repository.NewListAllRepositories(o.context, o.RepositoryListAllRepositoriesHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/projects/{project_name}/repositories/{repository_name}/artifacts"] = o.handler("ListArtifacts", artifact.NewListArtifacts(o.context, o.ArtifactListArtifactsHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/audit-logs"] = o.handler("ListAuditLogs", auditlog.NewListAuditLogs(o.context, o.AuditlogListAuditLogsHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/jobservice/queues"] = o.handler("ListJobQueues", jobservice.NewListJobQueues(o.context, o.JobserviceListJobQueuesHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/projects/{project_name_or_id}/members"] = o.handler("ListProjectMembers", member.NewListProjectMembers(o.context, o.MemberListProjectMembersHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/projects/{project_name_or_id}/metadatas"] = o.handler("ListProjectMetadatas", project_metadata.NewListProjectMetadatas(o.context, o.ProjectMetadataListProjectMetadatasHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/projects"] = o.handler("ListProjects", project.NewListProjects(o.context, o.ProjectListProjectsHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/quotas"] = o.handler("ListQuotas", quota.NewListQuotas(o.context, o.QuotaListQuotasHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/registries"] = o.handler("ListRegistries", registry.NewListRegistries(o.context, o.RegistryListRegistriesHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/replication/adapterinfos"] = o.handler("ListRegistryProviderInfos", registry.NewListRegistryProviderInfos(o.context, o.RegistryListRegistryProviderInfosHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/replication/adapters"] = o.handler("ListRegistryProviderTypes", registry.NewListRegistryProviderTypes(o.context, o.RegistryListRegistryProviderTypesHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/replication/executions"] = o.handler("ListReplicationExecutions", replication.NewListReplicationExecutions(o.context, o.ReplicationListReplicationExecutionsHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/replication/policies"] = o.handler("ListReplicationPolicies", replication.NewListReplicationPolicies(o.context, o.ReplicationListReplicationPoliciesHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/replication/executions/{id}/tasks"] = o.handler("ListReplicationTasks", replication.NewListReplicationTasks(o.context, o.ReplicationListReplicationTasksHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/projects/{project_name}/repositories"] = o.handler("ListRepositories", repository.NewListRepositories(o.context, o.RepositoryListRepositoriesHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/retentions/{id}/executions"] = o.handler("ListRetentionExecutions", retention.NewListRetentionExecutions(o.context, o.RetentionListRetentionExecutionsHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/retentions/{id}/executions/{eid}/tasks"] = o.handler("ListRetentionTasks", retention.NewListRetentionTasks(o.context, o.RetentionListRetentionTasksHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/projects/{project_name_or_id}/scanner/candidates"] = o.handler("ListScannerCandidatesOfProject", project.NewListScannerCandidatesOfProject(o.context, o.ProjectListScannerCandidatesOfProjectHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/scanners"] = o.handler("ListScanners", scanner.NewListScanners(o.context, o.ScannerListScannersHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/schedules"] = o.handler("ListSchedules", schedule.NewListSchedules(o.context, o.ScheduleListSchedulesHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/tags"] = o.handler("ListTags", artifact.NewListTags(o.context, o.ArtifactListTagsHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/usergroups"] = o.handler("ListUserGroups", usergroup.NewListUserGroups(o.context, o.UsergroupListUserGroupsHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/users"] = o.handler("ListUsers", user.NewListUsers(o.context, o.UserListUsersHandler)) + if o.handlers["PATCH"] == nil { + o.handlers["PATCH"] = make(map[string]http.Handler) + } + o.handlers["PATCH"]["/retentions/{id}/executions/{eid}"] = o.handler("OperateRetentionExecution", retention.NewOperateRetentionExecution(o.context, o.RetentionOperateRetentionExecutionHandler)) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/ldap/ping"] = o.handler("PingLdap", ldap.NewPingLdap(o.context, o.LdapPingLdapHandler)) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/system/oidc/ping"] = o.handler("PingOIDC", oidc.NewPingOIDC(o.context, o.OIDCPingOIDCHandler)) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/registries/ping"] = o.handler("PingRegistry", registry.NewPingRegistry(o.context, o.RegistryPingRegistryHandler)) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/scanners/ping"] = o.handler("PingScanner", scanner.NewPingScanner(o.context, o.ScannerPingScannerHandler)) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) + } + o.handlers["PUT"]["/system/CVEAllowlist"] = o.handler("PutSystemCVEAllowlist", system_cve_allowlist.NewPutSystemCVEAllowlist(o.context, o.SystemCVEAllowlistPutSystemCVEAllowlistHandler)) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/labels/{label_id}"] = o.handler("RemoveLabel", artifact.NewRemoveLabel(o.context, o.ArtifactRemoveLabelHandler)) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/scan"] = o.handler("ScanArtifact", scan.NewScanArtifact(o.context, o.ScanScanArtifactHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/search"] = o.handler("Search", search.NewSearch(o.context, o.SearchSearchHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/ldap/groups/search"] = o.handler("SearchLdapGroup", ldap.NewSearchLdapGroup(o.context, o.LdapSearchLdapGroupHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/ldap/users/search"] = o.handler("SearchLdapUser", ldap.NewSearchLdapUser(o.context, o.LdapSearchLdapUserHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/usergroups/search"] = o.handler("SearchUserGroups", usergroup.NewSearchUserGroups(o.context, o.UsergroupSearchUserGroupsHandler)) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/users/search"] = o.handler("SearchUsers", user.NewSearchUsers(o.context, o.UserSearchUsersHandler)) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) + } + o.handlers["PUT"]["/users/{user_id}/cli_secret"] = o.handler("SetCliSecret", user.NewSetCliSecret(o.context, o.UserSetCliSecretHandler)) + if o.handlers["PATCH"] == nil { + o.handlers["PATCH"] = make(map[string]http.Handler) + } + o.handlers["PATCH"]["/scanners/{registration_id}"] = o.handler("SetScannerAsDefault", scanner.NewSetScannerAsDefault(o.context, o.ScannerSetScannerAsDefaultHandler)) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) + } + o.handlers["PUT"]["/projects/{project_name_or_id}/scanner"] = o.handler("SetScannerOfProject", project.NewSetScannerOfProject(o.context, o.ProjectSetScannerOfProjectHandler)) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) + } + o.handlers["PUT"]["/users/{user_id}/sysadmin"] = o.handler("SetUserSysAdmin", user.NewSetUserSysAdmin(o.context, o.UserSetUserSysAdminHandler)) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/replication/executions"] = o.handler("StartReplication", replication.NewStartReplication(o.context, o.ReplicationStartReplicationHandler)) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) + } + o.handlers["PUT"]["/system/gc/{gc_id}"] = o.handler("StopGC", gc.NewStopGC(o.context, o.GCStopGCHandler)) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) + } + o.handlers["PUT"]["/system/purgeaudit/{purge_id}"] = o.handler("StopPurge", purge.NewStopPurge(o.context, o.PurgeStopPurgeHandler)) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) + } + o.handlers["PUT"]["/replication/executions/{id}"] = o.handler("StopReplication", replication.NewStopReplication(o.context, o.ReplicationStopReplicationHandler)) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) + } + o.handlers["PUT"]["/jobservice/jobs/{job_id}"] = o.handler("StopRunningJob", jobservice.NewStopRunningJob(o.context, o.JobserviceStopRunningJobHandler)) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/system/scanAll/stop"] = o.handler("StopScanAll", scan_all.NewStopScanAll(o.context, o.ScanAllStopScanAllHandler)) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/scan/stop"] = o.handler("StopScanArtifact", scan.NewStopScanArtifact(o.context, o.ScanStopScanArtifactHandler)) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/retentions/{id}/executions"] = o.handler("TriggerRetentionExecution", retention.NewTriggerRetentionExecution(o.context, o.RetentionTriggerRetentionExecutionHandler)) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) + } + o.handlers["PUT"]["/configurations"] = o.handler("UpdateConfigurations", configure.NewUpdateConfigurations(o.context, o.ConfigureUpdateConfigurationsHandler)) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) + } + o.handlers["PUT"]["/system/gc/schedule"] = o.handler("UpdateGCSchedule", gc.NewUpdateGCSchedule(o.context, o.GCUpdateGCScheduleHandler)) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) + } + o.handlers["PUT"]["/projects/{project_name_or_id}"] = o.handler("UpdateProject", project.NewUpdateProject(o.context, o.ProjectUpdateProjectHandler)) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) + } + o.handlers["PUT"]["/projects/{project_name_or_id}/members/{mid}"] = o.handler("UpdateProjectMember", member.NewUpdateProjectMember(o.context, o.MemberUpdateProjectMemberHandler)) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) + } + o.handlers["PUT"]["/projects/{project_name_or_id}/metadatas/{meta_name}"] = o.handler("UpdateProjectMetadata", project_metadata.NewUpdateProjectMetadata(o.context, o.ProjectMetadataUpdateProjectMetadataHandler)) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) + } + o.handlers["PUT"]["/system/purgeaudit/schedule"] = o.handler("UpdatePurgeSchedule", purge.NewUpdatePurgeSchedule(o.context, o.PurgeUpdatePurgeScheduleHandler)) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) + } + o.handlers["PUT"]["/quotas/{id}"] = o.handler("UpdateQuota", quota.NewUpdateQuota(o.context, o.QuotaUpdateQuotaHandler)) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) + } + o.handlers["PUT"]["/registries/{id}"] = o.handler("UpdateRegistry", registry.NewUpdateRegistry(o.context, o.RegistryUpdateRegistryHandler)) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) + } + o.handlers["PUT"]["/replication/policies/{id}"] = o.handler("UpdateReplicationPolicy", replication.NewUpdateReplicationPolicy(o.context, o.ReplicationUpdateReplicationPolicyHandler)) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) + } + o.handlers["PUT"]["/projects/{project_name}/repositories/{repository_name}"] = o.handler("UpdateRepository", repository.NewUpdateRepository(o.context, o.RepositoryUpdateRepositoryHandler)) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) + } + o.handlers["PUT"]["/retentions/{id}"] = o.handler("UpdateRetention", retention.NewUpdateRetention(o.context, o.RetentionUpdateRetentionHandler)) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) + } + o.handlers["PUT"]["/system/scanAll/schedule"] = o.handler("UpdateScanAllSchedule", scan_all.NewUpdateScanAllSchedule(o.context, o.ScanAllUpdateScanAllScheduleHandler)) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) + } + o.handlers["PUT"]["/scanners/{registration_id}"] = o.handler("UpdateScanner", scanner.NewUpdateScanner(o.context, o.ScannerUpdateScannerHandler)) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) + } + o.handlers["PUT"]["/usergroups/{group_id}"] = o.handler("UpdateUserGroup", usergroup.NewUpdateUserGroup(o.context, o.UsergroupUpdateUserGroupHandler)) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) + } + o.handlers["PUT"]["/users/{user_id}/password"] = o.handler("UpdateUserPassword", user.NewUpdateUserPassword(o.context, o.UserUpdateUserPasswordHandler)) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) + } + o.handlers["PUT"]["/users/{user_id}"] = o.handler("UpdateUserProfile", user.NewUpdateUserProfile(o.context, o.UserUpdateUserProfileHandler)) +} + +// Serve creates a http handler to serve the API over HTTP +// can be used directly in http.ListenAndServe(":8000", api.Serve(nil)) +func (o *HarborAPI) Serve(builder middleware.Builder) http.Handler { + o.Init() + + if o.Middleware != nil { + return o.Middleware(builder) + } + if o.useSwaggerUI { + return o.context.APIHandlerSwaggerUI(builder) + } + return o.context.APIHandler(builder) +} + +// Init allows you to just initialize the handler cache, you can then recompose the middleware as you see fit +func (o *HarborAPI) Init() { + if len(o.handlers) == 0 { + o.initHandlerCache() + } +} + +// RegisterConsumer allows you to add (or override) a consumer for a media type. +func (o *HarborAPI) RegisterConsumer(mediaType string, consumer runtime.Consumer) { + o.customConsumers[mediaType] = consumer +} + +// RegisterProducer allows you to add (or override) a producer for a media type. +func (o *HarborAPI) RegisterProducer(mediaType string, producer runtime.Producer) { + o.customProducers[mediaType] = producer +} + +// AddMiddlewareFor adds a http middleware to existing handler +func (o *HarborAPI) AddMiddlewareFor(method, path string, builder middleware.Builder) { + um := strings.ToUpper(method) + if path == "/" { + path = "" + } + o.Init() + if h, ok := o.handlers[um][path]; ok { + o.handlers[method][path] = builder(h) + } +} + +// RegisterMiddleware allows you to add (or override) a middleware for operation. +func (o *HarborAPI) RegisterMiddleware(operation string, builder middleware.Builder) { + o.operationMiddlewares[operation] = builder +} diff --git a/src/server/v2.0/restapi/operations/health/get_health.go b/src/server/v2.0/restapi/operations/health/get_health.go new file mode 100644 index 000000000..078f5ec2f --- /dev/null +++ b/src/server/v2.0/restapi/operations/health/get_health.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package health + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetHealthHandlerFunc turns a function with the right signature into a get health handler +type GetHealthHandlerFunc func(GetHealthParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetHealthHandlerFunc) Handle(params GetHealthParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetHealthHandler interface for that can handle valid get health params +type GetHealthHandler interface { + Handle(GetHealthParams, interface{}) middleware.Responder +} + +// NewGetHealth creates a new http.Handler for the get health operation +func NewGetHealth(ctx *middleware.Context, handler GetHealthHandler) *GetHealth { + return &GetHealth{Context: ctx, Handler: handler} +} + +/*GetHealth swagger:route GET /health health getHealth + +Check the status of Harbor components + +Check the status of Harbor components + +*/ +type GetHealth struct { + Context *middleware.Context + Handler GetHealthHandler +} + +func (o *GetHealth) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetHealthParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/health/get_health_parameters.go b/src/server/v2.0/restapi/operations/health/get_health_parameters.go new file mode 100644 index 000000000..b1798d2ef --- /dev/null +++ b/src/server/v2.0/restapi/operations/health/get_health_parameters.go @@ -0,0 +1,89 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package health + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewGetHealthParams creates a new GetHealthParams object +// no default values defined in spec. +func NewGetHealthParams() GetHealthParams { + + return GetHealthParams{} +} + +// GetHealthParams contains all the bound params for the get health operation +// typically these are obtained from a http.Request +// +// swagger:parameters getHealth +type GetHealthParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetHealthParams() beforehand. +func (o *GetHealthParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetHealthParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetHealthParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} diff --git a/src/server/v2.0/restapi/operations/health/get_health_responses.go b/src/server/v2.0/restapi/operations/health/get_health_responses.go new file mode 100644 index 000000000..93605f565 --- /dev/null +++ b/src/server/v2.0/restapi/operations/health/get_health_responses.go @@ -0,0 +1,124 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package health + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetHealthOKCode is the HTTP code returned for type GetHealthOK +const GetHealthOKCode int = 200 + +/*GetHealthOK The health status of Harbor components + +swagger:response getHealthOK +*/ +type GetHealthOK struct { + + /* + In: Body + */ + Payload *models.OverallHealthStatus `json:"body,omitempty"` +} + +// NewGetHealthOK creates GetHealthOK with default headers values +func NewGetHealthOK() *GetHealthOK { + + return &GetHealthOK{} +} + +// WithPayload adds the payload to the get health o k response +func (o *GetHealthOK) WithPayload(payload *models.OverallHealthStatus) *GetHealthOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get health o k response +func (o *GetHealthOK) SetPayload(payload *models.OverallHealthStatus) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHealthOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetHealthInternalServerErrorCode is the HTTP code returned for type GetHealthInternalServerError +const GetHealthInternalServerErrorCode int = 500 + +/*GetHealthInternalServerError Internal server error + +swagger:response getHealthInternalServerError +*/ +type GetHealthInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetHealthInternalServerError creates GetHealthInternalServerError with default headers values +func NewGetHealthInternalServerError() *GetHealthInternalServerError { + + return &GetHealthInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get health internal server error response +func (o *GetHealthInternalServerError) WithXRequestID(xRequestID string) *GetHealthInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get health internal server error response +func (o *GetHealthInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get health internal server error response +func (o *GetHealthInternalServerError) WithPayload(payload *models.Errors) *GetHealthInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get health internal server error response +func (o *GetHealthInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHealthInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/health/get_health_urlbuilder.go b/src/server/v2.0/restapi/operations/health/get_health_urlbuilder.go new file mode 100644 index 000000000..1cacf4651 --- /dev/null +++ b/src/server/v2.0/restapi/operations/health/get_health_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package health + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetHealthURL generates an URL for the get health operation +type GetHealthURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetHealthURL) WithBasePath(bp string) *GetHealthURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetHealthURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetHealthURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/health" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetHealthURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetHealthURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetHealthURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetHealthURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetHealthURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetHealthURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/icon/get_icon.go b/src/server/v2.0/restapi/operations/icon/get_icon.go new file mode 100644 index 000000000..319067fc4 --- /dev/null +++ b/src/server/v2.0/restapi/operations/icon/get_icon.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package icon + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetIconHandlerFunc turns a function with the right signature into a get icon handler +type GetIconHandlerFunc func(GetIconParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetIconHandlerFunc) Handle(params GetIconParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetIconHandler interface for that can handle valid get icon params +type GetIconHandler interface { + Handle(GetIconParams, interface{}) middleware.Responder +} + +// NewGetIcon creates a new http.Handler for the get icon operation +func NewGetIcon(ctx *middleware.Context, handler GetIconHandler) *GetIcon { + return &GetIcon{Context: ctx, Handler: handler} +} + +/*GetIcon swagger:route GET /icons/{digest} icon getIcon + +Get artifact icon + +Get the artifact icon with the specified digest. As the original icon image is resized and encoded before returning, the parameter "digest" in the path doesn't match the hash of the returned content + +*/ +type GetIcon struct { + Context *middleware.Context + Handler GetIconHandler +} + +func (o *GetIcon) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetIconParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/icon/get_icon_parameters.go b/src/server/v2.0/restapi/operations/icon/get_icon_parameters.go new file mode 100644 index 000000000..db2a0eb1c --- /dev/null +++ b/src/server/v2.0/restapi/operations/icon/get_icon_parameters.go @@ -0,0 +1,114 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package icon + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewGetIconParams creates a new GetIconParams object +// no default values defined in spec. +func NewGetIconParams() GetIconParams { + + return GetIconParams{} +} + +// GetIconParams contains all the bound params for the get icon operation +// typically these are obtained from a http.Request +// +// swagger:parameters getIcon +type GetIconParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The digest of the resource + Required: true + In: path + */ + Digest string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetIconParams() beforehand. +func (o *GetIconParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rDigest, rhkDigest, _ := route.Params.GetOK("digest") + if err := o.bindDigest(rDigest, rhkDigest, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetIconParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetIconParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindDigest binds and validates parameter Digest from path. +func (o *GetIconParams) bindDigest(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.Digest = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/icon/get_icon_responses.go b/src/server/v2.0/restapi/operations/icon/get_icon_responses.go new file mode 100644 index 000000000..1a5aee995 --- /dev/null +++ b/src/server/v2.0/restapi/operations/icon/get_icon_responses.go @@ -0,0 +1,256 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package icon + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetIconOKCode is the HTTP code returned for type GetIconOK +const GetIconOKCode int = 200 + +/*GetIconOK Success + +swagger:response getIconOK +*/ +type GetIconOK struct { + + /* + In: Body + */ + Payload *models.Icon `json:"body,omitempty"` +} + +// NewGetIconOK creates GetIconOK with default headers values +func NewGetIconOK() *GetIconOK { + + return &GetIconOK{} +} + +// WithPayload adds the payload to the get icon o k response +func (o *GetIconOK) WithPayload(payload *models.Icon) *GetIconOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get icon o k response +func (o *GetIconOK) SetPayload(payload *models.Icon) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetIconOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetIconBadRequestCode is the HTTP code returned for type GetIconBadRequest +const GetIconBadRequestCode int = 400 + +/*GetIconBadRequest Bad request + +swagger:response getIconBadRequest +*/ +type GetIconBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetIconBadRequest creates GetIconBadRequest with default headers values +func NewGetIconBadRequest() *GetIconBadRequest { + + return &GetIconBadRequest{} +} + +// WithXRequestID adds the xRequestId to the get icon bad request response +func (o *GetIconBadRequest) WithXRequestID(xRequestID string) *GetIconBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get icon bad request response +func (o *GetIconBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get icon bad request response +func (o *GetIconBadRequest) WithPayload(payload *models.Errors) *GetIconBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get icon bad request response +func (o *GetIconBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetIconBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetIconNotFoundCode is the HTTP code returned for type GetIconNotFound +const GetIconNotFoundCode int = 404 + +/*GetIconNotFound Not found + +swagger:response getIconNotFound +*/ +type GetIconNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetIconNotFound creates GetIconNotFound with default headers values +func NewGetIconNotFound() *GetIconNotFound { + + return &GetIconNotFound{} +} + +// WithXRequestID adds the xRequestId to the get icon not found response +func (o *GetIconNotFound) WithXRequestID(xRequestID string) *GetIconNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get icon not found response +func (o *GetIconNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get icon not found response +func (o *GetIconNotFound) WithPayload(payload *models.Errors) *GetIconNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get icon not found response +func (o *GetIconNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetIconNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetIconInternalServerErrorCode is the HTTP code returned for type GetIconInternalServerError +const GetIconInternalServerErrorCode int = 500 + +/*GetIconInternalServerError Internal server error + +swagger:response getIconInternalServerError +*/ +type GetIconInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetIconInternalServerError creates GetIconInternalServerError with default headers values +func NewGetIconInternalServerError() *GetIconInternalServerError { + + return &GetIconInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get icon internal server error response +func (o *GetIconInternalServerError) WithXRequestID(xRequestID string) *GetIconInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get icon internal server error response +func (o *GetIconInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get icon internal server error response +func (o *GetIconInternalServerError) WithPayload(payload *models.Errors) *GetIconInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get icon internal server error response +func (o *GetIconInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetIconInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/icon/get_icon_urlbuilder.go b/src/server/v2.0/restapi/operations/icon/get_icon_urlbuilder.go new file mode 100644 index 000000000..68600d3c6 --- /dev/null +++ b/src/server/v2.0/restapi/operations/icon/get_icon_urlbuilder.go @@ -0,0 +1,99 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package icon + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetIconURL generates an URL for the get icon operation +type GetIconURL struct { + Digest string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetIconURL) WithBasePath(bp string) *GetIconURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetIconURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetIconURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/icons/{digest}" + + digest := o.Digest + if digest != "" { + _path = strings.Replace(_path, "{digest}", digest, -1) + } else { + return nil, errors.New("digest is required on GetIconURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetIconURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetIconURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetIconURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetIconURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetIconURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetIconURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/immutable/create_immu_rule.go b/src/server/v2.0/restapi/operations/immutable/create_immu_rule.go new file mode 100644 index 000000000..b2c981ed3 --- /dev/null +++ b/src/server/v2.0/restapi/operations/immutable/create_immu_rule.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package immutable + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateImmuRuleHandlerFunc turns a function with the right signature into a create immu rule handler +type CreateImmuRuleHandlerFunc func(CreateImmuRuleParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateImmuRuleHandlerFunc) Handle(params CreateImmuRuleParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateImmuRuleHandler interface for that can handle valid create immu rule params +type CreateImmuRuleHandler interface { + Handle(CreateImmuRuleParams, interface{}) middleware.Responder +} + +// NewCreateImmuRule creates a new http.Handler for the create immu rule operation +func NewCreateImmuRule(ctx *middleware.Context, handler CreateImmuRuleHandler) *CreateImmuRule { + return &CreateImmuRule{Context: ctx, Handler: handler} +} + +/*CreateImmuRule swagger:route POST /projects/{project_name_or_id}/immutabletagrules immutable createImmuRule + +Add an immutable tag rule to current project + +This endpoint add an immutable tag rule to the project + + +*/ +type CreateImmuRule struct { + Context *middleware.Context + Handler CreateImmuRuleHandler +} + +func (o *CreateImmuRule) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewCreateImmuRuleParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/immutable/create_immu_rule_parameters.go b/src/server/v2.0/restapi/operations/immutable/create_immu_rule_parameters.go new file mode 100644 index 000000000..990dc9d97 --- /dev/null +++ b/src/server/v2.0/restapi/operations/immutable/create_immu_rule_parameters.go @@ -0,0 +1,186 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package immutable + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewCreateImmuRuleParams creates a new CreateImmuRuleParams object +// with the default values initialized. +func NewCreateImmuRuleParams() CreateImmuRuleParams { + + var ( + // initialize parameters with default values + + xIsResourceNameDefault = bool(false) + ) + + return CreateImmuRuleParams{ + XIsResourceName: &xIsResourceNameDefault, + } +} + +// CreateImmuRuleParams contains all the bound params for the create immu rule operation +// typically these are obtained from a http.Request +// +// swagger:parameters CreateImmuRule +type CreateImmuRuleParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + ImmutableRule *models.ImmutableRule + /*The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name. + In: header + Default: false + */ + XIsResourceName *bool + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The name or id of the project + Required: true + In: path + */ + ProjectNameOrID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateImmuRuleParams() beforehand. +func (o *CreateImmuRuleParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.ImmutableRule + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("immutableRule", "body", "")) + } else { + res = append(res, errors.NewParseError("immutableRule", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.ImmutableRule = &body + } + } + } else { + res = append(res, errors.Required("immutableRule", "body", "")) + } + if err := o.bindXIsResourceName(r.Header[http.CanonicalHeaderKey("X-Is-Resource-Name")], true, route.Formats); err != nil { + res = append(res, err) + } + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rProjectNameOrID, rhkProjectNameOrID, _ := route.Params.GetOK("project_name_or_id") + if err := o.bindProjectNameOrID(rProjectNameOrID, rhkProjectNameOrID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXIsResourceName binds and validates parameter XIsResourceName from header. +func (o *CreateImmuRuleParams) bindXIsResourceName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateImmuRuleParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("X-Is-Resource-Name", "header", "bool", raw) + } + o.XIsResourceName = &value + + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *CreateImmuRuleParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *CreateImmuRuleParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindProjectNameOrID binds and validates parameter ProjectNameOrID from path. +func (o *CreateImmuRuleParams) bindProjectNameOrID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectNameOrID = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/immutable/create_immu_rule_responses.go b/src/server/v2.0/restapi/operations/immutable/create_immu_rule_responses.go new file mode 100644 index 000000000..f33bae499 --- /dev/null +++ b/src/server/v2.0/restapi/operations/immutable/create_immu_rule_responses.go @@ -0,0 +1,412 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package immutable + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// CreateImmuRuleCreatedCode is the HTTP code returned for type CreateImmuRuleCreated +const CreateImmuRuleCreatedCode int = 201 + +/*CreateImmuRuleCreated Created + +swagger:response createImmuRuleCreated +*/ +type CreateImmuRuleCreated struct { + /*The location of the resource + + */ + Location string `json:"Location"` + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewCreateImmuRuleCreated creates CreateImmuRuleCreated with default headers values +func NewCreateImmuRuleCreated() *CreateImmuRuleCreated { + + return &CreateImmuRuleCreated{} +} + +// WithLocation adds the location to the create immu rule created response +func (o *CreateImmuRuleCreated) WithLocation(location string) *CreateImmuRuleCreated { + o.Location = location + return o +} + +// SetLocation sets the location to the create immu rule created response +func (o *CreateImmuRuleCreated) SetLocation(location string) { + o.Location = location +} + +// WithXRequestID adds the xRequestId to the create immu rule created response +func (o *CreateImmuRuleCreated) WithXRequestID(xRequestID string) *CreateImmuRuleCreated { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create immu rule created response +func (o *CreateImmuRuleCreated) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *CreateImmuRuleCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Location + + location := o.Location + if location != "" { + rw.Header().Set("Location", location) + } + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(201) +} + +// CreateImmuRuleBadRequestCode is the HTTP code returned for type CreateImmuRuleBadRequest +const CreateImmuRuleBadRequestCode int = 400 + +/*CreateImmuRuleBadRequest Bad request + +swagger:response createImmuRuleBadRequest +*/ +type CreateImmuRuleBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateImmuRuleBadRequest creates CreateImmuRuleBadRequest with default headers values +func NewCreateImmuRuleBadRequest() *CreateImmuRuleBadRequest { + + return &CreateImmuRuleBadRequest{} +} + +// WithXRequestID adds the xRequestId to the create immu rule bad request response +func (o *CreateImmuRuleBadRequest) WithXRequestID(xRequestID string) *CreateImmuRuleBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create immu rule bad request response +func (o *CreateImmuRuleBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create immu rule bad request response +func (o *CreateImmuRuleBadRequest) WithPayload(payload *models.Errors) *CreateImmuRuleBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create immu rule bad request response +func (o *CreateImmuRuleBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateImmuRuleBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateImmuRuleUnauthorizedCode is the HTTP code returned for type CreateImmuRuleUnauthorized +const CreateImmuRuleUnauthorizedCode int = 401 + +/*CreateImmuRuleUnauthorized Unauthorized + +swagger:response createImmuRuleUnauthorized +*/ +type CreateImmuRuleUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateImmuRuleUnauthorized creates CreateImmuRuleUnauthorized with default headers values +func NewCreateImmuRuleUnauthorized() *CreateImmuRuleUnauthorized { + + return &CreateImmuRuleUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the create immu rule unauthorized response +func (o *CreateImmuRuleUnauthorized) WithXRequestID(xRequestID string) *CreateImmuRuleUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create immu rule unauthorized response +func (o *CreateImmuRuleUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create immu rule unauthorized response +func (o *CreateImmuRuleUnauthorized) WithPayload(payload *models.Errors) *CreateImmuRuleUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create immu rule unauthorized response +func (o *CreateImmuRuleUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateImmuRuleUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateImmuRuleForbiddenCode is the HTTP code returned for type CreateImmuRuleForbidden +const CreateImmuRuleForbiddenCode int = 403 + +/*CreateImmuRuleForbidden Forbidden + +swagger:response createImmuRuleForbidden +*/ +type CreateImmuRuleForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateImmuRuleForbidden creates CreateImmuRuleForbidden with default headers values +func NewCreateImmuRuleForbidden() *CreateImmuRuleForbidden { + + return &CreateImmuRuleForbidden{} +} + +// WithXRequestID adds the xRequestId to the create immu rule forbidden response +func (o *CreateImmuRuleForbidden) WithXRequestID(xRequestID string) *CreateImmuRuleForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create immu rule forbidden response +func (o *CreateImmuRuleForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create immu rule forbidden response +func (o *CreateImmuRuleForbidden) WithPayload(payload *models.Errors) *CreateImmuRuleForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create immu rule forbidden response +func (o *CreateImmuRuleForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateImmuRuleForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateImmuRuleNotFoundCode is the HTTP code returned for type CreateImmuRuleNotFound +const CreateImmuRuleNotFoundCode int = 404 + +/*CreateImmuRuleNotFound Not found + +swagger:response createImmuRuleNotFound +*/ +type CreateImmuRuleNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateImmuRuleNotFound creates CreateImmuRuleNotFound with default headers values +func NewCreateImmuRuleNotFound() *CreateImmuRuleNotFound { + + return &CreateImmuRuleNotFound{} +} + +// WithXRequestID adds the xRequestId to the create immu rule not found response +func (o *CreateImmuRuleNotFound) WithXRequestID(xRequestID string) *CreateImmuRuleNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create immu rule not found response +func (o *CreateImmuRuleNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create immu rule not found response +func (o *CreateImmuRuleNotFound) WithPayload(payload *models.Errors) *CreateImmuRuleNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create immu rule not found response +func (o *CreateImmuRuleNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateImmuRuleNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateImmuRuleInternalServerErrorCode is the HTTP code returned for type CreateImmuRuleInternalServerError +const CreateImmuRuleInternalServerErrorCode int = 500 + +/*CreateImmuRuleInternalServerError Internal server error + +swagger:response createImmuRuleInternalServerError +*/ +type CreateImmuRuleInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateImmuRuleInternalServerError creates CreateImmuRuleInternalServerError with default headers values +func NewCreateImmuRuleInternalServerError() *CreateImmuRuleInternalServerError { + + return &CreateImmuRuleInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the create immu rule internal server error response +func (o *CreateImmuRuleInternalServerError) WithXRequestID(xRequestID string) *CreateImmuRuleInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create immu rule internal server error response +func (o *CreateImmuRuleInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create immu rule internal server error response +func (o *CreateImmuRuleInternalServerError) WithPayload(payload *models.Errors) *CreateImmuRuleInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create immu rule internal server error response +func (o *CreateImmuRuleInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateImmuRuleInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/immutable/create_immu_rule_urlbuilder.go b/src/server/v2.0/restapi/operations/immutable/create_immu_rule_urlbuilder.go new file mode 100644 index 000000000..0ac238512 --- /dev/null +++ b/src/server/v2.0/restapi/operations/immutable/create_immu_rule_urlbuilder.go @@ -0,0 +1,99 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package immutable + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// CreateImmuRuleURL generates an URL for the create immu rule operation +type CreateImmuRuleURL struct { + ProjectNameOrID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateImmuRuleURL) WithBasePath(bp string) *CreateImmuRuleURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateImmuRuleURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateImmuRuleURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name_or_id}/immutabletagrules" + + projectNameOrID := o.ProjectNameOrID + if projectNameOrID != "" { + _path = strings.Replace(_path, "{project_name_or_id}", projectNameOrID, -1) + } else { + return nil, errors.New("projectNameOrId is required on CreateImmuRuleURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateImmuRuleURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateImmuRuleURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateImmuRuleURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateImmuRuleURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateImmuRuleURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateImmuRuleURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/immutable/delete_immu_rule.go b/src/server/v2.0/restapi/operations/immutable/delete_immu_rule.go new file mode 100644 index 000000000..352af8039 --- /dev/null +++ b/src/server/v2.0/restapi/operations/immutable/delete_immu_rule.go @@ -0,0 +1,71 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package immutable + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteImmuRuleHandlerFunc turns a function with the right signature into a delete immu rule handler +type DeleteImmuRuleHandlerFunc func(DeleteImmuRuleParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteImmuRuleHandlerFunc) Handle(params DeleteImmuRuleParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteImmuRuleHandler interface for that can handle valid delete immu rule params +type DeleteImmuRuleHandler interface { + Handle(DeleteImmuRuleParams, interface{}) middleware.Responder +} + +// NewDeleteImmuRule creates a new http.Handler for the delete immu rule operation +func NewDeleteImmuRule(ctx *middleware.Context, handler DeleteImmuRuleHandler) *DeleteImmuRule { + return &DeleteImmuRule{Context: ctx, Handler: handler} +} + +/*DeleteImmuRule swagger:route DELETE /projects/{project_name_or_id}/immutabletagrules/{immutable_rule_id} immutable deleteImmuRule + +Delete the immutable tag rule. + +*/ +type DeleteImmuRule struct { + Context *middleware.Context + Handler DeleteImmuRuleHandler +} + +func (o *DeleteImmuRule) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewDeleteImmuRuleParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/immutable/delete_immu_rule_parameters.go b/src/server/v2.0/restapi/operations/immutable/delete_immu_rule_parameters.go new file mode 100644 index 000000000..192a0a0fa --- /dev/null +++ b/src/server/v2.0/restapi/operations/immutable/delete_immu_rule_parameters.go @@ -0,0 +1,184 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package immutable + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewDeleteImmuRuleParams creates a new DeleteImmuRuleParams object +// with the default values initialized. +func NewDeleteImmuRuleParams() DeleteImmuRuleParams { + + var ( + // initialize parameters with default values + + xIsResourceNameDefault = bool(false) + ) + + return DeleteImmuRuleParams{ + XIsResourceName: &xIsResourceNameDefault, + } +} + +// DeleteImmuRuleParams contains all the bound params for the delete immu rule operation +// typically these are obtained from a http.Request +// +// swagger:parameters DeleteImmuRule +type DeleteImmuRuleParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name. + In: header + Default: false + */ + XIsResourceName *bool + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The ID of the immutable rule + Required: true + In: path + */ + ImmutableRuleID int64 + /*The name or id of the project + Required: true + In: path + */ + ProjectNameOrID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteImmuRuleParams() beforehand. +func (o *DeleteImmuRuleParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXIsResourceName(r.Header[http.CanonicalHeaderKey("X-Is-Resource-Name")], true, route.Formats); err != nil { + res = append(res, err) + } + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rImmutableRuleID, rhkImmutableRuleID, _ := route.Params.GetOK("immutable_rule_id") + if err := o.bindImmutableRuleID(rImmutableRuleID, rhkImmutableRuleID, route.Formats); err != nil { + res = append(res, err) + } + + rProjectNameOrID, rhkProjectNameOrID, _ := route.Params.GetOK("project_name_or_id") + if err := o.bindProjectNameOrID(rProjectNameOrID, rhkProjectNameOrID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXIsResourceName binds and validates parameter XIsResourceName from header. +func (o *DeleteImmuRuleParams) bindXIsResourceName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteImmuRuleParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("X-Is-Resource-Name", "header", "bool", raw) + } + o.XIsResourceName = &value + + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *DeleteImmuRuleParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *DeleteImmuRuleParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindImmutableRuleID binds and validates parameter ImmutableRuleID from path. +func (o *DeleteImmuRuleParams) bindImmutableRuleID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("immutable_rule_id", "path", "int64", raw) + } + o.ImmutableRuleID = value + + return nil +} + +// bindProjectNameOrID binds and validates parameter ProjectNameOrID from path. +func (o *DeleteImmuRuleParams) bindProjectNameOrID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectNameOrID = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/immutable/delete_immu_rule_responses.go b/src/server/v2.0/restapi/operations/immutable/delete_immu_rule_responses.go new file mode 100644 index 000000000..33b4e8fc8 --- /dev/null +++ b/src/server/v2.0/restapi/operations/immutable/delete_immu_rule_responses.go @@ -0,0 +1,324 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package immutable + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// DeleteImmuRuleOKCode is the HTTP code returned for type DeleteImmuRuleOK +const DeleteImmuRuleOKCode int = 200 + +/*DeleteImmuRuleOK Success + +swagger:response deleteImmuRuleOK +*/ +type DeleteImmuRuleOK struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewDeleteImmuRuleOK creates DeleteImmuRuleOK with default headers values +func NewDeleteImmuRuleOK() *DeleteImmuRuleOK { + + return &DeleteImmuRuleOK{} +} + +// WithXRequestID adds the xRequestId to the delete immu rule o k response +func (o *DeleteImmuRuleOK) WithXRequestID(xRequestID string) *DeleteImmuRuleOK { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete immu rule o k response +func (o *DeleteImmuRuleOK) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *DeleteImmuRuleOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// DeleteImmuRuleBadRequestCode is the HTTP code returned for type DeleteImmuRuleBadRequest +const DeleteImmuRuleBadRequestCode int = 400 + +/*DeleteImmuRuleBadRequest Bad request + +swagger:response deleteImmuRuleBadRequest +*/ +type DeleteImmuRuleBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteImmuRuleBadRequest creates DeleteImmuRuleBadRequest with default headers values +func NewDeleteImmuRuleBadRequest() *DeleteImmuRuleBadRequest { + + return &DeleteImmuRuleBadRequest{} +} + +// WithXRequestID adds the xRequestId to the delete immu rule bad request response +func (o *DeleteImmuRuleBadRequest) WithXRequestID(xRequestID string) *DeleteImmuRuleBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete immu rule bad request response +func (o *DeleteImmuRuleBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete immu rule bad request response +func (o *DeleteImmuRuleBadRequest) WithPayload(payload *models.Errors) *DeleteImmuRuleBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete immu rule bad request response +func (o *DeleteImmuRuleBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteImmuRuleBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteImmuRuleUnauthorizedCode is the HTTP code returned for type DeleteImmuRuleUnauthorized +const DeleteImmuRuleUnauthorizedCode int = 401 + +/*DeleteImmuRuleUnauthorized Unauthorized + +swagger:response deleteImmuRuleUnauthorized +*/ +type DeleteImmuRuleUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteImmuRuleUnauthorized creates DeleteImmuRuleUnauthorized with default headers values +func NewDeleteImmuRuleUnauthorized() *DeleteImmuRuleUnauthorized { + + return &DeleteImmuRuleUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the delete immu rule unauthorized response +func (o *DeleteImmuRuleUnauthorized) WithXRequestID(xRequestID string) *DeleteImmuRuleUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete immu rule unauthorized response +func (o *DeleteImmuRuleUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete immu rule unauthorized response +func (o *DeleteImmuRuleUnauthorized) WithPayload(payload *models.Errors) *DeleteImmuRuleUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete immu rule unauthorized response +func (o *DeleteImmuRuleUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteImmuRuleUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteImmuRuleForbiddenCode is the HTTP code returned for type DeleteImmuRuleForbidden +const DeleteImmuRuleForbiddenCode int = 403 + +/*DeleteImmuRuleForbidden Forbidden + +swagger:response deleteImmuRuleForbidden +*/ +type DeleteImmuRuleForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteImmuRuleForbidden creates DeleteImmuRuleForbidden with default headers values +func NewDeleteImmuRuleForbidden() *DeleteImmuRuleForbidden { + + return &DeleteImmuRuleForbidden{} +} + +// WithXRequestID adds the xRequestId to the delete immu rule forbidden response +func (o *DeleteImmuRuleForbidden) WithXRequestID(xRequestID string) *DeleteImmuRuleForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete immu rule forbidden response +func (o *DeleteImmuRuleForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete immu rule forbidden response +func (o *DeleteImmuRuleForbidden) WithPayload(payload *models.Errors) *DeleteImmuRuleForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete immu rule forbidden response +func (o *DeleteImmuRuleForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteImmuRuleForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteImmuRuleInternalServerErrorCode is the HTTP code returned for type DeleteImmuRuleInternalServerError +const DeleteImmuRuleInternalServerErrorCode int = 500 + +/*DeleteImmuRuleInternalServerError Internal server error + +swagger:response deleteImmuRuleInternalServerError +*/ +type DeleteImmuRuleInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteImmuRuleInternalServerError creates DeleteImmuRuleInternalServerError with default headers values +func NewDeleteImmuRuleInternalServerError() *DeleteImmuRuleInternalServerError { + + return &DeleteImmuRuleInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the delete immu rule internal server error response +func (o *DeleteImmuRuleInternalServerError) WithXRequestID(xRequestID string) *DeleteImmuRuleInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete immu rule internal server error response +func (o *DeleteImmuRuleInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete immu rule internal server error response +func (o *DeleteImmuRuleInternalServerError) WithPayload(payload *models.Errors) *DeleteImmuRuleInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete immu rule internal server error response +func (o *DeleteImmuRuleInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteImmuRuleInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/immutable/delete_immu_rule_urlbuilder.go b/src/server/v2.0/restapi/operations/immutable/delete_immu_rule_urlbuilder.go new file mode 100644 index 000000000..e5e5f94d5 --- /dev/null +++ b/src/server/v2.0/restapi/operations/immutable/delete_immu_rule_urlbuilder.go @@ -0,0 +1,109 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package immutable + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteImmuRuleURL generates an URL for the delete immu rule operation +type DeleteImmuRuleURL struct { + ImmutableRuleID int64 + ProjectNameOrID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteImmuRuleURL) WithBasePath(bp string) *DeleteImmuRuleURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteImmuRuleURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteImmuRuleURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name_or_id}/immutabletagrules/{immutable_rule_id}" + + immutableRuleID := swag.FormatInt64(o.ImmutableRuleID) + if immutableRuleID != "" { + _path = strings.Replace(_path, "{immutable_rule_id}", immutableRuleID, -1) + } else { + return nil, errors.New("immutableRuleId is required on DeleteImmuRuleURL") + } + + projectNameOrID := o.ProjectNameOrID + if projectNameOrID != "" { + _path = strings.Replace(_path, "{project_name_or_id}", projectNameOrID, -1) + } else { + return nil, errors.New("projectNameOrId is required on DeleteImmuRuleURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteImmuRuleURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteImmuRuleURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteImmuRuleURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteImmuRuleURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteImmuRuleURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteImmuRuleURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/immutable/list_immu_rules.go b/src/server/v2.0/restapi/operations/immutable/list_immu_rules.go new file mode 100644 index 000000000..c8b908a55 --- /dev/null +++ b/src/server/v2.0/restapi/operations/immutable/list_immu_rules.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package immutable + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ListImmuRulesHandlerFunc turns a function with the right signature into a list immu rules handler +type ListImmuRulesHandlerFunc func(ListImmuRulesParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ListImmuRulesHandlerFunc) Handle(params ListImmuRulesParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ListImmuRulesHandler interface for that can handle valid list immu rules params +type ListImmuRulesHandler interface { + Handle(ListImmuRulesParams, interface{}) middleware.Responder +} + +// NewListImmuRules creates a new http.Handler for the list immu rules operation +func NewListImmuRules(ctx *middleware.Context, handler ListImmuRulesHandler) *ListImmuRules { + return &ListImmuRules{Context: ctx, Handler: handler} +} + +/*ListImmuRules swagger:route GET /projects/{project_name_or_id}/immutabletagrules immutable listImmuRules + +List all immutable tag rules of current project + +This endpoint returns the immutable tag rules of a project + + +*/ +type ListImmuRules struct { + Context *middleware.Context + Handler ListImmuRulesHandler +} + +func (o *ListImmuRules) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewListImmuRulesParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/immutable/list_immu_rules_parameters.go b/src/server/v2.0/restapi/operations/immutable/list_immu_rules_parameters.go new file mode 100644 index 000000000..99499945d --- /dev/null +++ b/src/server/v2.0/restapi/operations/immutable/list_immu_rules_parameters.go @@ -0,0 +1,300 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package immutable + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewListImmuRulesParams creates a new ListImmuRulesParams object +// with the default values initialized. +func NewListImmuRulesParams() ListImmuRulesParams { + + var ( + // initialize parameters with default values + + xIsResourceNameDefault = bool(false) + + pageDefault = int64(1) + pageSizeDefault = int64(10) + ) + + return ListImmuRulesParams{ + XIsResourceName: &xIsResourceNameDefault, + + Page: &pageDefault, + + PageSize: &pageSizeDefault, + } +} + +// ListImmuRulesParams contains all the bound params for the list immu rules operation +// typically these are obtained from a http.Request +// +// swagger:parameters ListImmuRules +type ListImmuRulesParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name. + In: header + Default: false + */ + XIsResourceName *bool + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The page number + In: query + Default: 1 + */ + Page *int64 + /*The size of per page + Maximum: 100 + In: query + Default: 10 + */ + PageSize *int64 + /*The name or id of the project + Required: true + In: path + */ + ProjectNameOrID string + /*Query string to query resources. Supported query patterns are "exact match(k=v)", "fuzzy match(k=~v)", "range(k=[min~max])", "list with union releationship(k={v1 v2 v3})" and "list with intersetion relationship(k=(v1 v2 v3))". The value of range and list can be string(enclosed by " or '), integer or time(in format "2020-04-09 02:36:00"). All of these query patterns should be put in the query string "q=xxx" and splitted by ",". e.g. q=k1=v1,k2=~v2,k3=[min~max] + In: query + */ + Q *string + /*Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + In: query + */ + Sort *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewListImmuRulesParams() beforehand. +func (o *ListImmuRulesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if err := o.bindXIsResourceName(r.Header[http.CanonicalHeaderKey("X-Is-Resource-Name")], true, route.Formats); err != nil { + res = append(res, err) + } + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + qPage, qhkPage, _ := qs.GetOK("page") + if err := o.bindPage(qPage, qhkPage, route.Formats); err != nil { + res = append(res, err) + } + + qPageSize, qhkPageSize, _ := qs.GetOK("page_size") + if err := o.bindPageSize(qPageSize, qhkPageSize, route.Formats); err != nil { + res = append(res, err) + } + + rProjectNameOrID, rhkProjectNameOrID, _ := route.Params.GetOK("project_name_or_id") + if err := o.bindProjectNameOrID(rProjectNameOrID, rhkProjectNameOrID, route.Formats); err != nil { + res = append(res, err) + } + + qQ, qhkQ, _ := qs.GetOK("q") + if err := o.bindQ(qQ, qhkQ, route.Formats); err != nil { + res = append(res, err) + } + + qSort, qhkSort, _ := qs.GetOK("sort") + if err := o.bindSort(qSort, qhkSort, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXIsResourceName binds and validates parameter XIsResourceName from header. +func (o *ListImmuRulesParams) bindXIsResourceName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListImmuRulesParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("X-Is-Resource-Name", "header", "bool", raw) + } + o.XIsResourceName = &value + + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *ListImmuRulesParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *ListImmuRulesParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindPage binds and validates parameter Page from query. +func (o *ListImmuRulesParams) bindPage(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListImmuRulesParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page", "query", "int64", raw) + } + o.Page = &value + + return nil +} + +// bindPageSize binds and validates parameter PageSize from query. +func (o *ListImmuRulesParams) bindPageSize(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListImmuRulesParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page_size", "query", "int64", raw) + } + o.PageSize = &value + + if err := o.validatePageSize(formats); err != nil { + return err + } + + return nil +} + +// validatePageSize carries on validations for parameter PageSize +func (o *ListImmuRulesParams) validatePageSize(formats strfmt.Registry) error { + + if err := validate.MaximumInt("page_size", "query", int64(*o.PageSize), 100, false); err != nil { + return err + } + + return nil +} + +// bindProjectNameOrID binds and validates parameter ProjectNameOrID from path. +func (o *ListImmuRulesParams) bindProjectNameOrID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectNameOrID = raw + + return nil +} + +// bindQ binds and validates parameter Q from query. +func (o *ListImmuRulesParams) bindQ(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Q = &raw + + return nil +} + +// bindSort binds and validates parameter Sort from query. +func (o *ListImmuRulesParams) bindSort(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Sort = &raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/immutable/list_immu_rules_responses.go b/src/server/v2.0/restapi/operations/immutable/list_immu_rules_responses.go new file mode 100644 index 000000000..f0c0e4c48 --- /dev/null +++ b/src/server/v2.0/restapi/operations/immutable/list_immu_rules_responses.go @@ -0,0 +1,370 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package immutable + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/swag" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// ListImmuRulesOKCode is the HTTP code returned for type ListImmuRulesOK +const ListImmuRulesOKCode int = 200 + +/*ListImmuRulesOK Success + +swagger:response listImmuRulesOK +*/ +type ListImmuRulesOK struct { + /*Link refers to the previous page and next page + + */ + Link string `json:"Link"` + /*The total count of immutable tag + + */ + XTotalCount int64 `json:"X-Total-Count"` + + /* + In: Body + */ + Payload []*models.ImmutableRule `json:"body,omitempty"` +} + +// NewListImmuRulesOK creates ListImmuRulesOK with default headers values +func NewListImmuRulesOK() *ListImmuRulesOK { + + return &ListImmuRulesOK{} +} + +// WithLink adds the link to the list immu rules o k response +func (o *ListImmuRulesOK) WithLink(link string) *ListImmuRulesOK { + o.Link = link + return o +} + +// SetLink sets the link to the list immu rules o k response +func (o *ListImmuRulesOK) SetLink(link string) { + o.Link = link +} + +// WithXTotalCount adds the xTotalCount to the list immu rules o k response +func (o *ListImmuRulesOK) WithXTotalCount(xTotalCount int64) *ListImmuRulesOK { + o.XTotalCount = xTotalCount + return o +} + +// SetXTotalCount sets the xTotalCount to the list immu rules o k response +func (o *ListImmuRulesOK) SetXTotalCount(xTotalCount int64) { + o.XTotalCount = xTotalCount +} + +// WithPayload adds the payload to the list immu rules o k response +func (o *ListImmuRulesOK) WithPayload(payload []*models.ImmutableRule) *ListImmuRulesOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list immu rules o k response +func (o *ListImmuRulesOK) SetPayload(payload []*models.ImmutableRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListImmuRulesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Link + + link := o.Link + if link != "" { + rw.Header().Set("Link", link) + } + + // response header X-Total-Count + + xTotalCount := swag.FormatInt64(o.XTotalCount) + if xTotalCount != "" { + rw.Header().Set("X-Total-Count", xTotalCount) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = make([]*models.ImmutableRule, 0, 50) + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ListImmuRulesBadRequestCode is the HTTP code returned for type ListImmuRulesBadRequest +const ListImmuRulesBadRequestCode int = 400 + +/*ListImmuRulesBadRequest Bad request + +swagger:response listImmuRulesBadRequest +*/ +type ListImmuRulesBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListImmuRulesBadRequest creates ListImmuRulesBadRequest with default headers values +func NewListImmuRulesBadRequest() *ListImmuRulesBadRequest { + + return &ListImmuRulesBadRequest{} +} + +// WithXRequestID adds the xRequestId to the list immu rules bad request response +func (o *ListImmuRulesBadRequest) WithXRequestID(xRequestID string) *ListImmuRulesBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list immu rules bad request response +func (o *ListImmuRulesBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list immu rules bad request response +func (o *ListImmuRulesBadRequest) WithPayload(payload *models.Errors) *ListImmuRulesBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list immu rules bad request response +func (o *ListImmuRulesBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListImmuRulesBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListImmuRulesUnauthorizedCode is the HTTP code returned for type ListImmuRulesUnauthorized +const ListImmuRulesUnauthorizedCode int = 401 + +/*ListImmuRulesUnauthorized Unauthorized + +swagger:response listImmuRulesUnauthorized +*/ +type ListImmuRulesUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListImmuRulesUnauthorized creates ListImmuRulesUnauthorized with default headers values +func NewListImmuRulesUnauthorized() *ListImmuRulesUnauthorized { + + return &ListImmuRulesUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the list immu rules unauthorized response +func (o *ListImmuRulesUnauthorized) WithXRequestID(xRequestID string) *ListImmuRulesUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list immu rules unauthorized response +func (o *ListImmuRulesUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list immu rules unauthorized response +func (o *ListImmuRulesUnauthorized) WithPayload(payload *models.Errors) *ListImmuRulesUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list immu rules unauthorized response +func (o *ListImmuRulesUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListImmuRulesUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListImmuRulesForbiddenCode is the HTTP code returned for type ListImmuRulesForbidden +const ListImmuRulesForbiddenCode int = 403 + +/*ListImmuRulesForbidden Forbidden + +swagger:response listImmuRulesForbidden +*/ +type ListImmuRulesForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListImmuRulesForbidden creates ListImmuRulesForbidden with default headers values +func NewListImmuRulesForbidden() *ListImmuRulesForbidden { + + return &ListImmuRulesForbidden{} +} + +// WithXRequestID adds the xRequestId to the list immu rules forbidden response +func (o *ListImmuRulesForbidden) WithXRequestID(xRequestID string) *ListImmuRulesForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list immu rules forbidden response +func (o *ListImmuRulesForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list immu rules forbidden response +func (o *ListImmuRulesForbidden) WithPayload(payload *models.Errors) *ListImmuRulesForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list immu rules forbidden response +func (o *ListImmuRulesForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListImmuRulesForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListImmuRulesInternalServerErrorCode is the HTTP code returned for type ListImmuRulesInternalServerError +const ListImmuRulesInternalServerErrorCode int = 500 + +/*ListImmuRulesInternalServerError Internal server error + +swagger:response listImmuRulesInternalServerError +*/ +type ListImmuRulesInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListImmuRulesInternalServerError creates ListImmuRulesInternalServerError with default headers values +func NewListImmuRulesInternalServerError() *ListImmuRulesInternalServerError { + + return &ListImmuRulesInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the list immu rules internal server error response +func (o *ListImmuRulesInternalServerError) WithXRequestID(xRequestID string) *ListImmuRulesInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list immu rules internal server error response +func (o *ListImmuRulesInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list immu rules internal server error response +func (o *ListImmuRulesInternalServerError) WithPayload(payload *models.Errors) *ListImmuRulesInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list immu rules internal server error response +func (o *ListImmuRulesInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListImmuRulesInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/immutable/list_immu_rules_urlbuilder.go b/src/server/v2.0/restapi/operations/immutable/list_immu_rules_urlbuilder.go new file mode 100644 index 000000000..512fa8296 --- /dev/null +++ b/src/server/v2.0/restapi/operations/immutable/list_immu_rules_urlbuilder.go @@ -0,0 +1,142 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package immutable + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ListImmuRulesURL generates an URL for the list immu rules operation +type ListImmuRulesURL struct { + ProjectNameOrID string + + Page *int64 + PageSize *int64 + Q *string + Sort *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListImmuRulesURL) WithBasePath(bp string) *ListImmuRulesURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListImmuRulesURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ListImmuRulesURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name_or_id}/immutabletagrules" + + projectNameOrID := o.ProjectNameOrID + if projectNameOrID != "" { + _path = strings.Replace(_path, "{project_name_or_id}", projectNameOrID, -1) + } else { + return nil, errors.New("projectNameOrId is required on ListImmuRulesURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var pageQ string + if o.Page != nil { + pageQ = swag.FormatInt64(*o.Page) + } + if pageQ != "" { + qs.Set("page", pageQ) + } + + var pageSizeQ string + if o.PageSize != nil { + pageSizeQ = swag.FormatInt64(*o.PageSize) + } + if pageSizeQ != "" { + qs.Set("page_size", pageSizeQ) + } + + var qQ string + if o.Q != nil { + qQ = *o.Q + } + if qQ != "" { + qs.Set("q", qQ) + } + + var sortQ string + if o.Sort != nil { + sortQ = *o.Sort + } + if sortQ != "" { + qs.Set("sort", sortQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ListImmuRulesURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ListImmuRulesURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ListImmuRulesURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ListImmuRulesURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ListImmuRulesURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ListImmuRulesURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/immutable/update_immu_rule.go b/src/server/v2.0/restapi/operations/immutable/update_immu_rule.go new file mode 100644 index 000000000..74258ae10 --- /dev/null +++ b/src/server/v2.0/restapi/operations/immutable/update_immu_rule.go @@ -0,0 +1,71 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package immutable + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// UpdateImmuRuleHandlerFunc turns a function with the right signature into a update immu rule handler +type UpdateImmuRuleHandlerFunc func(UpdateImmuRuleParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn UpdateImmuRuleHandlerFunc) Handle(params UpdateImmuRuleParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// UpdateImmuRuleHandler interface for that can handle valid update immu rule params +type UpdateImmuRuleHandler interface { + Handle(UpdateImmuRuleParams, interface{}) middleware.Responder +} + +// NewUpdateImmuRule creates a new http.Handler for the update immu rule operation +func NewUpdateImmuRule(ctx *middleware.Context, handler UpdateImmuRuleHandler) *UpdateImmuRule { + return &UpdateImmuRule{Context: ctx, Handler: handler} +} + +/*UpdateImmuRule swagger:route PUT /projects/{project_name_or_id}/immutabletagrules/{immutable_rule_id} immutable updateImmuRule + +Update the immutable tag rule or enable or disable the rule + +*/ +type UpdateImmuRule struct { + Context *middleware.Context + Handler UpdateImmuRuleHandler +} + +func (o *UpdateImmuRule) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewUpdateImmuRuleParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/immutable/update_immu_rule_parameters.go b/src/server/v2.0/restapi/operations/immutable/update_immu_rule_parameters.go new file mode 100644 index 000000000..49115ac83 --- /dev/null +++ b/src/server/v2.0/restapi/operations/immutable/update_immu_rule_parameters.go @@ -0,0 +1,215 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package immutable + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewUpdateImmuRuleParams creates a new UpdateImmuRuleParams object +// with the default values initialized. +func NewUpdateImmuRuleParams() UpdateImmuRuleParams { + + var ( + // initialize parameters with default values + + xIsResourceNameDefault = bool(false) + ) + + return UpdateImmuRuleParams{ + XIsResourceName: &xIsResourceNameDefault, + } +} + +// UpdateImmuRuleParams contains all the bound params for the update immu rule operation +// typically these are obtained from a http.Request +// +// swagger:parameters UpdateImmuRule +type UpdateImmuRuleParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + ImmutableRule *models.ImmutableRule + /*The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name. + In: header + Default: false + */ + XIsResourceName *bool + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The ID of the immutable rule + Required: true + In: path + */ + ImmutableRuleID int64 + /*The name or id of the project + Required: true + In: path + */ + ProjectNameOrID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewUpdateImmuRuleParams() beforehand. +func (o *UpdateImmuRuleParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.ImmutableRule + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("immutableRule", "body", "")) + } else { + res = append(res, errors.NewParseError("immutableRule", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.ImmutableRule = &body + } + } + } else { + res = append(res, errors.Required("immutableRule", "body", "")) + } + if err := o.bindXIsResourceName(r.Header[http.CanonicalHeaderKey("X-Is-Resource-Name")], true, route.Formats); err != nil { + res = append(res, err) + } + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rImmutableRuleID, rhkImmutableRuleID, _ := route.Params.GetOK("immutable_rule_id") + if err := o.bindImmutableRuleID(rImmutableRuleID, rhkImmutableRuleID, route.Formats); err != nil { + res = append(res, err) + } + + rProjectNameOrID, rhkProjectNameOrID, _ := route.Params.GetOK("project_name_or_id") + if err := o.bindProjectNameOrID(rProjectNameOrID, rhkProjectNameOrID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXIsResourceName binds and validates parameter XIsResourceName from header. +func (o *UpdateImmuRuleParams) bindXIsResourceName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewUpdateImmuRuleParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("X-Is-Resource-Name", "header", "bool", raw) + } + o.XIsResourceName = &value + + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *UpdateImmuRuleParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *UpdateImmuRuleParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindImmutableRuleID binds and validates parameter ImmutableRuleID from path. +func (o *UpdateImmuRuleParams) bindImmutableRuleID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("immutable_rule_id", "path", "int64", raw) + } + o.ImmutableRuleID = value + + return nil +} + +// bindProjectNameOrID binds and validates parameter ProjectNameOrID from path. +func (o *UpdateImmuRuleParams) bindProjectNameOrID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectNameOrID = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/immutable/update_immu_rule_responses.go b/src/server/v2.0/restapi/operations/immutable/update_immu_rule_responses.go new file mode 100644 index 000000000..d000b00c4 --- /dev/null +++ b/src/server/v2.0/restapi/operations/immutable/update_immu_rule_responses.go @@ -0,0 +1,324 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package immutable + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// UpdateImmuRuleOKCode is the HTTP code returned for type UpdateImmuRuleOK +const UpdateImmuRuleOKCode int = 200 + +/*UpdateImmuRuleOK Success + +swagger:response updateImmuRuleOK +*/ +type UpdateImmuRuleOK struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewUpdateImmuRuleOK creates UpdateImmuRuleOK with default headers values +func NewUpdateImmuRuleOK() *UpdateImmuRuleOK { + + return &UpdateImmuRuleOK{} +} + +// WithXRequestID adds the xRequestId to the update immu rule o k response +func (o *UpdateImmuRuleOK) WithXRequestID(xRequestID string) *UpdateImmuRuleOK { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update immu rule o k response +func (o *UpdateImmuRuleOK) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *UpdateImmuRuleOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// UpdateImmuRuleBadRequestCode is the HTTP code returned for type UpdateImmuRuleBadRequest +const UpdateImmuRuleBadRequestCode int = 400 + +/*UpdateImmuRuleBadRequest Bad request + +swagger:response updateImmuRuleBadRequest +*/ +type UpdateImmuRuleBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateImmuRuleBadRequest creates UpdateImmuRuleBadRequest with default headers values +func NewUpdateImmuRuleBadRequest() *UpdateImmuRuleBadRequest { + + return &UpdateImmuRuleBadRequest{} +} + +// WithXRequestID adds the xRequestId to the update immu rule bad request response +func (o *UpdateImmuRuleBadRequest) WithXRequestID(xRequestID string) *UpdateImmuRuleBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update immu rule bad request response +func (o *UpdateImmuRuleBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update immu rule bad request response +func (o *UpdateImmuRuleBadRequest) WithPayload(payload *models.Errors) *UpdateImmuRuleBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update immu rule bad request response +func (o *UpdateImmuRuleBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateImmuRuleBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateImmuRuleUnauthorizedCode is the HTTP code returned for type UpdateImmuRuleUnauthorized +const UpdateImmuRuleUnauthorizedCode int = 401 + +/*UpdateImmuRuleUnauthorized Unauthorized + +swagger:response updateImmuRuleUnauthorized +*/ +type UpdateImmuRuleUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateImmuRuleUnauthorized creates UpdateImmuRuleUnauthorized with default headers values +func NewUpdateImmuRuleUnauthorized() *UpdateImmuRuleUnauthorized { + + return &UpdateImmuRuleUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the update immu rule unauthorized response +func (o *UpdateImmuRuleUnauthorized) WithXRequestID(xRequestID string) *UpdateImmuRuleUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update immu rule unauthorized response +func (o *UpdateImmuRuleUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update immu rule unauthorized response +func (o *UpdateImmuRuleUnauthorized) WithPayload(payload *models.Errors) *UpdateImmuRuleUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update immu rule unauthorized response +func (o *UpdateImmuRuleUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateImmuRuleUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateImmuRuleForbiddenCode is the HTTP code returned for type UpdateImmuRuleForbidden +const UpdateImmuRuleForbiddenCode int = 403 + +/*UpdateImmuRuleForbidden Forbidden + +swagger:response updateImmuRuleForbidden +*/ +type UpdateImmuRuleForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateImmuRuleForbidden creates UpdateImmuRuleForbidden with default headers values +func NewUpdateImmuRuleForbidden() *UpdateImmuRuleForbidden { + + return &UpdateImmuRuleForbidden{} +} + +// WithXRequestID adds the xRequestId to the update immu rule forbidden response +func (o *UpdateImmuRuleForbidden) WithXRequestID(xRequestID string) *UpdateImmuRuleForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update immu rule forbidden response +func (o *UpdateImmuRuleForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update immu rule forbidden response +func (o *UpdateImmuRuleForbidden) WithPayload(payload *models.Errors) *UpdateImmuRuleForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update immu rule forbidden response +func (o *UpdateImmuRuleForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateImmuRuleForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateImmuRuleInternalServerErrorCode is the HTTP code returned for type UpdateImmuRuleInternalServerError +const UpdateImmuRuleInternalServerErrorCode int = 500 + +/*UpdateImmuRuleInternalServerError Internal server error + +swagger:response updateImmuRuleInternalServerError +*/ +type UpdateImmuRuleInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateImmuRuleInternalServerError creates UpdateImmuRuleInternalServerError with default headers values +func NewUpdateImmuRuleInternalServerError() *UpdateImmuRuleInternalServerError { + + return &UpdateImmuRuleInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the update immu rule internal server error response +func (o *UpdateImmuRuleInternalServerError) WithXRequestID(xRequestID string) *UpdateImmuRuleInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update immu rule internal server error response +func (o *UpdateImmuRuleInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update immu rule internal server error response +func (o *UpdateImmuRuleInternalServerError) WithPayload(payload *models.Errors) *UpdateImmuRuleInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update immu rule internal server error response +func (o *UpdateImmuRuleInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateImmuRuleInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/immutable/update_immu_rule_urlbuilder.go b/src/server/v2.0/restapi/operations/immutable/update_immu_rule_urlbuilder.go new file mode 100644 index 000000000..31b506f80 --- /dev/null +++ b/src/server/v2.0/restapi/operations/immutable/update_immu_rule_urlbuilder.go @@ -0,0 +1,109 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package immutable + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// UpdateImmuRuleURL generates an URL for the update immu rule operation +type UpdateImmuRuleURL struct { + ImmutableRuleID int64 + ProjectNameOrID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdateImmuRuleURL) WithBasePath(bp string) *UpdateImmuRuleURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdateImmuRuleURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *UpdateImmuRuleURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name_or_id}/immutabletagrules/{immutable_rule_id}" + + immutableRuleID := swag.FormatInt64(o.ImmutableRuleID) + if immutableRuleID != "" { + _path = strings.Replace(_path, "{immutable_rule_id}", immutableRuleID, -1) + } else { + return nil, errors.New("immutableRuleId is required on UpdateImmuRuleURL") + } + + projectNameOrID := o.ProjectNameOrID + if projectNameOrID != "" { + _path = strings.Replace(_path, "{project_name_or_id}", projectNameOrID, -1) + } else { + return nil, errors.New("projectNameOrId is required on UpdateImmuRuleURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *UpdateImmuRuleURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *UpdateImmuRuleURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *UpdateImmuRuleURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on UpdateImmuRuleURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on UpdateImmuRuleURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *UpdateImmuRuleURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/jobservice/action_pending_jobs.go b/src/server/v2.0/restapi/operations/jobservice/action_pending_jobs.go new file mode 100644 index 000000000..ccf35fb87 --- /dev/null +++ b/src/server/v2.0/restapi/operations/jobservice/action_pending_jobs.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package jobservice + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ActionPendingJobsHandlerFunc turns a function with the right signature into a action pending jobs handler +type ActionPendingJobsHandlerFunc func(ActionPendingJobsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ActionPendingJobsHandlerFunc) Handle(params ActionPendingJobsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ActionPendingJobsHandler interface for that can handle valid action pending jobs params +type ActionPendingJobsHandler interface { + Handle(ActionPendingJobsParams, interface{}) middleware.Responder +} + +// NewActionPendingJobs creates a new http.Handler for the action pending jobs operation +func NewActionPendingJobs(ctx *middleware.Context, handler ActionPendingJobsHandler) *ActionPendingJobs { + return &ActionPendingJobs{Context: ctx, Handler: handler} +} + +/*ActionPendingJobs swagger:route PUT /jobservice/queues/{job_type} jobservice actionPendingJobs + +stop and clean, pause, resume pending jobs in the queue + +stop and clean, pause, resume pending jobs in the queue + +*/ +type ActionPendingJobs struct { + Context *middleware.Context + Handler ActionPendingJobsHandler +} + +func (o *ActionPendingJobs) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewActionPendingJobsParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/jobservice/action_pending_jobs_parameters.go b/src/server/v2.0/restapi/operations/jobservice/action_pending_jobs_parameters.go new file mode 100644 index 000000000..bb2cd31ed --- /dev/null +++ b/src/server/v2.0/restapi/operations/jobservice/action_pending_jobs_parameters.go @@ -0,0 +1,145 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package jobservice + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewActionPendingJobsParams creates a new ActionPendingJobsParams object +// no default values defined in spec. +func NewActionPendingJobsParams() ActionPendingJobsParams { + + return ActionPendingJobsParams{} +} + +// ActionPendingJobsParams contains all the bound params for the action pending jobs operation +// typically these are obtained from a http.Request +// +// swagger:parameters actionPendingJobs +type ActionPendingJobsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /* + Required: true + In: body + */ + ActionRequest *models.ActionRequest + /*The type of the job. 'all' stands for all job types + Required: true + In: path + */ + JobType string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewActionPendingJobsParams() beforehand. +func (o *ActionPendingJobsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.ActionRequest + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("actionRequest", "body", "")) + } else { + res = append(res, errors.NewParseError("actionRequest", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.ActionRequest = &body + } + } + } else { + res = append(res, errors.Required("actionRequest", "body", "")) + } + rJobType, rhkJobType, _ := route.Params.GetOK("job_type") + if err := o.bindJobType(rJobType, rhkJobType, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *ActionPendingJobsParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *ActionPendingJobsParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindJobType binds and validates parameter JobType from path. +func (o *ActionPendingJobsParams) bindJobType(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.JobType = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/jobservice/action_pending_jobs_responses.go b/src/server/v2.0/restapi/operations/jobservice/action_pending_jobs_responses.go new file mode 100644 index 000000000..74a4777b4 --- /dev/null +++ b/src/server/v2.0/restapi/operations/jobservice/action_pending_jobs_responses.go @@ -0,0 +1,302 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package jobservice + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// ActionPendingJobsOKCode is the HTTP code returned for type ActionPendingJobsOK +const ActionPendingJobsOKCode int = 200 + +/*ActionPendingJobsOK take action to the jobs in the queue successfully. + +swagger:response actionPendingJobsOK +*/ +type ActionPendingJobsOK struct { +} + +// NewActionPendingJobsOK creates ActionPendingJobsOK with default headers values +func NewActionPendingJobsOK() *ActionPendingJobsOK { + + return &ActionPendingJobsOK{} +} + +// WriteResponse to the client +func (o *ActionPendingJobsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// ActionPendingJobsUnauthorizedCode is the HTTP code returned for type ActionPendingJobsUnauthorized +const ActionPendingJobsUnauthorizedCode int = 401 + +/*ActionPendingJobsUnauthorized Unauthorized + +swagger:response actionPendingJobsUnauthorized +*/ +type ActionPendingJobsUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewActionPendingJobsUnauthorized creates ActionPendingJobsUnauthorized with default headers values +func NewActionPendingJobsUnauthorized() *ActionPendingJobsUnauthorized { + + return &ActionPendingJobsUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the action pending jobs unauthorized response +func (o *ActionPendingJobsUnauthorized) WithXRequestID(xRequestID string) *ActionPendingJobsUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the action pending jobs unauthorized response +func (o *ActionPendingJobsUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the action pending jobs unauthorized response +func (o *ActionPendingJobsUnauthorized) WithPayload(payload *models.Errors) *ActionPendingJobsUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the action pending jobs unauthorized response +func (o *ActionPendingJobsUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ActionPendingJobsUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ActionPendingJobsForbiddenCode is the HTTP code returned for type ActionPendingJobsForbidden +const ActionPendingJobsForbiddenCode int = 403 + +/*ActionPendingJobsForbidden Forbidden + +swagger:response actionPendingJobsForbidden +*/ +type ActionPendingJobsForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewActionPendingJobsForbidden creates ActionPendingJobsForbidden with default headers values +func NewActionPendingJobsForbidden() *ActionPendingJobsForbidden { + + return &ActionPendingJobsForbidden{} +} + +// WithXRequestID adds the xRequestId to the action pending jobs forbidden response +func (o *ActionPendingJobsForbidden) WithXRequestID(xRequestID string) *ActionPendingJobsForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the action pending jobs forbidden response +func (o *ActionPendingJobsForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the action pending jobs forbidden response +func (o *ActionPendingJobsForbidden) WithPayload(payload *models.Errors) *ActionPendingJobsForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the action pending jobs forbidden response +func (o *ActionPendingJobsForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ActionPendingJobsForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ActionPendingJobsNotFoundCode is the HTTP code returned for type ActionPendingJobsNotFound +const ActionPendingJobsNotFoundCode int = 404 + +/*ActionPendingJobsNotFound Not found + +swagger:response actionPendingJobsNotFound +*/ +type ActionPendingJobsNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewActionPendingJobsNotFound creates ActionPendingJobsNotFound with default headers values +func NewActionPendingJobsNotFound() *ActionPendingJobsNotFound { + + return &ActionPendingJobsNotFound{} +} + +// WithXRequestID adds the xRequestId to the action pending jobs not found response +func (o *ActionPendingJobsNotFound) WithXRequestID(xRequestID string) *ActionPendingJobsNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the action pending jobs not found response +func (o *ActionPendingJobsNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the action pending jobs not found response +func (o *ActionPendingJobsNotFound) WithPayload(payload *models.Errors) *ActionPendingJobsNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the action pending jobs not found response +func (o *ActionPendingJobsNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ActionPendingJobsNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ActionPendingJobsInternalServerErrorCode is the HTTP code returned for type ActionPendingJobsInternalServerError +const ActionPendingJobsInternalServerErrorCode int = 500 + +/*ActionPendingJobsInternalServerError Internal server error + +swagger:response actionPendingJobsInternalServerError +*/ +type ActionPendingJobsInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewActionPendingJobsInternalServerError creates ActionPendingJobsInternalServerError with default headers values +func NewActionPendingJobsInternalServerError() *ActionPendingJobsInternalServerError { + + return &ActionPendingJobsInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the action pending jobs internal server error response +func (o *ActionPendingJobsInternalServerError) WithXRequestID(xRequestID string) *ActionPendingJobsInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the action pending jobs internal server error response +func (o *ActionPendingJobsInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the action pending jobs internal server error response +func (o *ActionPendingJobsInternalServerError) WithPayload(payload *models.Errors) *ActionPendingJobsInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the action pending jobs internal server error response +func (o *ActionPendingJobsInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ActionPendingJobsInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/jobservice/action_pending_jobs_urlbuilder.go b/src/server/v2.0/restapi/operations/jobservice/action_pending_jobs_urlbuilder.go new file mode 100644 index 000000000..ee50da4dc --- /dev/null +++ b/src/server/v2.0/restapi/operations/jobservice/action_pending_jobs_urlbuilder.go @@ -0,0 +1,99 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package jobservice + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// ActionPendingJobsURL generates an URL for the action pending jobs operation +type ActionPendingJobsURL struct { + JobType string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ActionPendingJobsURL) WithBasePath(bp string) *ActionPendingJobsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ActionPendingJobsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ActionPendingJobsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/jobservice/queues/{job_type}" + + jobType := o.JobType + if jobType != "" { + _path = strings.Replace(_path, "{job_type}", jobType, -1) + } else { + return nil, errors.New("jobType is required on ActionPendingJobsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ActionPendingJobsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ActionPendingJobsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ActionPendingJobsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ActionPendingJobsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ActionPendingJobsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ActionPendingJobsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/jobservice/get_worker_pools.go b/src/server/v2.0/restapi/operations/jobservice/get_worker_pools.go new file mode 100644 index 000000000..58c71ca83 --- /dev/null +++ b/src/server/v2.0/restapi/operations/jobservice/get_worker_pools.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package jobservice + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetWorkerPoolsHandlerFunc turns a function with the right signature into a get worker pools handler +type GetWorkerPoolsHandlerFunc func(GetWorkerPoolsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetWorkerPoolsHandlerFunc) Handle(params GetWorkerPoolsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetWorkerPoolsHandler interface for that can handle valid get worker pools params +type GetWorkerPoolsHandler interface { + Handle(GetWorkerPoolsParams, interface{}) middleware.Responder +} + +// NewGetWorkerPools creates a new http.Handler for the get worker pools operation +func NewGetWorkerPools(ctx *middleware.Context, handler GetWorkerPoolsHandler) *GetWorkerPools { + return &GetWorkerPools{Context: ctx, Handler: handler} +} + +/*GetWorkerPools swagger:route GET /jobservice/pools jobservice getWorkerPools + +Get worker pools + +Get worker pools + +*/ +type GetWorkerPools struct { + Context *middleware.Context + Handler GetWorkerPoolsHandler +} + +func (o *GetWorkerPools) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetWorkerPoolsParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/jobservice/get_worker_pools_parameters.go b/src/server/v2.0/restapi/operations/jobservice/get_worker_pools_parameters.go new file mode 100644 index 000000000..36255e68a --- /dev/null +++ b/src/server/v2.0/restapi/operations/jobservice/get_worker_pools_parameters.go @@ -0,0 +1,89 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package jobservice + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewGetWorkerPoolsParams creates a new GetWorkerPoolsParams object +// no default values defined in spec. +func NewGetWorkerPoolsParams() GetWorkerPoolsParams { + + return GetWorkerPoolsParams{} +} + +// GetWorkerPoolsParams contains all the bound params for the get worker pools operation +// typically these are obtained from a http.Request +// +// swagger:parameters getWorkerPools +type GetWorkerPoolsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetWorkerPoolsParams() beforehand. +func (o *GetWorkerPoolsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetWorkerPoolsParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetWorkerPoolsParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} diff --git a/src/server/v2.0/restapi/operations/jobservice/get_worker_pools_responses.go b/src/server/v2.0/restapi/operations/jobservice/get_worker_pools_responses.go new file mode 100644 index 000000000..8898369fb --- /dev/null +++ b/src/server/v2.0/restapi/operations/jobservice/get_worker_pools_responses.go @@ -0,0 +1,259 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package jobservice + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetWorkerPoolsOKCode is the HTTP code returned for type GetWorkerPoolsOK +const GetWorkerPoolsOKCode int = 200 + +/*GetWorkerPoolsOK Get worker pools successfully. + +swagger:response getWorkerPoolsOK +*/ +type GetWorkerPoolsOK struct { + + /* + In: Body + */ + Payload []*models.WorkerPool `json:"body,omitempty"` +} + +// NewGetWorkerPoolsOK creates GetWorkerPoolsOK with default headers values +func NewGetWorkerPoolsOK() *GetWorkerPoolsOK { + + return &GetWorkerPoolsOK{} +} + +// WithPayload adds the payload to the get worker pools o k response +func (o *GetWorkerPoolsOK) WithPayload(payload []*models.WorkerPool) *GetWorkerPoolsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get worker pools o k response +func (o *GetWorkerPoolsOK) SetPayload(payload []*models.WorkerPool) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetWorkerPoolsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = make([]*models.WorkerPool, 0, 50) + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// GetWorkerPoolsUnauthorizedCode is the HTTP code returned for type GetWorkerPoolsUnauthorized +const GetWorkerPoolsUnauthorizedCode int = 401 + +/*GetWorkerPoolsUnauthorized Unauthorized + +swagger:response getWorkerPoolsUnauthorized +*/ +type GetWorkerPoolsUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetWorkerPoolsUnauthorized creates GetWorkerPoolsUnauthorized with default headers values +func NewGetWorkerPoolsUnauthorized() *GetWorkerPoolsUnauthorized { + + return &GetWorkerPoolsUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the get worker pools unauthorized response +func (o *GetWorkerPoolsUnauthorized) WithXRequestID(xRequestID string) *GetWorkerPoolsUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get worker pools unauthorized response +func (o *GetWorkerPoolsUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get worker pools unauthorized response +func (o *GetWorkerPoolsUnauthorized) WithPayload(payload *models.Errors) *GetWorkerPoolsUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get worker pools unauthorized response +func (o *GetWorkerPoolsUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetWorkerPoolsUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetWorkerPoolsForbiddenCode is the HTTP code returned for type GetWorkerPoolsForbidden +const GetWorkerPoolsForbiddenCode int = 403 + +/*GetWorkerPoolsForbidden Forbidden + +swagger:response getWorkerPoolsForbidden +*/ +type GetWorkerPoolsForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetWorkerPoolsForbidden creates GetWorkerPoolsForbidden with default headers values +func NewGetWorkerPoolsForbidden() *GetWorkerPoolsForbidden { + + return &GetWorkerPoolsForbidden{} +} + +// WithXRequestID adds the xRequestId to the get worker pools forbidden response +func (o *GetWorkerPoolsForbidden) WithXRequestID(xRequestID string) *GetWorkerPoolsForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get worker pools forbidden response +func (o *GetWorkerPoolsForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get worker pools forbidden response +func (o *GetWorkerPoolsForbidden) WithPayload(payload *models.Errors) *GetWorkerPoolsForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get worker pools forbidden response +func (o *GetWorkerPoolsForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetWorkerPoolsForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetWorkerPoolsInternalServerErrorCode is the HTTP code returned for type GetWorkerPoolsInternalServerError +const GetWorkerPoolsInternalServerErrorCode int = 500 + +/*GetWorkerPoolsInternalServerError Internal server error + +swagger:response getWorkerPoolsInternalServerError +*/ +type GetWorkerPoolsInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetWorkerPoolsInternalServerError creates GetWorkerPoolsInternalServerError with default headers values +func NewGetWorkerPoolsInternalServerError() *GetWorkerPoolsInternalServerError { + + return &GetWorkerPoolsInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get worker pools internal server error response +func (o *GetWorkerPoolsInternalServerError) WithXRequestID(xRequestID string) *GetWorkerPoolsInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get worker pools internal server error response +func (o *GetWorkerPoolsInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get worker pools internal server error response +func (o *GetWorkerPoolsInternalServerError) WithPayload(payload *models.Errors) *GetWorkerPoolsInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get worker pools internal server error response +func (o *GetWorkerPoolsInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetWorkerPoolsInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/jobservice/get_worker_pools_urlbuilder.go b/src/server/v2.0/restapi/operations/jobservice/get_worker_pools_urlbuilder.go new file mode 100644 index 000000000..d24cf7683 --- /dev/null +++ b/src/server/v2.0/restapi/operations/jobservice/get_worker_pools_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package jobservice + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetWorkerPoolsURL generates an URL for the get worker pools operation +type GetWorkerPoolsURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetWorkerPoolsURL) WithBasePath(bp string) *GetWorkerPoolsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetWorkerPoolsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetWorkerPoolsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/jobservice/pools" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetWorkerPoolsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetWorkerPoolsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetWorkerPoolsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetWorkerPoolsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetWorkerPoolsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetWorkerPoolsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/jobservice/get_workers.go b/src/server/v2.0/restapi/operations/jobservice/get_workers.go new file mode 100644 index 000000000..5d11e3a88 --- /dev/null +++ b/src/server/v2.0/restapi/operations/jobservice/get_workers.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package jobservice + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetWorkersHandlerFunc turns a function with the right signature into a get workers handler +type GetWorkersHandlerFunc func(GetWorkersParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetWorkersHandlerFunc) Handle(params GetWorkersParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetWorkersHandler interface for that can handle valid get workers params +type GetWorkersHandler interface { + Handle(GetWorkersParams, interface{}) middleware.Responder +} + +// NewGetWorkers creates a new http.Handler for the get workers operation +func NewGetWorkers(ctx *middleware.Context, handler GetWorkersHandler) *GetWorkers { + return &GetWorkers{Context: ctx, Handler: handler} +} + +/*GetWorkers swagger:route GET /jobservice/pools/{pool_id}/workers jobservice getWorkers + +Get workers + +Get workers in current pool + +*/ +type GetWorkers struct { + Context *middleware.Context + Handler GetWorkersHandler +} + +func (o *GetWorkers) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetWorkersParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/jobservice/get_workers_parameters.go b/src/server/v2.0/restapi/operations/jobservice/get_workers_parameters.go new file mode 100644 index 000000000..e37ea23a8 --- /dev/null +++ b/src/server/v2.0/restapi/operations/jobservice/get_workers_parameters.go @@ -0,0 +1,114 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package jobservice + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewGetWorkersParams creates a new GetWorkersParams object +// no default values defined in spec. +func NewGetWorkersParams() GetWorkersParams { + + return GetWorkersParams{} +} + +// GetWorkersParams contains all the bound params for the get workers operation +// typically these are obtained from a http.Request +// +// swagger:parameters getWorkers +type GetWorkersParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The name of the pool. 'all' stands for all pools + Required: true + In: path + */ + PoolID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetWorkersParams() beforehand. +func (o *GetWorkersParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rPoolID, rhkPoolID, _ := route.Params.GetOK("pool_id") + if err := o.bindPoolID(rPoolID, rhkPoolID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetWorkersParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetWorkersParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindPoolID binds and validates parameter PoolID from path. +func (o *GetWorkersParams) bindPoolID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.PoolID = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/jobservice/get_workers_responses.go b/src/server/v2.0/restapi/operations/jobservice/get_workers_responses.go new file mode 100644 index 000000000..71ef0fd0c --- /dev/null +++ b/src/server/v2.0/restapi/operations/jobservice/get_workers_responses.go @@ -0,0 +1,325 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package jobservice + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetWorkersOKCode is the HTTP code returned for type GetWorkersOK +const GetWorkersOKCode int = 200 + +/*GetWorkersOK Get workers successfully. + +swagger:response getWorkersOK +*/ +type GetWorkersOK struct { + + /* + In: Body + */ + Payload []*models.Worker `json:"body,omitempty"` +} + +// NewGetWorkersOK creates GetWorkersOK with default headers values +func NewGetWorkersOK() *GetWorkersOK { + + return &GetWorkersOK{} +} + +// WithPayload adds the payload to the get workers o k response +func (o *GetWorkersOK) WithPayload(payload []*models.Worker) *GetWorkersOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get workers o k response +func (o *GetWorkersOK) SetPayload(payload []*models.Worker) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetWorkersOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = make([]*models.Worker, 0, 50) + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// GetWorkersUnauthorizedCode is the HTTP code returned for type GetWorkersUnauthorized +const GetWorkersUnauthorizedCode int = 401 + +/*GetWorkersUnauthorized Unauthorized + +swagger:response getWorkersUnauthorized +*/ +type GetWorkersUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetWorkersUnauthorized creates GetWorkersUnauthorized with default headers values +func NewGetWorkersUnauthorized() *GetWorkersUnauthorized { + + return &GetWorkersUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the get workers unauthorized response +func (o *GetWorkersUnauthorized) WithXRequestID(xRequestID string) *GetWorkersUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get workers unauthorized response +func (o *GetWorkersUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get workers unauthorized response +func (o *GetWorkersUnauthorized) WithPayload(payload *models.Errors) *GetWorkersUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get workers unauthorized response +func (o *GetWorkersUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetWorkersUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetWorkersForbiddenCode is the HTTP code returned for type GetWorkersForbidden +const GetWorkersForbiddenCode int = 403 + +/*GetWorkersForbidden Forbidden + +swagger:response getWorkersForbidden +*/ +type GetWorkersForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetWorkersForbidden creates GetWorkersForbidden with default headers values +func NewGetWorkersForbidden() *GetWorkersForbidden { + + return &GetWorkersForbidden{} +} + +// WithXRequestID adds the xRequestId to the get workers forbidden response +func (o *GetWorkersForbidden) WithXRequestID(xRequestID string) *GetWorkersForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get workers forbidden response +func (o *GetWorkersForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get workers forbidden response +func (o *GetWorkersForbidden) WithPayload(payload *models.Errors) *GetWorkersForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get workers forbidden response +func (o *GetWorkersForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetWorkersForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetWorkersNotFoundCode is the HTTP code returned for type GetWorkersNotFound +const GetWorkersNotFoundCode int = 404 + +/*GetWorkersNotFound Not found + +swagger:response getWorkersNotFound +*/ +type GetWorkersNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetWorkersNotFound creates GetWorkersNotFound with default headers values +func NewGetWorkersNotFound() *GetWorkersNotFound { + + return &GetWorkersNotFound{} +} + +// WithXRequestID adds the xRequestId to the get workers not found response +func (o *GetWorkersNotFound) WithXRequestID(xRequestID string) *GetWorkersNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get workers not found response +func (o *GetWorkersNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get workers not found response +func (o *GetWorkersNotFound) WithPayload(payload *models.Errors) *GetWorkersNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get workers not found response +func (o *GetWorkersNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetWorkersNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetWorkersInternalServerErrorCode is the HTTP code returned for type GetWorkersInternalServerError +const GetWorkersInternalServerErrorCode int = 500 + +/*GetWorkersInternalServerError Internal server error + +swagger:response getWorkersInternalServerError +*/ +type GetWorkersInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetWorkersInternalServerError creates GetWorkersInternalServerError with default headers values +func NewGetWorkersInternalServerError() *GetWorkersInternalServerError { + + return &GetWorkersInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get workers internal server error response +func (o *GetWorkersInternalServerError) WithXRequestID(xRequestID string) *GetWorkersInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get workers internal server error response +func (o *GetWorkersInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get workers internal server error response +func (o *GetWorkersInternalServerError) WithPayload(payload *models.Errors) *GetWorkersInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get workers internal server error response +func (o *GetWorkersInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetWorkersInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/jobservice/get_workers_urlbuilder.go b/src/server/v2.0/restapi/operations/jobservice/get_workers_urlbuilder.go new file mode 100644 index 000000000..11382babb --- /dev/null +++ b/src/server/v2.0/restapi/operations/jobservice/get_workers_urlbuilder.go @@ -0,0 +1,99 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package jobservice + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetWorkersURL generates an URL for the get workers operation +type GetWorkersURL struct { + PoolID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetWorkersURL) WithBasePath(bp string) *GetWorkersURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetWorkersURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetWorkersURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/jobservice/pools/{pool_id}/workers" + + poolID := o.PoolID + if poolID != "" { + _path = strings.Replace(_path, "{pool_id}", poolID, -1) + } else { + return nil, errors.New("poolId is required on GetWorkersURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetWorkersURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetWorkersURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetWorkersURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetWorkersURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetWorkersURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetWorkersURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/jobservice/list_job_queues.go b/src/server/v2.0/restapi/operations/jobservice/list_job_queues.go new file mode 100644 index 000000000..54753c5f9 --- /dev/null +++ b/src/server/v2.0/restapi/operations/jobservice/list_job_queues.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package jobservice + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ListJobQueuesHandlerFunc turns a function with the right signature into a list job queues handler +type ListJobQueuesHandlerFunc func(ListJobQueuesParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ListJobQueuesHandlerFunc) Handle(params ListJobQueuesParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ListJobQueuesHandler interface for that can handle valid list job queues params +type ListJobQueuesHandler interface { + Handle(ListJobQueuesParams, interface{}) middleware.Responder +} + +// NewListJobQueues creates a new http.Handler for the list job queues operation +func NewListJobQueues(ctx *middleware.Context, handler ListJobQueuesHandler) *ListJobQueues { + return &ListJobQueues{Context: ctx, Handler: handler} +} + +/*ListJobQueues swagger:route GET /jobservice/queues jobservice listJobQueues + +list job queues + +list job queue + +*/ +type ListJobQueues struct { + Context *middleware.Context + Handler ListJobQueuesHandler +} + +func (o *ListJobQueues) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewListJobQueuesParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/jobservice/list_job_queues_parameters.go b/src/server/v2.0/restapi/operations/jobservice/list_job_queues_parameters.go new file mode 100644 index 000000000..840eda44c --- /dev/null +++ b/src/server/v2.0/restapi/operations/jobservice/list_job_queues_parameters.go @@ -0,0 +1,89 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package jobservice + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewListJobQueuesParams creates a new ListJobQueuesParams object +// no default values defined in spec. +func NewListJobQueuesParams() ListJobQueuesParams { + + return ListJobQueuesParams{} +} + +// ListJobQueuesParams contains all the bound params for the list job queues operation +// typically these are obtained from a http.Request +// +// swagger:parameters listJobQueues +type ListJobQueuesParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewListJobQueuesParams() beforehand. +func (o *ListJobQueuesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *ListJobQueuesParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *ListJobQueuesParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} diff --git a/src/server/v2.0/restapi/operations/jobservice/list_job_queues_responses.go b/src/server/v2.0/restapi/operations/jobservice/list_job_queues_responses.go new file mode 100644 index 000000000..5f383f764 --- /dev/null +++ b/src/server/v2.0/restapi/operations/jobservice/list_job_queues_responses.go @@ -0,0 +1,325 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package jobservice + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// ListJobQueuesOKCode is the HTTP code returned for type ListJobQueuesOK +const ListJobQueuesOKCode int = 200 + +/*ListJobQueuesOK List job queue successfully. + +swagger:response listJobQueuesOK +*/ +type ListJobQueuesOK struct { + + /* + In: Body + */ + Payload []*models.JobQueue `json:"body,omitempty"` +} + +// NewListJobQueuesOK creates ListJobQueuesOK with default headers values +func NewListJobQueuesOK() *ListJobQueuesOK { + + return &ListJobQueuesOK{} +} + +// WithPayload adds the payload to the list job queues o k response +func (o *ListJobQueuesOK) WithPayload(payload []*models.JobQueue) *ListJobQueuesOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list job queues o k response +func (o *ListJobQueuesOK) SetPayload(payload []*models.JobQueue) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListJobQueuesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = make([]*models.JobQueue, 0, 50) + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ListJobQueuesUnauthorizedCode is the HTTP code returned for type ListJobQueuesUnauthorized +const ListJobQueuesUnauthorizedCode int = 401 + +/*ListJobQueuesUnauthorized Unauthorized + +swagger:response listJobQueuesUnauthorized +*/ +type ListJobQueuesUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListJobQueuesUnauthorized creates ListJobQueuesUnauthorized with default headers values +func NewListJobQueuesUnauthorized() *ListJobQueuesUnauthorized { + + return &ListJobQueuesUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the list job queues unauthorized response +func (o *ListJobQueuesUnauthorized) WithXRequestID(xRequestID string) *ListJobQueuesUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list job queues unauthorized response +func (o *ListJobQueuesUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list job queues unauthorized response +func (o *ListJobQueuesUnauthorized) WithPayload(payload *models.Errors) *ListJobQueuesUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list job queues unauthorized response +func (o *ListJobQueuesUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListJobQueuesUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListJobQueuesForbiddenCode is the HTTP code returned for type ListJobQueuesForbidden +const ListJobQueuesForbiddenCode int = 403 + +/*ListJobQueuesForbidden Forbidden + +swagger:response listJobQueuesForbidden +*/ +type ListJobQueuesForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListJobQueuesForbidden creates ListJobQueuesForbidden with default headers values +func NewListJobQueuesForbidden() *ListJobQueuesForbidden { + + return &ListJobQueuesForbidden{} +} + +// WithXRequestID adds the xRequestId to the list job queues forbidden response +func (o *ListJobQueuesForbidden) WithXRequestID(xRequestID string) *ListJobQueuesForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list job queues forbidden response +func (o *ListJobQueuesForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list job queues forbidden response +func (o *ListJobQueuesForbidden) WithPayload(payload *models.Errors) *ListJobQueuesForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list job queues forbidden response +func (o *ListJobQueuesForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListJobQueuesForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListJobQueuesNotFoundCode is the HTTP code returned for type ListJobQueuesNotFound +const ListJobQueuesNotFoundCode int = 404 + +/*ListJobQueuesNotFound Not found + +swagger:response listJobQueuesNotFound +*/ +type ListJobQueuesNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListJobQueuesNotFound creates ListJobQueuesNotFound with default headers values +func NewListJobQueuesNotFound() *ListJobQueuesNotFound { + + return &ListJobQueuesNotFound{} +} + +// WithXRequestID adds the xRequestId to the list job queues not found response +func (o *ListJobQueuesNotFound) WithXRequestID(xRequestID string) *ListJobQueuesNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list job queues not found response +func (o *ListJobQueuesNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list job queues not found response +func (o *ListJobQueuesNotFound) WithPayload(payload *models.Errors) *ListJobQueuesNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list job queues not found response +func (o *ListJobQueuesNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListJobQueuesNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListJobQueuesInternalServerErrorCode is the HTTP code returned for type ListJobQueuesInternalServerError +const ListJobQueuesInternalServerErrorCode int = 500 + +/*ListJobQueuesInternalServerError Internal server error + +swagger:response listJobQueuesInternalServerError +*/ +type ListJobQueuesInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListJobQueuesInternalServerError creates ListJobQueuesInternalServerError with default headers values +func NewListJobQueuesInternalServerError() *ListJobQueuesInternalServerError { + + return &ListJobQueuesInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the list job queues internal server error response +func (o *ListJobQueuesInternalServerError) WithXRequestID(xRequestID string) *ListJobQueuesInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list job queues internal server error response +func (o *ListJobQueuesInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list job queues internal server error response +func (o *ListJobQueuesInternalServerError) WithPayload(payload *models.Errors) *ListJobQueuesInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list job queues internal server error response +func (o *ListJobQueuesInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListJobQueuesInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/jobservice/list_job_queues_urlbuilder.go b/src/server/v2.0/restapi/operations/jobservice/list_job_queues_urlbuilder.go new file mode 100644 index 000000000..cb5379c19 --- /dev/null +++ b/src/server/v2.0/restapi/operations/jobservice/list_job_queues_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package jobservice + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// ListJobQueuesURL generates an URL for the list job queues operation +type ListJobQueuesURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListJobQueuesURL) WithBasePath(bp string) *ListJobQueuesURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListJobQueuesURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ListJobQueuesURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/jobservice/queues" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ListJobQueuesURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ListJobQueuesURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ListJobQueuesURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ListJobQueuesURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ListJobQueuesURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ListJobQueuesURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/jobservice/stop_running_job.go b/src/server/v2.0/restapi/operations/jobservice/stop_running_job.go new file mode 100644 index 000000000..6f56c21d5 --- /dev/null +++ b/src/server/v2.0/restapi/operations/jobservice/stop_running_job.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package jobservice + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// StopRunningJobHandlerFunc turns a function with the right signature into a stop running job handler +type StopRunningJobHandlerFunc func(StopRunningJobParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn StopRunningJobHandlerFunc) Handle(params StopRunningJobParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// StopRunningJobHandler interface for that can handle valid stop running job params +type StopRunningJobHandler interface { + Handle(StopRunningJobParams, interface{}) middleware.Responder +} + +// NewStopRunningJob creates a new http.Handler for the stop running job operation +func NewStopRunningJob(ctx *middleware.Context, handler StopRunningJobHandler) *StopRunningJob { + return &StopRunningJob{Context: ctx, Handler: handler} +} + +/*StopRunningJob swagger:route PUT /jobservice/jobs/{job_id} jobservice stopRunningJob + +Stop running job + +Stop running job + +*/ +type StopRunningJob struct { + Context *middleware.Context + Handler StopRunningJobHandler +} + +func (o *StopRunningJob) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewStopRunningJobParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/jobservice/stop_running_job_parameters.go b/src/server/v2.0/restapi/operations/jobservice/stop_running_job_parameters.go new file mode 100644 index 000000000..1927970f7 --- /dev/null +++ b/src/server/v2.0/restapi/operations/jobservice/stop_running_job_parameters.go @@ -0,0 +1,114 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package jobservice + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewStopRunningJobParams creates a new StopRunningJobParams object +// no default values defined in spec. +func NewStopRunningJobParams() StopRunningJobParams { + + return StopRunningJobParams{} +} + +// StopRunningJobParams contains all the bound params for the stop running job operation +// typically these are obtained from a http.Request +// +// swagger:parameters stopRunningJob +type StopRunningJobParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The id of the job. + Required: true + In: path + */ + JobID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewStopRunningJobParams() beforehand. +func (o *StopRunningJobParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rJobID, rhkJobID, _ := route.Params.GetOK("job_id") + if err := o.bindJobID(rJobID, rhkJobID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *StopRunningJobParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *StopRunningJobParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindJobID binds and validates parameter JobID from path. +func (o *StopRunningJobParams) bindJobID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.JobID = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/jobservice/stop_running_job_responses.go b/src/server/v2.0/restapi/operations/jobservice/stop_running_job_responses.go new file mode 100644 index 000000000..87e437926 --- /dev/null +++ b/src/server/v2.0/restapi/operations/jobservice/stop_running_job_responses.go @@ -0,0 +1,302 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package jobservice + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// StopRunningJobOKCode is the HTTP code returned for type StopRunningJobOK +const StopRunningJobOKCode int = 200 + +/*StopRunningJobOK Stop worker successfully. + +swagger:response stopRunningJobOK +*/ +type StopRunningJobOK struct { +} + +// NewStopRunningJobOK creates StopRunningJobOK with default headers values +func NewStopRunningJobOK() *StopRunningJobOK { + + return &StopRunningJobOK{} +} + +// WriteResponse to the client +func (o *StopRunningJobOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// StopRunningJobUnauthorizedCode is the HTTP code returned for type StopRunningJobUnauthorized +const StopRunningJobUnauthorizedCode int = 401 + +/*StopRunningJobUnauthorized Unauthorized + +swagger:response stopRunningJobUnauthorized +*/ +type StopRunningJobUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewStopRunningJobUnauthorized creates StopRunningJobUnauthorized with default headers values +func NewStopRunningJobUnauthorized() *StopRunningJobUnauthorized { + + return &StopRunningJobUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the stop running job unauthorized response +func (o *StopRunningJobUnauthorized) WithXRequestID(xRequestID string) *StopRunningJobUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the stop running job unauthorized response +func (o *StopRunningJobUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the stop running job unauthorized response +func (o *StopRunningJobUnauthorized) WithPayload(payload *models.Errors) *StopRunningJobUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the stop running job unauthorized response +func (o *StopRunningJobUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *StopRunningJobUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// StopRunningJobForbiddenCode is the HTTP code returned for type StopRunningJobForbidden +const StopRunningJobForbiddenCode int = 403 + +/*StopRunningJobForbidden Forbidden + +swagger:response stopRunningJobForbidden +*/ +type StopRunningJobForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewStopRunningJobForbidden creates StopRunningJobForbidden with default headers values +func NewStopRunningJobForbidden() *StopRunningJobForbidden { + + return &StopRunningJobForbidden{} +} + +// WithXRequestID adds the xRequestId to the stop running job forbidden response +func (o *StopRunningJobForbidden) WithXRequestID(xRequestID string) *StopRunningJobForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the stop running job forbidden response +func (o *StopRunningJobForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the stop running job forbidden response +func (o *StopRunningJobForbidden) WithPayload(payload *models.Errors) *StopRunningJobForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the stop running job forbidden response +func (o *StopRunningJobForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *StopRunningJobForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// StopRunningJobNotFoundCode is the HTTP code returned for type StopRunningJobNotFound +const StopRunningJobNotFoundCode int = 404 + +/*StopRunningJobNotFound Not found + +swagger:response stopRunningJobNotFound +*/ +type StopRunningJobNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewStopRunningJobNotFound creates StopRunningJobNotFound with default headers values +func NewStopRunningJobNotFound() *StopRunningJobNotFound { + + return &StopRunningJobNotFound{} +} + +// WithXRequestID adds the xRequestId to the stop running job not found response +func (o *StopRunningJobNotFound) WithXRequestID(xRequestID string) *StopRunningJobNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the stop running job not found response +func (o *StopRunningJobNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the stop running job not found response +func (o *StopRunningJobNotFound) WithPayload(payload *models.Errors) *StopRunningJobNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the stop running job not found response +func (o *StopRunningJobNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *StopRunningJobNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// StopRunningJobInternalServerErrorCode is the HTTP code returned for type StopRunningJobInternalServerError +const StopRunningJobInternalServerErrorCode int = 500 + +/*StopRunningJobInternalServerError Internal server error + +swagger:response stopRunningJobInternalServerError +*/ +type StopRunningJobInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewStopRunningJobInternalServerError creates StopRunningJobInternalServerError with default headers values +func NewStopRunningJobInternalServerError() *StopRunningJobInternalServerError { + + return &StopRunningJobInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the stop running job internal server error response +func (o *StopRunningJobInternalServerError) WithXRequestID(xRequestID string) *StopRunningJobInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the stop running job internal server error response +func (o *StopRunningJobInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the stop running job internal server error response +func (o *StopRunningJobInternalServerError) WithPayload(payload *models.Errors) *StopRunningJobInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the stop running job internal server error response +func (o *StopRunningJobInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *StopRunningJobInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/jobservice/stop_running_job_urlbuilder.go b/src/server/v2.0/restapi/operations/jobservice/stop_running_job_urlbuilder.go new file mode 100644 index 000000000..804fb437f --- /dev/null +++ b/src/server/v2.0/restapi/operations/jobservice/stop_running_job_urlbuilder.go @@ -0,0 +1,99 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package jobservice + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// StopRunningJobURL generates an URL for the stop running job operation +type StopRunningJobURL struct { + JobID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *StopRunningJobURL) WithBasePath(bp string) *StopRunningJobURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *StopRunningJobURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *StopRunningJobURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/jobservice/jobs/{job_id}" + + jobID := o.JobID + if jobID != "" { + _path = strings.Replace(_path, "{job_id}", jobID, -1) + } else { + return nil, errors.New("jobId is required on StopRunningJobURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *StopRunningJobURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *StopRunningJobURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *StopRunningJobURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on StopRunningJobURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on StopRunningJobURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *StopRunningJobURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/label/create_label.go b/src/server/v2.0/restapi/operations/label/create_label.go new file mode 100644 index 000000000..3bff974d0 --- /dev/null +++ b/src/server/v2.0/restapi/operations/label/create_label.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package label + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateLabelHandlerFunc turns a function with the right signature into a create label handler +type CreateLabelHandlerFunc func(CreateLabelParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateLabelHandlerFunc) Handle(params CreateLabelParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateLabelHandler interface for that can handle valid create label params +type CreateLabelHandler interface { + Handle(CreateLabelParams, interface{}) middleware.Responder +} + +// NewCreateLabel creates a new http.Handler for the create label operation +func NewCreateLabel(ctx *middleware.Context, handler CreateLabelHandler) *CreateLabel { + return &CreateLabel{Context: ctx, Handler: handler} +} + +/*CreateLabel swagger:route POST /labels label createLabel + +Post creates a label + +This endpoint let user creates a label. + + +*/ +type CreateLabel struct { + Context *middleware.Context + Handler CreateLabelHandler +} + +func (o *CreateLabel) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewCreateLabelParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/label/create_label_parameters.go b/src/server/v2.0/restapi/operations/label/create_label_parameters.go new file mode 100644 index 000000000..db7f843ea --- /dev/null +++ b/src/server/v2.0/restapi/operations/label/create_label_parameters.go @@ -0,0 +1,120 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package label + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewCreateLabelParams creates a new CreateLabelParams object +// no default values defined in spec. +func NewCreateLabelParams() CreateLabelParams { + + return CreateLabelParams{} +} + +// CreateLabelParams contains all the bound params for the create label operation +// typically these are obtained from a http.Request +// +// swagger:parameters CreateLabel +type CreateLabelParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The json object of label. + Required: true + In: body + */ + Label *models.Label +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateLabelParams() beforehand. +func (o *CreateLabelParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Label + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("label", "body", "")) + } else { + res = append(res, errors.NewParseError("label", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Label = &body + } + } + } else { + res = append(res, errors.Required("label", "body", "")) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *CreateLabelParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *CreateLabelParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} diff --git a/src/server/v2.0/restapi/operations/label/create_label_responses.go b/src/server/v2.0/restapi/operations/label/create_label_responses.go new file mode 100644 index 000000000..f5c88045a --- /dev/null +++ b/src/server/v2.0/restapi/operations/label/create_label_responses.go @@ -0,0 +1,390 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package label + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// CreateLabelCreatedCode is the HTTP code returned for type CreateLabelCreated +const CreateLabelCreatedCode int = 201 + +/*CreateLabelCreated Create successfully. + +swagger:response createLabelCreated +*/ +type CreateLabelCreated struct { + /*The URL of the created resource + + */ + Location string `json:"Location"` +} + +// NewCreateLabelCreated creates CreateLabelCreated with default headers values +func NewCreateLabelCreated() *CreateLabelCreated { + + return &CreateLabelCreated{} +} + +// WithLocation adds the location to the create label created response +func (o *CreateLabelCreated) WithLocation(location string) *CreateLabelCreated { + o.Location = location + return o +} + +// SetLocation sets the location to the create label created response +func (o *CreateLabelCreated) SetLocation(location string) { + o.Location = location +} + +// WriteResponse to the client +func (o *CreateLabelCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Location + + location := o.Location + if location != "" { + rw.Header().Set("Location", location) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(201) +} + +// CreateLabelBadRequestCode is the HTTP code returned for type CreateLabelBadRequest +const CreateLabelBadRequestCode int = 400 + +/*CreateLabelBadRequest Bad request + +swagger:response createLabelBadRequest +*/ +type CreateLabelBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateLabelBadRequest creates CreateLabelBadRequest with default headers values +func NewCreateLabelBadRequest() *CreateLabelBadRequest { + + return &CreateLabelBadRequest{} +} + +// WithXRequestID adds the xRequestId to the create label bad request response +func (o *CreateLabelBadRequest) WithXRequestID(xRequestID string) *CreateLabelBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create label bad request response +func (o *CreateLabelBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create label bad request response +func (o *CreateLabelBadRequest) WithPayload(payload *models.Errors) *CreateLabelBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create label bad request response +func (o *CreateLabelBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateLabelBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateLabelUnauthorizedCode is the HTTP code returned for type CreateLabelUnauthorized +const CreateLabelUnauthorizedCode int = 401 + +/*CreateLabelUnauthorized Unauthorized + +swagger:response createLabelUnauthorized +*/ +type CreateLabelUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateLabelUnauthorized creates CreateLabelUnauthorized with default headers values +func NewCreateLabelUnauthorized() *CreateLabelUnauthorized { + + return &CreateLabelUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the create label unauthorized response +func (o *CreateLabelUnauthorized) WithXRequestID(xRequestID string) *CreateLabelUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create label unauthorized response +func (o *CreateLabelUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create label unauthorized response +func (o *CreateLabelUnauthorized) WithPayload(payload *models.Errors) *CreateLabelUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create label unauthorized response +func (o *CreateLabelUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateLabelUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateLabelConflictCode is the HTTP code returned for type CreateLabelConflict +const CreateLabelConflictCode int = 409 + +/*CreateLabelConflict Conflict + +swagger:response createLabelConflict +*/ +type CreateLabelConflict struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateLabelConflict creates CreateLabelConflict with default headers values +func NewCreateLabelConflict() *CreateLabelConflict { + + return &CreateLabelConflict{} +} + +// WithXRequestID adds the xRequestId to the create label conflict response +func (o *CreateLabelConflict) WithXRequestID(xRequestID string) *CreateLabelConflict { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create label conflict response +func (o *CreateLabelConflict) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create label conflict response +func (o *CreateLabelConflict) WithPayload(payload *models.Errors) *CreateLabelConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create label conflict response +func (o *CreateLabelConflict) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateLabelConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateLabelUnsupportedMediaTypeCode is the HTTP code returned for type CreateLabelUnsupportedMediaType +const CreateLabelUnsupportedMediaTypeCode int = 415 + +/*CreateLabelUnsupportedMediaType Unsupported MediaType + +swagger:response createLabelUnsupportedMediaType +*/ +type CreateLabelUnsupportedMediaType struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateLabelUnsupportedMediaType creates CreateLabelUnsupportedMediaType with default headers values +func NewCreateLabelUnsupportedMediaType() *CreateLabelUnsupportedMediaType { + + return &CreateLabelUnsupportedMediaType{} +} + +// WithXRequestID adds the xRequestId to the create label unsupported media type response +func (o *CreateLabelUnsupportedMediaType) WithXRequestID(xRequestID string) *CreateLabelUnsupportedMediaType { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create label unsupported media type response +func (o *CreateLabelUnsupportedMediaType) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create label unsupported media type response +func (o *CreateLabelUnsupportedMediaType) WithPayload(payload *models.Errors) *CreateLabelUnsupportedMediaType { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create label unsupported media type response +func (o *CreateLabelUnsupportedMediaType) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateLabelUnsupportedMediaType) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(415) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateLabelInternalServerErrorCode is the HTTP code returned for type CreateLabelInternalServerError +const CreateLabelInternalServerErrorCode int = 500 + +/*CreateLabelInternalServerError Internal server error + +swagger:response createLabelInternalServerError +*/ +type CreateLabelInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateLabelInternalServerError creates CreateLabelInternalServerError with default headers values +func NewCreateLabelInternalServerError() *CreateLabelInternalServerError { + + return &CreateLabelInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the create label internal server error response +func (o *CreateLabelInternalServerError) WithXRequestID(xRequestID string) *CreateLabelInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create label internal server error response +func (o *CreateLabelInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create label internal server error response +func (o *CreateLabelInternalServerError) WithPayload(payload *models.Errors) *CreateLabelInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create label internal server error response +func (o *CreateLabelInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateLabelInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/label/create_label_urlbuilder.go b/src/server/v2.0/restapi/operations/label/create_label_urlbuilder.go new file mode 100644 index 000000000..28004367f --- /dev/null +++ b/src/server/v2.0/restapi/operations/label/create_label_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package label + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// CreateLabelURL generates an URL for the create label operation +type CreateLabelURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateLabelURL) WithBasePath(bp string) *CreateLabelURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateLabelURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateLabelURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/labels" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateLabelURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateLabelURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateLabelURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateLabelURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateLabelURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateLabelURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/label/delete_label.go b/src/server/v2.0/restapi/operations/label/delete_label.go new file mode 100644 index 000000000..03f4872ae --- /dev/null +++ b/src/server/v2.0/restapi/operations/label/delete_label.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package label + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteLabelHandlerFunc turns a function with the right signature into a delete label handler +type DeleteLabelHandlerFunc func(DeleteLabelParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteLabelHandlerFunc) Handle(params DeleteLabelParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteLabelHandler interface for that can handle valid delete label params +type DeleteLabelHandler interface { + Handle(DeleteLabelParams, interface{}) middleware.Responder +} + +// NewDeleteLabel creates a new http.Handler for the delete label operation +func NewDeleteLabel(ctx *middleware.Context, handler DeleteLabelHandler) *DeleteLabel { + return &DeleteLabel{Context: ctx, Handler: handler} +} + +/*DeleteLabel swagger:route DELETE /labels/{label_id} label deleteLabel + +Delete the label specified by ID. + +Delete the label specified by ID. + + +*/ +type DeleteLabel struct { + Context *middleware.Context + Handler DeleteLabelHandler +} + +func (o *DeleteLabel) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewDeleteLabelParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/label/delete_label_parameters.go b/src/server/v2.0/restapi/operations/label/delete_label_parameters.go new file mode 100644 index 000000000..9e7d5a6e5 --- /dev/null +++ b/src/server/v2.0/restapi/operations/label/delete_label_parameters.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package label + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewDeleteLabelParams creates a new DeleteLabelParams object +// no default values defined in spec. +func NewDeleteLabelParams() DeleteLabelParams { + + return DeleteLabelParams{} +} + +// DeleteLabelParams contains all the bound params for the delete label operation +// typically these are obtained from a http.Request +// +// swagger:parameters DeleteLabel +type DeleteLabelParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*Label ID + Required: true + In: path + */ + LabelID int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteLabelParams() beforehand. +func (o *DeleteLabelParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rLabelID, rhkLabelID, _ := route.Params.GetOK("label_id") + if err := o.bindLabelID(rLabelID, rhkLabelID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *DeleteLabelParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *DeleteLabelParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindLabelID binds and validates parameter LabelID from path. +func (o *DeleteLabelParams) bindLabelID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("label_id", "path", "int64", raw) + } + o.LabelID = value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/label/delete_label_responses.go b/src/server/v2.0/restapi/operations/label/delete_label_responses.go new file mode 100644 index 000000000..19b86ceeb --- /dev/null +++ b/src/server/v2.0/restapi/operations/label/delete_label_responses.go @@ -0,0 +1,324 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package label + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// DeleteLabelOKCode is the HTTP code returned for type DeleteLabelOK +const DeleteLabelOKCode int = 200 + +/*DeleteLabelOK Success + +swagger:response deleteLabelOK +*/ +type DeleteLabelOK struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewDeleteLabelOK creates DeleteLabelOK with default headers values +func NewDeleteLabelOK() *DeleteLabelOK { + + return &DeleteLabelOK{} +} + +// WithXRequestID adds the xRequestId to the delete label o k response +func (o *DeleteLabelOK) WithXRequestID(xRequestID string) *DeleteLabelOK { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete label o k response +func (o *DeleteLabelOK) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *DeleteLabelOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// DeleteLabelBadRequestCode is the HTTP code returned for type DeleteLabelBadRequest +const DeleteLabelBadRequestCode int = 400 + +/*DeleteLabelBadRequest Bad request + +swagger:response deleteLabelBadRequest +*/ +type DeleteLabelBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteLabelBadRequest creates DeleteLabelBadRequest with default headers values +func NewDeleteLabelBadRequest() *DeleteLabelBadRequest { + + return &DeleteLabelBadRequest{} +} + +// WithXRequestID adds the xRequestId to the delete label bad request response +func (o *DeleteLabelBadRequest) WithXRequestID(xRequestID string) *DeleteLabelBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete label bad request response +func (o *DeleteLabelBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete label bad request response +func (o *DeleteLabelBadRequest) WithPayload(payload *models.Errors) *DeleteLabelBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete label bad request response +func (o *DeleteLabelBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteLabelBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteLabelUnauthorizedCode is the HTTP code returned for type DeleteLabelUnauthorized +const DeleteLabelUnauthorizedCode int = 401 + +/*DeleteLabelUnauthorized Unauthorized + +swagger:response deleteLabelUnauthorized +*/ +type DeleteLabelUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteLabelUnauthorized creates DeleteLabelUnauthorized with default headers values +func NewDeleteLabelUnauthorized() *DeleteLabelUnauthorized { + + return &DeleteLabelUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the delete label unauthorized response +func (o *DeleteLabelUnauthorized) WithXRequestID(xRequestID string) *DeleteLabelUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete label unauthorized response +func (o *DeleteLabelUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete label unauthorized response +func (o *DeleteLabelUnauthorized) WithPayload(payload *models.Errors) *DeleteLabelUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete label unauthorized response +func (o *DeleteLabelUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteLabelUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteLabelNotFoundCode is the HTTP code returned for type DeleteLabelNotFound +const DeleteLabelNotFoundCode int = 404 + +/*DeleteLabelNotFound Not found + +swagger:response deleteLabelNotFound +*/ +type DeleteLabelNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteLabelNotFound creates DeleteLabelNotFound with default headers values +func NewDeleteLabelNotFound() *DeleteLabelNotFound { + + return &DeleteLabelNotFound{} +} + +// WithXRequestID adds the xRequestId to the delete label not found response +func (o *DeleteLabelNotFound) WithXRequestID(xRequestID string) *DeleteLabelNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete label not found response +func (o *DeleteLabelNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete label not found response +func (o *DeleteLabelNotFound) WithPayload(payload *models.Errors) *DeleteLabelNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete label not found response +func (o *DeleteLabelNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteLabelNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteLabelInternalServerErrorCode is the HTTP code returned for type DeleteLabelInternalServerError +const DeleteLabelInternalServerErrorCode int = 500 + +/*DeleteLabelInternalServerError Internal server error + +swagger:response deleteLabelInternalServerError +*/ +type DeleteLabelInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteLabelInternalServerError creates DeleteLabelInternalServerError with default headers values +func NewDeleteLabelInternalServerError() *DeleteLabelInternalServerError { + + return &DeleteLabelInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the delete label internal server error response +func (o *DeleteLabelInternalServerError) WithXRequestID(xRequestID string) *DeleteLabelInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete label internal server error response +func (o *DeleteLabelInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete label internal server error response +func (o *DeleteLabelInternalServerError) WithPayload(payload *models.Errors) *DeleteLabelInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete label internal server error response +func (o *DeleteLabelInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteLabelInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/label/delete_label_urlbuilder.go b/src/server/v2.0/restapi/operations/label/delete_label_urlbuilder.go new file mode 100644 index 000000000..3462705b1 --- /dev/null +++ b/src/server/v2.0/restapi/operations/label/delete_label_urlbuilder.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package label + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteLabelURL generates an URL for the delete label operation +type DeleteLabelURL struct { + LabelID int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteLabelURL) WithBasePath(bp string) *DeleteLabelURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteLabelURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteLabelURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/labels/{label_id}" + + labelID := swag.FormatInt64(o.LabelID) + if labelID != "" { + _path = strings.Replace(_path, "{label_id}", labelID, -1) + } else { + return nil, errors.New("labelId is required on DeleteLabelURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteLabelURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteLabelURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteLabelURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteLabelURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteLabelURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteLabelURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/label/get_label_by_id.go b/src/server/v2.0/restapi/operations/label/get_label_by_id.go new file mode 100644 index 000000000..b3a23eb99 --- /dev/null +++ b/src/server/v2.0/restapi/operations/label/get_label_by_id.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package label + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetLabelByIDHandlerFunc turns a function with the right signature into a get label by ID handler +type GetLabelByIDHandlerFunc func(GetLabelByIDParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetLabelByIDHandlerFunc) Handle(params GetLabelByIDParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetLabelByIDHandler interface for that can handle valid get label by ID params +type GetLabelByIDHandler interface { + Handle(GetLabelByIDParams, interface{}) middleware.Responder +} + +// NewGetLabelByID creates a new http.Handler for the get label by ID operation +func NewGetLabelByID(ctx *middleware.Context, handler GetLabelByIDHandler) *GetLabelByID { + return &GetLabelByID{Context: ctx, Handler: handler} +} + +/*GetLabelByID swagger:route GET /labels/{label_id} label getLabelById + +Get the label specified by ID. + +This endpoint let user get the label by specific ID. + + +*/ +type GetLabelByID struct { + Context *middleware.Context + Handler GetLabelByIDHandler +} + +func (o *GetLabelByID) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetLabelByIDParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/label/get_label_by_id_parameters.go b/src/server/v2.0/restapi/operations/label/get_label_by_id_parameters.go new file mode 100644 index 000000000..0fd9467bb --- /dev/null +++ b/src/server/v2.0/restapi/operations/label/get_label_by_id_parameters.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package label + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewGetLabelByIDParams creates a new GetLabelByIDParams object +// no default values defined in spec. +func NewGetLabelByIDParams() GetLabelByIDParams { + + return GetLabelByIDParams{} +} + +// GetLabelByIDParams contains all the bound params for the get label by ID operation +// typically these are obtained from a http.Request +// +// swagger:parameters GetLabelByID +type GetLabelByIDParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*Label ID + Required: true + In: path + */ + LabelID int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetLabelByIDParams() beforehand. +func (o *GetLabelByIDParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rLabelID, rhkLabelID, _ := route.Params.GetOK("label_id") + if err := o.bindLabelID(rLabelID, rhkLabelID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetLabelByIDParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetLabelByIDParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindLabelID binds and validates parameter LabelID from path. +func (o *GetLabelByIDParams) bindLabelID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("label_id", "path", "int64", raw) + } + o.LabelID = value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/label/get_label_by_id_responses.go b/src/server/v2.0/restapi/operations/label/get_label_by_id_responses.go new file mode 100644 index 000000000..2ee546116 --- /dev/null +++ b/src/server/v2.0/restapi/operations/label/get_label_by_id_responses.go @@ -0,0 +1,256 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package label + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetLabelByIDOKCode is the HTTP code returned for type GetLabelByIDOK +const GetLabelByIDOKCode int = 200 + +/*GetLabelByIDOK Get successfully. + +swagger:response getLabelByIdOK +*/ +type GetLabelByIDOK struct { + + /* + In: Body + */ + Payload *models.Label `json:"body,omitempty"` +} + +// NewGetLabelByIDOK creates GetLabelByIDOK with default headers values +func NewGetLabelByIDOK() *GetLabelByIDOK { + + return &GetLabelByIDOK{} +} + +// WithPayload adds the payload to the get label by Id o k response +func (o *GetLabelByIDOK) WithPayload(payload *models.Label) *GetLabelByIDOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get label by Id o k response +func (o *GetLabelByIDOK) SetPayload(payload *models.Label) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLabelByIDOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetLabelByIDUnauthorizedCode is the HTTP code returned for type GetLabelByIDUnauthorized +const GetLabelByIDUnauthorizedCode int = 401 + +/*GetLabelByIDUnauthorized Unauthorized + +swagger:response getLabelByIdUnauthorized +*/ +type GetLabelByIDUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetLabelByIDUnauthorized creates GetLabelByIDUnauthorized with default headers values +func NewGetLabelByIDUnauthorized() *GetLabelByIDUnauthorized { + + return &GetLabelByIDUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the get label by Id unauthorized response +func (o *GetLabelByIDUnauthorized) WithXRequestID(xRequestID string) *GetLabelByIDUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get label by Id unauthorized response +func (o *GetLabelByIDUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get label by Id unauthorized response +func (o *GetLabelByIDUnauthorized) WithPayload(payload *models.Errors) *GetLabelByIDUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get label by Id unauthorized response +func (o *GetLabelByIDUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLabelByIDUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetLabelByIDNotFoundCode is the HTTP code returned for type GetLabelByIDNotFound +const GetLabelByIDNotFoundCode int = 404 + +/*GetLabelByIDNotFound Not found + +swagger:response getLabelByIdNotFound +*/ +type GetLabelByIDNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetLabelByIDNotFound creates GetLabelByIDNotFound with default headers values +func NewGetLabelByIDNotFound() *GetLabelByIDNotFound { + + return &GetLabelByIDNotFound{} +} + +// WithXRequestID adds the xRequestId to the get label by Id not found response +func (o *GetLabelByIDNotFound) WithXRequestID(xRequestID string) *GetLabelByIDNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get label by Id not found response +func (o *GetLabelByIDNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get label by Id not found response +func (o *GetLabelByIDNotFound) WithPayload(payload *models.Errors) *GetLabelByIDNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get label by Id not found response +func (o *GetLabelByIDNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLabelByIDNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetLabelByIDInternalServerErrorCode is the HTTP code returned for type GetLabelByIDInternalServerError +const GetLabelByIDInternalServerErrorCode int = 500 + +/*GetLabelByIDInternalServerError Internal server error + +swagger:response getLabelByIdInternalServerError +*/ +type GetLabelByIDInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetLabelByIDInternalServerError creates GetLabelByIDInternalServerError with default headers values +func NewGetLabelByIDInternalServerError() *GetLabelByIDInternalServerError { + + return &GetLabelByIDInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get label by Id internal server error response +func (o *GetLabelByIDInternalServerError) WithXRequestID(xRequestID string) *GetLabelByIDInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get label by Id internal server error response +func (o *GetLabelByIDInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get label by Id internal server error response +func (o *GetLabelByIDInternalServerError) WithPayload(payload *models.Errors) *GetLabelByIDInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get label by Id internal server error response +func (o *GetLabelByIDInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLabelByIDInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/label/get_label_by_id_urlbuilder.go b/src/server/v2.0/restapi/operations/label/get_label_by_id_urlbuilder.go new file mode 100644 index 000000000..92aeb952c --- /dev/null +++ b/src/server/v2.0/restapi/operations/label/get_label_by_id_urlbuilder.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package label + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetLabelByIDURL generates an URL for the get label by ID operation +type GetLabelByIDURL struct { + LabelID int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetLabelByIDURL) WithBasePath(bp string) *GetLabelByIDURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetLabelByIDURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetLabelByIDURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/labels/{label_id}" + + labelID := swag.FormatInt64(o.LabelID) + if labelID != "" { + _path = strings.Replace(_path, "{label_id}", labelID, -1) + } else { + return nil, errors.New("labelId is required on GetLabelByIDURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetLabelByIDURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetLabelByIDURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetLabelByIDURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetLabelByIDURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetLabelByIDURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetLabelByIDURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/label/list_labels.go b/src/server/v2.0/restapi/operations/label/list_labels.go new file mode 100644 index 000000000..098cf177e --- /dev/null +++ b/src/server/v2.0/restapi/operations/label/list_labels.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package label + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ListLabelsHandlerFunc turns a function with the right signature into a list labels handler +type ListLabelsHandlerFunc func(ListLabelsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ListLabelsHandlerFunc) Handle(params ListLabelsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ListLabelsHandler interface for that can handle valid list labels params +type ListLabelsHandler interface { + Handle(ListLabelsParams, interface{}) middleware.Responder +} + +// NewListLabels creates a new http.Handler for the list labels operation +func NewListLabels(ctx *middleware.Context, handler ListLabelsHandler) *ListLabels { + return &ListLabels{Context: ctx, Handler: handler} +} + +/*ListLabels swagger:route GET /labels label listLabels + +List labels according to the query strings. + +This endpoint let user list labels by name, scope and project_id + + +*/ +type ListLabels struct { + Context *middleware.Context + Handler ListLabelsHandler +} + +func (o *ListLabels) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewListLabelsParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/label/list_labels_parameters.go b/src/server/v2.0/restapi/operations/label/list_labels_parameters.go new file mode 100644 index 000000000..4c780c687 --- /dev/null +++ b/src/server/v2.0/restapi/operations/label/list_labels_parameters.go @@ -0,0 +1,324 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package label + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewListLabelsParams creates a new ListLabelsParams object +// with the default values initialized. +func NewListLabelsParams() ListLabelsParams { + + var ( + // initialize parameters with default values + + pageDefault = int64(1) + pageSizeDefault = int64(10) + ) + + return ListLabelsParams{ + Page: &pageDefault, + + PageSize: &pageSizeDefault, + } +} + +// ListLabelsParams contains all the bound params for the list labels operation +// typically these are obtained from a http.Request +// +// swagger:parameters ListLabels +type ListLabelsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The label name. + In: query + */ + Name *string + /*The page number + In: query + Default: 1 + */ + Page *int64 + /*The size of per page + Maximum: 100 + In: query + Default: 10 + */ + PageSize *int64 + /*Relevant project ID, required when scope is p. + In: query + */ + ProjectID *int64 + /*Query string to query resources. Supported query patterns are "exact match(k=v)", "fuzzy match(k=~v)", "range(k=[min~max])", "list with union releationship(k={v1 v2 v3})" and "list with intersetion relationship(k=(v1 v2 v3))". The value of range and list can be string(enclosed by " or '), integer or time(in format "2020-04-09 02:36:00"). All of these query patterns should be put in the query string "q=xxx" and splitted by ",". e.g. q=k1=v1,k2=~v2,k3=[min~max] + In: query + */ + Q *string + /*The label scope. Valid values are g and p. g for global labels and p for project labels. + In: query + */ + Scope *string + /*Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + In: query + */ + Sort *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewListLabelsParams() beforehand. +func (o *ListLabelsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + qName, qhkName, _ := qs.GetOK("name") + if err := o.bindName(qName, qhkName, route.Formats); err != nil { + res = append(res, err) + } + + qPage, qhkPage, _ := qs.GetOK("page") + if err := o.bindPage(qPage, qhkPage, route.Formats); err != nil { + res = append(res, err) + } + + qPageSize, qhkPageSize, _ := qs.GetOK("page_size") + if err := o.bindPageSize(qPageSize, qhkPageSize, route.Formats); err != nil { + res = append(res, err) + } + + qProjectID, qhkProjectID, _ := qs.GetOK("project_id") + if err := o.bindProjectID(qProjectID, qhkProjectID, route.Formats); err != nil { + res = append(res, err) + } + + qQ, qhkQ, _ := qs.GetOK("q") + if err := o.bindQ(qQ, qhkQ, route.Formats); err != nil { + res = append(res, err) + } + + qScope, qhkScope, _ := qs.GetOK("scope") + if err := o.bindScope(qScope, qhkScope, route.Formats); err != nil { + res = append(res, err) + } + + qSort, qhkSort, _ := qs.GetOK("sort") + if err := o.bindSort(qSort, qhkSort, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *ListLabelsParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *ListLabelsParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindName binds and validates parameter Name from query. +func (o *ListLabelsParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Name = &raw + + return nil +} + +// bindPage binds and validates parameter Page from query. +func (o *ListLabelsParams) bindPage(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListLabelsParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page", "query", "int64", raw) + } + o.Page = &value + + return nil +} + +// bindPageSize binds and validates parameter PageSize from query. +func (o *ListLabelsParams) bindPageSize(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListLabelsParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page_size", "query", "int64", raw) + } + o.PageSize = &value + + if err := o.validatePageSize(formats); err != nil { + return err + } + + return nil +} + +// validatePageSize carries on validations for parameter PageSize +func (o *ListLabelsParams) validatePageSize(formats strfmt.Registry) error { + + if err := validate.MaximumInt("page_size", "query", int64(*o.PageSize), 100, false); err != nil { + return err + } + + return nil +} + +// bindProjectID binds and validates parameter ProjectID from query. +func (o *ListLabelsParams) bindProjectID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("project_id", "query", "int64", raw) + } + o.ProjectID = &value + + return nil +} + +// bindQ binds and validates parameter Q from query. +func (o *ListLabelsParams) bindQ(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Q = &raw + + return nil +} + +// bindScope binds and validates parameter Scope from query. +func (o *ListLabelsParams) bindScope(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Scope = &raw + + return nil +} + +// bindSort binds and validates parameter Sort from query. +func (o *ListLabelsParams) bindSort(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Sort = &raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/label/list_labels_responses.go b/src/server/v2.0/restapi/operations/label/list_labels_responses.go new file mode 100644 index 000000000..b64e01e76 --- /dev/null +++ b/src/server/v2.0/restapi/operations/label/list_labels_responses.go @@ -0,0 +1,304 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package label + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/swag" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// ListLabelsOKCode is the HTTP code returned for type ListLabelsOK +const ListLabelsOKCode int = 200 + +/*ListLabelsOK Get successfully. + +swagger:response listLabelsOK +*/ +type ListLabelsOK struct { + /*Link to previous page and next page + + */ + Link string `json:"Link"` + /*The total count of available items + + */ + XTotalCount int64 `json:"X-Total-Count"` + + /* + In: Body + */ + Payload []*models.Label `json:"body,omitempty"` +} + +// NewListLabelsOK creates ListLabelsOK with default headers values +func NewListLabelsOK() *ListLabelsOK { + + return &ListLabelsOK{} +} + +// WithLink adds the link to the list labels o k response +func (o *ListLabelsOK) WithLink(link string) *ListLabelsOK { + o.Link = link + return o +} + +// SetLink sets the link to the list labels o k response +func (o *ListLabelsOK) SetLink(link string) { + o.Link = link +} + +// WithXTotalCount adds the xTotalCount to the list labels o k response +func (o *ListLabelsOK) WithXTotalCount(xTotalCount int64) *ListLabelsOK { + o.XTotalCount = xTotalCount + return o +} + +// SetXTotalCount sets the xTotalCount to the list labels o k response +func (o *ListLabelsOK) SetXTotalCount(xTotalCount int64) { + o.XTotalCount = xTotalCount +} + +// WithPayload adds the payload to the list labels o k response +func (o *ListLabelsOK) WithPayload(payload []*models.Label) *ListLabelsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list labels o k response +func (o *ListLabelsOK) SetPayload(payload []*models.Label) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListLabelsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Link + + link := o.Link + if link != "" { + rw.Header().Set("Link", link) + } + + // response header X-Total-Count + + xTotalCount := swag.FormatInt64(o.XTotalCount) + if xTotalCount != "" { + rw.Header().Set("X-Total-Count", xTotalCount) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = make([]*models.Label, 0, 50) + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ListLabelsBadRequestCode is the HTTP code returned for type ListLabelsBadRequest +const ListLabelsBadRequestCode int = 400 + +/*ListLabelsBadRequest Bad request + +swagger:response listLabelsBadRequest +*/ +type ListLabelsBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListLabelsBadRequest creates ListLabelsBadRequest with default headers values +func NewListLabelsBadRequest() *ListLabelsBadRequest { + + return &ListLabelsBadRequest{} +} + +// WithXRequestID adds the xRequestId to the list labels bad request response +func (o *ListLabelsBadRequest) WithXRequestID(xRequestID string) *ListLabelsBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list labels bad request response +func (o *ListLabelsBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list labels bad request response +func (o *ListLabelsBadRequest) WithPayload(payload *models.Errors) *ListLabelsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list labels bad request response +func (o *ListLabelsBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListLabelsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListLabelsUnauthorizedCode is the HTTP code returned for type ListLabelsUnauthorized +const ListLabelsUnauthorizedCode int = 401 + +/*ListLabelsUnauthorized Unauthorized + +swagger:response listLabelsUnauthorized +*/ +type ListLabelsUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListLabelsUnauthorized creates ListLabelsUnauthorized with default headers values +func NewListLabelsUnauthorized() *ListLabelsUnauthorized { + + return &ListLabelsUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the list labels unauthorized response +func (o *ListLabelsUnauthorized) WithXRequestID(xRequestID string) *ListLabelsUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list labels unauthorized response +func (o *ListLabelsUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list labels unauthorized response +func (o *ListLabelsUnauthorized) WithPayload(payload *models.Errors) *ListLabelsUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list labels unauthorized response +func (o *ListLabelsUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListLabelsUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListLabelsInternalServerErrorCode is the HTTP code returned for type ListLabelsInternalServerError +const ListLabelsInternalServerErrorCode int = 500 + +/*ListLabelsInternalServerError Internal server error + +swagger:response listLabelsInternalServerError +*/ +type ListLabelsInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListLabelsInternalServerError creates ListLabelsInternalServerError with default headers values +func NewListLabelsInternalServerError() *ListLabelsInternalServerError { + + return &ListLabelsInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the list labels internal server error response +func (o *ListLabelsInternalServerError) WithXRequestID(xRequestID string) *ListLabelsInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list labels internal server error response +func (o *ListLabelsInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list labels internal server error response +func (o *ListLabelsInternalServerError) WithPayload(payload *models.Errors) *ListLabelsInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list labels internal server error response +func (o *ListLabelsInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListLabelsInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/label/list_labels_urlbuilder.go b/src/server/v2.0/restapi/operations/label/list_labels_urlbuilder.go new file mode 100644 index 000000000..9a3b41b3b --- /dev/null +++ b/src/server/v2.0/restapi/operations/label/list_labels_urlbuilder.go @@ -0,0 +1,159 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package label + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// ListLabelsURL generates an URL for the list labels operation +type ListLabelsURL struct { + Name *string + Page *int64 + PageSize *int64 + ProjectID *int64 + Q *string + Scope *string + Sort *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListLabelsURL) WithBasePath(bp string) *ListLabelsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListLabelsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ListLabelsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/labels" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var nameQ string + if o.Name != nil { + nameQ = *o.Name + } + if nameQ != "" { + qs.Set("name", nameQ) + } + + var pageQ string + if o.Page != nil { + pageQ = swag.FormatInt64(*o.Page) + } + if pageQ != "" { + qs.Set("page", pageQ) + } + + var pageSizeQ string + if o.PageSize != nil { + pageSizeQ = swag.FormatInt64(*o.PageSize) + } + if pageSizeQ != "" { + qs.Set("page_size", pageSizeQ) + } + + var projectIDQ string + if o.ProjectID != nil { + projectIDQ = swag.FormatInt64(*o.ProjectID) + } + if projectIDQ != "" { + qs.Set("project_id", projectIDQ) + } + + var qQ string + if o.Q != nil { + qQ = *o.Q + } + if qQ != "" { + qs.Set("q", qQ) + } + + var scopeQ string + if o.Scope != nil { + scopeQ = *o.Scope + } + if scopeQ != "" { + qs.Set("scope", scopeQ) + } + + var sortQ string + if o.Sort != nil { + sortQ = *o.Sort + } + if sortQ != "" { + qs.Set("sort", sortQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ListLabelsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ListLabelsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ListLabelsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ListLabelsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ListLabelsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ListLabelsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/label/update_label.go b/src/server/v2.0/restapi/operations/label/update_label.go new file mode 100644 index 000000000..25a3864cf --- /dev/null +++ b/src/server/v2.0/restapi/operations/label/update_label.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package label + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// UpdateLabelHandlerFunc turns a function with the right signature into a update label handler +type UpdateLabelHandlerFunc func(UpdateLabelParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn UpdateLabelHandlerFunc) Handle(params UpdateLabelParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// UpdateLabelHandler interface for that can handle valid update label params +type UpdateLabelHandler interface { + Handle(UpdateLabelParams, interface{}) middleware.Responder +} + +// NewUpdateLabel creates a new http.Handler for the update label operation +func NewUpdateLabel(ctx *middleware.Context, handler UpdateLabelHandler) *UpdateLabel { + return &UpdateLabel{Context: ctx, Handler: handler} +} + +/*UpdateLabel swagger:route PUT /labels/{label_id} label updateLabel + +Update the label properties. + +This endpoint let user update label properties. + + +*/ +type UpdateLabel struct { + Context *middleware.Context + Handler UpdateLabelHandler +} + +func (o *UpdateLabel) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewUpdateLabelParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/label/update_label_parameters.go b/src/server/v2.0/restapi/operations/label/update_label_parameters.go new file mode 100644 index 000000000..e0f71d9d2 --- /dev/null +++ b/src/server/v2.0/restapi/operations/label/update_label_parameters.go @@ -0,0 +1,150 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package label + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewUpdateLabelParams creates a new UpdateLabelParams object +// no default values defined in spec. +func NewUpdateLabelParams() UpdateLabelParams { + + return UpdateLabelParams{} +} + +// UpdateLabelParams contains all the bound params for the update label operation +// typically these are obtained from a http.Request +// +// swagger:parameters UpdateLabel +type UpdateLabelParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The updated label json object. + Required: true + In: body + */ + Label *models.Label + /*Label ID + Required: true + In: path + */ + LabelID int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewUpdateLabelParams() beforehand. +func (o *UpdateLabelParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Label + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("label", "body", "")) + } else { + res = append(res, errors.NewParseError("label", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Label = &body + } + } + } else { + res = append(res, errors.Required("label", "body", "")) + } + rLabelID, rhkLabelID, _ := route.Params.GetOK("label_id") + if err := o.bindLabelID(rLabelID, rhkLabelID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *UpdateLabelParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *UpdateLabelParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindLabelID binds and validates parameter LabelID from path. +func (o *UpdateLabelParams) bindLabelID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("label_id", "path", "int64", raw) + } + o.LabelID = value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/label/update_label_responses.go b/src/server/v2.0/restapi/operations/label/update_label_responses.go new file mode 100644 index 000000000..4ea6274d3 --- /dev/null +++ b/src/server/v2.0/restapi/operations/label/update_label_responses.go @@ -0,0 +1,390 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package label + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// UpdateLabelOKCode is the HTTP code returned for type UpdateLabelOK +const UpdateLabelOKCode int = 200 + +/*UpdateLabelOK Success + +swagger:response updateLabelOK +*/ +type UpdateLabelOK struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewUpdateLabelOK creates UpdateLabelOK with default headers values +func NewUpdateLabelOK() *UpdateLabelOK { + + return &UpdateLabelOK{} +} + +// WithXRequestID adds the xRequestId to the update label o k response +func (o *UpdateLabelOK) WithXRequestID(xRequestID string) *UpdateLabelOK { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update label o k response +func (o *UpdateLabelOK) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *UpdateLabelOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// UpdateLabelBadRequestCode is the HTTP code returned for type UpdateLabelBadRequest +const UpdateLabelBadRequestCode int = 400 + +/*UpdateLabelBadRequest Bad request + +swagger:response updateLabelBadRequest +*/ +type UpdateLabelBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateLabelBadRequest creates UpdateLabelBadRequest with default headers values +func NewUpdateLabelBadRequest() *UpdateLabelBadRequest { + + return &UpdateLabelBadRequest{} +} + +// WithXRequestID adds the xRequestId to the update label bad request response +func (o *UpdateLabelBadRequest) WithXRequestID(xRequestID string) *UpdateLabelBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update label bad request response +func (o *UpdateLabelBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update label bad request response +func (o *UpdateLabelBadRequest) WithPayload(payload *models.Errors) *UpdateLabelBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update label bad request response +func (o *UpdateLabelBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateLabelBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateLabelUnauthorizedCode is the HTTP code returned for type UpdateLabelUnauthorized +const UpdateLabelUnauthorizedCode int = 401 + +/*UpdateLabelUnauthorized Unauthorized + +swagger:response updateLabelUnauthorized +*/ +type UpdateLabelUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateLabelUnauthorized creates UpdateLabelUnauthorized with default headers values +func NewUpdateLabelUnauthorized() *UpdateLabelUnauthorized { + + return &UpdateLabelUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the update label unauthorized response +func (o *UpdateLabelUnauthorized) WithXRequestID(xRequestID string) *UpdateLabelUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update label unauthorized response +func (o *UpdateLabelUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update label unauthorized response +func (o *UpdateLabelUnauthorized) WithPayload(payload *models.Errors) *UpdateLabelUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update label unauthorized response +func (o *UpdateLabelUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateLabelUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateLabelNotFoundCode is the HTTP code returned for type UpdateLabelNotFound +const UpdateLabelNotFoundCode int = 404 + +/*UpdateLabelNotFound Not found + +swagger:response updateLabelNotFound +*/ +type UpdateLabelNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateLabelNotFound creates UpdateLabelNotFound with default headers values +func NewUpdateLabelNotFound() *UpdateLabelNotFound { + + return &UpdateLabelNotFound{} +} + +// WithXRequestID adds the xRequestId to the update label not found response +func (o *UpdateLabelNotFound) WithXRequestID(xRequestID string) *UpdateLabelNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update label not found response +func (o *UpdateLabelNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update label not found response +func (o *UpdateLabelNotFound) WithPayload(payload *models.Errors) *UpdateLabelNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update label not found response +func (o *UpdateLabelNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateLabelNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateLabelConflictCode is the HTTP code returned for type UpdateLabelConflict +const UpdateLabelConflictCode int = 409 + +/*UpdateLabelConflict Conflict + +swagger:response updateLabelConflict +*/ +type UpdateLabelConflict struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateLabelConflict creates UpdateLabelConflict with default headers values +func NewUpdateLabelConflict() *UpdateLabelConflict { + + return &UpdateLabelConflict{} +} + +// WithXRequestID adds the xRequestId to the update label conflict response +func (o *UpdateLabelConflict) WithXRequestID(xRequestID string) *UpdateLabelConflict { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update label conflict response +func (o *UpdateLabelConflict) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update label conflict response +func (o *UpdateLabelConflict) WithPayload(payload *models.Errors) *UpdateLabelConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update label conflict response +func (o *UpdateLabelConflict) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateLabelConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateLabelInternalServerErrorCode is the HTTP code returned for type UpdateLabelInternalServerError +const UpdateLabelInternalServerErrorCode int = 500 + +/*UpdateLabelInternalServerError Internal server error + +swagger:response updateLabelInternalServerError +*/ +type UpdateLabelInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateLabelInternalServerError creates UpdateLabelInternalServerError with default headers values +func NewUpdateLabelInternalServerError() *UpdateLabelInternalServerError { + + return &UpdateLabelInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the update label internal server error response +func (o *UpdateLabelInternalServerError) WithXRequestID(xRequestID string) *UpdateLabelInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update label internal server error response +func (o *UpdateLabelInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update label internal server error response +func (o *UpdateLabelInternalServerError) WithPayload(payload *models.Errors) *UpdateLabelInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update label internal server error response +func (o *UpdateLabelInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateLabelInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/label/update_label_urlbuilder.go b/src/server/v2.0/restapi/operations/label/update_label_urlbuilder.go new file mode 100644 index 000000000..e4e107516 --- /dev/null +++ b/src/server/v2.0/restapi/operations/label/update_label_urlbuilder.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package label + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// UpdateLabelURL generates an URL for the update label operation +type UpdateLabelURL struct { + LabelID int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdateLabelURL) WithBasePath(bp string) *UpdateLabelURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdateLabelURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *UpdateLabelURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/labels/{label_id}" + + labelID := swag.FormatInt64(o.LabelID) + if labelID != "" { + _path = strings.Replace(_path, "{label_id}", labelID, -1) + } else { + return nil, errors.New("labelId is required on UpdateLabelURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *UpdateLabelURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *UpdateLabelURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *UpdateLabelURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on UpdateLabelURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on UpdateLabelURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *UpdateLabelURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/ldap/import_ldap_user.go b/src/server/v2.0/restapi/operations/ldap/import_ldap_user.go new file mode 100644 index 000000000..41df6e2c3 --- /dev/null +++ b/src/server/v2.0/restapi/operations/ldap/import_ldap_user.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package ldap + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ImportLdapUserHandlerFunc turns a function with the right signature into a import ldap user handler +type ImportLdapUserHandlerFunc func(ImportLdapUserParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ImportLdapUserHandlerFunc) Handle(params ImportLdapUserParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ImportLdapUserHandler interface for that can handle valid import ldap user params +type ImportLdapUserHandler interface { + Handle(ImportLdapUserParams, interface{}) middleware.Responder +} + +// NewImportLdapUser creates a new http.Handler for the import ldap user operation +func NewImportLdapUser(ctx *middleware.Context, handler ImportLdapUserHandler) *ImportLdapUser { + return &ImportLdapUser{Context: ctx, Handler: handler} +} + +/*ImportLdapUser swagger:route POST /ldap/users/import Ldap importLdapUser + +Import selected available ldap users. + +This endpoint adds the selected available ldap users to harbor based on related configuration parameters from the system. System will try to guess the user email address and realname, add to harbor user information. If have errors when import user, will return the list of importing failed uid and the failed reason. + + +*/ +type ImportLdapUser struct { + Context *middleware.Context + Handler ImportLdapUserHandler +} + +func (o *ImportLdapUser) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewImportLdapUserParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/ldap/import_ldap_user_parameters.go b/src/server/v2.0/restapi/operations/ldap/import_ldap_user_parameters.go new file mode 100644 index 000000000..14902b1ac --- /dev/null +++ b/src/server/v2.0/restapi/operations/ldap/import_ldap_user_parameters.go @@ -0,0 +1,120 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package ldap + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewImportLdapUserParams creates a new ImportLdapUserParams object +// no default values defined in spec. +func NewImportLdapUserParams() ImportLdapUserParams { + + return ImportLdapUserParams{} +} + +// ImportLdapUserParams contains all the bound params for the import ldap user operation +// typically these are obtained from a http.Request +// +// swagger:parameters importLdapUser +type ImportLdapUserParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The uid listed for importing. This list will check users validity of ldap service based on configuration from the system. + Required: true + In: body + */ + UIDList *models.LdapImportUsers +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewImportLdapUserParams() beforehand. +func (o *ImportLdapUserParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.LdapImportUsers + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("uidList", "body", "")) + } else { + res = append(res, errors.NewParseError("uidList", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.UIDList = &body + } + } + } else { + res = append(res, errors.Required("uidList", "body", "")) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *ImportLdapUserParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *ImportLdapUserParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} diff --git a/src/server/v2.0/restapi/operations/ldap/import_ldap_user_responses.go b/src/server/v2.0/restapi/operations/ldap/import_ldap_user_responses.go new file mode 100644 index 000000000..7f0f25e3f --- /dev/null +++ b/src/server/v2.0/restapi/operations/ldap/import_ldap_user_responses.go @@ -0,0 +1,349 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package ldap + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// ImportLdapUserOKCode is the HTTP code returned for type ImportLdapUserOK +const ImportLdapUserOKCode int = 200 + +/*ImportLdapUserOK Add ldap users successfully. + +swagger:response importLdapUserOK +*/ +type ImportLdapUserOK struct { +} + +// NewImportLdapUserOK creates ImportLdapUserOK with default headers values +func NewImportLdapUserOK() *ImportLdapUserOK { + + return &ImportLdapUserOK{} +} + +// WriteResponse to the client +func (o *ImportLdapUserOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// ImportLdapUserBadRequestCode is the HTTP code returned for type ImportLdapUserBadRequest +const ImportLdapUserBadRequestCode int = 400 + +/*ImportLdapUserBadRequest Bad request + +swagger:response importLdapUserBadRequest +*/ +type ImportLdapUserBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewImportLdapUserBadRequest creates ImportLdapUserBadRequest with default headers values +func NewImportLdapUserBadRequest() *ImportLdapUserBadRequest { + + return &ImportLdapUserBadRequest{} +} + +// WithXRequestID adds the xRequestId to the import ldap user bad request response +func (o *ImportLdapUserBadRequest) WithXRequestID(xRequestID string) *ImportLdapUserBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the import ldap user bad request response +func (o *ImportLdapUserBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the import ldap user bad request response +func (o *ImportLdapUserBadRequest) WithPayload(payload *models.Errors) *ImportLdapUserBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the import ldap user bad request response +func (o *ImportLdapUserBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ImportLdapUserBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ImportLdapUserUnauthorizedCode is the HTTP code returned for type ImportLdapUserUnauthorized +const ImportLdapUserUnauthorizedCode int = 401 + +/*ImportLdapUserUnauthorized Unauthorized + +swagger:response importLdapUserUnauthorized +*/ +type ImportLdapUserUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewImportLdapUserUnauthorized creates ImportLdapUserUnauthorized with default headers values +func NewImportLdapUserUnauthorized() *ImportLdapUserUnauthorized { + + return &ImportLdapUserUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the import ldap user unauthorized response +func (o *ImportLdapUserUnauthorized) WithXRequestID(xRequestID string) *ImportLdapUserUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the import ldap user unauthorized response +func (o *ImportLdapUserUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the import ldap user unauthorized response +func (o *ImportLdapUserUnauthorized) WithPayload(payload *models.Errors) *ImportLdapUserUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the import ldap user unauthorized response +func (o *ImportLdapUserUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ImportLdapUserUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ImportLdapUserForbiddenCode is the HTTP code returned for type ImportLdapUserForbidden +const ImportLdapUserForbiddenCode int = 403 + +/*ImportLdapUserForbidden Forbidden + +swagger:response importLdapUserForbidden +*/ +type ImportLdapUserForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewImportLdapUserForbidden creates ImportLdapUserForbidden with default headers values +func NewImportLdapUserForbidden() *ImportLdapUserForbidden { + + return &ImportLdapUserForbidden{} +} + +// WithXRequestID adds the xRequestId to the import ldap user forbidden response +func (o *ImportLdapUserForbidden) WithXRequestID(xRequestID string) *ImportLdapUserForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the import ldap user forbidden response +func (o *ImportLdapUserForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the import ldap user forbidden response +func (o *ImportLdapUserForbidden) WithPayload(payload *models.Errors) *ImportLdapUserForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the import ldap user forbidden response +func (o *ImportLdapUserForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ImportLdapUserForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ImportLdapUserNotFoundCode is the HTTP code returned for type ImportLdapUserNotFound +const ImportLdapUserNotFoundCode int = 404 + +/*ImportLdapUserNotFound Failed import some users. + +swagger:response importLdapUserNotFound +*/ +type ImportLdapUserNotFound struct { + + /* + In: Body + */ + Payload []*models.LdapFailedImportUser `json:"body,omitempty"` +} + +// NewImportLdapUserNotFound creates ImportLdapUserNotFound with default headers values +func NewImportLdapUserNotFound() *ImportLdapUserNotFound { + + return &ImportLdapUserNotFound{} +} + +// WithPayload adds the payload to the import ldap user not found response +func (o *ImportLdapUserNotFound) WithPayload(payload []*models.LdapFailedImportUser) *ImportLdapUserNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the import ldap user not found response +func (o *ImportLdapUserNotFound) SetPayload(payload []*models.LdapFailedImportUser) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ImportLdapUserNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(404) + payload := o.Payload + if payload == nil { + // return empty array + payload = make([]*models.LdapFailedImportUser, 0, 50) + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ImportLdapUserInternalServerErrorCode is the HTTP code returned for type ImportLdapUserInternalServerError +const ImportLdapUserInternalServerErrorCode int = 500 + +/*ImportLdapUserInternalServerError Internal server error + +swagger:response importLdapUserInternalServerError +*/ +type ImportLdapUserInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewImportLdapUserInternalServerError creates ImportLdapUserInternalServerError with default headers values +func NewImportLdapUserInternalServerError() *ImportLdapUserInternalServerError { + + return &ImportLdapUserInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the import ldap user internal server error response +func (o *ImportLdapUserInternalServerError) WithXRequestID(xRequestID string) *ImportLdapUserInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the import ldap user internal server error response +func (o *ImportLdapUserInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the import ldap user internal server error response +func (o *ImportLdapUserInternalServerError) WithPayload(payload *models.Errors) *ImportLdapUserInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the import ldap user internal server error response +func (o *ImportLdapUserInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ImportLdapUserInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/ldap/import_ldap_user_urlbuilder.go b/src/server/v2.0/restapi/operations/ldap/import_ldap_user_urlbuilder.go new file mode 100644 index 000000000..2382fa548 --- /dev/null +++ b/src/server/v2.0/restapi/operations/ldap/import_ldap_user_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package ldap + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// ImportLdapUserURL generates an URL for the import ldap user operation +type ImportLdapUserURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ImportLdapUserURL) WithBasePath(bp string) *ImportLdapUserURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ImportLdapUserURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ImportLdapUserURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/ldap/users/import" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ImportLdapUserURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ImportLdapUserURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ImportLdapUserURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ImportLdapUserURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ImportLdapUserURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ImportLdapUserURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/ldap/ping_ldap.go b/src/server/v2.0/restapi/operations/ldap/ping_ldap.go new file mode 100644 index 000000000..44f572026 --- /dev/null +++ b/src/server/v2.0/restapi/operations/ldap/ping_ldap.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package ldap + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// PingLdapHandlerFunc turns a function with the right signature into a ping ldap handler +type PingLdapHandlerFunc func(PingLdapParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn PingLdapHandlerFunc) Handle(params PingLdapParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// PingLdapHandler interface for that can handle valid ping ldap params +type PingLdapHandler interface { + Handle(PingLdapParams, interface{}) middleware.Responder +} + +// NewPingLdap creates a new http.Handler for the ping ldap operation +func NewPingLdap(ctx *middleware.Context, handler PingLdapHandler) *PingLdap { + return &PingLdap{Context: ctx, Handler: handler} +} + +/*PingLdap swagger:route POST /ldap/ping Ldap pingLdap + +Ping available ldap service. + +This endpoint ping the available ldap service for test related configuration parameters. + + +*/ +type PingLdap struct { + Context *middleware.Context + Handler PingLdapHandler +} + +func (o *PingLdap) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewPingLdapParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/ldap/ping_ldap_parameters.go b/src/server/v2.0/restapi/operations/ldap/ping_ldap_parameters.go new file mode 100644 index 000000000..d22150c6a --- /dev/null +++ b/src/server/v2.0/restapi/operations/ldap/ping_ldap_parameters.go @@ -0,0 +1,112 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package ldap + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewPingLdapParams creates a new PingLdapParams object +// no default values defined in spec. +func NewPingLdapParams() PingLdapParams { + + return PingLdapParams{} +} + +// PingLdapParams contains all the bound params for the ping ldap operation +// typically these are obtained from a http.Request +// +// swagger:parameters pingLdap +type PingLdapParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*ldap configuration. support input ldap service configuration. If it is a empty request, will load current configuration from the system. + In: body + */ + Ldapconf *models.LdapConf +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewPingLdapParams() beforehand. +func (o *PingLdapParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.LdapConf + if err := route.Consumer.Consume(r.Body, &body); err != nil { + res = append(res, errors.NewParseError("ldapconf", "body", "", err)) + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Ldapconf = &body + } + } + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *PingLdapParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *PingLdapParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} diff --git a/src/server/v2.0/restapi/operations/ldap/ping_ldap_responses.go b/src/server/v2.0/restapi/operations/ldap/ping_ldap_responses.go new file mode 100644 index 000000000..6cf43cb55 --- /dev/null +++ b/src/server/v2.0/restapi/operations/ldap/ping_ldap_responses.go @@ -0,0 +1,322 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package ldap + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// PingLdapOKCode is the HTTP code returned for type PingLdapOK +const PingLdapOKCode int = 200 + +/*PingLdapOK Ping ldap service successfully. + +swagger:response pingLdapOK +*/ +type PingLdapOK struct { + + /* + In: Body + */ + Payload *models.LdapPingResult `json:"body,omitempty"` +} + +// NewPingLdapOK creates PingLdapOK with default headers values +func NewPingLdapOK() *PingLdapOK { + + return &PingLdapOK{} +} + +// WithPayload adds the payload to the ping ldap o k response +func (o *PingLdapOK) WithPayload(payload *models.LdapPingResult) *PingLdapOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the ping ldap o k response +func (o *PingLdapOK) SetPayload(payload *models.LdapPingResult) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PingLdapOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PingLdapBadRequestCode is the HTTP code returned for type PingLdapBadRequest +const PingLdapBadRequestCode int = 400 + +/*PingLdapBadRequest Bad request + +swagger:response pingLdapBadRequest +*/ +type PingLdapBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewPingLdapBadRequest creates PingLdapBadRequest with default headers values +func NewPingLdapBadRequest() *PingLdapBadRequest { + + return &PingLdapBadRequest{} +} + +// WithXRequestID adds the xRequestId to the ping ldap bad request response +func (o *PingLdapBadRequest) WithXRequestID(xRequestID string) *PingLdapBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the ping ldap bad request response +func (o *PingLdapBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the ping ldap bad request response +func (o *PingLdapBadRequest) WithPayload(payload *models.Errors) *PingLdapBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the ping ldap bad request response +func (o *PingLdapBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PingLdapBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PingLdapUnauthorizedCode is the HTTP code returned for type PingLdapUnauthorized +const PingLdapUnauthorizedCode int = 401 + +/*PingLdapUnauthorized Unauthorized + +swagger:response pingLdapUnauthorized +*/ +type PingLdapUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewPingLdapUnauthorized creates PingLdapUnauthorized with default headers values +func NewPingLdapUnauthorized() *PingLdapUnauthorized { + + return &PingLdapUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the ping ldap unauthorized response +func (o *PingLdapUnauthorized) WithXRequestID(xRequestID string) *PingLdapUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the ping ldap unauthorized response +func (o *PingLdapUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the ping ldap unauthorized response +func (o *PingLdapUnauthorized) WithPayload(payload *models.Errors) *PingLdapUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the ping ldap unauthorized response +func (o *PingLdapUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PingLdapUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PingLdapForbiddenCode is the HTTP code returned for type PingLdapForbidden +const PingLdapForbiddenCode int = 403 + +/*PingLdapForbidden Forbidden + +swagger:response pingLdapForbidden +*/ +type PingLdapForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewPingLdapForbidden creates PingLdapForbidden with default headers values +func NewPingLdapForbidden() *PingLdapForbidden { + + return &PingLdapForbidden{} +} + +// WithXRequestID adds the xRequestId to the ping ldap forbidden response +func (o *PingLdapForbidden) WithXRequestID(xRequestID string) *PingLdapForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the ping ldap forbidden response +func (o *PingLdapForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the ping ldap forbidden response +func (o *PingLdapForbidden) WithPayload(payload *models.Errors) *PingLdapForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the ping ldap forbidden response +func (o *PingLdapForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PingLdapForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PingLdapInternalServerErrorCode is the HTTP code returned for type PingLdapInternalServerError +const PingLdapInternalServerErrorCode int = 500 + +/*PingLdapInternalServerError Internal server error + +swagger:response pingLdapInternalServerError +*/ +type PingLdapInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewPingLdapInternalServerError creates PingLdapInternalServerError with default headers values +func NewPingLdapInternalServerError() *PingLdapInternalServerError { + + return &PingLdapInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the ping ldap internal server error response +func (o *PingLdapInternalServerError) WithXRequestID(xRequestID string) *PingLdapInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the ping ldap internal server error response +func (o *PingLdapInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the ping ldap internal server error response +func (o *PingLdapInternalServerError) WithPayload(payload *models.Errors) *PingLdapInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the ping ldap internal server error response +func (o *PingLdapInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PingLdapInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/ldap/ping_ldap_urlbuilder.go b/src/server/v2.0/restapi/operations/ldap/ping_ldap_urlbuilder.go new file mode 100644 index 000000000..83817c97c --- /dev/null +++ b/src/server/v2.0/restapi/operations/ldap/ping_ldap_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package ldap + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// PingLdapURL generates an URL for the ping ldap operation +type PingLdapURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *PingLdapURL) WithBasePath(bp string) *PingLdapURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *PingLdapURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *PingLdapURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/ldap/ping" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *PingLdapURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *PingLdapURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *PingLdapURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on PingLdapURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on PingLdapURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *PingLdapURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/ldap/search_ldap_group.go b/src/server/v2.0/restapi/operations/ldap/search_ldap_group.go new file mode 100644 index 000000000..317e14d0e --- /dev/null +++ b/src/server/v2.0/restapi/operations/ldap/search_ldap_group.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package ldap + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// SearchLdapGroupHandlerFunc turns a function with the right signature into a search ldap group handler +type SearchLdapGroupHandlerFunc func(SearchLdapGroupParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn SearchLdapGroupHandlerFunc) Handle(params SearchLdapGroupParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// SearchLdapGroupHandler interface for that can handle valid search ldap group params +type SearchLdapGroupHandler interface { + Handle(SearchLdapGroupParams, interface{}) middleware.Responder +} + +// NewSearchLdapGroup creates a new http.Handler for the search ldap group operation +func NewSearchLdapGroup(ctx *middleware.Context, handler SearchLdapGroupHandler) *SearchLdapGroup { + return &SearchLdapGroup{Context: ctx, Handler: handler} +} + +/*SearchLdapGroup swagger:route GET /ldap/groups/search Ldap searchLdapGroup + +Search available ldap groups. + +This endpoint searches the available ldap groups based on related configuration parameters. support to search by groupname or groupdn. + + +*/ +type SearchLdapGroup struct { + Context *middleware.Context + Handler SearchLdapGroupHandler +} + +func (o *SearchLdapGroup) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewSearchLdapGroupParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/ldap/search_ldap_group_parameters.go b/src/server/v2.0/restapi/operations/ldap/search_ldap_group_parameters.go new file mode 100644 index 000000000..f7790b302 --- /dev/null +++ b/src/server/v2.0/restapi/operations/ldap/search_ldap_group_parameters.go @@ -0,0 +1,146 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package ldap + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewSearchLdapGroupParams creates a new SearchLdapGroupParams object +// no default values defined in spec. +func NewSearchLdapGroupParams() SearchLdapGroupParams { + + return SearchLdapGroupParams{} +} + +// SearchLdapGroupParams contains all the bound params for the search ldap group operation +// typically these are obtained from a http.Request +// +// swagger:parameters searchLdapGroup +type SearchLdapGroupParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The LDAP group DN + In: query + */ + Groupdn *string + /*Ldap group name + In: query + */ + Groupname *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewSearchLdapGroupParams() beforehand. +func (o *SearchLdapGroupParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + qGroupdn, qhkGroupdn, _ := qs.GetOK("groupdn") + if err := o.bindGroupdn(qGroupdn, qhkGroupdn, route.Formats); err != nil { + res = append(res, err) + } + + qGroupname, qhkGroupname, _ := qs.GetOK("groupname") + if err := o.bindGroupname(qGroupname, qhkGroupname, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *SearchLdapGroupParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *SearchLdapGroupParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindGroupdn binds and validates parameter Groupdn from query. +func (o *SearchLdapGroupParams) bindGroupdn(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Groupdn = &raw + + return nil +} + +// bindGroupname binds and validates parameter Groupname from query. +func (o *SearchLdapGroupParams) bindGroupname(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Groupname = &raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/ldap/search_ldap_group_responses.go b/src/server/v2.0/restapi/operations/ldap/search_ldap_group_responses.go new file mode 100644 index 000000000..c1457ae8d --- /dev/null +++ b/src/server/v2.0/restapi/operations/ldap/search_ldap_group_responses.go @@ -0,0 +1,325 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package ldap + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// SearchLdapGroupOKCode is the HTTP code returned for type SearchLdapGroupOK +const SearchLdapGroupOKCode int = 200 + +/*SearchLdapGroupOK Search ldap group successfully. + +swagger:response searchLdapGroupOK +*/ +type SearchLdapGroupOK struct { + + /* + In: Body + */ + Payload []*models.UserGroup `json:"body,omitempty"` +} + +// NewSearchLdapGroupOK creates SearchLdapGroupOK with default headers values +func NewSearchLdapGroupOK() *SearchLdapGroupOK { + + return &SearchLdapGroupOK{} +} + +// WithPayload adds the payload to the search ldap group o k response +func (o *SearchLdapGroupOK) WithPayload(payload []*models.UserGroup) *SearchLdapGroupOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the search ldap group o k response +func (o *SearchLdapGroupOK) SetPayload(payload []*models.UserGroup) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *SearchLdapGroupOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = make([]*models.UserGroup, 0, 50) + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// SearchLdapGroupBadRequestCode is the HTTP code returned for type SearchLdapGroupBadRequest +const SearchLdapGroupBadRequestCode int = 400 + +/*SearchLdapGroupBadRequest Bad request + +swagger:response searchLdapGroupBadRequest +*/ +type SearchLdapGroupBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewSearchLdapGroupBadRequest creates SearchLdapGroupBadRequest with default headers values +func NewSearchLdapGroupBadRequest() *SearchLdapGroupBadRequest { + + return &SearchLdapGroupBadRequest{} +} + +// WithXRequestID adds the xRequestId to the search ldap group bad request response +func (o *SearchLdapGroupBadRequest) WithXRequestID(xRequestID string) *SearchLdapGroupBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the search ldap group bad request response +func (o *SearchLdapGroupBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the search ldap group bad request response +func (o *SearchLdapGroupBadRequest) WithPayload(payload *models.Errors) *SearchLdapGroupBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the search ldap group bad request response +func (o *SearchLdapGroupBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *SearchLdapGroupBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// SearchLdapGroupUnauthorizedCode is the HTTP code returned for type SearchLdapGroupUnauthorized +const SearchLdapGroupUnauthorizedCode int = 401 + +/*SearchLdapGroupUnauthorized Unauthorized + +swagger:response searchLdapGroupUnauthorized +*/ +type SearchLdapGroupUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewSearchLdapGroupUnauthorized creates SearchLdapGroupUnauthorized with default headers values +func NewSearchLdapGroupUnauthorized() *SearchLdapGroupUnauthorized { + + return &SearchLdapGroupUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the search ldap group unauthorized response +func (o *SearchLdapGroupUnauthorized) WithXRequestID(xRequestID string) *SearchLdapGroupUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the search ldap group unauthorized response +func (o *SearchLdapGroupUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the search ldap group unauthorized response +func (o *SearchLdapGroupUnauthorized) WithPayload(payload *models.Errors) *SearchLdapGroupUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the search ldap group unauthorized response +func (o *SearchLdapGroupUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *SearchLdapGroupUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// SearchLdapGroupForbiddenCode is the HTTP code returned for type SearchLdapGroupForbidden +const SearchLdapGroupForbiddenCode int = 403 + +/*SearchLdapGroupForbidden Forbidden + +swagger:response searchLdapGroupForbidden +*/ +type SearchLdapGroupForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewSearchLdapGroupForbidden creates SearchLdapGroupForbidden with default headers values +func NewSearchLdapGroupForbidden() *SearchLdapGroupForbidden { + + return &SearchLdapGroupForbidden{} +} + +// WithXRequestID adds the xRequestId to the search ldap group forbidden response +func (o *SearchLdapGroupForbidden) WithXRequestID(xRequestID string) *SearchLdapGroupForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the search ldap group forbidden response +func (o *SearchLdapGroupForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the search ldap group forbidden response +func (o *SearchLdapGroupForbidden) WithPayload(payload *models.Errors) *SearchLdapGroupForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the search ldap group forbidden response +func (o *SearchLdapGroupForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *SearchLdapGroupForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// SearchLdapGroupInternalServerErrorCode is the HTTP code returned for type SearchLdapGroupInternalServerError +const SearchLdapGroupInternalServerErrorCode int = 500 + +/*SearchLdapGroupInternalServerError Internal server error + +swagger:response searchLdapGroupInternalServerError +*/ +type SearchLdapGroupInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewSearchLdapGroupInternalServerError creates SearchLdapGroupInternalServerError with default headers values +func NewSearchLdapGroupInternalServerError() *SearchLdapGroupInternalServerError { + + return &SearchLdapGroupInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the search ldap group internal server error response +func (o *SearchLdapGroupInternalServerError) WithXRequestID(xRequestID string) *SearchLdapGroupInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the search ldap group internal server error response +func (o *SearchLdapGroupInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the search ldap group internal server error response +func (o *SearchLdapGroupInternalServerError) WithPayload(payload *models.Errors) *SearchLdapGroupInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the search ldap group internal server error response +func (o *SearchLdapGroupInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *SearchLdapGroupInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/ldap/search_ldap_group_urlbuilder.go b/src/server/v2.0/restapi/operations/ldap/search_ldap_group_urlbuilder.go new file mode 100644 index 000000000..7a7aee624 --- /dev/null +++ b/src/server/v2.0/restapi/operations/ldap/search_ldap_group_urlbuilder.go @@ -0,0 +1,112 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package ldap + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// SearchLdapGroupURL generates an URL for the search ldap group operation +type SearchLdapGroupURL struct { + Groupdn *string + Groupname *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *SearchLdapGroupURL) WithBasePath(bp string) *SearchLdapGroupURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *SearchLdapGroupURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *SearchLdapGroupURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/ldap/groups/search" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var groupdnQ string + if o.Groupdn != nil { + groupdnQ = *o.Groupdn + } + if groupdnQ != "" { + qs.Set("groupdn", groupdnQ) + } + + var groupnameQ string + if o.Groupname != nil { + groupnameQ = *o.Groupname + } + if groupnameQ != "" { + qs.Set("groupname", groupnameQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *SearchLdapGroupURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *SearchLdapGroupURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *SearchLdapGroupURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on SearchLdapGroupURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on SearchLdapGroupURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *SearchLdapGroupURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/ldap/search_ldap_user.go b/src/server/v2.0/restapi/operations/ldap/search_ldap_user.go new file mode 100644 index 000000000..e358f3b97 --- /dev/null +++ b/src/server/v2.0/restapi/operations/ldap/search_ldap_user.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package ldap + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// SearchLdapUserHandlerFunc turns a function with the right signature into a search ldap user handler +type SearchLdapUserHandlerFunc func(SearchLdapUserParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn SearchLdapUserHandlerFunc) Handle(params SearchLdapUserParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// SearchLdapUserHandler interface for that can handle valid search ldap user params +type SearchLdapUserHandler interface { + Handle(SearchLdapUserParams, interface{}) middleware.Responder +} + +// NewSearchLdapUser creates a new http.Handler for the search ldap user operation +func NewSearchLdapUser(ctx *middleware.Context, handler SearchLdapUserHandler) *SearchLdapUser { + return &SearchLdapUser{Context: ctx, Handler: handler} +} + +/*SearchLdapUser swagger:route GET /ldap/users/search Ldap searchLdapUser + +Search available ldap users. + +This endpoint searches the available ldap users based on related configuration parameters. Support searched by input ladp configuration, load configuration from the system and specific filter. + + +*/ +type SearchLdapUser struct { + Context *middleware.Context + Handler SearchLdapUserHandler +} + +func (o *SearchLdapUser) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewSearchLdapUserParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/ldap/search_ldap_user_parameters.go b/src/server/v2.0/restapi/operations/ldap/search_ldap_user_parameters.go new file mode 100644 index 000000000..c4746a396 --- /dev/null +++ b/src/server/v2.0/restapi/operations/ldap/search_ldap_user_parameters.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package ldap + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewSearchLdapUserParams creates a new SearchLdapUserParams object +// no default values defined in spec. +func NewSearchLdapUserParams() SearchLdapUserParams { + + return SearchLdapUserParams{} +} + +// SearchLdapUserParams contains all the bound params for the search ldap user operation +// typically these are obtained from a http.Request +// +// swagger:parameters searchLdapUser +type SearchLdapUserParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*Registered user ID + In: query + */ + Username *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewSearchLdapUserParams() beforehand. +func (o *SearchLdapUserParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + qUsername, qhkUsername, _ := qs.GetOK("username") + if err := o.bindUsername(qUsername, qhkUsername, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *SearchLdapUserParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *SearchLdapUserParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindUsername binds and validates parameter Username from query. +func (o *SearchLdapUserParams) bindUsername(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Username = &raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/ldap/search_ldap_user_responses.go b/src/server/v2.0/restapi/operations/ldap/search_ldap_user_responses.go new file mode 100644 index 000000000..4fdbc330f --- /dev/null +++ b/src/server/v2.0/restapi/operations/ldap/search_ldap_user_responses.go @@ -0,0 +1,325 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package ldap + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// SearchLdapUserOKCode is the HTTP code returned for type SearchLdapUserOK +const SearchLdapUserOKCode int = 200 + +/*SearchLdapUserOK Search ldap users successfully. + +swagger:response searchLdapUserOK +*/ +type SearchLdapUserOK struct { + + /* + In: Body + */ + Payload []*models.LdapUser `json:"body,omitempty"` +} + +// NewSearchLdapUserOK creates SearchLdapUserOK with default headers values +func NewSearchLdapUserOK() *SearchLdapUserOK { + + return &SearchLdapUserOK{} +} + +// WithPayload adds the payload to the search ldap user o k response +func (o *SearchLdapUserOK) WithPayload(payload []*models.LdapUser) *SearchLdapUserOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the search ldap user o k response +func (o *SearchLdapUserOK) SetPayload(payload []*models.LdapUser) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *SearchLdapUserOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = make([]*models.LdapUser, 0, 50) + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// SearchLdapUserBadRequestCode is the HTTP code returned for type SearchLdapUserBadRequest +const SearchLdapUserBadRequestCode int = 400 + +/*SearchLdapUserBadRequest Bad request + +swagger:response searchLdapUserBadRequest +*/ +type SearchLdapUserBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewSearchLdapUserBadRequest creates SearchLdapUserBadRequest with default headers values +func NewSearchLdapUserBadRequest() *SearchLdapUserBadRequest { + + return &SearchLdapUserBadRequest{} +} + +// WithXRequestID adds the xRequestId to the search ldap user bad request response +func (o *SearchLdapUserBadRequest) WithXRequestID(xRequestID string) *SearchLdapUserBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the search ldap user bad request response +func (o *SearchLdapUserBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the search ldap user bad request response +func (o *SearchLdapUserBadRequest) WithPayload(payload *models.Errors) *SearchLdapUserBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the search ldap user bad request response +func (o *SearchLdapUserBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *SearchLdapUserBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// SearchLdapUserUnauthorizedCode is the HTTP code returned for type SearchLdapUserUnauthorized +const SearchLdapUserUnauthorizedCode int = 401 + +/*SearchLdapUserUnauthorized Unauthorized + +swagger:response searchLdapUserUnauthorized +*/ +type SearchLdapUserUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewSearchLdapUserUnauthorized creates SearchLdapUserUnauthorized with default headers values +func NewSearchLdapUserUnauthorized() *SearchLdapUserUnauthorized { + + return &SearchLdapUserUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the search ldap user unauthorized response +func (o *SearchLdapUserUnauthorized) WithXRequestID(xRequestID string) *SearchLdapUserUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the search ldap user unauthorized response +func (o *SearchLdapUserUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the search ldap user unauthorized response +func (o *SearchLdapUserUnauthorized) WithPayload(payload *models.Errors) *SearchLdapUserUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the search ldap user unauthorized response +func (o *SearchLdapUserUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *SearchLdapUserUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// SearchLdapUserForbiddenCode is the HTTP code returned for type SearchLdapUserForbidden +const SearchLdapUserForbiddenCode int = 403 + +/*SearchLdapUserForbidden Forbidden + +swagger:response searchLdapUserForbidden +*/ +type SearchLdapUserForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewSearchLdapUserForbidden creates SearchLdapUserForbidden with default headers values +func NewSearchLdapUserForbidden() *SearchLdapUserForbidden { + + return &SearchLdapUserForbidden{} +} + +// WithXRequestID adds the xRequestId to the search ldap user forbidden response +func (o *SearchLdapUserForbidden) WithXRequestID(xRequestID string) *SearchLdapUserForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the search ldap user forbidden response +func (o *SearchLdapUserForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the search ldap user forbidden response +func (o *SearchLdapUserForbidden) WithPayload(payload *models.Errors) *SearchLdapUserForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the search ldap user forbidden response +func (o *SearchLdapUserForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *SearchLdapUserForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// SearchLdapUserInternalServerErrorCode is the HTTP code returned for type SearchLdapUserInternalServerError +const SearchLdapUserInternalServerErrorCode int = 500 + +/*SearchLdapUserInternalServerError Internal server error + +swagger:response searchLdapUserInternalServerError +*/ +type SearchLdapUserInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewSearchLdapUserInternalServerError creates SearchLdapUserInternalServerError with default headers values +func NewSearchLdapUserInternalServerError() *SearchLdapUserInternalServerError { + + return &SearchLdapUserInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the search ldap user internal server error response +func (o *SearchLdapUserInternalServerError) WithXRequestID(xRequestID string) *SearchLdapUserInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the search ldap user internal server error response +func (o *SearchLdapUserInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the search ldap user internal server error response +func (o *SearchLdapUserInternalServerError) WithPayload(payload *models.Errors) *SearchLdapUserInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the search ldap user internal server error response +func (o *SearchLdapUserInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *SearchLdapUserInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/ldap/search_ldap_user_urlbuilder.go b/src/server/v2.0/restapi/operations/ldap/search_ldap_user_urlbuilder.go new file mode 100644 index 000000000..6d4bba790 --- /dev/null +++ b/src/server/v2.0/restapi/operations/ldap/search_ldap_user_urlbuilder.go @@ -0,0 +1,103 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package ldap + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// SearchLdapUserURL generates an URL for the search ldap user operation +type SearchLdapUserURL struct { + Username *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *SearchLdapUserURL) WithBasePath(bp string) *SearchLdapUserURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *SearchLdapUserURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *SearchLdapUserURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/ldap/users/search" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var usernameQ string + if o.Username != nil { + usernameQ = *o.Username + } + if usernameQ != "" { + qs.Set("username", usernameQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *SearchLdapUserURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *SearchLdapUserURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *SearchLdapUserURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on SearchLdapUserURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on SearchLdapUserURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *SearchLdapUserURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/member/create_project_member.go b/src/server/v2.0/restapi/operations/member/create_project_member.go new file mode 100644 index 000000000..6ec358c1d --- /dev/null +++ b/src/server/v2.0/restapi/operations/member/create_project_member.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package member + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateProjectMemberHandlerFunc turns a function with the right signature into a create project member handler +type CreateProjectMemberHandlerFunc func(CreateProjectMemberParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateProjectMemberHandlerFunc) Handle(params CreateProjectMemberParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateProjectMemberHandler interface for that can handle valid create project member params +type CreateProjectMemberHandler interface { + Handle(CreateProjectMemberParams, interface{}) middleware.Responder +} + +// NewCreateProjectMember creates a new http.Handler for the create project member operation +func NewCreateProjectMember(ctx *middleware.Context, handler CreateProjectMemberHandler) *CreateProjectMember { + return &CreateProjectMember{Context: ctx, Handler: handler} +} + +/*CreateProjectMember swagger:route POST /projects/{project_name_or_id}/members member createProjectMember + +Create project member + +Create project member relationship, the member can be one of the user_member and group_member, The user_member need to specify user_id or username. If the user already exist in harbor DB, specify the user_id, If does not exist in harbor DB, it will SearchAndOnBoard the user. The group_member need to specify id or ldap_group_dn. If the group already exist in harbor DB. specify the user group's id, If does not exist, it will SearchAndOnBoard the group. + +*/ +type CreateProjectMember struct { + Context *middleware.Context + Handler CreateProjectMemberHandler +} + +func (o *CreateProjectMember) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewCreateProjectMemberParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/member/create_project_member_parameters.go b/src/server/v2.0/restapi/operations/member/create_project_member_parameters.go new file mode 100644 index 000000000..2f1f13c87 --- /dev/null +++ b/src/server/v2.0/restapi/operations/member/create_project_member_parameters.go @@ -0,0 +1,178 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package member + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewCreateProjectMemberParams creates a new CreateProjectMemberParams object +// with the default values initialized. +func NewCreateProjectMemberParams() CreateProjectMemberParams { + + var ( + // initialize parameters with default values + + xIsResourceNameDefault = bool(false) + ) + + return CreateProjectMemberParams{ + XIsResourceName: &xIsResourceNameDefault, + } +} + +// CreateProjectMemberParams contains all the bound params for the create project member operation +// typically these are obtained from a http.Request +// +// swagger:parameters createProjectMember +type CreateProjectMemberParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name. + In: header + Default: false + */ + XIsResourceName *bool + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /* + In: body + */ + ProjectMember *models.ProjectMember + /*The name or id of the project + Required: true + In: path + */ + ProjectNameOrID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateProjectMemberParams() beforehand. +func (o *CreateProjectMemberParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXIsResourceName(r.Header[http.CanonicalHeaderKey("X-Is-Resource-Name")], true, route.Formats); err != nil { + res = append(res, err) + } + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.ProjectMember + if err := route.Consumer.Consume(r.Body, &body); err != nil { + res = append(res, errors.NewParseError("projectMember", "body", "", err)) + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.ProjectMember = &body + } + } + } + rProjectNameOrID, rhkProjectNameOrID, _ := route.Params.GetOK("project_name_or_id") + if err := o.bindProjectNameOrID(rProjectNameOrID, rhkProjectNameOrID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXIsResourceName binds and validates parameter XIsResourceName from header. +func (o *CreateProjectMemberParams) bindXIsResourceName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateProjectMemberParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("X-Is-Resource-Name", "header", "bool", raw) + } + o.XIsResourceName = &value + + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *CreateProjectMemberParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *CreateProjectMemberParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindProjectNameOrID binds and validates parameter ProjectNameOrID from path. +func (o *CreateProjectMemberParams) bindProjectNameOrID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectNameOrID = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/member/create_project_member_responses.go b/src/server/v2.0/restapi/operations/member/create_project_member_responses.go new file mode 100644 index 000000000..8f3fa2934 --- /dev/null +++ b/src/server/v2.0/restapi/operations/member/create_project_member_responses.go @@ -0,0 +1,390 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package member + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// CreateProjectMemberCreatedCode is the HTTP code returned for type CreateProjectMemberCreated +const CreateProjectMemberCreatedCode int = 201 + +/*CreateProjectMemberCreated Project member created successfully. + +swagger:response createProjectMemberCreated +*/ +type CreateProjectMemberCreated struct { + /*The URL of the created resource + + */ + Location string `json:"Location"` +} + +// NewCreateProjectMemberCreated creates CreateProjectMemberCreated with default headers values +func NewCreateProjectMemberCreated() *CreateProjectMemberCreated { + + return &CreateProjectMemberCreated{} +} + +// WithLocation adds the location to the create project member created response +func (o *CreateProjectMemberCreated) WithLocation(location string) *CreateProjectMemberCreated { + o.Location = location + return o +} + +// SetLocation sets the location to the create project member created response +func (o *CreateProjectMemberCreated) SetLocation(location string) { + o.Location = location +} + +// WriteResponse to the client +func (o *CreateProjectMemberCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Location + + location := o.Location + if location != "" { + rw.Header().Set("Location", location) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(201) +} + +// CreateProjectMemberBadRequestCode is the HTTP code returned for type CreateProjectMemberBadRequest +const CreateProjectMemberBadRequestCode int = 400 + +/*CreateProjectMemberBadRequest Bad request + +swagger:response createProjectMemberBadRequest +*/ +type CreateProjectMemberBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateProjectMemberBadRequest creates CreateProjectMemberBadRequest with default headers values +func NewCreateProjectMemberBadRequest() *CreateProjectMemberBadRequest { + + return &CreateProjectMemberBadRequest{} +} + +// WithXRequestID adds the xRequestId to the create project member bad request response +func (o *CreateProjectMemberBadRequest) WithXRequestID(xRequestID string) *CreateProjectMemberBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create project member bad request response +func (o *CreateProjectMemberBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create project member bad request response +func (o *CreateProjectMemberBadRequest) WithPayload(payload *models.Errors) *CreateProjectMemberBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create project member bad request response +func (o *CreateProjectMemberBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateProjectMemberBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateProjectMemberUnauthorizedCode is the HTTP code returned for type CreateProjectMemberUnauthorized +const CreateProjectMemberUnauthorizedCode int = 401 + +/*CreateProjectMemberUnauthorized Unauthorized + +swagger:response createProjectMemberUnauthorized +*/ +type CreateProjectMemberUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateProjectMemberUnauthorized creates CreateProjectMemberUnauthorized with default headers values +func NewCreateProjectMemberUnauthorized() *CreateProjectMemberUnauthorized { + + return &CreateProjectMemberUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the create project member unauthorized response +func (o *CreateProjectMemberUnauthorized) WithXRequestID(xRequestID string) *CreateProjectMemberUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create project member unauthorized response +func (o *CreateProjectMemberUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create project member unauthorized response +func (o *CreateProjectMemberUnauthorized) WithPayload(payload *models.Errors) *CreateProjectMemberUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create project member unauthorized response +func (o *CreateProjectMemberUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateProjectMemberUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateProjectMemberForbiddenCode is the HTTP code returned for type CreateProjectMemberForbidden +const CreateProjectMemberForbiddenCode int = 403 + +/*CreateProjectMemberForbidden Forbidden + +swagger:response createProjectMemberForbidden +*/ +type CreateProjectMemberForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateProjectMemberForbidden creates CreateProjectMemberForbidden with default headers values +func NewCreateProjectMemberForbidden() *CreateProjectMemberForbidden { + + return &CreateProjectMemberForbidden{} +} + +// WithXRequestID adds the xRequestId to the create project member forbidden response +func (o *CreateProjectMemberForbidden) WithXRequestID(xRequestID string) *CreateProjectMemberForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create project member forbidden response +func (o *CreateProjectMemberForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create project member forbidden response +func (o *CreateProjectMemberForbidden) WithPayload(payload *models.Errors) *CreateProjectMemberForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create project member forbidden response +func (o *CreateProjectMemberForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateProjectMemberForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateProjectMemberConflictCode is the HTTP code returned for type CreateProjectMemberConflict +const CreateProjectMemberConflictCode int = 409 + +/*CreateProjectMemberConflict Conflict + +swagger:response createProjectMemberConflict +*/ +type CreateProjectMemberConflict struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateProjectMemberConflict creates CreateProjectMemberConflict with default headers values +func NewCreateProjectMemberConflict() *CreateProjectMemberConflict { + + return &CreateProjectMemberConflict{} +} + +// WithXRequestID adds the xRequestId to the create project member conflict response +func (o *CreateProjectMemberConflict) WithXRequestID(xRequestID string) *CreateProjectMemberConflict { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create project member conflict response +func (o *CreateProjectMemberConflict) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create project member conflict response +func (o *CreateProjectMemberConflict) WithPayload(payload *models.Errors) *CreateProjectMemberConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create project member conflict response +func (o *CreateProjectMemberConflict) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateProjectMemberConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateProjectMemberInternalServerErrorCode is the HTTP code returned for type CreateProjectMemberInternalServerError +const CreateProjectMemberInternalServerErrorCode int = 500 + +/*CreateProjectMemberInternalServerError Internal server error + +swagger:response createProjectMemberInternalServerError +*/ +type CreateProjectMemberInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateProjectMemberInternalServerError creates CreateProjectMemberInternalServerError with default headers values +func NewCreateProjectMemberInternalServerError() *CreateProjectMemberInternalServerError { + + return &CreateProjectMemberInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the create project member internal server error response +func (o *CreateProjectMemberInternalServerError) WithXRequestID(xRequestID string) *CreateProjectMemberInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create project member internal server error response +func (o *CreateProjectMemberInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create project member internal server error response +func (o *CreateProjectMemberInternalServerError) WithPayload(payload *models.Errors) *CreateProjectMemberInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create project member internal server error response +func (o *CreateProjectMemberInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateProjectMemberInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/member/create_project_member_urlbuilder.go b/src/server/v2.0/restapi/operations/member/create_project_member_urlbuilder.go new file mode 100644 index 000000000..9d1fd3aa0 --- /dev/null +++ b/src/server/v2.0/restapi/operations/member/create_project_member_urlbuilder.go @@ -0,0 +1,99 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package member + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// CreateProjectMemberURL generates an URL for the create project member operation +type CreateProjectMemberURL struct { + ProjectNameOrID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateProjectMemberURL) WithBasePath(bp string) *CreateProjectMemberURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateProjectMemberURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateProjectMemberURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name_or_id}/members" + + projectNameOrID := o.ProjectNameOrID + if projectNameOrID != "" { + _path = strings.Replace(_path, "{project_name_or_id}", projectNameOrID, -1) + } else { + return nil, errors.New("projectNameOrId is required on CreateProjectMemberURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateProjectMemberURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateProjectMemberURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateProjectMemberURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateProjectMemberURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateProjectMemberURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateProjectMemberURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/member/delete_project_member.go b/src/server/v2.0/restapi/operations/member/delete_project_member.go new file mode 100644 index 000000000..cad1e34c9 --- /dev/null +++ b/src/server/v2.0/restapi/operations/member/delete_project_member.go @@ -0,0 +1,71 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package member + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteProjectMemberHandlerFunc turns a function with the right signature into a delete project member handler +type DeleteProjectMemberHandlerFunc func(DeleteProjectMemberParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteProjectMemberHandlerFunc) Handle(params DeleteProjectMemberParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteProjectMemberHandler interface for that can handle valid delete project member params +type DeleteProjectMemberHandler interface { + Handle(DeleteProjectMemberParams, interface{}) middleware.Responder +} + +// NewDeleteProjectMember creates a new http.Handler for the delete project member operation +func NewDeleteProjectMember(ctx *middleware.Context, handler DeleteProjectMemberHandler) *DeleteProjectMember { + return &DeleteProjectMember{Context: ctx, Handler: handler} +} + +/*DeleteProjectMember swagger:route DELETE /projects/{project_name_or_id}/members/{mid} member deleteProjectMember + +Delete project member + +*/ +type DeleteProjectMember struct { + Context *middleware.Context + Handler DeleteProjectMemberHandler +} + +func (o *DeleteProjectMember) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewDeleteProjectMemberParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/member/delete_project_member_parameters.go b/src/server/v2.0/restapi/operations/member/delete_project_member_parameters.go new file mode 100644 index 000000000..6eb7397c1 --- /dev/null +++ b/src/server/v2.0/restapi/operations/member/delete_project_member_parameters.go @@ -0,0 +1,184 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package member + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewDeleteProjectMemberParams creates a new DeleteProjectMemberParams object +// with the default values initialized. +func NewDeleteProjectMemberParams() DeleteProjectMemberParams { + + var ( + // initialize parameters with default values + + xIsResourceNameDefault = bool(false) + ) + + return DeleteProjectMemberParams{ + XIsResourceName: &xIsResourceNameDefault, + } +} + +// DeleteProjectMemberParams contains all the bound params for the delete project member operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteProjectMember +type DeleteProjectMemberParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name. + In: header + Default: false + */ + XIsResourceName *bool + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*Member ID. + Required: true + In: path + */ + Mid int64 + /*The name or id of the project + Required: true + In: path + */ + ProjectNameOrID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteProjectMemberParams() beforehand. +func (o *DeleteProjectMemberParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXIsResourceName(r.Header[http.CanonicalHeaderKey("X-Is-Resource-Name")], true, route.Formats); err != nil { + res = append(res, err) + } + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rMid, rhkMid, _ := route.Params.GetOK("mid") + if err := o.bindMid(rMid, rhkMid, route.Formats); err != nil { + res = append(res, err) + } + + rProjectNameOrID, rhkProjectNameOrID, _ := route.Params.GetOK("project_name_or_id") + if err := o.bindProjectNameOrID(rProjectNameOrID, rhkProjectNameOrID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXIsResourceName binds and validates parameter XIsResourceName from header. +func (o *DeleteProjectMemberParams) bindXIsResourceName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteProjectMemberParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("X-Is-Resource-Name", "header", "bool", raw) + } + o.XIsResourceName = &value + + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *DeleteProjectMemberParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *DeleteProjectMemberParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindMid binds and validates parameter Mid from path. +func (o *DeleteProjectMemberParams) bindMid(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("mid", "path", "int64", raw) + } + o.Mid = value + + return nil +} + +// bindProjectNameOrID binds and validates parameter ProjectNameOrID from path. +func (o *DeleteProjectMemberParams) bindProjectNameOrID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectNameOrID = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/member/delete_project_member_responses.go b/src/server/v2.0/restapi/operations/member/delete_project_member_responses.go new file mode 100644 index 000000000..f8e876258 --- /dev/null +++ b/src/server/v2.0/restapi/operations/member/delete_project_member_responses.go @@ -0,0 +1,324 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package member + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// DeleteProjectMemberOKCode is the HTTP code returned for type DeleteProjectMemberOK +const DeleteProjectMemberOKCode int = 200 + +/*DeleteProjectMemberOK Success + +swagger:response deleteProjectMemberOK +*/ +type DeleteProjectMemberOK struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewDeleteProjectMemberOK creates DeleteProjectMemberOK with default headers values +func NewDeleteProjectMemberOK() *DeleteProjectMemberOK { + + return &DeleteProjectMemberOK{} +} + +// WithXRequestID adds the xRequestId to the delete project member o k response +func (o *DeleteProjectMemberOK) WithXRequestID(xRequestID string) *DeleteProjectMemberOK { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete project member o k response +func (o *DeleteProjectMemberOK) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *DeleteProjectMemberOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// DeleteProjectMemberBadRequestCode is the HTTP code returned for type DeleteProjectMemberBadRequest +const DeleteProjectMemberBadRequestCode int = 400 + +/*DeleteProjectMemberBadRequest Bad request + +swagger:response deleteProjectMemberBadRequest +*/ +type DeleteProjectMemberBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteProjectMemberBadRequest creates DeleteProjectMemberBadRequest with default headers values +func NewDeleteProjectMemberBadRequest() *DeleteProjectMemberBadRequest { + + return &DeleteProjectMemberBadRequest{} +} + +// WithXRequestID adds the xRequestId to the delete project member bad request response +func (o *DeleteProjectMemberBadRequest) WithXRequestID(xRequestID string) *DeleteProjectMemberBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete project member bad request response +func (o *DeleteProjectMemberBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete project member bad request response +func (o *DeleteProjectMemberBadRequest) WithPayload(payload *models.Errors) *DeleteProjectMemberBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete project member bad request response +func (o *DeleteProjectMemberBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteProjectMemberBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteProjectMemberUnauthorizedCode is the HTTP code returned for type DeleteProjectMemberUnauthorized +const DeleteProjectMemberUnauthorizedCode int = 401 + +/*DeleteProjectMemberUnauthorized Unauthorized + +swagger:response deleteProjectMemberUnauthorized +*/ +type DeleteProjectMemberUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteProjectMemberUnauthorized creates DeleteProjectMemberUnauthorized with default headers values +func NewDeleteProjectMemberUnauthorized() *DeleteProjectMemberUnauthorized { + + return &DeleteProjectMemberUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the delete project member unauthorized response +func (o *DeleteProjectMemberUnauthorized) WithXRequestID(xRequestID string) *DeleteProjectMemberUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete project member unauthorized response +func (o *DeleteProjectMemberUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete project member unauthorized response +func (o *DeleteProjectMemberUnauthorized) WithPayload(payload *models.Errors) *DeleteProjectMemberUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete project member unauthorized response +func (o *DeleteProjectMemberUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteProjectMemberUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteProjectMemberForbiddenCode is the HTTP code returned for type DeleteProjectMemberForbidden +const DeleteProjectMemberForbiddenCode int = 403 + +/*DeleteProjectMemberForbidden Forbidden + +swagger:response deleteProjectMemberForbidden +*/ +type DeleteProjectMemberForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteProjectMemberForbidden creates DeleteProjectMemberForbidden with default headers values +func NewDeleteProjectMemberForbidden() *DeleteProjectMemberForbidden { + + return &DeleteProjectMemberForbidden{} +} + +// WithXRequestID adds the xRequestId to the delete project member forbidden response +func (o *DeleteProjectMemberForbidden) WithXRequestID(xRequestID string) *DeleteProjectMemberForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete project member forbidden response +func (o *DeleteProjectMemberForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete project member forbidden response +func (o *DeleteProjectMemberForbidden) WithPayload(payload *models.Errors) *DeleteProjectMemberForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete project member forbidden response +func (o *DeleteProjectMemberForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteProjectMemberForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteProjectMemberInternalServerErrorCode is the HTTP code returned for type DeleteProjectMemberInternalServerError +const DeleteProjectMemberInternalServerErrorCode int = 500 + +/*DeleteProjectMemberInternalServerError Internal server error + +swagger:response deleteProjectMemberInternalServerError +*/ +type DeleteProjectMemberInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteProjectMemberInternalServerError creates DeleteProjectMemberInternalServerError with default headers values +func NewDeleteProjectMemberInternalServerError() *DeleteProjectMemberInternalServerError { + + return &DeleteProjectMemberInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the delete project member internal server error response +func (o *DeleteProjectMemberInternalServerError) WithXRequestID(xRequestID string) *DeleteProjectMemberInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete project member internal server error response +func (o *DeleteProjectMemberInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete project member internal server error response +func (o *DeleteProjectMemberInternalServerError) WithPayload(payload *models.Errors) *DeleteProjectMemberInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete project member internal server error response +func (o *DeleteProjectMemberInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteProjectMemberInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/member/delete_project_member_urlbuilder.go b/src/server/v2.0/restapi/operations/member/delete_project_member_urlbuilder.go new file mode 100644 index 000000000..0a57f3f60 --- /dev/null +++ b/src/server/v2.0/restapi/operations/member/delete_project_member_urlbuilder.go @@ -0,0 +1,109 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package member + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteProjectMemberURL generates an URL for the delete project member operation +type DeleteProjectMemberURL struct { + Mid int64 + ProjectNameOrID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteProjectMemberURL) WithBasePath(bp string) *DeleteProjectMemberURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteProjectMemberURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteProjectMemberURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name_or_id}/members/{mid}" + + mid := swag.FormatInt64(o.Mid) + if mid != "" { + _path = strings.Replace(_path, "{mid}", mid, -1) + } else { + return nil, errors.New("mid is required on DeleteProjectMemberURL") + } + + projectNameOrID := o.ProjectNameOrID + if projectNameOrID != "" { + _path = strings.Replace(_path, "{project_name_or_id}", projectNameOrID, -1) + } else { + return nil, errors.New("projectNameOrId is required on DeleteProjectMemberURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteProjectMemberURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteProjectMemberURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteProjectMemberURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteProjectMemberURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteProjectMemberURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteProjectMemberURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/member/get_project_member.go b/src/server/v2.0/restapi/operations/member/get_project_member.go new file mode 100644 index 000000000..268b3c59a --- /dev/null +++ b/src/server/v2.0/restapi/operations/member/get_project_member.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package member + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetProjectMemberHandlerFunc turns a function with the right signature into a get project member handler +type GetProjectMemberHandlerFunc func(GetProjectMemberParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetProjectMemberHandlerFunc) Handle(params GetProjectMemberParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetProjectMemberHandler interface for that can handle valid get project member params +type GetProjectMemberHandler interface { + Handle(GetProjectMemberParams, interface{}) middleware.Responder +} + +// NewGetProjectMember creates a new http.Handler for the get project member operation +func NewGetProjectMember(ctx *middleware.Context, handler GetProjectMemberHandler) *GetProjectMember { + return &GetProjectMember{Context: ctx, Handler: handler} +} + +/*GetProjectMember swagger:route GET /projects/{project_name_or_id}/members/{mid} member getProjectMember + +Get the project member information + +Get the project member information + +*/ +type GetProjectMember struct { + Context *middleware.Context + Handler GetProjectMemberHandler +} + +func (o *GetProjectMember) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetProjectMemberParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/member/get_project_member_parameters.go b/src/server/v2.0/restapi/operations/member/get_project_member_parameters.go new file mode 100644 index 000000000..9bb34e7e9 --- /dev/null +++ b/src/server/v2.0/restapi/operations/member/get_project_member_parameters.go @@ -0,0 +1,184 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package member + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewGetProjectMemberParams creates a new GetProjectMemberParams object +// with the default values initialized. +func NewGetProjectMemberParams() GetProjectMemberParams { + + var ( + // initialize parameters with default values + + xIsResourceNameDefault = bool(false) + ) + + return GetProjectMemberParams{ + XIsResourceName: &xIsResourceNameDefault, + } +} + +// GetProjectMemberParams contains all the bound params for the get project member operation +// typically these are obtained from a http.Request +// +// swagger:parameters getProjectMember +type GetProjectMemberParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name. + In: header + Default: false + */ + XIsResourceName *bool + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The member ID + Required: true + In: path + */ + Mid int64 + /*The name or id of the project + Required: true + In: path + */ + ProjectNameOrID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetProjectMemberParams() beforehand. +func (o *GetProjectMemberParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXIsResourceName(r.Header[http.CanonicalHeaderKey("X-Is-Resource-Name")], true, route.Formats); err != nil { + res = append(res, err) + } + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rMid, rhkMid, _ := route.Params.GetOK("mid") + if err := o.bindMid(rMid, rhkMid, route.Formats); err != nil { + res = append(res, err) + } + + rProjectNameOrID, rhkProjectNameOrID, _ := route.Params.GetOK("project_name_or_id") + if err := o.bindProjectNameOrID(rProjectNameOrID, rhkProjectNameOrID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXIsResourceName binds and validates parameter XIsResourceName from header. +func (o *GetProjectMemberParams) bindXIsResourceName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewGetProjectMemberParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("X-Is-Resource-Name", "header", "bool", raw) + } + o.XIsResourceName = &value + + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetProjectMemberParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetProjectMemberParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindMid binds and validates parameter Mid from path. +func (o *GetProjectMemberParams) bindMid(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("mid", "path", "int64", raw) + } + o.Mid = value + + return nil +} + +// bindProjectNameOrID binds and validates parameter ProjectNameOrID from path. +func (o *GetProjectMemberParams) bindProjectNameOrID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectNameOrID = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/member/get_project_member_responses.go b/src/server/v2.0/restapi/operations/member/get_project_member_responses.go new file mode 100644 index 000000000..a1924c801 --- /dev/null +++ b/src/server/v2.0/restapi/operations/member/get_project_member_responses.go @@ -0,0 +1,388 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package member + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetProjectMemberOKCode is the HTTP code returned for type GetProjectMemberOK +const GetProjectMemberOKCode int = 200 + +/*GetProjectMemberOK Project member retrieved successfully. + +swagger:response getProjectMemberOK +*/ +type GetProjectMemberOK struct { + + /* + In: Body + */ + Payload *models.ProjectMemberEntity `json:"body,omitempty"` +} + +// NewGetProjectMemberOK creates GetProjectMemberOK with default headers values +func NewGetProjectMemberOK() *GetProjectMemberOK { + + return &GetProjectMemberOK{} +} + +// WithPayload adds the payload to the get project member o k response +func (o *GetProjectMemberOK) WithPayload(payload *models.ProjectMemberEntity) *GetProjectMemberOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get project member o k response +func (o *GetProjectMemberOK) SetPayload(payload *models.ProjectMemberEntity) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetProjectMemberOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetProjectMemberBadRequestCode is the HTTP code returned for type GetProjectMemberBadRequest +const GetProjectMemberBadRequestCode int = 400 + +/*GetProjectMemberBadRequest Bad request + +swagger:response getProjectMemberBadRequest +*/ +type GetProjectMemberBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetProjectMemberBadRequest creates GetProjectMemberBadRequest with default headers values +func NewGetProjectMemberBadRequest() *GetProjectMemberBadRequest { + + return &GetProjectMemberBadRequest{} +} + +// WithXRequestID adds the xRequestId to the get project member bad request response +func (o *GetProjectMemberBadRequest) WithXRequestID(xRequestID string) *GetProjectMemberBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get project member bad request response +func (o *GetProjectMemberBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get project member bad request response +func (o *GetProjectMemberBadRequest) WithPayload(payload *models.Errors) *GetProjectMemberBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get project member bad request response +func (o *GetProjectMemberBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetProjectMemberBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetProjectMemberUnauthorizedCode is the HTTP code returned for type GetProjectMemberUnauthorized +const GetProjectMemberUnauthorizedCode int = 401 + +/*GetProjectMemberUnauthorized Unauthorized + +swagger:response getProjectMemberUnauthorized +*/ +type GetProjectMemberUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetProjectMemberUnauthorized creates GetProjectMemberUnauthorized with default headers values +func NewGetProjectMemberUnauthorized() *GetProjectMemberUnauthorized { + + return &GetProjectMemberUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the get project member unauthorized response +func (o *GetProjectMemberUnauthorized) WithXRequestID(xRequestID string) *GetProjectMemberUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get project member unauthorized response +func (o *GetProjectMemberUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get project member unauthorized response +func (o *GetProjectMemberUnauthorized) WithPayload(payload *models.Errors) *GetProjectMemberUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get project member unauthorized response +func (o *GetProjectMemberUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetProjectMemberUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetProjectMemberForbiddenCode is the HTTP code returned for type GetProjectMemberForbidden +const GetProjectMemberForbiddenCode int = 403 + +/*GetProjectMemberForbidden Forbidden + +swagger:response getProjectMemberForbidden +*/ +type GetProjectMemberForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetProjectMemberForbidden creates GetProjectMemberForbidden with default headers values +func NewGetProjectMemberForbidden() *GetProjectMemberForbidden { + + return &GetProjectMemberForbidden{} +} + +// WithXRequestID adds the xRequestId to the get project member forbidden response +func (o *GetProjectMemberForbidden) WithXRequestID(xRequestID string) *GetProjectMemberForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get project member forbidden response +func (o *GetProjectMemberForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get project member forbidden response +func (o *GetProjectMemberForbidden) WithPayload(payload *models.Errors) *GetProjectMemberForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get project member forbidden response +func (o *GetProjectMemberForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetProjectMemberForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetProjectMemberNotFoundCode is the HTTP code returned for type GetProjectMemberNotFound +const GetProjectMemberNotFoundCode int = 404 + +/*GetProjectMemberNotFound Not found + +swagger:response getProjectMemberNotFound +*/ +type GetProjectMemberNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetProjectMemberNotFound creates GetProjectMemberNotFound with default headers values +func NewGetProjectMemberNotFound() *GetProjectMemberNotFound { + + return &GetProjectMemberNotFound{} +} + +// WithXRequestID adds the xRequestId to the get project member not found response +func (o *GetProjectMemberNotFound) WithXRequestID(xRequestID string) *GetProjectMemberNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get project member not found response +func (o *GetProjectMemberNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get project member not found response +func (o *GetProjectMemberNotFound) WithPayload(payload *models.Errors) *GetProjectMemberNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get project member not found response +func (o *GetProjectMemberNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetProjectMemberNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetProjectMemberInternalServerErrorCode is the HTTP code returned for type GetProjectMemberInternalServerError +const GetProjectMemberInternalServerErrorCode int = 500 + +/*GetProjectMemberInternalServerError Internal server error + +swagger:response getProjectMemberInternalServerError +*/ +type GetProjectMemberInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetProjectMemberInternalServerError creates GetProjectMemberInternalServerError with default headers values +func NewGetProjectMemberInternalServerError() *GetProjectMemberInternalServerError { + + return &GetProjectMemberInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get project member internal server error response +func (o *GetProjectMemberInternalServerError) WithXRequestID(xRequestID string) *GetProjectMemberInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get project member internal server error response +func (o *GetProjectMemberInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get project member internal server error response +func (o *GetProjectMemberInternalServerError) WithPayload(payload *models.Errors) *GetProjectMemberInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get project member internal server error response +func (o *GetProjectMemberInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetProjectMemberInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/member/get_project_member_urlbuilder.go b/src/server/v2.0/restapi/operations/member/get_project_member_urlbuilder.go new file mode 100644 index 000000000..7315dc5c5 --- /dev/null +++ b/src/server/v2.0/restapi/operations/member/get_project_member_urlbuilder.go @@ -0,0 +1,109 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package member + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetProjectMemberURL generates an URL for the get project member operation +type GetProjectMemberURL struct { + Mid int64 + ProjectNameOrID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetProjectMemberURL) WithBasePath(bp string) *GetProjectMemberURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetProjectMemberURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetProjectMemberURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name_or_id}/members/{mid}" + + mid := swag.FormatInt64(o.Mid) + if mid != "" { + _path = strings.Replace(_path, "{mid}", mid, -1) + } else { + return nil, errors.New("mid is required on GetProjectMemberURL") + } + + projectNameOrID := o.ProjectNameOrID + if projectNameOrID != "" { + _path = strings.Replace(_path, "{project_name_or_id}", projectNameOrID, -1) + } else { + return nil, errors.New("projectNameOrId is required on GetProjectMemberURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetProjectMemberURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetProjectMemberURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetProjectMemberURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetProjectMemberURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetProjectMemberURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetProjectMemberURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/member/list_project_members.go b/src/server/v2.0/restapi/operations/member/list_project_members.go new file mode 100644 index 000000000..1a93c1ba0 --- /dev/null +++ b/src/server/v2.0/restapi/operations/member/list_project_members.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package member + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ListProjectMembersHandlerFunc turns a function with the right signature into a list project members handler +type ListProjectMembersHandlerFunc func(ListProjectMembersParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ListProjectMembersHandlerFunc) Handle(params ListProjectMembersParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ListProjectMembersHandler interface for that can handle valid list project members params +type ListProjectMembersHandler interface { + Handle(ListProjectMembersParams, interface{}) middleware.Responder +} + +// NewListProjectMembers creates a new http.Handler for the list project members operation +func NewListProjectMembers(ctx *middleware.Context, handler ListProjectMembersHandler) *ListProjectMembers { + return &ListProjectMembers{Context: ctx, Handler: handler} +} + +/*ListProjectMembers swagger:route GET /projects/{project_name_or_id}/members member listProjectMembers + +Get all project member information + +Get all project member information + +*/ +type ListProjectMembers struct { + Context *middleware.Context + Handler ListProjectMembersHandler +} + +func (o *ListProjectMembers) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewListProjectMembersParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/member/list_project_members_parameters.go b/src/server/v2.0/restapi/operations/member/list_project_members_parameters.go new file mode 100644 index 000000000..c648ba45c --- /dev/null +++ b/src/server/v2.0/restapi/operations/member/list_project_members_parameters.go @@ -0,0 +1,273 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package member + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewListProjectMembersParams creates a new ListProjectMembersParams object +// with the default values initialized. +func NewListProjectMembersParams() ListProjectMembersParams { + + var ( + // initialize parameters with default values + + xIsResourceNameDefault = bool(false) + + pageDefault = int64(1) + pageSizeDefault = int64(10) + ) + + return ListProjectMembersParams{ + XIsResourceName: &xIsResourceNameDefault, + + Page: &pageDefault, + + PageSize: &pageSizeDefault, + } +} + +// ListProjectMembersParams contains all the bound params for the list project members operation +// typically these are obtained from a http.Request +// +// swagger:parameters listProjectMembers +type ListProjectMembersParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name. + In: header + Default: false + */ + XIsResourceName *bool + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The entity name to search. + In: query + */ + Entityname *string + /*The page number + In: query + Default: 1 + */ + Page *int64 + /*The size of per page + Maximum: 100 + In: query + Default: 10 + */ + PageSize *int64 + /*The name or id of the project + Required: true + In: path + */ + ProjectNameOrID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewListProjectMembersParams() beforehand. +func (o *ListProjectMembersParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if err := o.bindXIsResourceName(r.Header[http.CanonicalHeaderKey("X-Is-Resource-Name")], true, route.Formats); err != nil { + res = append(res, err) + } + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + qEntityname, qhkEntityname, _ := qs.GetOK("entityname") + if err := o.bindEntityname(qEntityname, qhkEntityname, route.Formats); err != nil { + res = append(res, err) + } + + qPage, qhkPage, _ := qs.GetOK("page") + if err := o.bindPage(qPage, qhkPage, route.Formats); err != nil { + res = append(res, err) + } + + qPageSize, qhkPageSize, _ := qs.GetOK("page_size") + if err := o.bindPageSize(qPageSize, qhkPageSize, route.Formats); err != nil { + res = append(res, err) + } + + rProjectNameOrID, rhkProjectNameOrID, _ := route.Params.GetOK("project_name_or_id") + if err := o.bindProjectNameOrID(rProjectNameOrID, rhkProjectNameOrID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXIsResourceName binds and validates parameter XIsResourceName from header. +func (o *ListProjectMembersParams) bindXIsResourceName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListProjectMembersParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("X-Is-Resource-Name", "header", "bool", raw) + } + o.XIsResourceName = &value + + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *ListProjectMembersParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *ListProjectMembersParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindEntityname binds and validates parameter Entityname from query. +func (o *ListProjectMembersParams) bindEntityname(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Entityname = &raw + + return nil +} + +// bindPage binds and validates parameter Page from query. +func (o *ListProjectMembersParams) bindPage(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListProjectMembersParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page", "query", "int64", raw) + } + o.Page = &value + + return nil +} + +// bindPageSize binds and validates parameter PageSize from query. +func (o *ListProjectMembersParams) bindPageSize(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListProjectMembersParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page_size", "query", "int64", raw) + } + o.PageSize = &value + + if err := o.validatePageSize(formats); err != nil { + return err + } + + return nil +} + +// validatePageSize carries on validations for parameter PageSize +func (o *ListProjectMembersParams) validatePageSize(formats strfmt.Registry) error { + + if err := validate.MaximumInt("page_size", "query", int64(*o.PageSize), 100, false); err != nil { + return err + } + + return nil +} + +// bindProjectNameOrID binds and validates parameter ProjectNameOrID from path. +func (o *ListProjectMembersParams) bindProjectNameOrID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectNameOrID = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/member/list_project_members_responses.go b/src/server/v2.0/restapi/operations/member/list_project_members_responses.go new file mode 100644 index 000000000..baef016ef --- /dev/null +++ b/src/server/v2.0/restapi/operations/member/list_project_members_responses.go @@ -0,0 +1,436 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package member + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/swag" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// ListProjectMembersOKCode is the HTTP code returned for type ListProjectMembersOK +const ListProjectMembersOKCode int = 200 + +/*ListProjectMembersOK Get project members successfully. + +swagger:response listProjectMembersOK +*/ +type ListProjectMembersOK struct { + /*Link refers to the previous page and next page + + */ + Link string `json:"Link"` + /*The total count of members + + */ + XTotalCount int64 `json:"X-Total-Count"` + + /* + In: Body + */ + Payload []*models.ProjectMemberEntity `json:"body,omitempty"` +} + +// NewListProjectMembersOK creates ListProjectMembersOK with default headers values +func NewListProjectMembersOK() *ListProjectMembersOK { + + return &ListProjectMembersOK{} +} + +// WithLink adds the link to the list project members o k response +func (o *ListProjectMembersOK) WithLink(link string) *ListProjectMembersOK { + o.Link = link + return o +} + +// SetLink sets the link to the list project members o k response +func (o *ListProjectMembersOK) SetLink(link string) { + o.Link = link +} + +// WithXTotalCount adds the xTotalCount to the list project members o k response +func (o *ListProjectMembersOK) WithXTotalCount(xTotalCount int64) *ListProjectMembersOK { + o.XTotalCount = xTotalCount + return o +} + +// SetXTotalCount sets the xTotalCount to the list project members o k response +func (o *ListProjectMembersOK) SetXTotalCount(xTotalCount int64) { + o.XTotalCount = xTotalCount +} + +// WithPayload adds the payload to the list project members o k response +func (o *ListProjectMembersOK) WithPayload(payload []*models.ProjectMemberEntity) *ListProjectMembersOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list project members o k response +func (o *ListProjectMembersOK) SetPayload(payload []*models.ProjectMemberEntity) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListProjectMembersOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Link + + link := o.Link + if link != "" { + rw.Header().Set("Link", link) + } + + // response header X-Total-Count + + xTotalCount := swag.FormatInt64(o.XTotalCount) + if xTotalCount != "" { + rw.Header().Set("X-Total-Count", xTotalCount) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = make([]*models.ProjectMemberEntity, 0, 50) + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ListProjectMembersBadRequestCode is the HTTP code returned for type ListProjectMembersBadRequest +const ListProjectMembersBadRequestCode int = 400 + +/*ListProjectMembersBadRequest Bad request + +swagger:response listProjectMembersBadRequest +*/ +type ListProjectMembersBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListProjectMembersBadRequest creates ListProjectMembersBadRequest with default headers values +func NewListProjectMembersBadRequest() *ListProjectMembersBadRequest { + + return &ListProjectMembersBadRequest{} +} + +// WithXRequestID adds the xRequestId to the list project members bad request response +func (o *ListProjectMembersBadRequest) WithXRequestID(xRequestID string) *ListProjectMembersBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list project members bad request response +func (o *ListProjectMembersBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list project members bad request response +func (o *ListProjectMembersBadRequest) WithPayload(payload *models.Errors) *ListProjectMembersBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list project members bad request response +func (o *ListProjectMembersBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListProjectMembersBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListProjectMembersUnauthorizedCode is the HTTP code returned for type ListProjectMembersUnauthorized +const ListProjectMembersUnauthorizedCode int = 401 + +/*ListProjectMembersUnauthorized Unauthorized + +swagger:response listProjectMembersUnauthorized +*/ +type ListProjectMembersUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListProjectMembersUnauthorized creates ListProjectMembersUnauthorized with default headers values +func NewListProjectMembersUnauthorized() *ListProjectMembersUnauthorized { + + return &ListProjectMembersUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the list project members unauthorized response +func (o *ListProjectMembersUnauthorized) WithXRequestID(xRequestID string) *ListProjectMembersUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list project members unauthorized response +func (o *ListProjectMembersUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list project members unauthorized response +func (o *ListProjectMembersUnauthorized) WithPayload(payload *models.Errors) *ListProjectMembersUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list project members unauthorized response +func (o *ListProjectMembersUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListProjectMembersUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListProjectMembersForbiddenCode is the HTTP code returned for type ListProjectMembersForbidden +const ListProjectMembersForbiddenCode int = 403 + +/*ListProjectMembersForbidden Forbidden + +swagger:response listProjectMembersForbidden +*/ +type ListProjectMembersForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListProjectMembersForbidden creates ListProjectMembersForbidden with default headers values +func NewListProjectMembersForbidden() *ListProjectMembersForbidden { + + return &ListProjectMembersForbidden{} +} + +// WithXRequestID adds the xRequestId to the list project members forbidden response +func (o *ListProjectMembersForbidden) WithXRequestID(xRequestID string) *ListProjectMembersForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list project members forbidden response +func (o *ListProjectMembersForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list project members forbidden response +func (o *ListProjectMembersForbidden) WithPayload(payload *models.Errors) *ListProjectMembersForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list project members forbidden response +func (o *ListProjectMembersForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListProjectMembersForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListProjectMembersNotFoundCode is the HTTP code returned for type ListProjectMembersNotFound +const ListProjectMembersNotFoundCode int = 404 + +/*ListProjectMembersNotFound Not found + +swagger:response listProjectMembersNotFound +*/ +type ListProjectMembersNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListProjectMembersNotFound creates ListProjectMembersNotFound with default headers values +func NewListProjectMembersNotFound() *ListProjectMembersNotFound { + + return &ListProjectMembersNotFound{} +} + +// WithXRequestID adds the xRequestId to the list project members not found response +func (o *ListProjectMembersNotFound) WithXRequestID(xRequestID string) *ListProjectMembersNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list project members not found response +func (o *ListProjectMembersNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list project members not found response +func (o *ListProjectMembersNotFound) WithPayload(payload *models.Errors) *ListProjectMembersNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list project members not found response +func (o *ListProjectMembersNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListProjectMembersNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListProjectMembersInternalServerErrorCode is the HTTP code returned for type ListProjectMembersInternalServerError +const ListProjectMembersInternalServerErrorCode int = 500 + +/*ListProjectMembersInternalServerError Internal server error + +swagger:response listProjectMembersInternalServerError +*/ +type ListProjectMembersInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListProjectMembersInternalServerError creates ListProjectMembersInternalServerError with default headers values +func NewListProjectMembersInternalServerError() *ListProjectMembersInternalServerError { + + return &ListProjectMembersInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the list project members internal server error response +func (o *ListProjectMembersInternalServerError) WithXRequestID(xRequestID string) *ListProjectMembersInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list project members internal server error response +func (o *ListProjectMembersInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list project members internal server error response +func (o *ListProjectMembersInternalServerError) WithPayload(payload *models.Errors) *ListProjectMembersInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list project members internal server error response +func (o *ListProjectMembersInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListProjectMembersInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/member/list_project_members_urlbuilder.go b/src/server/v2.0/restapi/operations/member/list_project_members_urlbuilder.go new file mode 100644 index 000000000..ad5281b06 --- /dev/null +++ b/src/server/v2.0/restapi/operations/member/list_project_members_urlbuilder.go @@ -0,0 +1,133 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package member + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ListProjectMembersURL generates an URL for the list project members operation +type ListProjectMembersURL struct { + ProjectNameOrID string + + Entityname *string + Page *int64 + PageSize *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListProjectMembersURL) WithBasePath(bp string) *ListProjectMembersURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListProjectMembersURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ListProjectMembersURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name_or_id}/members" + + projectNameOrID := o.ProjectNameOrID + if projectNameOrID != "" { + _path = strings.Replace(_path, "{project_name_or_id}", projectNameOrID, -1) + } else { + return nil, errors.New("projectNameOrId is required on ListProjectMembersURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var entitynameQ string + if o.Entityname != nil { + entitynameQ = *o.Entityname + } + if entitynameQ != "" { + qs.Set("entityname", entitynameQ) + } + + var pageQ string + if o.Page != nil { + pageQ = swag.FormatInt64(*o.Page) + } + if pageQ != "" { + qs.Set("page", pageQ) + } + + var pageSizeQ string + if o.PageSize != nil { + pageSizeQ = swag.FormatInt64(*o.PageSize) + } + if pageSizeQ != "" { + qs.Set("page_size", pageSizeQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ListProjectMembersURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ListProjectMembersURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ListProjectMembersURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ListProjectMembersURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ListProjectMembersURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ListProjectMembersURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/member/update_project_member.go b/src/server/v2.0/restapi/operations/member/update_project_member.go new file mode 100644 index 000000000..9d865a351 --- /dev/null +++ b/src/server/v2.0/restapi/operations/member/update_project_member.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package member + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// UpdateProjectMemberHandlerFunc turns a function with the right signature into a update project member handler +type UpdateProjectMemberHandlerFunc func(UpdateProjectMemberParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn UpdateProjectMemberHandlerFunc) Handle(params UpdateProjectMemberParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// UpdateProjectMemberHandler interface for that can handle valid update project member params +type UpdateProjectMemberHandler interface { + Handle(UpdateProjectMemberParams, interface{}) middleware.Responder +} + +// NewUpdateProjectMember creates a new http.Handler for the update project member operation +func NewUpdateProjectMember(ctx *middleware.Context, handler UpdateProjectMemberHandler) *UpdateProjectMember { + return &UpdateProjectMember{Context: ctx, Handler: handler} +} + +/*UpdateProjectMember swagger:route PUT /projects/{project_name_or_id}/members/{mid} member updateProjectMember + +Update project member + +Update project member relationship + +*/ +type UpdateProjectMember struct { + Context *middleware.Context + Handler UpdateProjectMemberHandler +} + +func (o *UpdateProjectMember) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewUpdateProjectMemberParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/member/update_project_member_parameters.go b/src/server/v2.0/restapi/operations/member/update_project_member_parameters.go new file mode 100644 index 000000000..f77079741 --- /dev/null +++ b/src/server/v2.0/restapi/operations/member/update_project_member_parameters.go @@ -0,0 +1,207 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package member + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewUpdateProjectMemberParams creates a new UpdateProjectMemberParams object +// with the default values initialized. +func NewUpdateProjectMemberParams() UpdateProjectMemberParams { + + var ( + // initialize parameters with default values + + xIsResourceNameDefault = bool(false) + ) + + return UpdateProjectMemberParams{ + XIsResourceName: &xIsResourceNameDefault, + } +} + +// UpdateProjectMemberParams contains all the bound params for the update project member operation +// typically these are obtained from a http.Request +// +// swagger:parameters updateProjectMember +type UpdateProjectMemberParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name. + In: header + Default: false + */ + XIsResourceName *bool + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*Member ID. + Required: true + In: path + */ + Mid int64 + /*The name or id of the project + Required: true + In: path + */ + ProjectNameOrID string + /* + In: body + */ + Role *models.RoleRequest +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewUpdateProjectMemberParams() beforehand. +func (o *UpdateProjectMemberParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXIsResourceName(r.Header[http.CanonicalHeaderKey("X-Is-Resource-Name")], true, route.Formats); err != nil { + res = append(res, err) + } + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rMid, rhkMid, _ := route.Params.GetOK("mid") + if err := o.bindMid(rMid, rhkMid, route.Formats); err != nil { + res = append(res, err) + } + + rProjectNameOrID, rhkProjectNameOrID, _ := route.Params.GetOK("project_name_or_id") + if err := o.bindProjectNameOrID(rProjectNameOrID, rhkProjectNameOrID, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.RoleRequest + if err := route.Consumer.Consume(r.Body, &body); err != nil { + res = append(res, errors.NewParseError("role", "body", "", err)) + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Role = &body + } + } + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXIsResourceName binds and validates parameter XIsResourceName from header. +func (o *UpdateProjectMemberParams) bindXIsResourceName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewUpdateProjectMemberParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("X-Is-Resource-Name", "header", "bool", raw) + } + o.XIsResourceName = &value + + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *UpdateProjectMemberParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *UpdateProjectMemberParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindMid binds and validates parameter Mid from path. +func (o *UpdateProjectMemberParams) bindMid(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("mid", "path", "int64", raw) + } + o.Mid = value + + return nil +} + +// bindProjectNameOrID binds and validates parameter ProjectNameOrID from path. +func (o *UpdateProjectMemberParams) bindProjectNameOrID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectNameOrID = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/member/update_project_member_responses.go b/src/server/v2.0/restapi/operations/member/update_project_member_responses.go new file mode 100644 index 000000000..48685de3b --- /dev/null +++ b/src/server/v2.0/restapi/operations/member/update_project_member_responses.go @@ -0,0 +1,390 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package member + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// UpdateProjectMemberOKCode is the HTTP code returned for type UpdateProjectMemberOK +const UpdateProjectMemberOKCode int = 200 + +/*UpdateProjectMemberOK Success + +swagger:response updateProjectMemberOK +*/ +type UpdateProjectMemberOK struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewUpdateProjectMemberOK creates UpdateProjectMemberOK with default headers values +func NewUpdateProjectMemberOK() *UpdateProjectMemberOK { + + return &UpdateProjectMemberOK{} +} + +// WithXRequestID adds the xRequestId to the update project member o k response +func (o *UpdateProjectMemberOK) WithXRequestID(xRequestID string) *UpdateProjectMemberOK { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update project member o k response +func (o *UpdateProjectMemberOK) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *UpdateProjectMemberOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// UpdateProjectMemberBadRequestCode is the HTTP code returned for type UpdateProjectMemberBadRequest +const UpdateProjectMemberBadRequestCode int = 400 + +/*UpdateProjectMemberBadRequest Bad request + +swagger:response updateProjectMemberBadRequest +*/ +type UpdateProjectMemberBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateProjectMemberBadRequest creates UpdateProjectMemberBadRequest with default headers values +func NewUpdateProjectMemberBadRequest() *UpdateProjectMemberBadRequest { + + return &UpdateProjectMemberBadRequest{} +} + +// WithXRequestID adds the xRequestId to the update project member bad request response +func (o *UpdateProjectMemberBadRequest) WithXRequestID(xRequestID string) *UpdateProjectMemberBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update project member bad request response +func (o *UpdateProjectMemberBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update project member bad request response +func (o *UpdateProjectMemberBadRequest) WithPayload(payload *models.Errors) *UpdateProjectMemberBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update project member bad request response +func (o *UpdateProjectMemberBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateProjectMemberBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateProjectMemberUnauthorizedCode is the HTTP code returned for type UpdateProjectMemberUnauthorized +const UpdateProjectMemberUnauthorizedCode int = 401 + +/*UpdateProjectMemberUnauthorized Unauthorized + +swagger:response updateProjectMemberUnauthorized +*/ +type UpdateProjectMemberUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateProjectMemberUnauthorized creates UpdateProjectMemberUnauthorized with default headers values +func NewUpdateProjectMemberUnauthorized() *UpdateProjectMemberUnauthorized { + + return &UpdateProjectMemberUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the update project member unauthorized response +func (o *UpdateProjectMemberUnauthorized) WithXRequestID(xRequestID string) *UpdateProjectMemberUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update project member unauthorized response +func (o *UpdateProjectMemberUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update project member unauthorized response +func (o *UpdateProjectMemberUnauthorized) WithPayload(payload *models.Errors) *UpdateProjectMemberUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update project member unauthorized response +func (o *UpdateProjectMemberUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateProjectMemberUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateProjectMemberForbiddenCode is the HTTP code returned for type UpdateProjectMemberForbidden +const UpdateProjectMemberForbiddenCode int = 403 + +/*UpdateProjectMemberForbidden Forbidden + +swagger:response updateProjectMemberForbidden +*/ +type UpdateProjectMemberForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateProjectMemberForbidden creates UpdateProjectMemberForbidden with default headers values +func NewUpdateProjectMemberForbidden() *UpdateProjectMemberForbidden { + + return &UpdateProjectMemberForbidden{} +} + +// WithXRequestID adds the xRequestId to the update project member forbidden response +func (o *UpdateProjectMemberForbidden) WithXRequestID(xRequestID string) *UpdateProjectMemberForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update project member forbidden response +func (o *UpdateProjectMemberForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update project member forbidden response +func (o *UpdateProjectMemberForbidden) WithPayload(payload *models.Errors) *UpdateProjectMemberForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update project member forbidden response +func (o *UpdateProjectMemberForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateProjectMemberForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateProjectMemberNotFoundCode is the HTTP code returned for type UpdateProjectMemberNotFound +const UpdateProjectMemberNotFoundCode int = 404 + +/*UpdateProjectMemberNotFound Not found + +swagger:response updateProjectMemberNotFound +*/ +type UpdateProjectMemberNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateProjectMemberNotFound creates UpdateProjectMemberNotFound with default headers values +func NewUpdateProjectMemberNotFound() *UpdateProjectMemberNotFound { + + return &UpdateProjectMemberNotFound{} +} + +// WithXRequestID adds the xRequestId to the update project member not found response +func (o *UpdateProjectMemberNotFound) WithXRequestID(xRequestID string) *UpdateProjectMemberNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update project member not found response +func (o *UpdateProjectMemberNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update project member not found response +func (o *UpdateProjectMemberNotFound) WithPayload(payload *models.Errors) *UpdateProjectMemberNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update project member not found response +func (o *UpdateProjectMemberNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateProjectMemberNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateProjectMemberInternalServerErrorCode is the HTTP code returned for type UpdateProjectMemberInternalServerError +const UpdateProjectMemberInternalServerErrorCode int = 500 + +/*UpdateProjectMemberInternalServerError Internal server error + +swagger:response updateProjectMemberInternalServerError +*/ +type UpdateProjectMemberInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateProjectMemberInternalServerError creates UpdateProjectMemberInternalServerError with default headers values +func NewUpdateProjectMemberInternalServerError() *UpdateProjectMemberInternalServerError { + + return &UpdateProjectMemberInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the update project member internal server error response +func (o *UpdateProjectMemberInternalServerError) WithXRequestID(xRequestID string) *UpdateProjectMemberInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update project member internal server error response +func (o *UpdateProjectMemberInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update project member internal server error response +func (o *UpdateProjectMemberInternalServerError) WithPayload(payload *models.Errors) *UpdateProjectMemberInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update project member internal server error response +func (o *UpdateProjectMemberInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateProjectMemberInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/member/update_project_member_urlbuilder.go b/src/server/v2.0/restapi/operations/member/update_project_member_urlbuilder.go new file mode 100644 index 000000000..117de9b5b --- /dev/null +++ b/src/server/v2.0/restapi/operations/member/update_project_member_urlbuilder.go @@ -0,0 +1,109 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package member + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// UpdateProjectMemberURL generates an URL for the update project member operation +type UpdateProjectMemberURL struct { + Mid int64 + ProjectNameOrID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdateProjectMemberURL) WithBasePath(bp string) *UpdateProjectMemberURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdateProjectMemberURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *UpdateProjectMemberURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name_or_id}/members/{mid}" + + mid := swag.FormatInt64(o.Mid) + if mid != "" { + _path = strings.Replace(_path, "{mid}", mid, -1) + } else { + return nil, errors.New("mid is required on UpdateProjectMemberURL") + } + + projectNameOrID := o.ProjectNameOrID + if projectNameOrID != "" { + _path = strings.Replace(_path, "{project_name_or_id}", projectNameOrID, -1) + } else { + return nil, errors.New("projectNameOrId is required on UpdateProjectMemberURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *UpdateProjectMemberURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *UpdateProjectMemberURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *UpdateProjectMemberURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on UpdateProjectMemberURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on UpdateProjectMemberURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *UpdateProjectMemberURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/oidc/ping_oidc.go b/src/server/v2.0/restapi/operations/oidc/ping_oidc.go new file mode 100644 index 000000000..681eb96fa --- /dev/null +++ b/src/server/v2.0/restapi/operations/oidc/ping_oidc.go @@ -0,0 +1,111 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package oidc + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// PingOIDCHandlerFunc turns a function with the right signature into a ping OIDC handler +type PingOIDCHandlerFunc func(PingOIDCParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn PingOIDCHandlerFunc) Handle(params PingOIDCParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// PingOIDCHandler interface for that can handle valid ping OIDC params +type PingOIDCHandler interface { + Handle(PingOIDCParams, interface{}) middleware.Responder +} + +// NewPingOIDC creates a new http.Handler for the ping OIDC operation +func NewPingOIDC(ctx *middleware.Context, handler PingOIDCHandler) *PingOIDC { + return &PingOIDC{Context: ctx, Handler: handler} +} + +/*PingOIDC swagger:route POST /system/oidc/ping oidc pingOidc + +Test the OIDC endpoint. + +Test the OIDC endpoint, the setting of the endpoint is provided in the request. This API can only be called by system admin. + + +*/ +type PingOIDC struct { + Context *middleware.Context + Handler PingOIDCHandler +} + +func (o *PingOIDC) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewPingOIDCParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} + +// PingOIDCBody ping OIDC body +// +// swagger:model PingOIDCBody +type PingOIDCBody struct { + + // The URL of OIDC endpoint to be tested. + URL string `json:"url,omitempty"` + + // Whether the certificate should be verified + VerifyCert bool `json:"verify_cert,omitempty"` +} + +// Validate validates this ping OIDC body +func (o *PingOIDCBody) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *PingOIDCBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *PingOIDCBody) UnmarshalBinary(b []byte) error { + var res PingOIDCBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} diff --git a/src/server/v2.0/restapi/operations/oidc/ping_oidc_parameters.go b/src/server/v2.0/restapi/operations/oidc/ping_oidc_parameters.go new file mode 100644 index 000000000..cfe7f48e6 --- /dev/null +++ b/src/server/v2.0/restapi/operations/oidc/ping_oidc_parameters.go @@ -0,0 +1,118 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package oidc + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewPingOIDCParams creates a new PingOIDCParams object +// no default values defined in spec. +func NewPingOIDCParams() PingOIDCParams { + + return PingOIDCParams{} +} + +// PingOIDCParams contains all the bound params for the ping OIDC operation +// typically these are obtained from a http.Request +// +// swagger:parameters pingOIDC +type PingOIDCParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*Request body for OIDC endpoint to be tested. + Required: true + In: body + */ + Endpoint PingOIDCBody +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewPingOIDCParams() beforehand. +func (o *PingOIDCParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body PingOIDCBody + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("endpoint", "body", "")) + } else { + res = append(res, errors.NewParseError("endpoint", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Endpoint = body + } + } + } else { + res = append(res, errors.Required("endpoint", "body", "")) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *PingOIDCParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *PingOIDCParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} diff --git a/src/server/v2.0/restapi/operations/oidc/ping_oidc_responses.go b/src/server/v2.0/restapi/operations/oidc/ping_oidc_responses.go new file mode 100644 index 000000000..f3d521dfb --- /dev/null +++ b/src/server/v2.0/restapi/operations/oidc/ping_oidc_responses.go @@ -0,0 +1,258 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package oidc + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// PingOIDCOKCode is the HTTP code returned for type PingOIDCOK +const PingOIDCOKCode int = 200 + +/*PingOIDCOK Success + +swagger:response pingOidcOK +*/ +type PingOIDCOK struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewPingOIDCOK creates PingOIDCOK with default headers values +func NewPingOIDCOK() *PingOIDCOK { + + return &PingOIDCOK{} +} + +// WithXRequestID adds the xRequestId to the ping Oidc o k response +func (o *PingOIDCOK) WithXRequestID(xRequestID string) *PingOIDCOK { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the ping Oidc o k response +func (o *PingOIDCOK) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *PingOIDCOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// PingOIDCBadRequestCode is the HTTP code returned for type PingOIDCBadRequest +const PingOIDCBadRequestCode int = 400 + +/*PingOIDCBadRequest Bad request + +swagger:response pingOidcBadRequest +*/ +type PingOIDCBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewPingOIDCBadRequest creates PingOIDCBadRequest with default headers values +func NewPingOIDCBadRequest() *PingOIDCBadRequest { + + return &PingOIDCBadRequest{} +} + +// WithXRequestID adds the xRequestId to the ping Oidc bad request response +func (o *PingOIDCBadRequest) WithXRequestID(xRequestID string) *PingOIDCBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the ping Oidc bad request response +func (o *PingOIDCBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the ping Oidc bad request response +func (o *PingOIDCBadRequest) WithPayload(payload *models.Errors) *PingOIDCBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the ping Oidc bad request response +func (o *PingOIDCBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PingOIDCBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PingOIDCUnauthorizedCode is the HTTP code returned for type PingOIDCUnauthorized +const PingOIDCUnauthorizedCode int = 401 + +/*PingOIDCUnauthorized Unauthorized + +swagger:response pingOidcUnauthorized +*/ +type PingOIDCUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewPingOIDCUnauthorized creates PingOIDCUnauthorized with default headers values +func NewPingOIDCUnauthorized() *PingOIDCUnauthorized { + + return &PingOIDCUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the ping Oidc unauthorized response +func (o *PingOIDCUnauthorized) WithXRequestID(xRequestID string) *PingOIDCUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the ping Oidc unauthorized response +func (o *PingOIDCUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the ping Oidc unauthorized response +func (o *PingOIDCUnauthorized) WithPayload(payload *models.Errors) *PingOIDCUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the ping Oidc unauthorized response +func (o *PingOIDCUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PingOIDCUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PingOIDCForbiddenCode is the HTTP code returned for type PingOIDCForbidden +const PingOIDCForbiddenCode int = 403 + +/*PingOIDCForbidden Forbidden + +swagger:response pingOidcForbidden +*/ +type PingOIDCForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewPingOIDCForbidden creates PingOIDCForbidden with default headers values +func NewPingOIDCForbidden() *PingOIDCForbidden { + + return &PingOIDCForbidden{} +} + +// WithXRequestID adds the xRequestId to the ping Oidc forbidden response +func (o *PingOIDCForbidden) WithXRequestID(xRequestID string) *PingOIDCForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the ping Oidc forbidden response +func (o *PingOIDCForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the ping Oidc forbidden response +func (o *PingOIDCForbidden) WithPayload(payload *models.Errors) *PingOIDCForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the ping Oidc forbidden response +func (o *PingOIDCForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PingOIDCForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/oidc/ping_oidc_urlbuilder.go b/src/server/v2.0/restapi/operations/oidc/ping_oidc_urlbuilder.go new file mode 100644 index 000000000..543636b90 --- /dev/null +++ b/src/server/v2.0/restapi/operations/oidc/ping_oidc_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package oidc + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// PingOIDCURL generates an URL for the ping OIDC operation +type PingOIDCURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *PingOIDCURL) WithBasePath(bp string) *PingOIDCURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *PingOIDCURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *PingOIDCURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/system/oidc/ping" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *PingOIDCURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *PingOIDCURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *PingOIDCURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on PingOIDCURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on PingOIDCURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *PingOIDCURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/ping/get_ping.go b/src/server/v2.0/restapi/operations/ping/get_ping.go new file mode 100644 index 000000000..5163265d1 --- /dev/null +++ b/src/server/v2.0/restapi/operations/ping/get_ping.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package ping + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetPingHandlerFunc turns a function with the right signature into a get ping handler +type GetPingHandlerFunc func(GetPingParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetPingHandlerFunc) Handle(params GetPingParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetPingHandler interface for that can handle valid get ping params +type GetPingHandler interface { + Handle(GetPingParams, interface{}) middleware.Responder +} + +// NewGetPing creates a new http.Handler for the get ping operation +func NewGetPing(ctx *middleware.Context, handler GetPingHandler) *GetPing { + return &GetPing{Context: ctx, Handler: handler} +} + +/*GetPing swagger:route GET /ping ping getPing + +Ping Harbor to check if it's alive. + +This API simply replies a pong to indicate the process to handle API is up, disregarding the health status of dependent components. + +*/ +type GetPing struct { + Context *middleware.Context + Handler GetPingHandler +} + +func (o *GetPing) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetPingParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/ping/get_ping_parameters.go b/src/server/v2.0/restapi/operations/ping/get_ping_parameters.go new file mode 100644 index 000000000..7989c345e --- /dev/null +++ b/src/server/v2.0/restapi/operations/ping/get_ping_parameters.go @@ -0,0 +1,89 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package ping + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewGetPingParams creates a new GetPingParams object +// no default values defined in spec. +func NewGetPingParams() GetPingParams { + + return GetPingParams{} +} + +// GetPingParams contains all the bound params for the get ping operation +// typically these are obtained from a http.Request +// +// swagger:parameters getPing +type GetPingParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetPingParams() beforehand. +func (o *GetPingParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetPingParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetPingParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} diff --git a/src/server/v2.0/restapi/operations/ping/get_ping_responses.go b/src/server/v2.0/restapi/operations/ping/get_ping_responses.go new file mode 100644 index 000000000..d51e33e7a --- /dev/null +++ b/src/server/v2.0/restapi/operations/ping/get_ping_responses.go @@ -0,0 +1,54 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package ping + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" +) + +// GetPingOKCode is the HTTP code returned for type GetPingOK +const GetPingOKCode int = 200 + +/*GetPingOK The API server is alive + +swagger:response getPingOK +*/ +type GetPingOK struct { + + /* + In: Body + */ + Payload string `json:"body,omitempty"` +} + +// NewGetPingOK creates GetPingOK with default headers values +func NewGetPingOK() *GetPingOK { + + return &GetPingOK{} +} + +// WithPayload adds the payload to the get ping o k response +func (o *GetPingOK) WithPayload(payload string) *GetPingOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get ping o k response +func (o *GetPingOK) SetPayload(payload string) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetPingOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} diff --git a/src/server/v2.0/restapi/operations/ping/get_ping_urlbuilder.go b/src/server/v2.0/restapi/operations/ping/get_ping_urlbuilder.go new file mode 100644 index 000000000..8516a6b43 --- /dev/null +++ b/src/server/v2.0/restapi/operations/ping/get_ping_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package ping + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetPingURL generates an URL for the get ping operation +type GetPingURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetPingURL) WithBasePath(bp string) *GetPingURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetPingURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetPingURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/ping" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetPingURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetPingURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetPingURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetPingURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetPingURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetPingURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/preheat/create_instance.go b/src/server/v2.0/restapi/operations/preheat/create_instance.go new file mode 100644 index 000000000..b2abc3119 --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/create_instance.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateInstanceHandlerFunc turns a function with the right signature into a create instance handler +type CreateInstanceHandlerFunc func(CreateInstanceParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateInstanceHandlerFunc) Handle(params CreateInstanceParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateInstanceHandler interface for that can handle valid create instance params +type CreateInstanceHandler interface { + Handle(CreateInstanceParams, interface{}) middleware.Responder +} + +// NewCreateInstance creates a new http.Handler for the create instance operation +func NewCreateInstance(ctx *middleware.Context, handler CreateInstanceHandler) *CreateInstance { + return &CreateInstance{Context: ctx, Handler: handler} +} + +/*CreateInstance swagger:route POST /p2p/preheat/instances preheat createInstance + +Create p2p provider instances + +Create p2p provider instances + +*/ +type CreateInstance struct { + Context *middleware.Context + Handler CreateInstanceHandler +} + +func (o *CreateInstance) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewCreateInstanceParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/preheat/create_instance_parameters.go b/src/server/v2.0/restapi/operations/preheat/create_instance_parameters.go new file mode 100644 index 000000000..ddd90f4a5 --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/create_instance_parameters.go @@ -0,0 +1,120 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewCreateInstanceParams creates a new CreateInstanceParams object +// no default values defined in spec. +func NewCreateInstanceParams() CreateInstanceParams { + + return CreateInstanceParams{} +} + +// CreateInstanceParams contains all the bound params for the create instance operation +// typically these are obtained from a http.Request +// +// swagger:parameters CreateInstance +type CreateInstanceParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The JSON object of instance. + Required: true + In: body + */ + Instance *models.Instance +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateInstanceParams() beforehand. +func (o *CreateInstanceParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Instance + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("instance", "body", "")) + } else { + res = append(res, errors.NewParseError("instance", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Instance = &body + } + } + } else { + res = append(res, errors.Required("instance", "body", "")) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *CreateInstanceParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *CreateInstanceParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} diff --git a/src/server/v2.0/restapi/operations/preheat/create_instance_responses.go b/src/server/v2.0/restapi/operations/preheat/create_instance_responses.go new file mode 100644 index 000000000..92e2adc81 --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/create_instance_responses.go @@ -0,0 +1,478 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// CreateInstanceCreatedCode is the HTTP code returned for type CreateInstanceCreated +const CreateInstanceCreatedCode int = 201 + +/*CreateInstanceCreated Created + +swagger:response createInstanceCreated +*/ +type CreateInstanceCreated struct { + /*The location of the resource + + */ + Location string `json:"Location"` + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewCreateInstanceCreated creates CreateInstanceCreated with default headers values +func NewCreateInstanceCreated() *CreateInstanceCreated { + + return &CreateInstanceCreated{} +} + +// WithLocation adds the location to the create instance created response +func (o *CreateInstanceCreated) WithLocation(location string) *CreateInstanceCreated { + o.Location = location + return o +} + +// SetLocation sets the location to the create instance created response +func (o *CreateInstanceCreated) SetLocation(location string) { + o.Location = location +} + +// WithXRequestID adds the xRequestId to the create instance created response +func (o *CreateInstanceCreated) WithXRequestID(xRequestID string) *CreateInstanceCreated { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create instance created response +func (o *CreateInstanceCreated) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *CreateInstanceCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Location + + location := o.Location + if location != "" { + rw.Header().Set("Location", location) + } + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(201) +} + +// CreateInstanceBadRequestCode is the HTTP code returned for type CreateInstanceBadRequest +const CreateInstanceBadRequestCode int = 400 + +/*CreateInstanceBadRequest Bad request + +swagger:response createInstanceBadRequest +*/ +type CreateInstanceBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateInstanceBadRequest creates CreateInstanceBadRequest with default headers values +func NewCreateInstanceBadRequest() *CreateInstanceBadRequest { + + return &CreateInstanceBadRequest{} +} + +// WithXRequestID adds the xRequestId to the create instance bad request response +func (o *CreateInstanceBadRequest) WithXRequestID(xRequestID string) *CreateInstanceBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create instance bad request response +func (o *CreateInstanceBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create instance bad request response +func (o *CreateInstanceBadRequest) WithPayload(payload *models.Errors) *CreateInstanceBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create instance bad request response +func (o *CreateInstanceBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateInstanceBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateInstanceUnauthorizedCode is the HTTP code returned for type CreateInstanceUnauthorized +const CreateInstanceUnauthorizedCode int = 401 + +/*CreateInstanceUnauthorized Unauthorized + +swagger:response createInstanceUnauthorized +*/ +type CreateInstanceUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateInstanceUnauthorized creates CreateInstanceUnauthorized with default headers values +func NewCreateInstanceUnauthorized() *CreateInstanceUnauthorized { + + return &CreateInstanceUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the create instance unauthorized response +func (o *CreateInstanceUnauthorized) WithXRequestID(xRequestID string) *CreateInstanceUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create instance unauthorized response +func (o *CreateInstanceUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create instance unauthorized response +func (o *CreateInstanceUnauthorized) WithPayload(payload *models.Errors) *CreateInstanceUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create instance unauthorized response +func (o *CreateInstanceUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateInstanceUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateInstanceForbiddenCode is the HTTP code returned for type CreateInstanceForbidden +const CreateInstanceForbiddenCode int = 403 + +/*CreateInstanceForbidden Forbidden + +swagger:response createInstanceForbidden +*/ +type CreateInstanceForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateInstanceForbidden creates CreateInstanceForbidden with default headers values +func NewCreateInstanceForbidden() *CreateInstanceForbidden { + + return &CreateInstanceForbidden{} +} + +// WithXRequestID adds the xRequestId to the create instance forbidden response +func (o *CreateInstanceForbidden) WithXRequestID(xRequestID string) *CreateInstanceForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create instance forbidden response +func (o *CreateInstanceForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create instance forbidden response +func (o *CreateInstanceForbidden) WithPayload(payload *models.Errors) *CreateInstanceForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create instance forbidden response +func (o *CreateInstanceForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateInstanceForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateInstanceNotFoundCode is the HTTP code returned for type CreateInstanceNotFound +const CreateInstanceNotFoundCode int = 404 + +/*CreateInstanceNotFound Not found + +swagger:response createInstanceNotFound +*/ +type CreateInstanceNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateInstanceNotFound creates CreateInstanceNotFound with default headers values +func NewCreateInstanceNotFound() *CreateInstanceNotFound { + + return &CreateInstanceNotFound{} +} + +// WithXRequestID adds the xRequestId to the create instance not found response +func (o *CreateInstanceNotFound) WithXRequestID(xRequestID string) *CreateInstanceNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create instance not found response +func (o *CreateInstanceNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create instance not found response +func (o *CreateInstanceNotFound) WithPayload(payload *models.Errors) *CreateInstanceNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create instance not found response +func (o *CreateInstanceNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateInstanceNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateInstanceConflictCode is the HTTP code returned for type CreateInstanceConflict +const CreateInstanceConflictCode int = 409 + +/*CreateInstanceConflict Conflict + +swagger:response createInstanceConflict +*/ +type CreateInstanceConflict struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateInstanceConflict creates CreateInstanceConflict with default headers values +func NewCreateInstanceConflict() *CreateInstanceConflict { + + return &CreateInstanceConflict{} +} + +// WithXRequestID adds the xRequestId to the create instance conflict response +func (o *CreateInstanceConflict) WithXRequestID(xRequestID string) *CreateInstanceConflict { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create instance conflict response +func (o *CreateInstanceConflict) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create instance conflict response +func (o *CreateInstanceConflict) WithPayload(payload *models.Errors) *CreateInstanceConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create instance conflict response +func (o *CreateInstanceConflict) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateInstanceConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateInstanceInternalServerErrorCode is the HTTP code returned for type CreateInstanceInternalServerError +const CreateInstanceInternalServerErrorCode int = 500 + +/*CreateInstanceInternalServerError Internal server error + +swagger:response createInstanceInternalServerError +*/ +type CreateInstanceInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateInstanceInternalServerError creates CreateInstanceInternalServerError with default headers values +func NewCreateInstanceInternalServerError() *CreateInstanceInternalServerError { + + return &CreateInstanceInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the create instance internal server error response +func (o *CreateInstanceInternalServerError) WithXRequestID(xRequestID string) *CreateInstanceInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create instance internal server error response +func (o *CreateInstanceInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create instance internal server error response +func (o *CreateInstanceInternalServerError) WithPayload(payload *models.Errors) *CreateInstanceInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create instance internal server error response +func (o *CreateInstanceInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateInstanceInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/preheat/create_instance_urlbuilder.go b/src/server/v2.0/restapi/operations/preheat/create_instance_urlbuilder.go new file mode 100644 index 000000000..7cad1b2a1 --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/create_instance_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// CreateInstanceURL generates an URL for the create instance operation +type CreateInstanceURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateInstanceURL) WithBasePath(bp string) *CreateInstanceURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateInstanceURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateInstanceURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/p2p/preheat/instances" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateInstanceURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateInstanceURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateInstanceURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateInstanceURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateInstanceURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateInstanceURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/preheat/create_policy.go b/src/server/v2.0/restapi/operations/preheat/create_policy.go new file mode 100644 index 000000000..77171b770 --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/create_policy.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreatePolicyHandlerFunc turns a function with the right signature into a create policy handler +type CreatePolicyHandlerFunc func(CreatePolicyParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreatePolicyHandlerFunc) Handle(params CreatePolicyParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreatePolicyHandler interface for that can handle valid create policy params +type CreatePolicyHandler interface { + Handle(CreatePolicyParams, interface{}) middleware.Responder +} + +// NewCreatePolicy creates a new http.Handler for the create policy operation +func NewCreatePolicy(ctx *middleware.Context, handler CreatePolicyHandler) *CreatePolicy { + return &CreatePolicy{Context: ctx, Handler: handler} +} + +/*CreatePolicy swagger:route POST /projects/{project_name}/preheat/policies preheat createPolicy + +Create a preheat policy under a project + +Create a preheat policy under a project + +*/ +type CreatePolicy struct { + Context *middleware.Context + Handler CreatePolicyHandler +} + +func (o *CreatePolicy) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewCreatePolicyParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/preheat/create_policy_parameters.go b/src/server/v2.0/restapi/operations/preheat/create_policy_parameters.go new file mode 100644 index 000000000..724f56d33 --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/create_policy_parameters.go @@ -0,0 +1,145 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewCreatePolicyParams creates a new CreatePolicyParams object +// no default values defined in spec. +func NewCreatePolicyParams() CreatePolicyParams { + + return CreatePolicyParams{} +} + +// CreatePolicyParams contains all the bound params for the create policy operation +// typically these are obtained from a http.Request +// +// swagger:parameters CreatePolicy +type CreatePolicyParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The policy schema info + Required: true + In: body + */ + Policy *models.PreheatPolicy + /*The name of the project + Required: true + In: path + */ + ProjectName string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreatePolicyParams() beforehand. +func (o *CreatePolicyParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.PreheatPolicy + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("policy", "body", "")) + } else { + res = append(res, errors.NewParseError("policy", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Policy = &body + } + } + } else { + res = append(res, errors.Required("policy", "body", "")) + } + rProjectName, rhkProjectName, _ := route.Params.GetOK("project_name") + if err := o.bindProjectName(rProjectName, rhkProjectName, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *CreatePolicyParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *CreatePolicyParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindProjectName binds and validates parameter ProjectName from path. +func (o *CreatePolicyParams) bindProjectName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectName = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/preheat/create_policy_responses.go b/src/server/v2.0/restapi/operations/preheat/create_policy_responses.go new file mode 100644 index 000000000..25a45ad1d --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/create_policy_responses.go @@ -0,0 +1,412 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// CreatePolicyCreatedCode is the HTTP code returned for type CreatePolicyCreated +const CreatePolicyCreatedCode int = 201 + +/*CreatePolicyCreated Created + +swagger:response createPolicyCreated +*/ +type CreatePolicyCreated struct { + /*The location of the resource + + */ + Location string `json:"Location"` + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewCreatePolicyCreated creates CreatePolicyCreated with default headers values +func NewCreatePolicyCreated() *CreatePolicyCreated { + + return &CreatePolicyCreated{} +} + +// WithLocation adds the location to the create policy created response +func (o *CreatePolicyCreated) WithLocation(location string) *CreatePolicyCreated { + o.Location = location + return o +} + +// SetLocation sets the location to the create policy created response +func (o *CreatePolicyCreated) SetLocation(location string) { + o.Location = location +} + +// WithXRequestID adds the xRequestId to the create policy created response +func (o *CreatePolicyCreated) WithXRequestID(xRequestID string) *CreatePolicyCreated { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create policy created response +func (o *CreatePolicyCreated) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *CreatePolicyCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Location + + location := o.Location + if location != "" { + rw.Header().Set("Location", location) + } + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(201) +} + +// CreatePolicyBadRequestCode is the HTTP code returned for type CreatePolicyBadRequest +const CreatePolicyBadRequestCode int = 400 + +/*CreatePolicyBadRequest Bad request + +swagger:response createPolicyBadRequest +*/ +type CreatePolicyBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreatePolicyBadRequest creates CreatePolicyBadRequest with default headers values +func NewCreatePolicyBadRequest() *CreatePolicyBadRequest { + + return &CreatePolicyBadRequest{} +} + +// WithXRequestID adds the xRequestId to the create policy bad request response +func (o *CreatePolicyBadRequest) WithXRequestID(xRequestID string) *CreatePolicyBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create policy bad request response +func (o *CreatePolicyBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create policy bad request response +func (o *CreatePolicyBadRequest) WithPayload(payload *models.Errors) *CreatePolicyBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create policy bad request response +func (o *CreatePolicyBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreatePolicyBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreatePolicyUnauthorizedCode is the HTTP code returned for type CreatePolicyUnauthorized +const CreatePolicyUnauthorizedCode int = 401 + +/*CreatePolicyUnauthorized Unauthorized + +swagger:response createPolicyUnauthorized +*/ +type CreatePolicyUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreatePolicyUnauthorized creates CreatePolicyUnauthorized with default headers values +func NewCreatePolicyUnauthorized() *CreatePolicyUnauthorized { + + return &CreatePolicyUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the create policy unauthorized response +func (o *CreatePolicyUnauthorized) WithXRequestID(xRequestID string) *CreatePolicyUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create policy unauthorized response +func (o *CreatePolicyUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create policy unauthorized response +func (o *CreatePolicyUnauthorized) WithPayload(payload *models.Errors) *CreatePolicyUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create policy unauthorized response +func (o *CreatePolicyUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreatePolicyUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreatePolicyForbiddenCode is the HTTP code returned for type CreatePolicyForbidden +const CreatePolicyForbiddenCode int = 403 + +/*CreatePolicyForbidden Forbidden + +swagger:response createPolicyForbidden +*/ +type CreatePolicyForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreatePolicyForbidden creates CreatePolicyForbidden with default headers values +func NewCreatePolicyForbidden() *CreatePolicyForbidden { + + return &CreatePolicyForbidden{} +} + +// WithXRequestID adds the xRequestId to the create policy forbidden response +func (o *CreatePolicyForbidden) WithXRequestID(xRequestID string) *CreatePolicyForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create policy forbidden response +func (o *CreatePolicyForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create policy forbidden response +func (o *CreatePolicyForbidden) WithPayload(payload *models.Errors) *CreatePolicyForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create policy forbidden response +func (o *CreatePolicyForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreatePolicyForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreatePolicyConflictCode is the HTTP code returned for type CreatePolicyConflict +const CreatePolicyConflictCode int = 409 + +/*CreatePolicyConflict Conflict + +swagger:response createPolicyConflict +*/ +type CreatePolicyConflict struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreatePolicyConflict creates CreatePolicyConflict with default headers values +func NewCreatePolicyConflict() *CreatePolicyConflict { + + return &CreatePolicyConflict{} +} + +// WithXRequestID adds the xRequestId to the create policy conflict response +func (o *CreatePolicyConflict) WithXRequestID(xRequestID string) *CreatePolicyConflict { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create policy conflict response +func (o *CreatePolicyConflict) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create policy conflict response +func (o *CreatePolicyConflict) WithPayload(payload *models.Errors) *CreatePolicyConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create policy conflict response +func (o *CreatePolicyConflict) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreatePolicyConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreatePolicyInternalServerErrorCode is the HTTP code returned for type CreatePolicyInternalServerError +const CreatePolicyInternalServerErrorCode int = 500 + +/*CreatePolicyInternalServerError Internal server error + +swagger:response createPolicyInternalServerError +*/ +type CreatePolicyInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreatePolicyInternalServerError creates CreatePolicyInternalServerError with default headers values +func NewCreatePolicyInternalServerError() *CreatePolicyInternalServerError { + + return &CreatePolicyInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the create policy internal server error response +func (o *CreatePolicyInternalServerError) WithXRequestID(xRequestID string) *CreatePolicyInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create policy internal server error response +func (o *CreatePolicyInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create policy internal server error response +func (o *CreatePolicyInternalServerError) WithPayload(payload *models.Errors) *CreatePolicyInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create policy internal server error response +func (o *CreatePolicyInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreatePolicyInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/preheat/create_policy_urlbuilder.go b/src/server/v2.0/restapi/operations/preheat/create_policy_urlbuilder.go new file mode 100644 index 000000000..95d8b34c7 --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/create_policy_urlbuilder.go @@ -0,0 +1,99 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// CreatePolicyURL generates an URL for the create policy operation +type CreatePolicyURL struct { + ProjectName string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreatePolicyURL) WithBasePath(bp string) *CreatePolicyURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreatePolicyURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreatePolicyURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name}/preheat/policies" + + projectName := o.ProjectName + if projectName != "" { + _path = strings.Replace(_path, "{project_name}", projectName, -1) + } else { + return nil, errors.New("projectName is required on CreatePolicyURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreatePolicyURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreatePolicyURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreatePolicyURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreatePolicyURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreatePolicyURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreatePolicyURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/preheat/delete_instance.go b/src/server/v2.0/restapi/operations/preheat/delete_instance.go new file mode 100644 index 000000000..aa69387b2 --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/delete_instance.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteInstanceHandlerFunc turns a function with the right signature into a delete instance handler +type DeleteInstanceHandlerFunc func(DeleteInstanceParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteInstanceHandlerFunc) Handle(params DeleteInstanceParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteInstanceHandler interface for that can handle valid delete instance params +type DeleteInstanceHandler interface { + Handle(DeleteInstanceParams, interface{}) middleware.Responder +} + +// NewDeleteInstance creates a new http.Handler for the delete instance operation +func NewDeleteInstance(ctx *middleware.Context, handler DeleteInstanceHandler) *DeleteInstance { + return &DeleteInstance{Context: ctx, Handler: handler} +} + +/*DeleteInstance swagger:route DELETE /p2p/preheat/instances/{preheat_instance_name} preheat deleteInstance + +Delete the specified P2P provider instance + +Delete the specified P2P provider instance + +*/ +type DeleteInstance struct { + Context *middleware.Context + Handler DeleteInstanceHandler +} + +func (o *DeleteInstance) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewDeleteInstanceParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/preheat/delete_instance_parameters.go b/src/server/v2.0/restapi/operations/preheat/delete_instance_parameters.go new file mode 100644 index 000000000..83b5305db --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/delete_instance_parameters.go @@ -0,0 +1,114 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewDeleteInstanceParams creates a new DeleteInstanceParams object +// no default values defined in spec. +func NewDeleteInstanceParams() DeleteInstanceParams { + + return DeleteInstanceParams{} +} + +// DeleteInstanceParams contains all the bound params for the delete instance operation +// typically these are obtained from a http.Request +// +// swagger:parameters DeleteInstance +type DeleteInstanceParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*Instance Name + Required: true + In: path + */ + PreheatInstanceName string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteInstanceParams() beforehand. +func (o *DeleteInstanceParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rPreheatInstanceName, rhkPreheatInstanceName, _ := route.Params.GetOK("preheat_instance_name") + if err := o.bindPreheatInstanceName(rPreheatInstanceName, rhkPreheatInstanceName, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *DeleteInstanceParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *DeleteInstanceParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindPreheatInstanceName binds and validates parameter PreheatInstanceName from path. +func (o *DeleteInstanceParams) bindPreheatInstanceName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.PreheatInstanceName = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/preheat/delete_instance_responses.go b/src/server/v2.0/restapi/operations/preheat/delete_instance_responses.go new file mode 100644 index 000000000..9ae94959d --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/delete_instance_responses.go @@ -0,0 +1,324 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// DeleteInstanceOKCode is the HTTP code returned for type DeleteInstanceOK +const DeleteInstanceOKCode int = 200 + +/*DeleteInstanceOK Success + +swagger:response deleteInstanceOK +*/ +type DeleteInstanceOK struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewDeleteInstanceOK creates DeleteInstanceOK with default headers values +func NewDeleteInstanceOK() *DeleteInstanceOK { + + return &DeleteInstanceOK{} +} + +// WithXRequestID adds the xRequestId to the delete instance o k response +func (o *DeleteInstanceOK) WithXRequestID(xRequestID string) *DeleteInstanceOK { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete instance o k response +func (o *DeleteInstanceOK) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *DeleteInstanceOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// DeleteInstanceUnauthorizedCode is the HTTP code returned for type DeleteInstanceUnauthorized +const DeleteInstanceUnauthorizedCode int = 401 + +/*DeleteInstanceUnauthorized Unauthorized + +swagger:response deleteInstanceUnauthorized +*/ +type DeleteInstanceUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteInstanceUnauthorized creates DeleteInstanceUnauthorized with default headers values +func NewDeleteInstanceUnauthorized() *DeleteInstanceUnauthorized { + + return &DeleteInstanceUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the delete instance unauthorized response +func (o *DeleteInstanceUnauthorized) WithXRequestID(xRequestID string) *DeleteInstanceUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete instance unauthorized response +func (o *DeleteInstanceUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete instance unauthorized response +func (o *DeleteInstanceUnauthorized) WithPayload(payload *models.Errors) *DeleteInstanceUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete instance unauthorized response +func (o *DeleteInstanceUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteInstanceUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteInstanceForbiddenCode is the HTTP code returned for type DeleteInstanceForbidden +const DeleteInstanceForbiddenCode int = 403 + +/*DeleteInstanceForbidden Forbidden + +swagger:response deleteInstanceForbidden +*/ +type DeleteInstanceForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteInstanceForbidden creates DeleteInstanceForbidden with default headers values +func NewDeleteInstanceForbidden() *DeleteInstanceForbidden { + + return &DeleteInstanceForbidden{} +} + +// WithXRequestID adds the xRequestId to the delete instance forbidden response +func (o *DeleteInstanceForbidden) WithXRequestID(xRequestID string) *DeleteInstanceForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete instance forbidden response +func (o *DeleteInstanceForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete instance forbidden response +func (o *DeleteInstanceForbidden) WithPayload(payload *models.Errors) *DeleteInstanceForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete instance forbidden response +func (o *DeleteInstanceForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteInstanceForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteInstanceNotFoundCode is the HTTP code returned for type DeleteInstanceNotFound +const DeleteInstanceNotFoundCode int = 404 + +/*DeleteInstanceNotFound Not found + +swagger:response deleteInstanceNotFound +*/ +type DeleteInstanceNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteInstanceNotFound creates DeleteInstanceNotFound with default headers values +func NewDeleteInstanceNotFound() *DeleteInstanceNotFound { + + return &DeleteInstanceNotFound{} +} + +// WithXRequestID adds the xRequestId to the delete instance not found response +func (o *DeleteInstanceNotFound) WithXRequestID(xRequestID string) *DeleteInstanceNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete instance not found response +func (o *DeleteInstanceNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete instance not found response +func (o *DeleteInstanceNotFound) WithPayload(payload *models.Errors) *DeleteInstanceNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete instance not found response +func (o *DeleteInstanceNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteInstanceNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteInstanceInternalServerErrorCode is the HTTP code returned for type DeleteInstanceInternalServerError +const DeleteInstanceInternalServerErrorCode int = 500 + +/*DeleteInstanceInternalServerError Internal server error + +swagger:response deleteInstanceInternalServerError +*/ +type DeleteInstanceInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteInstanceInternalServerError creates DeleteInstanceInternalServerError with default headers values +func NewDeleteInstanceInternalServerError() *DeleteInstanceInternalServerError { + + return &DeleteInstanceInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the delete instance internal server error response +func (o *DeleteInstanceInternalServerError) WithXRequestID(xRequestID string) *DeleteInstanceInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete instance internal server error response +func (o *DeleteInstanceInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete instance internal server error response +func (o *DeleteInstanceInternalServerError) WithPayload(payload *models.Errors) *DeleteInstanceInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete instance internal server error response +func (o *DeleteInstanceInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteInstanceInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/preheat/delete_instance_urlbuilder.go b/src/server/v2.0/restapi/operations/preheat/delete_instance_urlbuilder.go new file mode 100644 index 000000000..5a825a2c5 --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/delete_instance_urlbuilder.go @@ -0,0 +1,99 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// DeleteInstanceURL generates an URL for the delete instance operation +type DeleteInstanceURL struct { + PreheatInstanceName string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteInstanceURL) WithBasePath(bp string) *DeleteInstanceURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteInstanceURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteInstanceURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/p2p/preheat/instances/{preheat_instance_name}" + + preheatInstanceName := o.PreheatInstanceName + if preheatInstanceName != "" { + _path = strings.Replace(_path, "{preheat_instance_name}", preheatInstanceName, -1) + } else { + return nil, errors.New("preheatInstanceName is required on DeleteInstanceURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteInstanceURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteInstanceURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteInstanceURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteInstanceURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteInstanceURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteInstanceURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/preheat/delete_policy.go b/src/server/v2.0/restapi/operations/preheat/delete_policy.go new file mode 100644 index 000000000..410f0c979 --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/delete_policy.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeletePolicyHandlerFunc turns a function with the right signature into a delete policy handler +type DeletePolicyHandlerFunc func(DeletePolicyParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeletePolicyHandlerFunc) Handle(params DeletePolicyParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeletePolicyHandler interface for that can handle valid delete policy params +type DeletePolicyHandler interface { + Handle(DeletePolicyParams, interface{}) middleware.Responder +} + +// NewDeletePolicy creates a new http.Handler for the delete policy operation +func NewDeletePolicy(ctx *middleware.Context, handler DeletePolicyHandler) *DeletePolicy { + return &DeletePolicy{Context: ctx, Handler: handler} +} + +/*DeletePolicy swagger:route DELETE /projects/{project_name}/preheat/policies/{preheat_policy_name} preheat deletePolicy + +Delete a preheat policy + +Delete a preheat policy + +*/ +type DeletePolicy struct { + Context *middleware.Context + Handler DeletePolicyHandler +} + +func (o *DeletePolicy) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewDeletePolicyParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/preheat/delete_policy_parameters.go b/src/server/v2.0/restapi/operations/preheat/delete_policy_parameters.go new file mode 100644 index 000000000..d3743cae8 --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/delete_policy_parameters.go @@ -0,0 +1,139 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewDeletePolicyParams creates a new DeletePolicyParams object +// no default values defined in spec. +func NewDeletePolicyParams() DeletePolicyParams { + + return DeletePolicyParams{} +} + +// DeletePolicyParams contains all the bound params for the delete policy operation +// typically these are obtained from a http.Request +// +// swagger:parameters DeletePolicy +type DeletePolicyParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*Preheat Policy Name + Required: true + In: path + */ + PreheatPolicyName string + /*The name of the project + Required: true + In: path + */ + ProjectName string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeletePolicyParams() beforehand. +func (o *DeletePolicyParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rPreheatPolicyName, rhkPreheatPolicyName, _ := route.Params.GetOK("preheat_policy_name") + if err := o.bindPreheatPolicyName(rPreheatPolicyName, rhkPreheatPolicyName, route.Formats); err != nil { + res = append(res, err) + } + + rProjectName, rhkProjectName, _ := route.Params.GetOK("project_name") + if err := o.bindProjectName(rProjectName, rhkProjectName, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *DeletePolicyParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *DeletePolicyParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindPreheatPolicyName binds and validates parameter PreheatPolicyName from path. +func (o *DeletePolicyParams) bindPreheatPolicyName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.PreheatPolicyName = raw + + return nil +} + +// bindProjectName binds and validates parameter ProjectName from path. +func (o *DeletePolicyParams) bindProjectName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectName = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/preheat/delete_policy_responses.go b/src/server/v2.0/restapi/operations/preheat/delete_policy_responses.go new file mode 100644 index 000000000..7f337c016 --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/delete_policy_responses.go @@ -0,0 +1,390 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// DeletePolicyOKCode is the HTTP code returned for type DeletePolicyOK +const DeletePolicyOKCode int = 200 + +/*DeletePolicyOK Success + +swagger:response deletePolicyOK +*/ +type DeletePolicyOK struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewDeletePolicyOK creates DeletePolicyOK with default headers values +func NewDeletePolicyOK() *DeletePolicyOK { + + return &DeletePolicyOK{} +} + +// WithXRequestID adds the xRequestId to the delete policy o k response +func (o *DeletePolicyOK) WithXRequestID(xRequestID string) *DeletePolicyOK { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete policy o k response +func (o *DeletePolicyOK) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *DeletePolicyOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// DeletePolicyBadRequestCode is the HTTP code returned for type DeletePolicyBadRequest +const DeletePolicyBadRequestCode int = 400 + +/*DeletePolicyBadRequest Bad request + +swagger:response deletePolicyBadRequest +*/ +type DeletePolicyBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeletePolicyBadRequest creates DeletePolicyBadRequest with default headers values +func NewDeletePolicyBadRequest() *DeletePolicyBadRequest { + + return &DeletePolicyBadRequest{} +} + +// WithXRequestID adds the xRequestId to the delete policy bad request response +func (o *DeletePolicyBadRequest) WithXRequestID(xRequestID string) *DeletePolicyBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete policy bad request response +func (o *DeletePolicyBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete policy bad request response +func (o *DeletePolicyBadRequest) WithPayload(payload *models.Errors) *DeletePolicyBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete policy bad request response +func (o *DeletePolicyBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeletePolicyBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeletePolicyUnauthorizedCode is the HTTP code returned for type DeletePolicyUnauthorized +const DeletePolicyUnauthorizedCode int = 401 + +/*DeletePolicyUnauthorized Unauthorized + +swagger:response deletePolicyUnauthorized +*/ +type DeletePolicyUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeletePolicyUnauthorized creates DeletePolicyUnauthorized with default headers values +func NewDeletePolicyUnauthorized() *DeletePolicyUnauthorized { + + return &DeletePolicyUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the delete policy unauthorized response +func (o *DeletePolicyUnauthorized) WithXRequestID(xRequestID string) *DeletePolicyUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete policy unauthorized response +func (o *DeletePolicyUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete policy unauthorized response +func (o *DeletePolicyUnauthorized) WithPayload(payload *models.Errors) *DeletePolicyUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete policy unauthorized response +func (o *DeletePolicyUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeletePolicyUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeletePolicyForbiddenCode is the HTTP code returned for type DeletePolicyForbidden +const DeletePolicyForbiddenCode int = 403 + +/*DeletePolicyForbidden Forbidden + +swagger:response deletePolicyForbidden +*/ +type DeletePolicyForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeletePolicyForbidden creates DeletePolicyForbidden with default headers values +func NewDeletePolicyForbidden() *DeletePolicyForbidden { + + return &DeletePolicyForbidden{} +} + +// WithXRequestID adds the xRequestId to the delete policy forbidden response +func (o *DeletePolicyForbidden) WithXRequestID(xRequestID string) *DeletePolicyForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete policy forbidden response +func (o *DeletePolicyForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete policy forbidden response +func (o *DeletePolicyForbidden) WithPayload(payload *models.Errors) *DeletePolicyForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete policy forbidden response +func (o *DeletePolicyForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeletePolicyForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeletePolicyNotFoundCode is the HTTP code returned for type DeletePolicyNotFound +const DeletePolicyNotFoundCode int = 404 + +/*DeletePolicyNotFound Not found + +swagger:response deletePolicyNotFound +*/ +type DeletePolicyNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeletePolicyNotFound creates DeletePolicyNotFound with default headers values +func NewDeletePolicyNotFound() *DeletePolicyNotFound { + + return &DeletePolicyNotFound{} +} + +// WithXRequestID adds the xRequestId to the delete policy not found response +func (o *DeletePolicyNotFound) WithXRequestID(xRequestID string) *DeletePolicyNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete policy not found response +func (o *DeletePolicyNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete policy not found response +func (o *DeletePolicyNotFound) WithPayload(payload *models.Errors) *DeletePolicyNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete policy not found response +func (o *DeletePolicyNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeletePolicyNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeletePolicyInternalServerErrorCode is the HTTP code returned for type DeletePolicyInternalServerError +const DeletePolicyInternalServerErrorCode int = 500 + +/*DeletePolicyInternalServerError Internal server error + +swagger:response deletePolicyInternalServerError +*/ +type DeletePolicyInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeletePolicyInternalServerError creates DeletePolicyInternalServerError with default headers values +func NewDeletePolicyInternalServerError() *DeletePolicyInternalServerError { + + return &DeletePolicyInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the delete policy internal server error response +func (o *DeletePolicyInternalServerError) WithXRequestID(xRequestID string) *DeletePolicyInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete policy internal server error response +func (o *DeletePolicyInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete policy internal server error response +func (o *DeletePolicyInternalServerError) WithPayload(payload *models.Errors) *DeletePolicyInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete policy internal server error response +func (o *DeletePolicyInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeletePolicyInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/preheat/delete_policy_urlbuilder.go b/src/server/v2.0/restapi/operations/preheat/delete_policy_urlbuilder.go new file mode 100644 index 000000000..65f44d2be --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/delete_policy_urlbuilder.go @@ -0,0 +1,107 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// DeletePolicyURL generates an URL for the delete policy operation +type DeletePolicyURL struct { + PreheatPolicyName string + ProjectName string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeletePolicyURL) WithBasePath(bp string) *DeletePolicyURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeletePolicyURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeletePolicyURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name}/preheat/policies/{preheat_policy_name}" + + preheatPolicyName := o.PreheatPolicyName + if preheatPolicyName != "" { + _path = strings.Replace(_path, "{preheat_policy_name}", preheatPolicyName, -1) + } else { + return nil, errors.New("preheatPolicyName is required on DeletePolicyURL") + } + + projectName := o.ProjectName + if projectName != "" { + _path = strings.Replace(_path, "{project_name}", projectName, -1) + } else { + return nil, errors.New("projectName is required on DeletePolicyURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeletePolicyURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeletePolicyURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeletePolicyURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeletePolicyURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeletePolicyURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeletePolicyURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/preheat/get_execution.go b/src/server/v2.0/restapi/operations/preheat/get_execution.go new file mode 100644 index 000000000..ee83fbdb1 --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/get_execution.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetExecutionHandlerFunc turns a function with the right signature into a get execution handler +type GetExecutionHandlerFunc func(GetExecutionParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetExecutionHandlerFunc) Handle(params GetExecutionParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetExecutionHandler interface for that can handle valid get execution params +type GetExecutionHandler interface { + Handle(GetExecutionParams, interface{}) middleware.Responder +} + +// NewGetExecution creates a new http.Handler for the get execution operation +func NewGetExecution(ctx *middleware.Context, handler GetExecutionHandler) *GetExecution { + return &GetExecution{Context: ctx, Handler: handler} +} + +/*GetExecution swagger:route GET /projects/{project_name}/preheat/policies/{preheat_policy_name}/executions/{execution_id} preheat getExecution + +Get a execution detail by id + +Get a execution detail by id + +*/ +type GetExecution struct { + Context *middleware.Context + Handler GetExecutionHandler +} + +func (o *GetExecution) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetExecutionParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/preheat/get_execution_parameters.go b/src/server/v2.0/restapi/operations/preheat/get_execution_parameters.go new file mode 100644 index 000000000..dca03b414 --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/get_execution_parameters.go @@ -0,0 +1,169 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewGetExecutionParams creates a new GetExecutionParams object +// no default values defined in spec. +func NewGetExecutionParams() GetExecutionParams { + + return GetExecutionParams{} +} + +// GetExecutionParams contains all the bound params for the get execution operation +// typically these are obtained from a http.Request +// +// swagger:parameters GetExecution +type GetExecutionParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*Execution ID + Required: true + In: path + */ + ExecutionID int64 + /*Preheat Policy Name + Required: true + In: path + */ + PreheatPolicyName string + /*The name of the project + Required: true + In: path + */ + ProjectName string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetExecutionParams() beforehand. +func (o *GetExecutionParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rExecutionID, rhkExecutionID, _ := route.Params.GetOK("execution_id") + if err := o.bindExecutionID(rExecutionID, rhkExecutionID, route.Formats); err != nil { + res = append(res, err) + } + + rPreheatPolicyName, rhkPreheatPolicyName, _ := route.Params.GetOK("preheat_policy_name") + if err := o.bindPreheatPolicyName(rPreheatPolicyName, rhkPreheatPolicyName, route.Formats); err != nil { + res = append(res, err) + } + + rProjectName, rhkProjectName, _ := route.Params.GetOK("project_name") + if err := o.bindProjectName(rProjectName, rhkProjectName, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetExecutionParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetExecutionParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindExecutionID binds and validates parameter ExecutionID from path. +func (o *GetExecutionParams) bindExecutionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("execution_id", "path", "int64", raw) + } + o.ExecutionID = value + + return nil +} + +// bindPreheatPolicyName binds and validates parameter PreheatPolicyName from path. +func (o *GetExecutionParams) bindPreheatPolicyName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.PreheatPolicyName = raw + + return nil +} + +// bindProjectName binds and validates parameter ProjectName from path. +func (o *GetExecutionParams) bindProjectName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectName = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/preheat/get_execution_responses.go b/src/server/v2.0/restapi/operations/preheat/get_execution_responses.go new file mode 100644 index 000000000..bd81d8688 --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/get_execution_responses.go @@ -0,0 +1,388 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetExecutionOKCode is the HTTP code returned for type GetExecutionOK +const GetExecutionOKCode int = 200 + +/*GetExecutionOK Get execution success + +swagger:response getExecutionOK +*/ +type GetExecutionOK struct { + + /* + In: Body + */ + Payload *models.Execution `json:"body,omitempty"` +} + +// NewGetExecutionOK creates GetExecutionOK with default headers values +func NewGetExecutionOK() *GetExecutionOK { + + return &GetExecutionOK{} +} + +// WithPayload adds the payload to the get execution o k response +func (o *GetExecutionOK) WithPayload(payload *models.Execution) *GetExecutionOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get execution o k response +func (o *GetExecutionOK) SetPayload(payload *models.Execution) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetExecutionOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetExecutionBadRequestCode is the HTTP code returned for type GetExecutionBadRequest +const GetExecutionBadRequestCode int = 400 + +/*GetExecutionBadRequest Bad request + +swagger:response getExecutionBadRequest +*/ +type GetExecutionBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetExecutionBadRequest creates GetExecutionBadRequest with default headers values +func NewGetExecutionBadRequest() *GetExecutionBadRequest { + + return &GetExecutionBadRequest{} +} + +// WithXRequestID adds the xRequestId to the get execution bad request response +func (o *GetExecutionBadRequest) WithXRequestID(xRequestID string) *GetExecutionBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get execution bad request response +func (o *GetExecutionBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get execution bad request response +func (o *GetExecutionBadRequest) WithPayload(payload *models.Errors) *GetExecutionBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get execution bad request response +func (o *GetExecutionBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetExecutionBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetExecutionUnauthorizedCode is the HTTP code returned for type GetExecutionUnauthorized +const GetExecutionUnauthorizedCode int = 401 + +/*GetExecutionUnauthorized Unauthorized + +swagger:response getExecutionUnauthorized +*/ +type GetExecutionUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetExecutionUnauthorized creates GetExecutionUnauthorized with default headers values +func NewGetExecutionUnauthorized() *GetExecutionUnauthorized { + + return &GetExecutionUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the get execution unauthorized response +func (o *GetExecutionUnauthorized) WithXRequestID(xRequestID string) *GetExecutionUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get execution unauthorized response +func (o *GetExecutionUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get execution unauthorized response +func (o *GetExecutionUnauthorized) WithPayload(payload *models.Errors) *GetExecutionUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get execution unauthorized response +func (o *GetExecutionUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetExecutionUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetExecutionForbiddenCode is the HTTP code returned for type GetExecutionForbidden +const GetExecutionForbiddenCode int = 403 + +/*GetExecutionForbidden Forbidden + +swagger:response getExecutionForbidden +*/ +type GetExecutionForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetExecutionForbidden creates GetExecutionForbidden with default headers values +func NewGetExecutionForbidden() *GetExecutionForbidden { + + return &GetExecutionForbidden{} +} + +// WithXRequestID adds the xRequestId to the get execution forbidden response +func (o *GetExecutionForbidden) WithXRequestID(xRequestID string) *GetExecutionForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get execution forbidden response +func (o *GetExecutionForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get execution forbidden response +func (o *GetExecutionForbidden) WithPayload(payload *models.Errors) *GetExecutionForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get execution forbidden response +func (o *GetExecutionForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetExecutionForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetExecutionNotFoundCode is the HTTP code returned for type GetExecutionNotFound +const GetExecutionNotFoundCode int = 404 + +/*GetExecutionNotFound Not found + +swagger:response getExecutionNotFound +*/ +type GetExecutionNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetExecutionNotFound creates GetExecutionNotFound with default headers values +func NewGetExecutionNotFound() *GetExecutionNotFound { + + return &GetExecutionNotFound{} +} + +// WithXRequestID adds the xRequestId to the get execution not found response +func (o *GetExecutionNotFound) WithXRequestID(xRequestID string) *GetExecutionNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get execution not found response +func (o *GetExecutionNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get execution not found response +func (o *GetExecutionNotFound) WithPayload(payload *models.Errors) *GetExecutionNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get execution not found response +func (o *GetExecutionNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetExecutionNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetExecutionInternalServerErrorCode is the HTTP code returned for type GetExecutionInternalServerError +const GetExecutionInternalServerErrorCode int = 500 + +/*GetExecutionInternalServerError Internal server error + +swagger:response getExecutionInternalServerError +*/ +type GetExecutionInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetExecutionInternalServerError creates GetExecutionInternalServerError with default headers values +func NewGetExecutionInternalServerError() *GetExecutionInternalServerError { + + return &GetExecutionInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get execution internal server error response +func (o *GetExecutionInternalServerError) WithXRequestID(xRequestID string) *GetExecutionInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get execution internal server error response +func (o *GetExecutionInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get execution internal server error response +func (o *GetExecutionInternalServerError) WithPayload(payload *models.Errors) *GetExecutionInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get execution internal server error response +func (o *GetExecutionInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetExecutionInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/preheat/get_execution_urlbuilder.go b/src/server/v2.0/restapi/operations/preheat/get_execution_urlbuilder.go new file mode 100644 index 000000000..6a6534cb7 --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/get_execution_urlbuilder.go @@ -0,0 +1,117 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetExecutionURL generates an URL for the get execution operation +type GetExecutionURL struct { + ExecutionID int64 + PreheatPolicyName string + ProjectName string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetExecutionURL) WithBasePath(bp string) *GetExecutionURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetExecutionURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetExecutionURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name}/preheat/policies/{preheat_policy_name}/executions/{execution_id}" + + executionID := swag.FormatInt64(o.ExecutionID) + if executionID != "" { + _path = strings.Replace(_path, "{execution_id}", executionID, -1) + } else { + return nil, errors.New("executionId is required on GetExecutionURL") + } + + preheatPolicyName := o.PreheatPolicyName + if preheatPolicyName != "" { + _path = strings.Replace(_path, "{preheat_policy_name}", preheatPolicyName, -1) + } else { + return nil, errors.New("preheatPolicyName is required on GetExecutionURL") + } + + projectName := o.ProjectName + if projectName != "" { + _path = strings.Replace(_path, "{project_name}", projectName, -1) + } else { + return nil, errors.New("projectName is required on GetExecutionURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetExecutionURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetExecutionURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetExecutionURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetExecutionURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetExecutionURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetExecutionURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/preheat/get_instance.go b/src/server/v2.0/restapi/operations/preheat/get_instance.go new file mode 100644 index 000000000..53d035063 --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/get_instance.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetInstanceHandlerFunc turns a function with the right signature into a get instance handler +type GetInstanceHandlerFunc func(GetInstanceParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetInstanceHandlerFunc) Handle(params GetInstanceParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetInstanceHandler interface for that can handle valid get instance params +type GetInstanceHandler interface { + Handle(GetInstanceParams, interface{}) middleware.Responder +} + +// NewGetInstance creates a new http.Handler for the get instance operation +func NewGetInstance(ctx *middleware.Context, handler GetInstanceHandler) *GetInstance { + return &GetInstance{Context: ctx, Handler: handler} +} + +/*GetInstance swagger:route GET /p2p/preheat/instances/{preheat_instance_name} preheat getInstance + +Get a P2P provider instance + +Get a P2P provider instance + +*/ +type GetInstance struct { + Context *middleware.Context + Handler GetInstanceHandler +} + +func (o *GetInstance) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetInstanceParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/preheat/get_instance_parameters.go b/src/server/v2.0/restapi/operations/preheat/get_instance_parameters.go new file mode 100644 index 000000000..d0b4963ae --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/get_instance_parameters.go @@ -0,0 +1,114 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewGetInstanceParams creates a new GetInstanceParams object +// no default values defined in spec. +func NewGetInstanceParams() GetInstanceParams { + + return GetInstanceParams{} +} + +// GetInstanceParams contains all the bound params for the get instance operation +// typically these are obtained from a http.Request +// +// swagger:parameters GetInstance +type GetInstanceParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*Instance Name + Required: true + In: path + */ + PreheatInstanceName string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetInstanceParams() beforehand. +func (o *GetInstanceParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rPreheatInstanceName, rhkPreheatInstanceName, _ := route.Params.GetOK("preheat_instance_name") + if err := o.bindPreheatInstanceName(rPreheatInstanceName, rhkPreheatInstanceName, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetInstanceParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetInstanceParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindPreheatInstanceName binds and validates parameter PreheatInstanceName from path. +func (o *GetInstanceParams) bindPreheatInstanceName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.PreheatInstanceName = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/preheat/get_instance_responses.go b/src/server/v2.0/restapi/operations/preheat/get_instance_responses.go new file mode 100644 index 000000000..33c90cca3 --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/get_instance_responses.go @@ -0,0 +1,388 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetInstanceOKCode is the HTTP code returned for type GetInstanceOK +const GetInstanceOKCode int = 200 + +/*GetInstanceOK Success + +swagger:response getInstanceOK +*/ +type GetInstanceOK struct { + + /* + In: Body + */ + Payload *models.Instance `json:"body,omitempty"` +} + +// NewGetInstanceOK creates GetInstanceOK with default headers values +func NewGetInstanceOK() *GetInstanceOK { + + return &GetInstanceOK{} +} + +// WithPayload adds the payload to the get instance o k response +func (o *GetInstanceOK) WithPayload(payload *models.Instance) *GetInstanceOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get instance o k response +func (o *GetInstanceOK) SetPayload(payload *models.Instance) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetInstanceOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetInstanceBadRequestCode is the HTTP code returned for type GetInstanceBadRequest +const GetInstanceBadRequestCode int = 400 + +/*GetInstanceBadRequest Bad request + +swagger:response getInstanceBadRequest +*/ +type GetInstanceBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetInstanceBadRequest creates GetInstanceBadRequest with default headers values +func NewGetInstanceBadRequest() *GetInstanceBadRequest { + + return &GetInstanceBadRequest{} +} + +// WithXRequestID adds the xRequestId to the get instance bad request response +func (o *GetInstanceBadRequest) WithXRequestID(xRequestID string) *GetInstanceBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get instance bad request response +func (o *GetInstanceBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get instance bad request response +func (o *GetInstanceBadRequest) WithPayload(payload *models.Errors) *GetInstanceBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get instance bad request response +func (o *GetInstanceBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetInstanceBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetInstanceUnauthorizedCode is the HTTP code returned for type GetInstanceUnauthorized +const GetInstanceUnauthorizedCode int = 401 + +/*GetInstanceUnauthorized Unauthorized + +swagger:response getInstanceUnauthorized +*/ +type GetInstanceUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetInstanceUnauthorized creates GetInstanceUnauthorized with default headers values +func NewGetInstanceUnauthorized() *GetInstanceUnauthorized { + + return &GetInstanceUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the get instance unauthorized response +func (o *GetInstanceUnauthorized) WithXRequestID(xRequestID string) *GetInstanceUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get instance unauthorized response +func (o *GetInstanceUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get instance unauthorized response +func (o *GetInstanceUnauthorized) WithPayload(payload *models.Errors) *GetInstanceUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get instance unauthorized response +func (o *GetInstanceUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetInstanceUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetInstanceForbiddenCode is the HTTP code returned for type GetInstanceForbidden +const GetInstanceForbiddenCode int = 403 + +/*GetInstanceForbidden Forbidden + +swagger:response getInstanceForbidden +*/ +type GetInstanceForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetInstanceForbidden creates GetInstanceForbidden with default headers values +func NewGetInstanceForbidden() *GetInstanceForbidden { + + return &GetInstanceForbidden{} +} + +// WithXRequestID adds the xRequestId to the get instance forbidden response +func (o *GetInstanceForbidden) WithXRequestID(xRequestID string) *GetInstanceForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get instance forbidden response +func (o *GetInstanceForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get instance forbidden response +func (o *GetInstanceForbidden) WithPayload(payload *models.Errors) *GetInstanceForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get instance forbidden response +func (o *GetInstanceForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetInstanceForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetInstanceNotFoundCode is the HTTP code returned for type GetInstanceNotFound +const GetInstanceNotFoundCode int = 404 + +/*GetInstanceNotFound Not found + +swagger:response getInstanceNotFound +*/ +type GetInstanceNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetInstanceNotFound creates GetInstanceNotFound with default headers values +func NewGetInstanceNotFound() *GetInstanceNotFound { + + return &GetInstanceNotFound{} +} + +// WithXRequestID adds the xRequestId to the get instance not found response +func (o *GetInstanceNotFound) WithXRequestID(xRequestID string) *GetInstanceNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get instance not found response +func (o *GetInstanceNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get instance not found response +func (o *GetInstanceNotFound) WithPayload(payload *models.Errors) *GetInstanceNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get instance not found response +func (o *GetInstanceNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetInstanceNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetInstanceInternalServerErrorCode is the HTTP code returned for type GetInstanceInternalServerError +const GetInstanceInternalServerErrorCode int = 500 + +/*GetInstanceInternalServerError Internal server error + +swagger:response getInstanceInternalServerError +*/ +type GetInstanceInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetInstanceInternalServerError creates GetInstanceInternalServerError with default headers values +func NewGetInstanceInternalServerError() *GetInstanceInternalServerError { + + return &GetInstanceInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get instance internal server error response +func (o *GetInstanceInternalServerError) WithXRequestID(xRequestID string) *GetInstanceInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get instance internal server error response +func (o *GetInstanceInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get instance internal server error response +func (o *GetInstanceInternalServerError) WithPayload(payload *models.Errors) *GetInstanceInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get instance internal server error response +func (o *GetInstanceInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetInstanceInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/preheat/get_instance_urlbuilder.go b/src/server/v2.0/restapi/operations/preheat/get_instance_urlbuilder.go new file mode 100644 index 000000000..a010088e0 --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/get_instance_urlbuilder.go @@ -0,0 +1,99 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetInstanceURL generates an URL for the get instance operation +type GetInstanceURL struct { + PreheatInstanceName string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetInstanceURL) WithBasePath(bp string) *GetInstanceURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetInstanceURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetInstanceURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/p2p/preheat/instances/{preheat_instance_name}" + + preheatInstanceName := o.PreheatInstanceName + if preheatInstanceName != "" { + _path = strings.Replace(_path, "{preheat_instance_name}", preheatInstanceName, -1) + } else { + return nil, errors.New("preheatInstanceName is required on GetInstanceURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetInstanceURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetInstanceURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetInstanceURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetInstanceURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetInstanceURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetInstanceURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/preheat/get_policy.go b/src/server/v2.0/restapi/operations/preheat/get_policy.go new file mode 100644 index 000000000..6f1b3c5c3 --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/get_policy.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetPolicyHandlerFunc turns a function with the right signature into a get policy handler +type GetPolicyHandlerFunc func(GetPolicyParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetPolicyHandlerFunc) Handle(params GetPolicyParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetPolicyHandler interface for that can handle valid get policy params +type GetPolicyHandler interface { + Handle(GetPolicyParams, interface{}) middleware.Responder +} + +// NewGetPolicy creates a new http.Handler for the get policy operation +func NewGetPolicy(ctx *middleware.Context, handler GetPolicyHandler) *GetPolicy { + return &GetPolicy{Context: ctx, Handler: handler} +} + +/*GetPolicy swagger:route GET /projects/{project_name}/preheat/policies/{preheat_policy_name} preheat getPolicy + +Get a preheat policy + +Get a preheat policy + +*/ +type GetPolicy struct { + Context *middleware.Context + Handler GetPolicyHandler +} + +func (o *GetPolicy) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetPolicyParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/preheat/get_policy_parameters.go b/src/server/v2.0/restapi/operations/preheat/get_policy_parameters.go new file mode 100644 index 000000000..7f06fd7f5 --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/get_policy_parameters.go @@ -0,0 +1,139 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewGetPolicyParams creates a new GetPolicyParams object +// no default values defined in spec. +func NewGetPolicyParams() GetPolicyParams { + + return GetPolicyParams{} +} + +// GetPolicyParams contains all the bound params for the get policy operation +// typically these are obtained from a http.Request +// +// swagger:parameters GetPolicy +type GetPolicyParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*Preheat Policy Name + Required: true + In: path + */ + PreheatPolicyName string + /*The name of the project + Required: true + In: path + */ + ProjectName string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetPolicyParams() beforehand. +func (o *GetPolicyParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rPreheatPolicyName, rhkPreheatPolicyName, _ := route.Params.GetOK("preheat_policy_name") + if err := o.bindPreheatPolicyName(rPreheatPolicyName, rhkPreheatPolicyName, route.Formats); err != nil { + res = append(res, err) + } + + rProjectName, rhkProjectName, _ := route.Params.GetOK("project_name") + if err := o.bindProjectName(rProjectName, rhkProjectName, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetPolicyParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetPolicyParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindPreheatPolicyName binds and validates parameter PreheatPolicyName from path. +func (o *GetPolicyParams) bindPreheatPolicyName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.PreheatPolicyName = raw + + return nil +} + +// bindProjectName binds and validates parameter ProjectName from path. +func (o *GetPolicyParams) bindProjectName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectName = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/preheat/get_policy_responses.go b/src/server/v2.0/restapi/operations/preheat/get_policy_responses.go new file mode 100644 index 000000000..0ffd8e15b --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/get_policy_responses.go @@ -0,0 +1,388 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetPolicyOKCode is the HTTP code returned for type GetPolicyOK +const GetPolicyOKCode int = 200 + +/*GetPolicyOK Get a preheat policy success + +swagger:response getPolicyOK +*/ +type GetPolicyOK struct { + + /* + In: Body + */ + Payload *models.PreheatPolicy `json:"body,omitempty"` +} + +// NewGetPolicyOK creates GetPolicyOK with default headers values +func NewGetPolicyOK() *GetPolicyOK { + + return &GetPolicyOK{} +} + +// WithPayload adds the payload to the get policy o k response +func (o *GetPolicyOK) WithPayload(payload *models.PreheatPolicy) *GetPolicyOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get policy o k response +func (o *GetPolicyOK) SetPayload(payload *models.PreheatPolicy) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetPolicyOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetPolicyBadRequestCode is the HTTP code returned for type GetPolicyBadRequest +const GetPolicyBadRequestCode int = 400 + +/*GetPolicyBadRequest Bad request + +swagger:response getPolicyBadRequest +*/ +type GetPolicyBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetPolicyBadRequest creates GetPolicyBadRequest with default headers values +func NewGetPolicyBadRequest() *GetPolicyBadRequest { + + return &GetPolicyBadRequest{} +} + +// WithXRequestID adds the xRequestId to the get policy bad request response +func (o *GetPolicyBadRequest) WithXRequestID(xRequestID string) *GetPolicyBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get policy bad request response +func (o *GetPolicyBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get policy bad request response +func (o *GetPolicyBadRequest) WithPayload(payload *models.Errors) *GetPolicyBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get policy bad request response +func (o *GetPolicyBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetPolicyBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetPolicyUnauthorizedCode is the HTTP code returned for type GetPolicyUnauthorized +const GetPolicyUnauthorizedCode int = 401 + +/*GetPolicyUnauthorized Unauthorized + +swagger:response getPolicyUnauthorized +*/ +type GetPolicyUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetPolicyUnauthorized creates GetPolicyUnauthorized with default headers values +func NewGetPolicyUnauthorized() *GetPolicyUnauthorized { + + return &GetPolicyUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the get policy unauthorized response +func (o *GetPolicyUnauthorized) WithXRequestID(xRequestID string) *GetPolicyUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get policy unauthorized response +func (o *GetPolicyUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get policy unauthorized response +func (o *GetPolicyUnauthorized) WithPayload(payload *models.Errors) *GetPolicyUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get policy unauthorized response +func (o *GetPolicyUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetPolicyUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetPolicyForbiddenCode is the HTTP code returned for type GetPolicyForbidden +const GetPolicyForbiddenCode int = 403 + +/*GetPolicyForbidden Forbidden + +swagger:response getPolicyForbidden +*/ +type GetPolicyForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetPolicyForbidden creates GetPolicyForbidden with default headers values +func NewGetPolicyForbidden() *GetPolicyForbidden { + + return &GetPolicyForbidden{} +} + +// WithXRequestID adds the xRequestId to the get policy forbidden response +func (o *GetPolicyForbidden) WithXRequestID(xRequestID string) *GetPolicyForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get policy forbidden response +func (o *GetPolicyForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get policy forbidden response +func (o *GetPolicyForbidden) WithPayload(payload *models.Errors) *GetPolicyForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get policy forbidden response +func (o *GetPolicyForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetPolicyForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetPolicyNotFoundCode is the HTTP code returned for type GetPolicyNotFound +const GetPolicyNotFoundCode int = 404 + +/*GetPolicyNotFound Not found + +swagger:response getPolicyNotFound +*/ +type GetPolicyNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetPolicyNotFound creates GetPolicyNotFound with default headers values +func NewGetPolicyNotFound() *GetPolicyNotFound { + + return &GetPolicyNotFound{} +} + +// WithXRequestID adds the xRequestId to the get policy not found response +func (o *GetPolicyNotFound) WithXRequestID(xRequestID string) *GetPolicyNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get policy not found response +func (o *GetPolicyNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get policy not found response +func (o *GetPolicyNotFound) WithPayload(payload *models.Errors) *GetPolicyNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get policy not found response +func (o *GetPolicyNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetPolicyNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetPolicyInternalServerErrorCode is the HTTP code returned for type GetPolicyInternalServerError +const GetPolicyInternalServerErrorCode int = 500 + +/*GetPolicyInternalServerError Internal server error + +swagger:response getPolicyInternalServerError +*/ +type GetPolicyInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetPolicyInternalServerError creates GetPolicyInternalServerError with default headers values +func NewGetPolicyInternalServerError() *GetPolicyInternalServerError { + + return &GetPolicyInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get policy internal server error response +func (o *GetPolicyInternalServerError) WithXRequestID(xRequestID string) *GetPolicyInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get policy internal server error response +func (o *GetPolicyInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get policy internal server error response +func (o *GetPolicyInternalServerError) WithPayload(payload *models.Errors) *GetPolicyInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get policy internal server error response +func (o *GetPolicyInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetPolicyInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/preheat/get_policy_urlbuilder.go b/src/server/v2.0/restapi/operations/preheat/get_policy_urlbuilder.go new file mode 100644 index 000000000..76eb25e86 --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/get_policy_urlbuilder.go @@ -0,0 +1,107 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetPolicyURL generates an URL for the get policy operation +type GetPolicyURL struct { + PreheatPolicyName string + ProjectName string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetPolicyURL) WithBasePath(bp string) *GetPolicyURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetPolicyURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetPolicyURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name}/preheat/policies/{preheat_policy_name}" + + preheatPolicyName := o.PreheatPolicyName + if preheatPolicyName != "" { + _path = strings.Replace(_path, "{preheat_policy_name}", preheatPolicyName, -1) + } else { + return nil, errors.New("preheatPolicyName is required on GetPolicyURL") + } + + projectName := o.ProjectName + if projectName != "" { + _path = strings.Replace(_path, "{project_name}", projectName, -1) + } else { + return nil, errors.New("projectName is required on GetPolicyURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetPolicyURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetPolicyURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetPolicyURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetPolicyURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetPolicyURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetPolicyURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/preheat/get_preheat_log.go b/src/server/v2.0/restapi/operations/preheat/get_preheat_log.go new file mode 100644 index 000000000..859d9d8e9 --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/get_preheat_log.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetPreheatLogHandlerFunc turns a function with the right signature into a get preheat log handler +type GetPreheatLogHandlerFunc func(GetPreheatLogParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetPreheatLogHandlerFunc) Handle(params GetPreheatLogParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetPreheatLogHandler interface for that can handle valid get preheat log params +type GetPreheatLogHandler interface { + Handle(GetPreheatLogParams, interface{}) middleware.Responder +} + +// NewGetPreheatLog creates a new http.Handler for the get preheat log operation +func NewGetPreheatLog(ctx *middleware.Context, handler GetPreheatLogHandler) *GetPreheatLog { + return &GetPreheatLog{Context: ctx, Handler: handler} +} + +/*GetPreheatLog swagger:route GET /projects/{project_name}/preheat/policies/{preheat_policy_name}/executions/{execution_id}/tasks/{task_id}/logs preheat getPreheatLog + +Get the log text stream of the specified task for the given execution + +Get the log text stream of the specified task for the given execution + +*/ +type GetPreheatLog struct { + Context *middleware.Context + Handler GetPreheatLogHandler +} + +func (o *GetPreheatLog) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetPreheatLogParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/preheat/get_preheat_log_parameters.go b/src/server/v2.0/restapi/operations/preheat/get_preheat_log_parameters.go new file mode 100644 index 000000000..18a02e191 --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/get_preheat_log_parameters.go @@ -0,0 +1,198 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewGetPreheatLogParams creates a new GetPreheatLogParams object +// no default values defined in spec. +func NewGetPreheatLogParams() GetPreheatLogParams { + + return GetPreheatLogParams{} +} + +// GetPreheatLogParams contains all the bound params for the get preheat log operation +// typically these are obtained from a http.Request +// +// swagger:parameters GetPreheatLog +type GetPreheatLogParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*Execution ID + Required: true + In: path + */ + ExecutionID int64 + /*Preheat Policy Name + Required: true + In: path + */ + PreheatPolicyName string + /*The name of the project + Required: true + In: path + */ + ProjectName string + /*Task ID + Required: true + In: path + */ + TaskID int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetPreheatLogParams() beforehand. +func (o *GetPreheatLogParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rExecutionID, rhkExecutionID, _ := route.Params.GetOK("execution_id") + if err := o.bindExecutionID(rExecutionID, rhkExecutionID, route.Formats); err != nil { + res = append(res, err) + } + + rPreheatPolicyName, rhkPreheatPolicyName, _ := route.Params.GetOK("preheat_policy_name") + if err := o.bindPreheatPolicyName(rPreheatPolicyName, rhkPreheatPolicyName, route.Formats); err != nil { + res = append(res, err) + } + + rProjectName, rhkProjectName, _ := route.Params.GetOK("project_name") + if err := o.bindProjectName(rProjectName, rhkProjectName, route.Formats); err != nil { + res = append(res, err) + } + + rTaskID, rhkTaskID, _ := route.Params.GetOK("task_id") + if err := o.bindTaskID(rTaskID, rhkTaskID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetPreheatLogParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetPreheatLogParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindExecutionID binds and validates parameter ExecutionID from path. +func (o *GetPreheatLogParams) bindExecutionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("execution_id", "path", "int64", raw) + } + o.ExecutionID = value + + return nil +} + +// bindPreheatPolicyName binds and validates parameter PreheatPolicyName from path. +func (o *GetPreheatLogParams) bindPreheatPolicyName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.PreheatPolicyName = raw + + return nil +} + +// bindProjectName binds and validates parameter ProjectName from path. +func (o *GetPreheatLogParams) bindProjectName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectName = raw + + return nil +} + +// bindTaskID binds and validates parameter TaskID from path. +func (o *GetPreheatLogParams) bindTaskID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("task_id", "path", "int64", raw) + } + o.TaskID = value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/preheat/get_preheat_log_responses.go b/src/server/v2.0/restapi/operations/preheat/get_preheat_log_responses.go new file mode 100644 index 000000000..ab219df6a --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/get_preheat_log_responses.go @@ -0,0 +1,408 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetPreheatLogOKCode is the HTTP code returned for type GetPreheatLogOK +const GetPreheatLogOKCode int = 200 + +/*GetPreheatLogOK Get log success + +swagger:response getPreheatLogOK +*/ +type GetPreheatLogOK struct { + /*Content type of response + + */ + ContentType string `json:"Content-Type"` + + /* + In: Body + */ + Payload string `json:"body,omitempty"` +} + +// NewGetPreheatLogOK creates GetPreheatLogOK with default headers values +func NewGetPreheatLogOK() *GetPreheatLogOK { + + return &GetPreheatLogOK{} +} + +// WithContentType adds the contentType to the get preheat log o k response +func (o *GetPreheatLogOK) WithContentType(contentType string) *GetPreheatLogOK { + o.ContentType = contentType + return o +} + +// SetContentType sets the contentType to the get preheat log o k response +func (o *GetPreheatLogOK) SetContentType(contentType string) { + o.ContentType = contentType +} + +// WithPayload adds the payload to the get preheat log o k response +func (o *GetPreheatLogOK) WithPayload(payload string) *GetPreheatLogOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get preheat log o k response +func (o *GetPreheatLogOK) SetPayload(payload string) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetPreheatLogOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Content-Type + + contentType := o.ContentType + if contentType != "" { + rw.Header().Set("Content-Type", contentType) + } + + rw.WriteHeader(200) + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// GetPreheatLogBadRequestCode is the HTTP code returned for type GetPreheatLogBadRequest +const GetPreheatLogBadRequestCode int = 400 + +/*GetPreheatLogBadRequest Bad request + +swagger:response getPreheatLogBadRequest +*/ +type GetPreheatLogBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetPreheatLogBadRequest creates GetPreheatLogBadRequest with default headers values +func NewGetPreheatLogBadRequest() *GetPreheatLogBadRequest { + + return &GetPreheatLogBadRequest{} +} + +// WithXRequestID adds the xRequestId to the get preheat log bad request response +func (o *GetPreheatLogBadRequest) WithXRequestID(xRequestID string) *GetPreheatLogBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get preheat log bad request response +func (o *GetPreheatLogBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get preheat log bad request response +func (o *GetPreheatLogBadRequest) WithPayload(payload *models.Errors) *GetPreheatLogBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get preheat log bad request response +func (o *GetPreheatLogBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetPreheatLogBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetPreheatLogUnauthorizedCode is the HTTP code returned for type GetPreheatLogUnauthorized +const GetPreheatLogUnauthorizedCode int = 401 + +/*GetPreheatLogUnauthorized Unauthorized + +swagger:response getPreheatLogUnauthorized +*/ +type GetPreheatLogUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetPreheatLogUnauthorized creates GetPreheatLogUnauthorized with default headers values +func NewGetPreheatLogUnauthorized() *GetPreheatLogUnauthorized { + + return &GetPreheatLogUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the get preheat log unauthorized response +func (o *GetPreheatLogUnauthorized) WithXRequestID(xRequestID string) *GetPreheatLogUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get preheat log unauthorized response +func (o *GetPreheatLogUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get preheat log unauthorized response +func (o *GetPreheatLogUnauthorized) WithPayload(payload *models.Errors) *GetPreheatLogUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get preheat log unauthorized response +func (o *GetPreheatLogUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetPreheatLogUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetPreheatLogForbiddenCode is the HTTP code returned for type GetPreheatLogForbidden +const GetPreheatLogForbiddenCode int = 403 + +/*GetPreheatLogForbidden Forbidden + +swagger:response getPreheatLogForbidden +*/ +type GetPreheatLogForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetPreheatLogForbidden creates GetPreheatLogForbidden with default headers values +func NewGetPreheatLogForbidden() *GetPreheatLogForbidden { + + return &GetPreheatLogForbidden{} +} + +// WithXRequestID adds the xRequestId to the get preheat log forbidden response +func (o *GetPreheatLogForbidden) WithXRequestID(xRequestID string) *GetPreheatLogForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get preheat log forbidden response +func (o *GetPreheatLogForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get preheat log forbidden response +func (o *GetPreheatLogForbidden) WithPayload(payload *models.Errors) *GetPreheatLogForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get preheat log forbidden response +func (o *GetPreheatLogForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetPreheatLogForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetPreheatLogNotFoundCode is the HTTP code returned for type GetPreheatLogNotFound +const GetPreheatLogNotFoundCode int = 404 + +/*GetPreheatLogNotFound Not found + +swagger:response getPreheatLogNotFound +*/ +type GetPreheatLogNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetPreheatLogNotFound creates GetPreheatLogNotFound with default headers values +func NewGetPreheatLogNotFound() *GetPreheatLogNotFound { + + return &GetPreheatLogNotFound{} +} + +// WithXRequestID adds the xRequestId to the get preheat log not found response +func (o *GetPreheatLogNotFound) WithXRequestID(xRequestID string) *GetPreheatLogNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get preheat log not found response +func (o *GetPreheatLogNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get preheat log not found response +func (o *GetPreheatLogNotFound) WithPayload(payload *models.Errors) *GetPreheatLogNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get preheat log not found response +func (o *GetPreheatLogNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetPreheatLogNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetPreheatLogInternalServerErrorCode is the HTTP code returned for type GetPreheatLogInternalServerError +const GetPreheatLogInternalServerErrorCode int = 500 + +/*GetPreheatLogInternalServerError Internal server error + +swagger:response getPreheatLogInternalServerError +*/ +type GetPreheatLogInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetPreheatLogInternalServerError creates GetPreheatLogInternalServerError with default headers values +func NewGetPreheatLogInternalServerError() *GetPreheatLogInternalServerError { + + return &GetPreheatLogInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get preheat log internal server error response +func (o *GetPreheatLogInternalServerError) WithXRequestID(xRequestID string) *GetPreheatLogInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get preheat log internal server error response +func (o *GetPreheatLogInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get preheat log internal server error response +func (o *GetPreheatLogInternalServerError) WithPayload(payload *models.Errors) *GetPreheatLogInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get preheat log internal server error response +func (o *GetPreheatLogInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetPreheatLogInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/preheat/get_preheat_log_urlbuilder.go b/src/server/v2.0/restapi/operations/preheat/get_preheat_log_urlbuilder.go new file mode 100644 index 000000000..2c397ecfb --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/get_preheat_log_urlbuilder.go @@ -0,0 +1,125 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetPreheatLogURL generates an URL for the get preheat log operation +type GetPreheatLogURL struct { + ExecutionID int64 + PreheatPolicyName string + ProjectName string + TaskID int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetPreheatLogURL) WithBasePath(bp string) *GetPreheatLogURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetPreheatLogURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetPreheatLogURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name}/preheat/policies/{preheat_policy_name}/executions/{execution_id}/tasks/{task_id}/logs" + + executionID := swag.FormatInt64(o.ExecutionID) + if executionID != "" { + _path = strings.Replace(_path, "{execution_id}", executionID, -1) + } else { + return nil, errors.New("executionId is required on GetPreheatLogURL") + } + + preheatPolicyName := o.PreheatPolicyName + if preheatPolicyName != "" { + _path = strings.Replace(_path, "{preheat_policy_name}", preheatPolicyName, -1) + } else { + return nil, errors.New("preheatPolicyName is required on GetPreheatLogURL") + } + + projectName := o.ProjectName + if projectName != "" { + _path = strings.Replace(_path, "{project_name}", projectName, -1) + } else { + return nil, errors.New("projectName is required on GetPreheatLogURL") + } + + taskID := swag.FormatInt64(o.TaskID) + if taskID != "" { + _path = strings.Replace(_path, "{task_id}", taskID, -1) + } else { + return nil, errors.New("taskId is required on GetPreheatLogURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetPreheatLogURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetPreheatLogURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetPreheatLogURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetPreheatLogURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetPreheatLogURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetPreheatLogURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/preheat/list_executions.go b/src/server/v2.0/restapi/operations/preheat/list_executions.go new file mode 100644 index 000000000..b6db02fbc --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/list_executions.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ListExecutionsHandlerFunc turns a function with the right signature into a list executions handler +type ListExecutionsHandlerFunc func(ListExecutionsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ListExecutionsHandlerFunc) Handle(params ListExecutionsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ListExecutionsHandler interface for that can handle valid list executions params +type ListExecutionsHandler interface { + Handle(ListExecutionsParams, interface{}) middleware.Responder +} + +// NewListExecutions creates a new http.Handler for the list executions operation +func NewListExecutions(ctx *middleware.Context, handler ListExecutionsHandler) *ListExecutions { + return &ListExecutions{Context: ctx, Handler: handler} +} + +/*ListExecutions swagger:route GET /projects/{project_name}/preheat/policies/{preheat_policy_name}/executions preheat listExecutions + +List executions for the given policy + +List executions for the given policy + +*/ +type ListExecutions struct { + Context *middleware.Context + Handler ListExecutionsHandler +} + +func (o *ListExecutions) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewListExecutionsParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/preheat/list_executions_parameters.go b/src/server/v2.0/restapi/operations/preheat/list_executions_parameters.go new file mode 100644 index 000000000..dfdedc50a --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/list_executions_parameters.go @@ -0,0 +1,289 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewListExecutionsParams creates a new ListExecutionsParams object +// with the default values initialized. +func NewListExecutionsParams() ListExecutionsParams { + + var ( + // initialize parameters with default values + + pageDefault = int64(1) + pageSizeDefault = int64(10) + ) + + return ListExecutionsParams{ + Page: &pageDefault, + + PageSize: &pageSizeDefault, + } +} + +// ListExecutionsParams contains all the bound params for the list executions operation +// typically these are obtained from a http.Request +// +// swagger:parameters ListExecutions +type ListExecutionsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The page number + In: query + Default: 1 + */ + Page *int64 + /*The size of per page + Maximum: 100 + In: query + Default: 10 + */ + PageSize *int64 + /*Preheat Policy Name + Required: true + In: path + */ + PreheatPolicyName string + /*The name of the project + Required: true + In: path + */ + ProjectName string + /*Query string to query resources. Supported query patterns are "exact match(k=v)", "fuzzy match(k=~v)", "range(k=[min~max])", "list with union releationship(k={v1 v2 v3})" and "list with intersetion relationship(k=(v1 v2 v3))". The value of range and list can be string(enclosed by " or '), integer or time(in format "2020-04-09 02:36:00"). All of these query patterns should be put in the query string "q=xxx" and splitted by ",". e.g. q=k1=v1,k2=~v2,k3=[min~max] + In: query + */ + Q *string + /*Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + In: query + */ + Sort *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewListExecutionsParams() beforehand. +func (o *ListExecutionsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + qPage, qhkPage, _ := qs.GetOK("page") + if err := o.bindPage(qPage, qhkPage, route.Formats); err != nil { + res = append(res, err) + } + + qPageSize, qhkPageSize, _ := qs.GetOK("page_size") + if err := o.bindPageSize(qPageSize, qhkPageSize, route.Formats); err != nil { + res = append(res, err) + } + + rPreheatPolicyName, rhkPreheatPolicyName, _ := route.Params.GetOK("preheat_policy_name") + if err := o.bindPreheatPolicyName(rPreheatPolicyName, rhkPreheatPolicyName, route.Formats); err != nil { + res = append(res, err) + } + + rProjectName, rhkProjectName, _ := route.Params.GetOK("project_name") + if err := o.bindProjectName(rProjectName, rhkProjectName, route.Formats); err != nil { + res = append(res, err) + } + + qQ, qhkQ, _ := qs.GetOK("q") + if err := o.bindQ(qQ, qhkQ, route.Formats); err != nil { + res = append(res, err) + } + + qSort, qhkSort, _ := qs.GetOK("sort") + if err := o.bindSort(qSort, qhkSort, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *ListExecutionsParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *ListExecutionsParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindPage binds and validates parameter Page from query. +func (o *ListExecutionsParams) bindPage(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListExecutionsParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page", "query", "int64", raw) + } + o.Page = &value + + return nil +} + +// bindPageSize binds and validates parameter PageSize from query. +func (o *ListExecutionsParams) bindPageSize(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListExecutionsParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page_size", "query", "int64", raw) + } + o.PageSize = &value + + if err := o.validatePageSize(formats); err != nil { + return err + } + + return nil +} + +// validatePageSize carries on validations for parameter PageSize +func (o *ListExecutionsParams) validatePageSize(formats strfmt.Registry) error { + + if err := validate.MaximumInt("page_size", "query", int64(*o.PageSize), 100, false); err != nil { + return err + } + + return nil +} + +// bindPreheatPolicyName binds and validates parameter PreheatPolicyName from path. +func (o *ListExecutionsParams) bindPreheatPolicyName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.PreheatPolicyName = raw + + return nil +} + +// bindProjectName binds and validates parameter ProjectName from path. +func (o *ListExecutionsParams) bindProjectName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectName = raw + + return nil +} + +// bindQ binds and validates parameter Q from query. +func (o *ListExecutionsParams) bindQ(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Q = &raw + + return nil +} + +// bindSort binds and validates parameter Sort from query. +func (o *ListExecutionsParams) bindSort(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Sort = &raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/preheat/list_executions_responses.go b/src/server/v2.0/restapi/operations/preheat/list_executions_responses.go new file mode 100644 index 000000000..baea48042 --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/list_executions_responses.go @@ -0,0 +1,436 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/swag" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// ListExecutionsOKCode is the HTTP code returned for type ListExecutionsOK +const ListExecutionsOKCode int = 200 + +/*ListExecutionsOK List executions success + +swagger:response listExecutionsOK +*/ +type ListExecutionsOK struct { + /*Link refers to the previous page and next page + + */ + Link string `json:"Link"` + /*The total count of executions + + */ + XTotalCount int64 `json:"X-Total-Count"` + + /* + In: Body + */ + Payload []*models.Execution `json:"body,omitempty"` +} + +// NewListExecutionsOK creates ListExecutionsOK with default headers values +func NewListExecutionsOK() *ListExecutionsOK { + + return &ListExecutionsOK{} +} + +// WithLink adds the link to the list executions o k response +func (o *ListExecutionsOK) WithLink(link string) *ListExecutionsOK { + o.Link = link + return o +} + +// SetLink sets the link to the list executions o k response +func (o *ListExecutionsOK) SetLink(link string) { + o.Link = link +} + +// WithXTotalCount adds the xTotalCount to the list executions o k response +func (o *ListExecutionsOK) WithXTotalCount(xTotalCount int64) *ListExecutionsOK { + o.XTotalCount = xTotalCount + return o +} + +// SetXTotalCount sets the xTotalCount to the list executions o k response +func (o *ListExecutionsOK) SetXTotalCount(xTotalCount int64) { + o.XTotalCount = xTotalCount +} + +// WithPayload adds the payload to the list executions o k response +func (o *ListExecutionsOK) WithPayload(payload []*models.Execution) *ListExecutionsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list executions o k response +func (o *ListExecutionsOK) SetPayload(payload []*models.Execution) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListExecutionsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Link + + link := o.Link + if link != "" { + rw.Header().Set("Link", link) + } + + // response header X-Total-Count + + xTotalCount := swag.FormatInt64(o.XTotalCount) + if xTotalCount != "" { + rw.Header().Set("X-Total-Count", xTotalCount) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = make([]*models.Execution, 0, 50) + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ListExecutionsBadRequestCode is the HTTP code returned for type ListExecutionsBadRequest +const ListExecutionsBadRequestCode int = 400 + +/*ListExecutionsBadRequest Bad request + +swagger:response listExecutionsBadRequest +*/ +type ListExecutionsBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListExecutionsBadRequest creates ListExecutionsBadRequest with default headers values +func NewListExecutionsBadRequest() *ListExecutionsBadRequest { + + return &ListExecutionsBadRequest{} +} + +// WithXRequestID adds the xRequestId to the list executions bad request response +func (o *ListExecutionsBadRequest) WithXRequestID(xRequestID string) *ListExecutionsBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list executions bad request response +func (o *ListExecutionsBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list executions bad request response +func (o *ListExecutionsBadRequest) WithPayload(payload *models.Errors) *ListExecutionsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list executions bad request response +func (o *ListExecutionsBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListExecutionsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListExecutionsUnauthorizedCode is the HTTP code returned for type ListExecutionsUnauthorized +const ListExecutionsUnauthorizedCode int = 401 + +/*ListExecutionsUnauthorized Unauthorized + +swagger:response listExecutionsUnauthorized +*/ +type ListExecutionsUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListExecutionsUnauthorized creates ListExecutionsUnauthorized with default headers values +func NewListExecutionsUnauthorized() *ListExecutionsUnauthorized { + + return &ListExecutionsUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the list executions unauthorized response +func (o *ListExecutionsUnauthorized) WithXRequestID(xRequestID string) *ListExecutionsUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list executions unauthorized response +func (o *ListExecutionsUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list executions unauthorized response +func (o *ListExecutionsUnauthorized) WithPayload(payload *models.Errors) *ListExecutionsUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list executions unauthorized response +func (o *ListExecutionsUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListExecutionsUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListExecutionsForbiddenCode is the HTTP code returned for type ListExecutionsForbidden +const ListExecutionsForbiddenCode int = 403 + +/*ListExecutionsForbidden Forbidden + +swagger:response listExecutionsForbidden +*/ +type ListExecutionsForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListExecutionsForbidden creates ListExecutionsForbidden with default headers values +func NewListExecutionsForbidden() *ListExecutionsForbidden { + + return &ListExecutionsForbidden{} +} + +// WithXRequestID adds the xRequestId to the list executions forbidden response +func (o *ListExecutionsForbidden) WithXRequestID(xRequestID string) *ListExecutionsForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list executions forbidden response +func (o *ListExecutionsForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list executions forbidden response +func (o *ListExecutionsForbidden) WithPayload(payload *models.Errors) *ListExecutionsForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list executions forbidden response +func (o *ListExecutionsForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListExecutionsForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListExecutionsNotFoundCode is the HTTP code returned for type ListExecutionsNotFound +const ListExecutionsNotFoundCode int = 404 + +/*ListExecutionsNotFound Not found + +swagger:response listExecutionsNotFound +*/ +type ListExecutionsNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListExecutionsNotFound creates ListExecutionsNotFound with default headers values +func NewListExecutionsNotFound() *ListExecutionsNotFound { + + return &ListExecutionsNotFound{} +} + +// WithXRequestID adds the xRequestId to the list executions not found response +func (o *ListExecutionsNotFound) WithXRequestID(xRequestID string) *ListExecutionsNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list executions not found response +func (o *ListExecutionsNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list executions not found response +func (o *ListExecutionsNotFound) WithPayload(payload *models.Errors) *ListExecutionsNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list executions not found response +func (o *ListExecutionsNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListExecutionsNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListExecutionsInternalServerErrorCode is the HTTP code returned for type ListExecutionsInternalServerError +const ListExecutionsInternalServerErrorCode int = 500 + +/*ListExecutionsInternalServerError Internal server error + +swagger:response listExecutionsInternalServerError +*/ +type ListExecutionsInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListExecutionsInternalServerError creates ListExecutionsInternalServerError with default headers values +func NewListExecutionsInternalServerError() *ListExecutionsInternalServerError { + + return &ListExecutionsInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the list executions internal server error response +func (o *ListExecutionsInternalServerError) WithXRequestID(xRequestID string) *ListExecutionsInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list executions internal server error response +func (o *ListExecutionsInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list executions internal server error response +func (o *ListExecutionsInternalServerError) WithPayload(payload *models.Errors) *ListExecutionsInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list executions internal server error response +func (o *ListExecutionsInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListExecutionsInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/preheat/list_executions_urlbuilder.go b/src/server/v2.0/restapi/operations/preheat/list_executions_urlbuilder.go new file mode 100644 index 000000000..dd3bfc28a --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/list_executions_urlbuilder.go @@ -0,0 +1,150 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ListExecutionsURL generates an URL for the list executions operation +type ListExecutionsURL struct { + PreheatPolicyName string + ProjectName string + + Page *int64 + PageSize *int64 + Q *string + Sort *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListExecutionsURL) WithBasePath(bp string) *ListExecutionsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListExecutionsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ListExecutionsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name}/preheat/policies/{preheat_policy_name}/executions" + + preheatPolicyName := o.PreheatPolicyName + if preheatPolicyName != "" { + _path = strings.Replace(_path, "{preheat_policy_name}", preheatPolicyName, -1) + } else { + return nil, errors.New("preheatPolicyName is required on ListExecutionsURL") + } + + projectName := o.ProjectName + if projectName != "" { + _path = strings.Replace(_path, "{project_name}", projectName, -1) + } else { + return nil, errors.New("projectName is required on ListExecutionsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var pageQ string + if o.Page != nil { + pageQ = swag.FormatInt64(*o.Page) + } + if pageQ != "" { + qs.Set("page", pageQ) + } + + var pageSizeQ string + if o.PageSize != nil { + pageSizeQ = swag.FormatInt64(*o.PageSize) + } + if pageSizeQ != "" { + qs.Set("page_size", pageSizeQ) + } + + var qQ string + if o.Q != nil { + qQ = *o.Q + } + if qQ != "" { + qs.Set("q", qQ) + } + + var sortQ string + if o.Sort != nil { + sortQ = *o.Sort + } + if sortQ != "" { + qs.Set("sort", sortQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ListExecutionsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ListExecutionsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ListExecutionsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ListExecutionsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ListExecutionsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ListExecutionsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/preheat/list_instances.go b/src/server/v2.0/restapi/operations/preheat/list_instances.go new file mode 100644 index 000000000..356757810 --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/list_instances.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ListInstancesHandlerFunc turns a function with the right signature into a list instances handler +type ListInstancesHandlerFunc func(ListInstancesParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ListInstancesHandlerFunc) Handle(params ListInstancesParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ListInstancesHandler interface for that can handle valid list instances params +type ListInstancesHandler interface { + Handle(ListInstancesParams, interface{}) middleware.Responder +} + +// NewListInstances creates a new http.Handler for the list instances operation +func NewListInstances(ctx *middleware.Context, handler ListInstancesHandler) *ListInstances { + return &ListInstances{Context: ctx, Handler: handler} +} + +/*ListInstances swagger:route GET /p2p/preheat/instances preheat listInstances + +List P2P provider instances + +List P2P provider instances + +*/ +type ListInstances struct { + Context *middleware.Context + Handler ListInstancesHandler +} + +func (o *ListInstances) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewListInstancesParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/preheat/list_instances_parameters.go b/src/server/v2.0/restapi/operations/preheat/list_instances_parameters.go new file mode 100644 index 000000000..044c8862e --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/list_instances_parameters.go @@ -0,0 +1,239 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewListInstancesParams creates a new ListInstancesParams object +// with the default values initialized. +func NewListInstancesParams() ListInstancesParams { + + var ( + // initialize parameters with default values + + pageDefault = int64(1) + pageSizeDefault = int64(10) + ) + + return ListInstancesParams{ + Page: &pageDefault, + + PageSize: &pageSizeDefault, + } +} + +// ListInstancesParams contains all the bound params for the list instances operation +// typically these are obtained from a http.Request +// +// swagger:parameters ListInstances +type ListInstancesParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The page number + In: query + Default: 1 + */ + Page *int64 + /*The size of per page + Maximum: 100 + In: query + Default: 10 + */ + PageSize *int64 + /*Query string to query resources. Supported query patterns are "exact match(k=v)", "fuzzy match(k=~v)", "range(k=[min~max])", "list with union releationship(k={v1 v2 v3})" and "list with intersetion relationship(k=(v1 v2 v3))". The value of range and list can be string(enclosed by " or '), integer or time(in format "2020-04-09 02:36:00"). All of these query patterns should be put in the query string "q=xxx" and splitted by ",". e.g. q=k1=v1,k2=~v2,k3=[min~max] + In: query + */ + Q *string + /*Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + In: query + */ + Sort *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewListInstancesParams() beforehand. +func (o *ListInstancesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + qPage, qhkPage, _ := qs.GetOK("page") + if err := o.bindPage(qPage, qhkPage, route.Formats); err != nil { + res = append(res, err) + } + + qPageSize, qhkPageSize, _ := qs.GetOK("page_size") + if err := o.bindPageSize(qPageSize, qhkPageSize, route.Formats); err != nil { + res = append(res, err) + } + + qQ, qhkQ, _ := qs.GetOK("q") + if err := o.bindQ(qQ, qhkQ, route.Formats); err != nil { + res = append(res, err) + } + + qSort, qhkSort, _ := qs.GetOK("sort") + if err := o.bindSort(qSort, qhkSort, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *ListInstancesParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *ListInstancesParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindPage binds and validates parameter Page from query. +func (o *ListInstancesParams) bindPage(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListInstancesParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page", "query", "int64", raw) + } + o.Page = &value + + return nil +} + +// bindPageSize binds and validates parameter PageSize from query. +func (o *ListInstancesParams) bindPageSize(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListInstancesParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page_size", "query", "int64", raw) + } + o.PageSize = &value + + if err := o.validatePageSize(formats); err != nil { + return err + } + + return nil +} + +// validatePageSize carries on validations for parameter PageSize +func (o *ListInstancesParams) validatePageSize(formats strfmt.Registry) error { + + if err := validate.MaximumInt("page_size", "query", int64(*o.PageSize), 100, false); err != nil { + return err + } + + return nil +} + +// bindQ binds and validates parameter Q from query. +func (o *ListInstancesParams) bindQ(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Q = &raw + + return nil +} + +// bindSort binds and validates parameter Sort from query. +func (o *ListInstancesParams) bindSort(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Sort = &raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/preheat/list_instances_responses.go b/src/server/v2.0/restapi/operations/preheat/list_instances_responses.go new file mode 100644 index 000000000..a3c687447 --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/list_instances_responses.go @@ -0,0 +1,436 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/swag" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// ListInstancesOKCode is the HTTP code returned for type ListInstancesOK +const ListInstancesOKCode int = 200 + +/*ListInstancesOK Success + +swagger:response listInstancesOK +*/ +type ListInstancesOK struct { + /*Link refers to the previous page and next page + + */ + Link string `json:"Link"` + /*The total count of preheating provider instances + + */ + XTotalCount int64 `json:"X-Total-Count"` + + /* + In: Body + */ + Payload []*models.Instance `json:"body,omitempty"` +} + +// NewListInstancesOK creates ListInstancesOK with default headers values +func NewListInstancesOK() *ListInstancesOK { + + return &ListInstancesOK{} +} + +// WithLink adds the link to the list instances o k response +func (o *ListInstancesOK) WithLink(link string) *ListInstancesOK { + o.Link = link + return o +} + +// SetLink sets the link to the list instances o k response +func (o *ListInstancesOK) SetLink(link string) { + o.Link = link +} + +// WithXTotalCount adds the xTotalCount to the list instances o k response +func (o *ListInstancesOK) WithXTotalCount(xTotalCount int64) *ListInstancesOK { + o.XTotalCount = xTotalCount + return o +} + +// SetXTotalCount sets the xTotalCount to the list instances o k response +func (o *ListInstancesOK) SetXTotalCount(xTotalCount int64) { + o.XTotalCount = xTotalCount +} + +// WithPayload adds the payload to the list instances o k response +func (o *ListInstancesOK) WithPayload(payload []*models.Instance) *ListInstancesOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list instances o k response +func (o *ListInstancesOK) SetPayload(payload []*models.Instance) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListInstancesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Link + + link := o.Link + if link != "" { + rw.Header().Set("Link", link) + } + + // response header X-Total-Count + + xTotalCount := swag.FormatInt64(o.XTotalCount) + if xTotalCount != "" { + rw.Header().Set("X-Total-Count", xTotalCount) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = make([]*models.Instance, 0, 50) + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ListInstancesBadRequestCode is the HTTP code returned for type ListInstancesBadRequest +const ListInstancesBadRequestCode int = 400 + +/*ListInstancesBadRequest Bad request + +swagger:response listInstancesBadRequest +*/ +type ListInstancesBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListInstancesBadRequest creates ListInstancesBadRequest with default headers values +func NewListInstancesBadRequest() *ListInstancesBadRequest { + + return &ListInstancesBadRequest{} +} + +// WithXRequestID adds the xRequestId to the list instances bad request response +func (o *ListInstancesBadRequest) WithXRequestID(xRequestID string) *ListInstancesBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list instances bad request response +func (o *ListInstancesBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list instances bad request response +func (o *ListInstancesBadRequest) WithPayload(payload *models.Errors) *ListInstancesBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list instances bad request response +func (o *ListInstancesBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListInstancesBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListInstancesUnauthorizedCode is the HTTP code returned for type ListInstancesUnauthorized +const ListInstancesUnauthorizedCode int = 401 + +/*ListInstancesUnauthorized Unauthorized + +swagger:response listInstancesUnauthorized +*/ +type ListInstancesUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListInstancesUnauthorized creates ListInstancesUnauthorized with default headers values +func NewListInstancesUnauthorized() *ListInstancesUnauthorized { + + return &ListInstancesUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the list instances unauthorized response +func (o *ListInstancesUnauthorized) WithXRequestID(xRequestID string) *ListInstancesUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list instances unauthorized response +func (o *ListInstancesUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list instances unauthorized response +func (o *ListInstancesUnauthorized) WithPayload(payload *models.Errors) *ListInstancesUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list instances unauthorized response +func (o *ListInstancesUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListInstancesUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListInstancesForbiddenCode is the HTTP code returned for type ListInstancesForbidden +const ListInstancesForbiddenCode int = 403 + +/*ListInstancesForbidden Forbidden + +swagger:response listInstancesForbidden +*/ +type ListInstancesForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListInstancesForbidden creates ListInstancesForbidden with default headers values +func NewListInstancesForbidden() *ListInstancesForbidden { + + return &ListInstancesForbidden{} +} + +// WithXRequestID adds the xRequestId to the list instances forbidden response +func (o *ListInstancesForbidden) WithXRequestID(xRequestID string) *ListInstancesForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list instances forbidden response +func (o *ListInstancesForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list instances forbidden response +func (o *ListInstancesForbidden) WithPayload(payload *models.Errors) *ListInstancesForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list instances forbidden response +func (o *ListInstancesForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListInstancesForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListInstancesNotFoundCode is the HTTP code returned for type ListInstancesNotFound +const ListInstancesNotFoundCode int = 404 + +/*ListInstancesNotFound Not found + +swagger:response listInstancesNotFound +*/ +type ListInstancesNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListInstancesNotFound creates ListInstancesNotFound with default headers values +func NewListInstancesNotFound() *ListInstancesNotFound { + + return &ListInstancesNotFound{} +} + +// WithXRequestID adds the xRequestId to the list instances not found response +func (o *ListInstancesNotFound) WithXRequestID(xRequestID string) *ListInstancesNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list instances not found response +func (o *ListInstancesNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list instances not found response +func (o *ListInstancesNotFound) WithPayload(payload *models.Errors) *ListInstancesNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list instances not found response +func (o *ListInstancesNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListInstancesNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListInstancesInternalServerErrorCode is the HTTP code returned for type ListInstancesInternalServerError +const ListInstancesInternalServerErrorCode int = 500 + +/*ListInstancesInternalServerError Internal server error + +swagger:response listInstancesInternalServerError +*/ +type ListInstancesInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListInstancesInternalServerError creates ListInstancesInternalServerError with default headers values +func NewListInstancesInternalServerError() *ListInstancesInternalServerError { + + return &ListInstancesInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the list instances internal server error response +func (o *ListInstancesInternalServerError) WithXRequestID(xRequestID string) *ListInstancesInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list instances internal server error response +func (o *ListInstancesInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list instances internal server error response +func (o *ListInstancesInternalServerError) WithPayload(payload *models.Errors) *ListInstancesInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list instances internal server error response +func (o *ListInstancesInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListInstancesInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/preheat/list_instances_urlbuilder.go b/src/server/v2.0/restapi/operations/preheat/list_instances_urlbuilder.go new file mode 100644 index 000000000..fd29899a1 --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/list_instances_urlbuilder.go @@ -0,0 +1,132 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// ListInstancesURL generates an URL for the list instances operation +type ListInstancesURL struct { + Page *int64 + PageSize *int64 + Q *string + Sort *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListInstancesURL) WithBasePath(bp string) *ListInstancesURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListInstancesURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ListInstancesURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/p2p/preheat/instances" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var pageQ string + if o.Page != nil { + pageQ = swag.FormatInt64(*o.Page) + } + if pageQ != "" { + qs.Set("page", pageQ) + } + + var pageSizeQ string + if o.PageSize != nil { + pageSizeQ = swag.FormatInt64(*o.PageSize) + } + if pageSizeQ != "" { + qs.Set("page_size", pageSizeQ) + } + + var qQ string + if o.Q != nil { + qQ = *o.Q + } + if qQ != "" { + qs.Set("q", qQ) + } + + var sortQ string + if o.Sort != nil { + sortQ = *o.Sort + } + if sortQ != "" { + qs.Set("sort", sortQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ListInstancesURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ListInstancesURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ListInstancesURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ListInstancesURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ListInstancesURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ListInstancesURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/preheat/list_policies.go b/src/server/v2.0/restapi/operations/preheat/list_policies.go new file mode 100644 index 000000000..c3f0bea96 --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/list_policies.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ListPoliciesHandlerFunc turns a function with the right signature into a list policies handler +type ListPoliciesHandlerFunc func(ListPoliciesParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ListPoliciesHandlerFunc) Handle(params ListPoliciesParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ListPoliciesHandler interface for that can handle valid list policies params +type ListPoliciesHandler interface { + Handle(ListPoliciesParams, interface{}) middleware.Responder +} + +// NewListPolicies creates a new http.Handler for the list policies operation +func NewListPolicies(ctx *middleware.Context, handler ListPoliciesHandler) *ListPolicies { + return &ListPolicies{Context: ctx, Handler: handler} +} + +/*ListPolicies swagger:route GET /projects/{project_name}/preheat/policies preheat listPolicies + +List preheat policies + +List preheat policies + +*/ +type ListPolicies struct { + Context *middleware.Context + Handler ListPoliciesHandler +} + +func (o *ListPolicies) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewListPoliciesParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/preheat/list_policies_parameters.go b/src/server/v2.0/restapi/operations/preheat/list_policies_parameters.go new file mode 100644 index 000000000..3cde44a42 --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/list_policies_parameters.go @@ -0,0 +1,264 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewListPoliciesParams creates a new ListPoliciesParams object +// with the default values initialized. +func NewListPoliciesParams() ListPoliciesParams { + + var ( + // initialize parameters with default values + + pageDefault = int64(1) + pageSizeDefault = int64(10) + ) + + return ListPoliciesParams{ + Page: &pageDefault, + + PageSize: &pageSizeDefault, + } +} + +// ListPoliciesParams contains all the bound params for the list policies operation +// typically these are obtained from a http.Request +// +// swagger:parameters ListPolicies +type ListPoliciesParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The page number + In: query + Default: 1 + */ + Page *int64 + /*The size of per page + Maximum: 100 + In: query + Default: 10 + */ + PageSize *int64 + /*The name of the project + Required: true + In: path + */ + ProjectName string + /*Query string to query resources. Supported query patterns are "exact match(k=v)", "fuzzy match(k=~v)", "range(k=[min~max])", "list with union releationship(k={v1 v2 v3})" and "list with intersetion relationship(k=(v1 v2 v3))". The value of range and list can be string(enclosed by " or '), integer or time(in format "2020-04-09 02:36:00"). All of these query patterns should be put in the query string "q=xxx" and splitted by ",". e.g. q=k1=v1,k2=~v2,k3=[min~max] + In: query + */ + Q *string + /*Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + In: query + */ + Sort *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewListPoliciesParams() beforehand. +func (o *ListPoliciesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + qPage, qhkPage, _ := qs.GetOK("page") + if err := o.bindPage(qPage, qhkPage, route.Formats); err != nil { + res = append(res, err) + } + + qPageSize, qhkPageSize, _ := qs.GetOK("page_size") + if err := o.bindPageSize(qPageSize, qhkPageSize, route.Formats); err != nil { + res = append(res, err) + } + + rProjectName, rhkProjectName, _ := route.Params.GetOK("project_name") + if err := o.bindProjectName(rProjectName, rhkProjectName, route.Formats); err != nil { + res = append(res, err) + } + + qQ, qhkQ, _ := qs.GetOK("q") + if err := o.bindQ(qQ, qhkQ, route.Formats); err != nil { + res = append(res, err) + } + + qSort, qhkSort, _ := qs.GetOK("sort") + if err := o.bindSort(qSort, qhkSort, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *ListPoliciesParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *ListPoliciesParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindPage binds and validates parameter Page from query. +func (o *ListPoliciesParams) bindPage(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListPoliciesParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page", "query", "int64", raw) + } + o.Page = &value + + return nil +} + +// bindPageSize binds and validates parameter PageSize from query. +func (o *ListPoliciesParams) bindPageSize(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListPoliciesParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page_size", "query", "int64", raw) + } + o.PageSize = &value + + if err := o.validatePageSize(formats); err != nil { + return err + } + + return nil +} + +// validatePageSize carries on validations for parameter PageSize +func (o *ListPoliciesParams) validatePageSize(formats strfmt.Registry) error { + + if err := validate.MaximumInt("page_size", "query", int64(*o.PageSize), 100, false); err != nil { + return err + } + + return nil +} + +// bindProjectName binds and validates parameter ProjectName from path. +func (o *ListPoliciesParams) bindProjectName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectName = raw + + return nil +} + +// bindQ binds and validates parameter Q from query. +func (o *ListPoliciesParams) bindQ(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Q = &raw + + return nil +} + +// bindSort binds and validates parameter Sort from query. +func (o *ListPoliciesParams) bindSort(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Sort = &raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/preheat/list_policies_responses.go b/src/server/v2.0/restapi/operations/preheat/list_policies_responses.go new file mode 100644 index 000000000..b9eb83250 --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/list_policies_responses.go @@ -0,0 +1,370 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/swag" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// ListPoliciesOKCode is the HTTP code returned for type ListPoliciesOK +const ListPoliciesOKCode int = 200 + +/*ListPoliciesOK List preheat policies success + +swagger:response listPoliciesOK +*/ +type ListPoliciesOK struct { + /*Link refers to the previous page and next page + + */ + Link string `json:"Link"` + /*The total count of policies + + */ + XTotalCount int64 `json:"X-Total-Count"` + + /* + In: Body + */ + Payload []*models.PreheatPolicy `json:"body,omitempty"` +} + +// NewListPoliciesOK creates ListPoliciesOK with default headers values +func NewListPoliciesOK() *ListPoliciesOK { + + return &ListPoliciesOK{} +} + +// WithLink adds the link to the list policies o k response +func (o *ListPoliciesOK) WithLink(link string) *ListPoliciesOK { + o.Link = link + return o +} + +// SetLink sets the link to the list policies o k response +func (o *ListPoliciesOK) SetLink(link string) { + o.Link = link +} + +// WithXTotalCount adds the xTotalCount to the list policies o k response +func (o *ListPoliciesOK) WithXTotalCount(xTotalCount int64) *ListPoliciesOK { + o.XTotalCount = xTotalCount + return o +} + +// SetXTotalCount sets the xTotalCount to the list policies o k response +func (o *ListPoliciesOK) SetXTotalCount(xTotalCount int64) { + o.XTotalCount = xTotalCount +} + +// WithPayload adds the payload to the list policies o k response +func (o *ListPoliciesOK) WithPayload(payload []*models.PreheatPolicy) *ListPoliciesOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list policies o k response +func (o *ListPoliciesOK) SetPayload(payload []*models.PreheatPolicy) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListPoliciesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Link + + link := o.Link + if link != "" { + rw.Header().Set("Link", link) + } + + // response header X-Total-Count + + xTotalCount := swag.FormatInt64(o.XTotalCount) + if xTotalCount != "" { + rw.Header().Set("X-Total-Count", xTotalCount) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = make([]*models.PreheatPolicy, 0, 50) + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ListPoliciesBadRequestCode is the HTTP code returned for type ListPoliciesBadRequest +const ListPoliciesBadRequestCode int = 400 + +/*ListPoliciesBadRequest Bad request + +swagger:response listPoliciesBadRequest +*/ +type ListPoliciesBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListPoliciesBadRequest creates ListPoliciesBadRequest with default headers values +func NewListPoliciesBadRequest() *ListPoliciesBadRequest { + + return &ListPoliciesBadRequest{} +} + +// WithXRequestID adds the xRequestId to the list policies bad request response +func (o *ListPoliciesBadRequest) WithXRequestID(xRequestID string) *ListPoliciesBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list policies bad request response +func (o *ListPoliciesBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list policies bad request response +func (o *ListPoliciesBadRequest) WithPayload(payload *models.Errors) *ListPoliciesBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list policies bad request response +func (o *ListPoliciesBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListPoliciesBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListPoliciesUnauthorizedCode is the HTTP code returned for type ListPoliciesUnauthorized +const ListPoliciesUnauthorizedCode int = 401 + +/*ListPoliciesUnauthorized Unauthorized + +swagger:response listPoliciesUnauthorized +*/ +type ListPoliciesUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListPoliciesUnauthorized creates ListPoliciesUnauthorized with default headers values +func NewListPoliciesUnauthorized() *ListPoliciesUnauthorized { + + return &ListPoliciesUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the list policies unauthorized response +func (o *ListPoliciesUnauthorized) WithXRequestID(xRequestID string) *ListPoliciesUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list policies unauthorized response +func (o *ListPoliciesUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list policies unauthorized response +func (o *ListPoliciesUnauthorized) WithPayload(payload *models.Errors) *ListPoliciesUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list policies unauthorized response +func (o *ListPoliciesUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListPoliciesUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListPoliciesForbiddenCode is the HTTP code returned for type ListPoliciesForbidden +const ListPoliciesForbiddenCode int = 403 + +/*ListPoliciesForbidden Forbidden + +swagger:response listPoliciesForbidden +*/ +type ListPoliciesForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListPoliciesForbidden creates ListPoliciesForbidden with default headers values +func NewListPoliciesForbidden() *ListPoliciesForbidden { + + return &ListPoliciesForbidden{} +} + +// WithXRequestID adds the xRequestId to the list policies forbidden response +func (o *ListPoliciesForbidden) WithXRequestID(xRequestID string) *ListPoliciesForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list policies forbidden response +func (o *ListPoliciesForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list policies forbidden response +func (o *ListPoliciesForbidden) WithPayload(payload *models.Errors) *ListPoliciesForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list policies forbidden response +func (o *ListPoliciesForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListPoliciesForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListPoliciesInternalServerErrorCode is the HTTP code returned for type ListPoliciesInternalServerError +const ListPoliciesInternalServerErrorCode int = 500 + +/*ListPoliciesInternalServerError Internal server error + +swagger:response listPoliciesInternalServerError +*/ +type ListPoliciesInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListPoliciesInternalServerError creates ListPoliciesInternalServerError with default headers values +func NewListPoliciesInternalServerError() *ListPoliciesInternalServerError { + + return &ListPoliciesInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the list policies internal server error response +func (o *ListPoliciesInternalServerError) WithXRequestID(xRequestID string) *ListPoliciesInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list policies internal server error response +func (o *ListPoliciesInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list policies internal server error response +func (o *ListPoliciesInternalServerError) WithPayload(payload *models.Errors) *ListPoliciesInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list policies internal server error response +func (o *ListPoliciesInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListPoliciesInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/preheat/list_policies_urlbuilder.go b/src/server/v2.0/restapi/operations/preheat/list_policies_urlbuilder.go new file mode 100644 index 000000000..5d7e18045 --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/list_policies_urlbuilder.go @@ -0,0 +1,142 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ListPoliciesURL generates an URL for the list policies operation +type ListPoliciesURL struct { + ProjectName string + + Page *int64 + PageSize *int64 + Q *string + Sort *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListPoliciesURL) WithBasePath(bp string) *ListPoliciesURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListPoliciesURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ListPoliciesURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name}/preheat/policies" + + projectName := o.ProjectName + if projectName != "" { + _path = strings.Replace(_path, "{project_name}", projectName, -1) + } else { + return nil, errors.New("projectName is required on ListPoliciesURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var pageQ string + if o.Page != nil { + pageQ = swag.FormatInt64(*o.Page) + } + if pageQ != "" { + qs.Set("page", pageQ) + } + + var pageSizeQ string + if o.PageSize != nil { + pageSizeQ = swag.FormatInt64(*o.PageSize) + } + if pageSizeQ != "" { + qs.Set("page_size", pageSizeQ) + } + + var qQ string + if o.Q != nil { + qQ = *o.Q + } + if qQ != "" { + qs.Set("q", qQ) + } + + var sortQ string + if o.Sort != nil { + sortQ = *o.Sort + } + if sortQ != "" { + qs.Set("sort", sortQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ListPoliciesURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ListPoliciesURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ListPoliciesURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ListPoliciesURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ListPoliciesURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ListPoliciesURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/preheat/list_providers.go b/src/server/v2.0/restapi/operations/preheat/list_providers.go new file mode 100644 index 000000000..6f627951a --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/list_providers.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ListProvidersHandlerFunc turns a function with the right signature into a list providers handler +type ListProvidersHandlerFunc func(ListProvidersParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ListProvidersHandlerFunc) Handle(params ListProvidersParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ListProvidersHandler interface for that can handle valid list providers params +type ListProvidersHandler interface { + Handle(ListProvidersParams, interface{}) middleware.Responder +} + +// NewListProviders creates a new http.Handler for the list providers operation +func NewListProviders(ctx *middleware.Context, handler ListProvidersHandler) *ListProviders { + return &ListProviders{Context: ctx, Handler: handler} +} + +/*ListProviders swagger:route GET /p2p/preheat/providers preheat listProviders + +List P2P providers + +List P2P providers + +*/ +type ListProviders struct { + Context *middleware.Context + Handler ListProvidersHandler +} + +func (o *ListProviders) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewListProvidersParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/preheat/list_providers_parameters.go b/src/server/v2.0/restapi/operations/preheat/list_providers_parameters.go new file mode 100644 index 000000000..087d33514 --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/list_providers_parameters.go @@ -0,0 +1,89 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewListProvidersParams creates a new ListProvidersParams object +// no default values defined in spec. +func NewListProvidersParams() ListProvidersParams { + + return ListProvidersParams{} +} + +// ListProvidersParams contains all the bound params for the list providers operation +// typically these are obtained from a http.Request +// +// swagger:parameters ListProviders +type ListProvidersParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewListProvidersParams() beforehand. +func (o *ListProvidersParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *ListProvidersParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *ListProvidersParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} diff --git a/src/server/v2.0/restapi/operations/preheat/list_providers_responses.go b/src/server/v2.0/restapi/operations/preheat/list_providers_responses.go new file mode 100644 index 000000000..b7bf8419f --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/list_providers_responses.go @@ -0,0 +1,391 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// ListProvidersOKCode is the HTTP code returned for type ListProvidersOK +const ListProvidersOKCode int = 200 + +/*ListProvidersOK Success + +swagger:response listProvidersOK +*/ +type ListProvidersOK struct { + + /* + In: Body + */ + Payload []*models.Metadata `json:"body,omitempty"` +} + +// NewListProvidersOK creates ListProvidersOK with default headers values +func NewListProvidersOK() *ListProvidersOK { + + return &ListProvidersOK{} +} + +// WithPayload adds the payload to the list providers o k response +func (o *ListProvidersOK) WithPayload(payload []*models.Metadata) *ListProvidersOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list providers o k response +func (o *ListProvidersOK) SetPayload(payload []*models.Metadata) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListProvidersOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = make([]*models.Metadata, 0, 50) + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ListProvidersBadRequestCode is the HTTP code returned for type ListProvidersBadRequest +const ListProvidersBadRequestCode int = 400 + +/*ListProvidersBadRequest Bad request + +swagger:response listProvidersBadRequest +*/ +type ListProvidersBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListProvidersBadRequest creates ListProvidersBadRequest with default headers values +func NewListProvidersBadRequest() *ListProvidersBadRequest { + + return &ListProvidersBadRequest{} +} + +// WithXRequestID adds the xRequestId to the list providers bad request response +func (o *ListProvidersBadRequest) WithXRequestID(xRequestID string) *ListProvidersBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list providers bad request response +func (o *ListProvidersBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list providers bad request response +func (o *ListProvidersBadRequest) WithPayload(payload *models.Errors) *ListProvidersBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list providers bad request response +func (o *ListProvidersBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListProvidersBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListProvidersUnauthorizedCode is the HTTP code returned for type ListProvidersUnauthorized +const ListProvidersUnauthorizedCode int = 401 + +/*ListProvidersUnauthorized Unauthorized + +swagger:response listProvidersUnauthorized +*/ +type ListProvidersUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListProvidersUnauthorized creates ListProvidersUnauthorized with default headers values +func NewListProvidersUnauthorized() *ListProvidersUnauthorized { + + return &ListProvidersUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the list providers unauthorized response +func (o *ListProvidersUnauthorized) WithXRequestID(xRequestID string) *ListProvidersUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list providers unauthorized response +func (o *ListProvidersUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list providers unauthorized response +func (o *ListProvidersUnauthorized) WithPayload(payload *models.Errors) *ListProvidersUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list providers unauthorized response +func (o *ListProvidersUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListProvidersUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListProvidersForbiddenCode is the HTTP code returned for type ListProvidersForbidden +const ListProvidersForbiddenCode int = 403 + +/*ListProvidersForbidden Forbidden + +swagger:response listProvidersForbidden +*/ +type ListProvidersForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListProvidersForbidden creates ListProvidersForbidden with default headers values +func NewListProvidersForbidden() *ListProvidersForbidden { + + return &ListProvidersForbidden{} +} + +// WithXRequestID adds the xRequestId to the list providers forbidden response +func (o *ListProvidersForbidden) WithXRequestID(xRequestID string) *ListProvidersForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list providers forbidden response +func (o *ListProvidersForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list providers forbidden response +func (o *ListProvidersForbidden) WithPayload(payload *models.Errors) *ListProvidersForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list providers forbidden response +func (o *ListProvidersForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListProvidersForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListProvidersNotFoundCode is the HTTP code returned for type ListProvidersNotFound +const ListProvidersNotFoundCode int = 404 + +/*ListProvidersNotFound Not found + +swagger:response listProvidersNotFound +*/ +type ListProvidersNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListProvidersNotFound creates ListProvidersNotFound with default headers values +func NewListProvidersNotFound() *ListProvidersNotFound { + + return &ListProvidersNotFound{} +} + +// WithXRequestID adds the xRequestId to the list providers not found response +func (o *ListProvidersNotFound) WithXRequestID(xRequestID string) *ListProvidersNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list providers not found response +func (o *ListProvidersNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list providers not found response +func (o *ListProvidersNotFound) WithPayload(payload *models.Errors) *ListProvidersNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list providers not found response +func (o *ListProvidersNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListProvidersNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListProvidersInternalServerErrorCode is the HTTP code returned for type ListProvidersInternalServerError +const ListProvidersInternalServerErrorCode int = 500 + +/*ListProvidersInternalServerError Internal server error + +swagger:response listProvidersInternalServerError +*/ +type ListProvidersInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListProvidersInternalServerError creates ListProvidersInternalServerError with default headers values +func NewListProvidersInternalServerError() *ListProvidersInternalServerError { + + return &ListProvidersInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the list providers internal server error response +func (o *ListProvidersInternalServerError) WithXRequestID(xRequestID string) *ListProvidersInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list providers internal server error response +func (o *ListProvidersInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list providers internal server error response +func (o *ListProvidersInternalServerError) WithPayload(payload *models.Errors) *ListProvidersInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list providers internal server error response +func (o *ListProvidersInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListProvidersInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/preheat/list_providers_under_project.go b/src/server/v2.0/restapi/operations/preheat/list_providers_under_project.go new file mode 100644 index 000000000..a2b8efe45 --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/list_providers_under_project.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ListProvidersUnderProjectHandlerFunc turns a function with the right signature into a list providers under project handler +type ListProvidersUnderProjectHandlerFunc func(ListProvidersUnderProjectParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ListProvidersUnderProjectHandlerFunc) Handle(params ListProvidersUnderProjectParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ListProvidersUnderProjectHandler interface for that can handle valid list providers under project params +type ListProvidersUnderProjectHandler interface { + Handle(ListProvidersUnderProjectParams, interface{}) middleware.Responder +} + +// NewListProvidersUnderProject creates a new http.Handler for the list providers under project operation +func NewListProvidersUnderProject(ctx *middleware.Context, handler ListProvidersUnderProjectHandler) *ListProvidersUnderProject { + return &ListProvidersUnderProject{Context: ctx, Handler: handler} +} + +/*ListProvidersUnderProject swagger:route GET /projects/{project_name}/preheat/providers preheat listProvidersUnderProject + +Get all providers at project level + +Get all providers at project level + +*/ +type ListProvidersUnderProject struct { + Context *middleware.Context + Handler ListProvidersUnderProjectHandler +} + +func (o *ListProvidersUnderProject) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewListProvidersUnderProjectParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/preheat/list_providers_under_project_parameters.go b/src/server/v2.0/restapi/operations/preheat/list_providers_under_project_parameters.go new file mode 100644 index 000000000..1942d8a1e --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/list_providers_under_project_parameters.go @@ -0,0 +1,114 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewListProvidersUnderProjectParams creates a new ListProvidersUnderProjectParams object +// no default values defined in spec. +func NewListProvidersUnderProjectParams() ListProvidersUnderProjectParams { + + return ListProvidersUnderProjectParams{} +} + +// ListProvidersUnderProjectParams contains all the bound params for the list providers under project operation +// typically these are obtained from a http.Request +// +// swagger:parameters ListProvidersUnderProject +type ListProvidersUnderProjectParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The name of the project + Required: true + In: path + */ + ProjectName string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewListProvidersUnderProjectParams() beforehand. +func (o *ListProvidersUnderProjectParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rProjectName, rhkProjectName, _ := route.Params.GetOK("project_name") + if err := o.bindProjectName(rProjectName, rhkProjectName, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *ListProvidersUnderProjectParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *ListProvidersUnderProjectParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindProjectName binds and validates parameter ProjectName from path. +func (o *ListProvidersUnderProjectParams) bindProjectName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectName = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/preheat/list_providers_under_project_responses.go b/src/server/v2.0/restapi/operations/preheat/list_providers_under_project_responses.go new file mode 100644 index 000000000..f65310b7a --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/list_providers_under_project_responses.go @@ -0,0 +1,391 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// ListProvidersUnderProjectOKCode is the HTTP code returned for type ListProvidersUnderProjectOK +const ListProvidersUnderProjectOKCode int = 200 + +/*ListProvidersUnderProjectOK Success + +swagger:response listProvidersUnderProjectOK +*/ +type ListProvidersUnderProjectOK struct { + + /* + In: Body + */ + Payload []*models.ProviderUnderProject `json:"body,omitempty"` +} + +// NewListProvidersUnderProjectOK creates ListProvidersUnderProjectOK with default headers values +func NewListProvidersUnderProjectOK() *ListProvidersUnderProjectOK { + + return &ListProvidersUnderProjectOK{} +} + +// WithPayload adds the payload to the list providers under project o k response +func (o *ListProvidersUnderProjectOK) WithPayload(payload []*models.ProviderUnderProject) *ListProvidersUnderProjectOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list providers under project o k response +func (o *ListProvidersUnderProjectOK) SetPayload(payload []*models.ProviderUnderProject) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListProvidersUnderProjectOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = make([]*models.ProviderUnderProject, 0, 50) + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ListProvidersUnderProjectBadRequestCode is the HTTP code returned for type ListProvidersUnderProjectBadRequest +const ListProvidersUnderProjectBadRequestCode int = 400 + +/*ListProvidersUnderProjectBadRequest Bad request + +swagger:response listProvidersUnderProjectBadRequest +*/ +type ListProvidersUnderProjectBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListProvidersUnderProjectBadRequest creates ListProvidersUnderProjectBadRequest with default headers values +func NewListProvidersUnderProjectBadRequest() *ListProvidersUnderProjectBadRequest { + + return &ListProvidersUnderProjectBadRequest{} +} + +// WithXRequestID adds the xRequestId to the list providers under project bad request response +func (o *ListProvidersUnderProjectBadRequest) WithXRequestID(xRequestID string) *ListProvidersUnderProjectBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list providers under project bad request response +func (o *ListProvidersUnderProjectBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list providers under project bad request response +func (o *ListProvidersUnderProjectBadRequest) WithPayload(payload *models.Errors) *ListProvidersUnderProjectBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list providers under project bad request response +func (o *ListProvidersUnderProjectBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListProvidersUnderProjectBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListProvidersUnderProjectUnauthorizedCode is the HTTP code returned for type ListProvidersUnderProjectUnauthorized +const ListProvidersUnderProjectUnauthorizedCode int = 401 + +/*ListProvidersUnderProjectUnauthorized Unauthorized + +swagger:response listProvidersUnderProjectUnauthorized +*/ +type ListProvidersUnderProjectUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListProvidersUnderProjectUnauthorized creates ListProvidersUnderProjectUnauthorized with default headers values +func NewListProvidersUnderProjectUnauthorized() *ListProvidersUnderProjectUnauthorized { + + return &ListProvidersUnderProjectUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the list providers under project unauthorized response +func (o *ListProvidersUnderProjectUnauthorized) WithXRequestID(xRequestID string) *ListProvidersUnderProjectUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list providers under project unauthorized response +func (o *ListProvidersUnderProjectUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list providers under project unauthorized response +func (o *ListProvidersUnderProjectUnauthorized) WithPayload(payload *models.Errors) *ListProvidersUnderProjectUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list providers under project unauthorized response +func (o *ListProvidersUnderProjectUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListProvidersUnderProjectUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListProvidersUnderProjectForbiddenCode is the HTTP code returned for type ListProvidersUnderProjectForbidden +const ListProvidersUnderProjectForbiddenCode int = 403 + +/*ListProvidersUnderProjectForbidden Forbidden + +swagger:response listProvidersUnderProjectForbidden +*/ +type ListProvidersUnderProjectForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListProvidersUnderProjectForbidden creates ListProvidersUnderProjectForbidden with default headers values +func NewListProvidersUnderProjectForbidden() *ListProvidersUnderProjectForbidden { + + return &ListProvidersUnderProjectForbidden{} +} + +// WithXRequestID adds the xRequestId to the list providers under project forbidden response +func (o *ListProvidersUnderProjectForbidden) WithXRequestID(xRequestID string) *ListProvidersUnderProjectForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list providers under project forbidden response +func (o *ListProvidersUnderProjectForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list providers under project forbidden response +func (o *ListProvidersUnderProjectForbidden) WithPayload(payload *models.Errors) *ListProvidersUnderProjectForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list providers under project forbidden response +func (o *ListProvidersUnderProjectForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListProvidersUnderProjectForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListProvidersUnderProjectNotFoundCode is the HTTP code returned for type ListProvidersUnderProjectNotFound +const ListProvidersUnderProjectNotFoundCode int = 404 + +/*ListProvidersUnderProjectNotFound Not found + +swagger:response listProvidersUnderProjectNotFound +*/ +type ListProvidersUnderProjectNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListProvidersUnderProjectNotFound creates ListProvidersUnderProjectNotFound with default headers values +func NewListProvidersUnderProjectNotFound() *ListProvidersUnderProjectNotFound { + + return &ListProvidersUnderProjectNotFound{} +} + +// WithXRequestID adds the xRequestId to the list providers under project not found response +func (o *ListProvidersUnderProjectNotFound) WithXRequestID(xRequestID string) *ListProvidersUnderProjectNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list providers under project not found response +func (o *ListProvidersUnderProjectNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list providers under project not found response +func (o *ListProvidersUnderProjectNotFound) WithPayload(payload *models.Errors) *ListProvidersUnderProjectNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list providers under project not found response +func (o *ListProvidersUnderProjectNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListProvidersUnderProjectNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListProvidersUnderProjectInternalServerErrorCode is the HTTP code returned for type ListProvidersUnderProjectInternalServerError +const ListProvidersUnderProjectInternalServerErrorCode int = 500 + +/*ListProvidersUnderProjectInternalServerError Internal server error + +swagger:response listProvidersUnderProjectInternalServerError +*/ +type ListProvidersUnderProjectInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListProvidersUnderProjectInternalServerError creates ListProvidersUnderProjectInternalServerError with default headers values +func NewListProvidersUnderProjectInternalServerError() *ListProvidersUnderProjectInternalServerError { + + return &ListProvidersUnderProjectInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the list providers under project internal server error response +func (o *ListProvidersUnderProjectInternalServerError) WithXRequestID(xRequestID string) *ListProvidersUnderProjectInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list providers under project internal server error response +func (o *ListProvidersUnderProjectInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list providers under project internal server error response +func (o *ListProvidersUnderProjectInternalServerError) WithPayload(payload *models.Errors) *ListProvidersUnderProjectInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list providers under project internal server error response +func (o *ListProvidersUnderProjectInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListProvidersUnderProjectInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/preheat/list_providers_under_project_urlbuilder.go b/src/server/v2.0/restapi/operations/preheat/list_providers_under_project_urlbuilder.go new file mode 100644 index 000000000..96ce8b392 --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/list_providers_under_project_urlbuilder.go @@ -0,0 +1,99 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// ListProvidersUnderProjectURL generates an URL for the list providers under project operation +type ListProvidersUnderProjectURL struct { + ProjectName string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListProvidersUnderProjectURL) WithBasePath(bp string) *ListProvidersUnderProjectURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListProvidersUnderProjectURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ListProvidersUnderProjectURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name}/preheat/providers" + + projectName := o.ProjectName + if projectName != "" { + _path = strings.Replace(_path, "{project_name}", projectName, -1) + } else { + return nil, errors.New("projectName is required on ListProvidersUnderProjectURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ListProvidersUnderProjectURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ListProvidersUnderProjectURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ListProvidersUnderProjectURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ListProvidersUnderProjectURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ListProvidersUnderProjectURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ListProvidersUnderProjectURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/preheat/list_providers_urlbuilder.go b/src/server/v2.0/restapi/operations/preheat/list_providers_urlbuilder.go new file mode 100644 index 000000000..c06d8de15 --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/list_providers_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// ListProvidersURL generates an URL for the list providers operation +type ListProvidersURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListProvidersURL) WithBasePath(bp string) *ListProvidersURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListProvidersURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ListProvidersURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/p2p/preheat/providers" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ListProvidersURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ListProvidersURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ListProvidersURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ListProvidersURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ListProvidersURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ListProvidersURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/preheat/list_tasks.go b/src/server/v2.0/restapi/operations/preheat/list_tasks.go new file mode 100644 index 000000000..4f2fd67e2 --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/list_tasks.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ListTasksHandlerFunc turns a function with the right signature into a list tasks handler +type ListTasksHandlerFunc func(ListTasksParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ListTasksHandlerFunc) Handle(params ListTasksParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ListTasksHandler interface for that can handle valid list tasks params +type ListTasksHandler interface { + Handle(ListTasksParams, interface{}) middleware.Responder +} + +// NewListTasks creates a new http.Handler for the list tasks operation +func NewListTasks(ctx *middleware.Context, handler ListTasksHandler) *ListTasks { + return &ListTasks{Context: ctx, Handler: handler} +} + +/*ListTasks swagger:route GET /projects/{project_name}/preheat/policies/{preheat_policy_name}/executions/{execution_id}/tasks preheat listTasks + +List all the related tasks for the given execution + +List all the related tasks for the given execution + +*/ +type ListTasks struct { + Context *middleware.Context + Handler ListTasksHandler +} + +func (o *ListTasks) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewListTasksParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/preheat/list_tasks_parameters.go b/src/server/v2.0/restapi/operations/preheat/list_tasks_parameters.go new file mode 100644 index 000000000..8c45a9f32 --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/list_tasks_parameters.go @@ -0,0 +1,318 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewListTasksParams creates a new ListTasksParams object +// with the default values initialized. +func NewListTasksParams() ListTasksParams { + + var ( + // initialize parameters with default values + + pageDefault = int64(1) + pageSizeDefault = int64(10) + ) + + return ListTasksParams{ + Page: &pageDefault, + + PageSize: &pageSizeDefault, + } +} + +// ListTasksParams contains all the bound params for the list tasks operation +// typically these are obtained from a http.Request +// +// swagger:parameters ListTasks +type ListTasksParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*Execution ID + Required: true + In: path + */ + ExecutionID int64 + /*The page number + In: query + Default: 1 + */ + Page *int64 + /*The size of per page + Maximum: 100 + In: query + Default: 10 + */ + PageSize *int64 + /*Preheat Policy Name + Required: true + In: path + */ + PreheatPolicyName string + /*The name of the project + Required: true + In: path + */ + ProjectName string + /*Query string to query resources. Supported query patterns are "exact match(k=v)", "fuzzy match(k=~v)", "range(k=[min~max])", "list with union releationship(k={v1 v2 v3})" and "list with intersetion relationship(k=(v1 v2 v3))". The value of range and list can be string(enclosed by " or '), integer or time(in format "2020-04-09 02:36:00"). All of these query patterns should be put in the query string "q=xxx" and splitted by ",". e.g. q=k1=v1,k2=~v2,k3=[min~max] + In: query + */ + Q *string + /*Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + In: query + */ + Sort *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewListTasksParams() beforehand. +func (o *ListTasksParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rExecutionID, rhkExecutionID, _ := route.Params.GetOK("execution_id") + if err := o.bindExecutionID(rExecutionID, rhkExecutionID, route.Formats); err != nil { + res = append(res, err) + } + + qPage, qhkPage, _ := qs.GetOK("page") + if err := o.bindPage(qPage, qhkPage, route.Formats); err != nil { + res = append(res, err) + } + + qPageSize, qhkPageSize, _ := qs.GetOK("page_size") + if err := o.bindPageSize(qPageSize, qhkPageSize, route.Formats); err != nil { + res = append(res, err) + } + + rPreheatPolicyName, rhkPreheatPolicyName, _ := route.Params.GetOK("preheat_policy_name") + if err := o.bindPreheatPolicyName(rPreheatPolicyName, rhkPreheatPolicyName, route.Formats); err != nil { + res = append(res, err) + } + + rProjectName, rhkProjectName, _ := route.Params.GetOK("project_name") + if err := o.bindProjectName(rProjectName, rhkProjectName, route.Formats); err != nil { + res = append(res, err) + } + + qQ, qhkQ, _ := qs.GetOK("q") + if err := o.bindQ(qQ, qhkQ, route.Formats); err != nil { + res = append(res, err) + } + + qSort, qhkSort, _ := qs.GetOK("sort") + if err := o.bindSort(qSort, qhkSort, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *ListTasksParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *ListTasksParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindExecutionID binds and validates parameter ExecutionID from path. +func (o *ListTasksParams) bindExecutionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("execution_id", "path", "int64", raw) + } + o.ExecutionID = value + + return nil +} + +// bindPage binds and validates parameter Page from query. +func (o *ListTasksParams) bindPage(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListTasksParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page", "query", "int64", raw) + } + o.Page = &value + + return nil +} + +// bindPageSize binds and validates parameter PageSize from query. +func (o *ListTasksParams) bindPageSize(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListTasksParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page_size", "query", "int64", raw) + } + o.PageSize = &value + + if err := o.validatePageSize(formats); err != nil { + return err + } + + return nil +} + +// validatePageSize carries on validations for parameter PageSize +func (o *ListTasksParams) validatePageSize(formats strfmt.Registry) error { + + if err := validate.MaximumInt("page_size", "query", int64(*o.PageSize), 100, false); err != nil { + return err + } + + return nil +} + +// bindPreheatPolicyName binds and validates parameter PreheatPolicyName from path. +func (o *ListTasksParams) bindPreheatPolicyName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.PreheatPolicyName = raw + + return nil +} + +// bindProjectName binds and validates parameter ProjectName from path. +func (o *ListTasksParams) bindProjectName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectName = raw + + return nil +} + +// bindQ binds and validates parameter Q from query. +func (o *ListTasksParams) bindQ(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Q = &raw + + return nil +} + +// bindSort binds and validates parameter Sort from query. +func (o *ListTasksParams) bindSort(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Sort = &raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/preheat/list_tasks_responses.go b/src/server/v2.0/restapi/operations/preheat/list_tasks_responses.go new file mode 100644 index 000000000..578909da2 --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/list_tasks_responses.go @@ -0,0 +1,436 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/swag" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// ListTasksOKCode is the HTTP code returned for type ListTasksOK +const ListTasksOKCode int = 200 + +/*ListTasksOK List tasks success + +swagger:response listTasksOK +*/ +type ListTasksOK struct { + /*Link refers to the previous page and next page + + */ + Link string `json:"Link"` + /*The total count of tasks + + */ + XTotalCount int64 `json:"X-Total-Count"` + + /* + In: Body + */ + Payload []*models.Task `json:"body,omitempty"` +} + +// NewListTasksOK creates ListTasksOK with default headers values +func NewListTasksOK() *ListTasksOK { + + return &ListTasksOK{} +} + +// WithLink adds the link to the list tasks o k response +func (o *ListTasksOK) WithLink(link string) *ListTasksOK { + o.Link = link + return o +} + +// SetLink sets the link to the list tasks o k response +func (o *ListTasksOK) SetLink(link string) { + o.Link = link +} + +// WithXTotalCount adds the xTotalCount to the list tasks o k response +func (o *ListTasksOK) WithXTotalCount(xTotalCount int64) *ListTasksOK { + o.XTotalCount = xTotalCount + return o +} + +// SetXTotalCount sets the xTotalCount to the list tasks o k response +func (o *ListTasksOK) SetXTotalCount(xTotalCount int64) { + o.XTotalCount = xTotalCount +} + +// WithPayload adds the payload to the list tasks o k response +func (o *ListTasksOK) WithPayload(payload []*models.Task) *ListTasksOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list tasks o k response +func (o *ListTasksOK) SetPayload(payload []*models.Task) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListTasksOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Link + + link := o.Link + if link != "" { + rw.Header().Set("Link", link) + } + + // response header X-Total-Count + + xTotalCount := swag.FormatInt64(o.XTotalCount) + if xTotalCount != "" { + rw.Header().Set("X-Total-Count", xTotalCount) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = make([]*models.Task, 0, 50) + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ListTasksBadRequestCode is the HTTP code returned for type ListTasksBadRequest +const ListTasksBadRequestCode int = 400 + +/*ListTasksBadRequest Bad request + +swagger:response listTasksBadRequest +*/ +type ListTasksBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListTasksBadRequest creates ListTasksBadRequest with default headers values +func NewListTasksBadRequest() *ListTasksBadRequest { + + return &ListTasksBadRequest{} +} + +// WithXRequestID adds the xRequestId to the list tasks bad request response +func (o *ListTasksBadRequest) WithXRequestID(xRequestID string) *ListTasksBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list tasks bad request response +func (o *ListTasksBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list tasks bad request response +func (o *ListTasksBadRequest) WithPayload(payload *models.Errors) *ListTasksBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list tasks bad request response +func (o *ListTasksBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListTasksBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListTasksUnauthorizedCode is the HTTP code returned for type ListTasksUnauthorized +const ListTasksUnauthorizedCode int = 401 + +/*ListTasksUnauthorized Unauthorized + +swagger:response listTasksUnauthorized +*/ +type ListTasksUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListTasksUnauthorized creates ListTasksUnauthorized with default headers values +func NewListTasksUnauthorized() *ListTasksUnauthorized { + + return &ListTasksUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the list tasks unauthorized response +func (o *ListTasksUnauthorized) WithXRequestID(xRequestID string) *ListTasksUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list tasks unauthorized response +func (o *ListTasksUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list tasks unauthorized response +func (o *ListTasksUnauthorized) WithPayload(payload *models.Errors) *ListTasksUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list tasks unauthorized response +func (o *ListTasksUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListTasksUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListTasksForbiddenCode is the HTTP code returned for type ListTasksForbidden +const ListTasksForbiddenCode int = 403 + +/*ListTasksForbidden Forbidden + +swagger:response listTasksForbidden +*/ +type ListTasksForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListTasksForbidden creates ListTasksForbidden with default headers values +func NewListTasksForbidden() *ListTasksForbidden { + + return &ListTasksForbidden{} +} + +// WithXRequestID adds the xRequestId to the list tasks forbidden response +func (o *ListTasksForbidden) WithXRequestID(xRequestID string) *ListTasksForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list tasks forbidden response +func (o *ListTasksForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list tasks forbidden response +func (o *ListTasksForbidden) WithPayload(payload *models.Errors) *ListTasksForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list tasks forbidden response +func (o *ListTasksForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListTasksForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListTasksNotFoundCode is the HTTP code returned for type ListTasksNotFound +const ListTasksNotFoundCode int = 404 + +/*ListTasksNotFound Not found + +swagger:response listTasksNotFound +*/ +type ListTasksNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListTasksNotFound creates ListTasksNotFound with default headers values +func NewListTasksNotFound() *ListTasksNotFound { + + return &ListTasksNotFound{} +} + +// WithXRequestID adds the xRequestId to the list tasks not found response +func (o *ListTasksNotFound) WithXRequestID(xRequestID string) *ListTasksNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list tasks not found response +func (o *ListTasksNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list tasks not found response +func (o *ListTasksNotFound) WithPayload(payload *models.Errors) *ListTasksNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list tasks not found response +func (o *ListTasksNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListTasksNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListTasksInternalServerErrorCode is the HTTP code returned for type ListTasksInternalServerError +const ListTasksInternalServerErrorCode int = 500 + +/*ListTasksInternalServerError Internal server error + +swagger:response listTasksInternalServerError +*/ +type ListTasksInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListTasksInternalServerError creates ListTasksInternalServerError with default headers values +func NewListTasksInternalServerError() *ListTasksInternalServerError { + + return &ListTasksInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the list tasks internal server error response +func (o *ListTasksInternalServerError) WithXRequestID(xRequestID string) *ListTasksInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list tasks internal server error response +func (o *ListTasksInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list tasks internal server error response +func (o *ListTasksInternalServerError) WithPayload(payload *models.Errors) *ListTasksInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list tasks internal server error response +func (o *ListTasksInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListTasksInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/preheat/list_tasks_urlbuilder.go b/src/server/v2.0/restapi/operations/preheat/list_tasks_urlbuilder.go new file mode 100644 index 000000000..0c9f9bf0d --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/list_tasks_urlbuilder.go @@ -0,0 +1,158 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ListTasksURL generates an URL for the list tasks operation +type ListTasksURL struct { + ExecutionID int64 + PreheatPolicyName string + ProjectName string + + Page *int64 + PageSize *int64 + Q *string + Sort *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListTasksURL) WithBasePath(bp string) *ListTasksURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListTasksURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ListTasksURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name}/preheat/policies/{preheat_policy_name}/executions/{execution_id}/tasks" + + executionID := swag.FormatInt64(o.ExecutionID) + if executionID != "" { + _path = strings.Replace(_path, "{execution_id}", executionID, -1) + } else { + return nil, errors.New("executionId is required on ListTasksURL") + } + + preheatPolicyName := o.PreheatPolicyName + if preheatPolicyName != "" { + _path = strings.Replace(_path, "{preheat_policy_name}", preheatPolicyName, -1) + } else { + return nil, errors.New("preheatPolicyName is required on ListTasksURL") + } + + projectName := o.ProjectName + if projectName != "" { + _path = strings.Replace(_path, "{project_name}", projectName, -1) + } else { + return nil, errors.New("projectName is required on ListTasksURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var pageQ string + if o.Page != nil { + pageQ = swag.FormatInt64(*o.Page) + } + if pageQ != "" { + qs.Set("page", pageQ) + } + + var pageSizeQ string + if o.PageSize != nil { + pageSizeQ = swag.FormatInt64(*o.PageSize) + } + if pageSizeQ != "" { + qs.Set("page_size", pageSizeQ) + } + + var qQ string + if o.Q != nil { + qQ = *o.Q + } + if qQ != "" { + qs.Set("q", qQ) + } + + var sortQ string + if o.Sort != nil { + sortQ = *o.Sort + } + if sortQ != "" { + qs.Set("sort", sortQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ListTasksURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ListTasksURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ListTasksURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ListTasksURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ListTasksURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ListTasksURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/preheat/manual_preheat.go b/src/server/v2.0/restapi/operations/preheat/manual_preheat.go new file mode 100644 index 000000000..fafd5ef9f --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/manual_preheat.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ManualPreheatHandlerFunc turns a function with the right signature into a manual preheat handler +type ManualPreheatHandlerFunc func(ManualPreheatParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ManualPreheatHandlerFunc) Handle(params ManualPreheatParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ManualPreheatHandler interface for that can handle valid manual preheat params +type ManualPreheatHandler interface { + Handle(ManualPreheatParams, interface{}) middleware.Responder +} + +// NewManualPreheat creates a new http.Handler for the manual preheat operation +func NewManualPreheat(ctx *middleware.Context, handler ManualPreheatHandler) *ManualPreheat { + return &ManualPreheat{Context: ctx, Handler: handler} +} + +/*ManualPreheat swagger:route POST /projects/{project_name}/preheat/policies/{preheat_policy_name} preheat manualPreheat + +Manual preheat + +Manual preheat + +*/ +type ManualPreheat struct { + Context *middleware.Context + Handler ManualPreheatHandler +} + +func (o *ManualPreheat) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewManualPreheatParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/preheat/manual_preheat_parameters.go b/src/server/v2.0/restapi/operations/preheat/manual_preheat_parameters.go new file mode 100644 index 000000000..ac0cc1c2c --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/manual_preheat_parameters.go @@ -0,0 +1,170 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewManualPreheatParams creates a new ManualPreheatParams object +// no default values defined in spec. +func NewManualPreheatParams() ManualPreheatParams { + + return ManualPreheatParams{} +} + +// ManualPreheatParams contains all the bound params for the manual preheat operation +// typically these are obtained from a http.Request +// +// swagger:parameters ManualPreheat +type ManualPreheatParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The policy schema info + Required: true + In: body + */ + Policy *models.PreheatPolicy + /*Preheat Policy Name + Required: true + In: path + */ + PreheatPolicyName string + /*The name of the project + Required: true + In: path + */ + ProjectName string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewManualPreheatParams() beforehand. +func (o *ManualPreheatParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.PreheatPolicy + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("policy", "body", "")) + } else { + res = append(res, errors.NewParseError("policy", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Policy = &body + } + } + } else { + res = append(res, errors.Required("policy", "body", "")) + } + rPreheatPolicyName, rhkPreheatPolicyName, _ := route.Params.GetOK("preheat_policy_name") + if err := o.bindPreheatPolicyName(rPreheatPolicyName, rhkPreheatPolicyName, route.Formats); err != nil { + res = append(res, err) + } + + rProjectName, rhkProjectName, _ := route.Params.GetOK("project_name") + if err := o.bindProjectName(rProjectName, rhkProjectName, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *ManualPreheatParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *ManualPreheatParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindPreheatPolicyName binds and validates parameter PreheatPolicyName from path. +func (o *ManualPreheatParams) bindPreheatPolicyName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.PreheatPolicyName = raw + + return nil +} + +// bindProjectName binds and validates parameter ProjectName from path. +func (o *ManualPreheatParams) bindProjectName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectName = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/preheat/manual_preheat_responses.go b/src/server/v2.0/restapi/operations/preheat/manual_preheat_responses.go new file mode 100644 index 000000000..947c6ed68 --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/manual_preheat_responses.go @@ -0,0 +1,412 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// ManualPreheatCreatedCode is the HTTP code returned for type ManualPreheatCreated +const ManualPreheatCreatedCode int = 201 + +/*ManualPreheatCreated Created + +swagger:response manualPreheatCreated +*/ +type ManualPreheatCreated struct { + /*The location of the resource + + */ + Location string `json:"Location"` + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewManualPreheatCreated creates ManualPreheatCreated with default headers values +func NewManualPreheatCreated() *ManualPreheatCreated { + + return &ManualPreheatCreated{} +} + +// WithLocation adds the location to the manual preheat created response +func (o *ManualPreheatCreated) WithLocation(location string) *ManualPreheatCreated { + o.Location = location + return o +} + +// SetLocation sets the location to the manual preheat created response +func (o *ManualPreheatCreated) SetLocation(location string) { + o.Location = location +} + +// WithXRequestID adds the xRequestId to the manual preheat created response +func (o *ManualPreheatCreated) WithXRequestID(xRequestID string) *ManualPreheatCreated { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the manual preheat created response +func (o *ManualPreheatCreated) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *ManualPreheatCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Location + + location := o.Location + if location != "" { + rw.Header().Set("Location", location) + } + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(201) +} + +// ManualPreheatBadRequestCode is the HTTP code returned for type ManualPreheatBadRequest +const ManualPreheatBadRequestCode int = 400 + +/*ManualPreheatBadRequest Bad request + +swagger:response manualPreheatBadRequest +*/ +type ManualPreheatBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewManualPreheatBadRequest creates ManualPreheatBadRequest with default headers values +func NewManualPreheatBadRequest() *ManualPreheatBadRequest { + + return &ManualPreheatBadRequest{} +} + +// WithXRequestID adds the xRequestId to the manual preheat bad request response +func (o *ManualPreheatBadRequest) WithXRequestID(xRequestID string) *ManualPreheatBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the manual preheat bad request response +func (o *ManualPreheatBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the manual preheat bad request response +func (o *ManualPreheatBadRequest) WithPayload(payload *models.Errors) *ManualPreheatBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the manual preheat bad request response +func (o *ManualPreheatBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ManualPreheatBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ManualPreheatUnauthorizedCode is the HTTP code returned for type ManualPreheatUnauthorized +const ManualPreheatUnauthorizedCode int = 401 + +/*ManualPreheatUnauthorized Unauthorized + +swagger:response manualPreheatUnauthorized +*/ +type ManualPreheatUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewManualPreheatUnauthorized creates ManualPreheatUnauthorized with default headers values +func NewManualPreheatUnauthorized() *ManualPreheatUnauthorized { + + return &ManualPreheatUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the manual preheat unauthorized response +func (o *ManualPreheatUnauthorized) WithXRequestID(xRequestID string) *ManualPreheatUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the manual preheat unauthorized response +func (o *ManualPreheatUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the manual preheat unauthorized response +func (o *ManualPreheatUnauthorized) WithPayload(payload *models.Errors) *ManualPreheatUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the manual preheat unauthorized response +func (o *ManualPreheatUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ManualPreheatUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ManualPreheatForbiddenCode is the HTTP code returned for type ManualPreheatForbidden +const ManualPreheatForbiddenCode int = 403 + +/*ManualPreheatForbidden Forbidden + +swagger:response manualPreheatForbidden +*/ +type ManualPreheatForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewManualPreheatForbidden creates ManualPreheatForbidden with default headers values +func NewManualPreheatForbidden() *ManualPreheatForbidden { + + return &ManualPreheatForbidden{} +} + +// WithXRequestID adds the xRequestId to the manual preheat forbidden response +func (o *ManualPreheatForbidden) WithXRequestID(xRequestID string) *ManualPreheatForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the manual preheat forbidden response +func (o *ManualPreheatForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the manual preheat forbidden response +func (o *ManualPreheatForbidden) WithPayload(payload *models.Errors) *ManualPreheatForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the manual preheat forbidden response +func (o *ManualPreheatForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ManualPreheatForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ManualPreheatNotFoundCode is the HTTP code returned for type ManualPreheatNotFound +const ManualPreheatNotFoundCode int = 404 + +/*ManualPreheatNotFound Not found + +swagger:response manualPreheatNotFound +*/ +type ManualPreheatNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewManualPreheatNotFound creates ManualPreheatNotFound with default headers values +func NewManualPreheatNotFound() *ManualPreheatNotFound { + + return &ManualPreheatNotFound{} +} + +// WithXRequestID adds the xRequestId to the manual preheat not found response +func (o *ManualPreheatNotFound) WithXRequestID(xRequestID string) *ManualPreheatNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the manual preheat not found response +func (o *ManualPreheatNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the manual preheat not found response +func (o *ManualPreheatNotFound) WithPayload(payload *models.Errors) *ManualPreheatNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the manual preheat not found response +func (o *ManualPreheatNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ManualPreheatNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ManualPreheatInternalServerErrorCode is the HTTP code returned for type ManualPreheatInternalServerError +const ManualPreheatInternalServerErrorCode int = 500 + +/*ManualPreheatInternalServerError Internal server error + +swagger:response manualPreheatInternalServerError +*/ +type ManualPreheatInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewManualPreheatInternalServerError creates ManualPreheatInternalServerError with default headers values +func NewManualPreheatInternalServerError() *ManualPreheatInternalServerError { + + return &ManualPreheatInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the manual preheat internal server error response +func (o *ManualPreheatInternalServerError) WithXRequestID(xRequestID string) *ManualPreheatInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the manual preheat internal server error response +func (o *ManualPreheatInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the manual preheat internal server error response +func (o *ManualPreheatInternalServerError) WithPayload(payload *models.Errors) *ManualPreheatInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the manual preheat internal server error response +func (o *ManualPreheatInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ManualPreheatInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/preheat/manual_preheat_urlbuilder.go b/src/server/v2.0/restapi/operations/preheat/manual_preheat_urlbuilder.go new file mode 100644 index 000000000..4b72ea4c2 --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/manual_preheat_urlbuilder.go @@ -0,0 +1,107 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// ManualPreheatURL generates an URL for the manual preheat operation +type ManualPreheatURL struct { + PreheatPolicyName string + ProjectName string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ManualPreheatURL) WithBasePath(bp string) *ManualPreheatURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ManualPreheatURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ManualPreheatURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name}/preheat/policies/{preheat_policy_name}" + + preheatPolicyName := o.PreheatPolicyName + if preheatPolicyName != "" { + _path = strings.Replace(_path, "{preheat_policy_name}", preheatPolicyName, -1) + } else { + return nil, errors.New("preheatPolicyName is required on ManualPreheatURL") + } + + projectName := o.ProjectName + if projectName != "" { + _path = strings.Replace(_path, "{project_name}", projectName, -1) + } else { + return nil, errors.New("projectName is required on ManualPreheatURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ManualPreheatURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ManualPreheatURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ManualPreheatURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ManualPreheatURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ManualPreheatURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ManualPreheatURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/preheat/ping_instances.go b/src/server/v2.0/restapi/operations/preheat/ping_instances.go new file mode 100644 index 000000000..6ab7378e0 --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/ping_instances.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// PingInstancesHandlerFunc turns a function with the right signature into a ping instances handler +type PingInstancesHandlerFunc func(PingInstancesParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn PingInstancesHandlerFunc) Handle(params PingInstancesParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// PingInstancesHandler interface for that can handle valid ping instances params +type PingInstancesHandler interface { + Handle(PingInstancesParams, interface{}) middleware.Responder +} + +// NewPingInstances creates a new http.Handler for the ping instances operation +func NewPingInstances(ctx *middleware.Context, handler PingInstancesHandler) *PingInstances { + return &PingInstances{Context: ctx, Handler: handler} +} + +/*PingInstances swagger:route POST /p2p/preheat/instances/ping preheat pingInstances + +Ping status of a instance. + +This endpoint checks status of a instance, the instance can be given by ID or Endpoint URL (together with credential) + + +*/ +type PingInstances struct { + Context *middleware.Context + Handler PingInstancesHandler +} + +func (o *PingInstances) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewPingInstancesParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/preheat/ping_instances_parameters.go b/src/server/v2.0/restapi/operations/preheat/ping_instances_parameters.go new file mode 100644 index 000000000..b4d7a8176 --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/ping_instances_parameters.go @@ -0,0 +1,120 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewPingInstancesParams creates a new PingInstancesParams object +// no default values defined in spec. +func NewPingInstancesParams() PingInstancesParams { + + return PingInstancesParams{} +} + +// PingInstancesParams contains all the bound params for the ping instances operation +// typically these are obtained from a http.Request +// +// swagger:parameters PingInstances +type PingInstancesParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The JSON object of instance. + Required: true + In: body + */ + Instance *models.Instance +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewPingInstancesParams() beforehand. +func (o *PingInstancesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Instance + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("instance", "body", "")) + } else { + res = append(res, errors.NewParseError("instance", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Instance = &body + } + } + } else { + res = append(res, errors.Required("instance", "body", "")) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *PingInstancesParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *PingInstancesParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} diff --git a/src/server/v2.0/restapi/operations/preheat/ping_instances_responses.go b/src/server/v2.0/restapi/operations/preheat/ping_instances_responses.go new file mode 100644 index 000000000..ec1cca7d5 --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/ping_instances_responses.go @@ -0,0 +1,282 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// PingInstancesOKCode is the HTTP code returned for type PingInstancesOK +const PingInstancesOKCode int = 200 + +/*PingInstancesOK Success + +swagger:response pingInstancesOK +*/ +type PingInstancesOK struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewPingInstancesOK creates PingInstancesOK with default headers values +func NewPingInstancesOK() *PingInstancesOK { + + return &PingInstancesOK{} +} + +// WithXRequestID adds the xRequestId to the ping instances o k response +func (o *PingInstancesOK) WithXRequestID(xRequestID string) *PingInstancesOK { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the ping instances o k response +func (o *PingInstancesOK) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *PingInstancesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// PingInstancesBadRequestCode is the HTTP code returned for type PingInstancesBadRequest +const PingInstancesBadRequestCode int = 400 + +/*PingInstancesBadRequest Bad request + +swagger:response pingInstancesBadRequest +*/ +type PingInstancesBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewPingInstancesBadRequest creates PingInstancesBadRequest with default headers values +func NewPingInstancesBadRequest() *PingInstancesBadRequest { + + return &PingInstancesBadRequest{} +} + +// WithXRequestID adds the xRequestId to the ping instances bad request response +func (o *PingInstancesBadRequest) WithXRequestID(xRequestID string) *PingInstancesBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the ping instances bad request response +func (o *PingInstancesBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the ping instances bad request response +func (o *PingInstancesBadRequest) WithPayload(payload *models.Errors) *PingInstancesBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the ping instances bad request response +func (o *PingInstancesBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PingInstancesBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PingInstancesUnauthorizedCode is the HTTP code returned for type PingInstancesUnauthorized +const PingInstancesUnauthorizedCode int = 401 + +/*PingInstancesUnauthorized Unauthorized + +swagger:response pingInstancesUnauthorized +*/ +type PingInstancesUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewPingInstancesUnauthorized creates PingInstancesUnauthorized with default headers values +func NewPingInstancesUnauthorized() *PingInstancesUnauthorized { + + return &PingInstancesUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the ping instances unauthorized response +func (o *PingInstancesUnauthorized) WithXRequestID(xRequestID string) *PingInstancesUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the ping instances unauthorized response +func (o *PingInstancesUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the ping instances unauthorized response +func (o *PingInstancesUnauthorized) WithPayload(payload *models.Errors) *PingInstancesUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the ping instances unauthorized response +func (o *PingInstancesUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PingInstancesUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PingInstancesNotFoundCode is the HTTP code returned for type PingInstancesNotFound +const PingInstancesNotFoundCode int = 404 + +/*PingInstancesNotFound Instance not found (when instance is provided by ID). + +swagger:response pingInstancesNotFound +*/ +type PingInstancesNotFound struct { +} + +// NewPingInstancesNotFound creates PingInstancesNotFound with default headers values +func NewPingInstancesNotFound() *PingInstancesNotFound { + + return &PingInstancesNotFound{} +} + +// WriteResponse to the client +func (o *PingInstancesNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(404) +} + +// PingInstancesInternalServerErrorCode is the HTTP code returned for type PingInstancesInternalServerError +const PingInstancesInternalServerErrorCode int = 500 + +/*PingInstancesInternalServerError Internal server error + +swagger:response pingInstancesInternalServerError +*/ +type PingInstancesInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewPingInstancesInternalServerError creates PingInstancesInternalServerError with default headers values +func NewPingInstancesInternalServerError() *PingInstancesInternalServerError { + + return &PingInstancesInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the ping instances internal server error response +func (o *PingInstancesInternalServerError) WithXRequestID(xRequestID string) *PingInstancesInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the ping instances internal server error response +func (o *PingInstancesInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the ping instances internal server error response +func (o *PingInstancesInternalServerError) WithPayload(payload *models.Errors) *PingInstancesInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the ping instances internal server error response +func (o *PingInstancesInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PingInstancesInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/preheat/ping_instances_urlbuilder.go b/src/server/v2.0/restapi/operations/preheat/ping_instances_urlbuilder.go new file mode 100644 index 000000000..408a5755a --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/ping_instances_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// PingInstancesURL generates an URL for the ping instances operation +type PingInstancesURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *PingInstancesURL) WithBasePath(bp string) *PingInstancesURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *PingInstancesURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *PingInstancesURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/p2p/preheat/instances/ping" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *PingInstancesURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *PingInstancesURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *PingInstancesURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on PingInstancesURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on PingInstancesURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *PingInstancesURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/preheat/stop_execution.go b/src/server/v2.0/restapi/operations/preheat/stop_execution.go new file mode 100644 index 000000000..9f0866158 --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/stop_execution.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// StopExecutionHandlerFunc turns a function with the right signature into a stop execution handler +type StopExecutionHandlerFunc func(StopExecutionParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn StopExecutionHandlerFunc) Handle(params StopExecutionParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// StopExecutionHandler interface for that can handle valid stop execution params +type StopExecutionHandler interface { + Handle(StopExecutionParams, interface{}) middleware.Responder +} + +// NewStopExecution creates a new http.Handler for the stop execution operation +func NewStopExecution(ctx *middleware.Context, handler StopExecutionHandler) *StopExecution { + return &StopExecution{Context: ctx, Handler: handler} +} + +/*StopExecution swagger:route PATCH /projects/{project_name}/preheat/policies/{preheat_policy_name}/executions/{execution_id} preheat stopExecution + +Stop a execution + +Stop a execution + +*/ +type StopExecution struct { + Context *middleware.Context + Handler StopExecutionHandler +} + +func (o *StopExecution) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewStopExecutionParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/preheat/stop_execution_parameters.go b/src/server/v2.0/restapi/operations/preheat/stop_execution_parameters.go new file mode 100644 index 000000000..1ac7633fc --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/stop_execution_parameters.go @@ -0,0 +1,200 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewStopExecutionParams creates a new StopExecutionParams object +// no default values defined in spec. +func NewStopExecutionParams() StopExecutionParams { + + return StopExecutionParams{} +} + +// StopExecutionParams contains all the bound params for the stop execution operation +// typically these are obtained from a http.Request +// +// swagger:parameters StopExecution +type StopExecutionParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The data of execution + Required: true + In: body + */ + Execution *models.Execution + /*Execution ID + Required: true + In: path + */ + ExecutionID int64 + /*Preheat Policy Name + Required: true + In: path + */ + PreheatPolicyName string + /*The name of the project + Required: true + In: path + */ + ProjectName string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewStopExecutionParams() beforehand. +func (o *StopExecutionParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Execution + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("execution", "body", "")) + } else { + res = append(res, errors.NewParseError("execution", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Execution = &body + } + } + } else { + res = append(res, errors.Required("execution", "body", "")) + } + rExecutionID, rhkExecutionID, _ := route.Params.GetOK("execution_id") + if err := o.bindExecutionID(rExecutionID, rhkExecutionID, route.Formats); err != nil { + res = append(res, err) + } + + rPreheatPolicyName, rhkPreheatPolicyName, _ := route.Params.GetOK("preheat_policy_name") + if err := o.bindPreheatPolicyName(rPreheatPolicyName, rhkPreheatPolicyName, route.Formats); err != nil { + res = append(res, err) + } + + rProjectName, rhkProjectName, _ := route.Params.GetOK("project_name") + if err := o.bindProjectName(rProjectName, rhkProjectName, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *StopExecutionParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *StopExecutionParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindExecutionID binds and validates parameter ExecutionID from path. +func (o *StopExecutionParams) bindExecutionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("execution_id", "path", "int64", raw) + } + o.ExecutionID = value + + return nil +} + +// bindPreheatPolicyName binds and validates parameter PreheatPolicyName from path. +func (o *StopExecutionParams) bindPreheatPolicyName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.PreheatPolicyName = raw + + return nil +} + +// bindProjectName binds and validates parameter ProjectName from path. +func (o *StopExecutionParams) bindProjectName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectName = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/preheat/stop_execution_responses.go b/src/server/v2.0/restapi/operations/preheat/stop_execution_responses.go new file mode 100644 index 000000000..cd400fbe9 --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/stop_execution_responses.go @@ -0,0 +1,390 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// StopExecutionOKCode is the HTTP code returned for type StopExecutionOK +const StopExecutionOKCode int = 200 + +/*StopExecutionOK Success + +swagger:response stopExecutionOK +*/ +type StopExecutionOK struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewStopExecutionOK creates StopExecutionOK with default headers values +func NewStopExecutionOK() *StopExecutionOK { + + return &StopExecutionOK{} +} + +// WithXRequestID adds the xRequestId to the stop execution o k response +func (o *StopExecutionOK) WithXRequestID(xRequestID string) *StopExecutionOK { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the stop execution o k response +func (o *StopExecutionOK) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *StopExecutionOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// StopExecutionBadRequestCode is the HTTP code returned for type StopExecutionBadRequest +const StopExecutionBadRequestCode int = 400 + +/*StopExecutionBadRequest Bad request + +swagger:response stopExecutionBadRequest +*/ +type StopExecutionBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewStopExecutionBadRequest creates StopExecutionBadRequest with default headers values +func NewStopExecutionBadRequest() *StopExecutionBadRequest { + + return &StopExecutionBadRequest{} +} + +// WithXRequestID adds the xRequestId to the stop execution bad request response +func (o *StopExecutionBadRequest) WithXRequestID(xRequestID string) *StopExecutionBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the stop execution bad request response +func (o *StopExecutionBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the stop execution bad request response +func (o *StopExecutionBadRequest) WithPayload(payload *models.Errors) *StopExecutionBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the stop execution bad request response +func (o *StopExecutionBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *StopExecutionBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// StopExecutionUnauthorizedCode is the HTTP code returned for type StopExecutionUnauthorized +const StopExecutionUnauthorizedCode int = 401 + +/*StopExecutionUnauthorized Unauthorized + +swagger:response stopExecutionUnauthorized +*/ +type StopExecutionUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewStopExecutionUnauthorized creates StopExecutionUnauthorized with default headers values +func NewStopExecutionUnauthorized() *StopExecutionUnauthorized { + + return &StopExecutionUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the stop execution unauthorized response +func (o *StopExecutionUnauthorized) WithXRequestID(xRequestID string) *StopExecutionUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the stop execution unauthorized response +func (o *StopExecutionUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the stop execution unauthorized response +func (o *StopExecutionUnauthorized) WithPayload(payload *models.Errors) *StopExecutionUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the stop execution unauthorized response +func (o *StopExecutionUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *StopExecutionUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// StopExecutionForbiddenCode is the HTTP code returned for type StopExecutionForbidden +const StopExecutionForbiddenCode int = 403 + +/*StopExecutionForbidden Forbidden + +swagger:response stopExecutionForbidden +*/ +type StopExecutionForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewStopExecutionForbidden creates StopExecutionForbidden with default headers values +func NewStopExecutionForbidden() *StopExecutionForbidden { + + return &StopExecutionForbidden{} +} + +// WithXRequestID adds the xRequestId to the stop execution forbidden response +func (o *StopExecutionForbidden) WithXRequestID(xRequestID string) *StopExecutionForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the stop execution forbidden response +func (o *StopExecutionForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the stop execution forbidden response +func (o *StopExecutionForbidden) WithPayload(payload *models.Errors) *StopExecutionForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the stop execution forbidden response +func (o *StopExecutionForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *StopExecutionForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// StopExecutionNotFoundCode is the HTTP code returned for type StopExecutionNotFound +const StopExecutionNotFoundCode int = 404 + +/*StopExecutionNotFound Not found + +swagger:response stopExecutionNotFound +*/ +type StopExecutionNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewStopExecutionNotFound creates StopExecutionNotFound with default headers values +func NewStopExecutionNotFound() *StopExecutionNotFound { + + return &StopExecutionNotFound{} +} + +// WithXRequestID adds the xRequestId to the stop execution not found response +func (o *StopExecutionNotFound) WithXRequestID(xRequestID string) *StopExecutionNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the stop execution not found response +func (o *StopExecutionNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the stop execution not found response +func (o *StopExecutionNotFound) WithPayload(payload *models.Errors) *StopExecutionNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the stop execution not found response +func (o *StopExecutionNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *StopExecutionNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// StopExecutionInternalServerErrorCode is the HTTP code returned for type StopExecutionInternalServerError +const StopExecutionInternalServerErrorCode int = 500 + +/*StopExecutionInternalServerError Internal server error + +swagger:response stopExecutionInternalServerError +*/ +type StopExecutionInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewStopExecutionInternalServerError creates StopExecutionInternalServerError with default headers values +func NewStopExecutionInternalServerError() *StopExecutionInternalServerError { + + return &StopExecutionInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the stop execution internal server error response +func (o *StopExecutionInternalServerError) WithXRequestID(xRequestID string) *StopExecutionInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the stop execution internal server error response +func (o *StopExecutionInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the stop execution internal server error response +func (o *StopExecutionInternalServerError) WithPayload(payload *models.Errors) *StopExecutionInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the stop execution internal server error response +func (o *StopExecutionInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *StopExecutionInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/preheat/stop_execution_urlbuilder.go b/src/server/v2.0/restapi/operations/preheat/stop_execution_urlbuilder.go new file mode 100644 index 000000000..accb7ef2d --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/stop_execution_urlbuilder.go @@ -0,0 +1,117 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// StopExecutionURL generates an URL for the stop execution operation +type StopExecutionURL struct { + ExecutionID int64 + PreheatPolicyName string + ProjectName string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *StopExecutionURL) WithBasePath(bp string) *StopExecutionURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *StopExecutionURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *StopExecutionURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name}/preheat/policies/{preheat_policy_name}/executions/{execution_id}" + + executionID := swag.FormatInt64(o.ExecutionID) + if executionID != "" { + _path = strings.Replace(_path, "{execution_id}", executionID, -1) + } else { + return nil, errors.New("executionId is required on StopExecutionURL") + } + + preheatPolicyName := o.PreheatPolicyName + if preheatPolicyName != "" { + _path = strings.Replace(_path, "{preheat_policy_name}", preheatPolicyName, -1) + } else { + return nil, errors.New("preheatPolicyName is required on StopExecutionURL") + } + + projectName := o.ProjectName + if projectName != "" { + _path = strings.Replace(_path, "{project_name}", projectName, -1) + } else { + return nil, errors.New("projectName is required on StopExecutionURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *StopExecutionURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *StopExecutionURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *StopExecutionURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on StopExecutionURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on StopExecutionURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *StopExecutionURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/preheat/update_instance.go b/src/server/v2.0/restapi/operations/preheat/update_instance.go new file mode 100644 index 000000000..a6b0b83c0 --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/update_instance.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// UpdateInstanceHandlerFunc turns a function with the right signature into a update instance handler +type UpdateInstanceHandlerFunc func(UpdateInstanceParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn UpdateInstanceHandlerFunc) Handle(params UpdateInstanceParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// UpdateInstanceHandler interface for that can handle valid update instance params +type UpdateInstanceHandler interface { + Handle(UpdateInstanceParams, interface{}) middleware.Responder +} + +// NewUpdateInstance creates a new http.Handler for the update instance operation +func NewUpdateInstance(ctx *middleware.Context, handler UpdateInstanceHandler) *UpdateInstance { + return &UpdateInstance{Context: ctx, Handler: handler} +} + +/*UpdateInstance swagger:route PUT /p2p/preheat/instances/{preheat_instance_name} preheat updateInstance + +Update the specified P2P provider instance + +Update the specified P2P provider instance + +*/ +type UpdateInstance struct { + Context *middleware.Context + Handler UpdateInstanceHandler +} + +func (o *UpdateInstance) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewUpdateInstanceParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/preheat/update_instance_parameters.go b/src/server/v2.0/restapi/operations/preheat/update_instance_parameters.go new file mode 100644 index 000000000..e024abd58 --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/update_instance_parameters.go @@ -0,0 +1,145 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewUpdateInstanceParams creates a new UpdateInstanceParams object +// no default values defined in spec. +func NewUpdateInstanceParams() UpdateInstanceParams { + + return UpdateInstanceParams{} +} + +// UpdateInstanceParams contains all the bound params for the update instance operation +// typically these are obtained from a http.Request +// +// swagger:parameters UpdateInstance +type UpdateInstanceParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The instance to update + Required: true + In: body + */ + Instance *models.Instance + /*Instance Name + Required: true + In: path + */ + PreheatInstanceName string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewUpdateInstanceParams() beforehand. +func (o *UpdateInstanceParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Instance + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("instance", "body", "")) + } else { + res = append(res, errors.NewParseError("instance", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Instance = &body + } + } + } else { + res = append(res, errors.Required("instance", "body", "")) + } + rPreheatInstanceName, rhkPreheatInstanceName, _ := route.Params.GetOK("preheat_instance_name") + if err := o.bindPreheatInstanceName(rPreheatInstanceName, rhkPreheatInstanceName, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *UpdateInstanceParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *UpdateInstanceParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindPreheatInstanceName binds and validates parameter PreheatInstanceName from path. +func (o *UpdateInstanceParams) bindPreheatInstanceName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.PreheatInstanceName = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/preheat/update_instance_responses.go b/src/server/v2.0/restapi/operations/preheat/update_instance_responses.go new file mode 100644 index 000000000..ae3634ca2 --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/update_instance_responses.go @@ -0,0 +1,390 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// UpdateInstanceOKCode is the HTTP code returned for type UpdateInstanceOK +const UpdateInstanceOKCode int = 200 + +/*UpdateInstanceOK Success + +swagger:response updateInstanceOK +*/ +type UpdateInstanceOK struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewUpdateInstanceOK creates UpdateInstanceOK with default headers values +func NewUpdateInstanceOK() *UpdateInstanceOK { + + return &UpdateInstanceOK{} +} + +// WithXRequestID adds the xRequestId to the update instance o k response +func (o *UpdateInstanceOK) WithXRequestID(xRequestID string) *UpdateInstanceOK { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update instance o k response +func (o *UpdateInstanceOK) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *UpdateInstanceOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// UpdateInstanceBadRequestCode is the HTTP code returned for type UpdateInstanceBadRequest +const UpdateInstanceBadRequestCode int = 400 + +/*UpdateInstanceBadRequest Bad request + +swagger:response updateInstanceBadRequest +*/ +type UpdateInstanceBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateInstanceBadRequest creates UpdateInstanceBadRequest with default headers values +func NewUpdateInstanceBadRequest() *UpdateInstanceBadRequest { + + return &UpdateInstanceBadRequest{} +} + +// WithXRequestID adds the xRequestId to the update instance bad request response +func (o *UpdateInstanceBadRequest) WithXRequestID(xRequestID string) *UpdateInstanceBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update instance bad request response +func (o *UpdateInstanceBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update instance bad request response +func (o *UpdateInstanceBadRequest) WithPayload(payload *models.Errors) *UpdateInstanceBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update instance bad request response +func (o *UpdateInstanceBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateInstanceBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateInstanceUnauthorizedCode is the HTTP code returned for type UpdateInstanceUnauthorized +const UpdateInstanceUnauthorizedCode int = 401 + +/*UpdateInstanceUnauthorized Unauthorized + +swagger:response updateInstanceUnauthorized +*/ +type UpdateInstanceUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateInstanceUnauthorized creates UpdateInstanceUnauthorized with default headers values +func NewUpdateInstanceUnauthorized() *UpdateInstanceUnauthorized { + + return &UpdateInstanceUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the update instance unauthorized response +func (o *UpdateInstanceUnauthorized) WithXRequestID(xRequestID string) *UpdateInstanceUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update instance unauthorized response +func (o *UpdateInstanceUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update instance unauthorized response +func (o *UpdateInstanceUnauthorized) WithPayload(payload *models.Errors) *UpdateInstanceUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update instance unauthorized response +func (o *UpdateInstanceUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateInstanceUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateInstanceForbiddenCode is the HTTP code returned for type UpdateInstanceForbidden +const UpdateInstanceForbiddenCode int = 403 + +/*UpdateInstanceForbidden Forbidden + +swagger:response updateInstanceForbidden +*/ +type UpdateInstanceForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateInstanceForbidden creates UpdateInstanceForbidden with default headers values +func NewUpdateInstanceForbidden() *UpdateInstanceForbidden { + + return &UpdateInstanceForbidden{} +} + +// WithXRequestID adds the xRequestId to the update instance forbidden response +func (o *UpdateInstanceForbidden) WithXRequestID(xRequestID string) *UpdateInstanceForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update instance forbidden response +func (o *UpdateInstanceForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update instance forbidden response +func (o *UpdateInstanceForbidden) WithPayload(payload *models.Errors) *UpdateInstanceForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update instance forbidden response +func (o *UpdateInstanceForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateInstanceForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateInstanceNotFoundCode is the HTTP code returned for type UpdateInstanceNotFound +const UpdateInstanceNotFoundCode int = 404 + +/*UpdateInstanceNotFound Not found + +swagger:response updateInstanceNotFound +*/ +type UpdateInstanceNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateInstanceNotFound creates UpdateInstanceNotFound with default headers values +func NewUpdateInstanceNotFound() *UpdateInstanceNotFound { + + return &UpdateInstanceNotFound{} +} + +// WithXRequestID adds the xRequestId to the update instance not found response +func (o *UpdateInstanceNotFound) WithXRequestID(xRequestID string) *UpdateInstanceNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update instance not found response +func (o *UpdateInstanceNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update instance not found response +func (o *UpdateInstanceNotFound) WithPayload(payload *models.Errors) *UpdateInstanceNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update instance not found response +func (o *UpdateInstanceNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateInstanceNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateInstanceInternalServerErrorCode is the HTTP code returned for type UpdateInstanceInternalServerError +const UpdateInstanceInternalServerErrorCode int = 500 + +/*UpdateInstanceInternalServerError Internal server error + +swagger:response updateInstanceInternalServerError +*/ +type UpdateInstanceInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateInstanceInternalServerError creates UpdateInstanceInternalServerError with default headers values +func NewUpdateInstanceInternalServerError() *UpdateInstanceInternalServerError { + + return &UpdateInstanceInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the update instance internal server error response +func (o *UpdateInstanceInternalServerError) WithXRequestID(xRequestID string) *UpdateInstanceInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update instance internal server error response +func (o *UpdateInstanceInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update instance internal server error response +func (o *UpdateInstanceInternalServerError) WithPayload(payload *models.Errors) *UpdateInstanceInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update instance internal server error response +func (o *UpdateInstanceInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateInstanceInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/preheat/update_instance_urlbuilder.go b/src/server/v2.0/restapi/operations/preheat/update_instance_urlbuilder.go new file mode 100644 index 000000000..4ba0ca60a --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/update_instance_urlbuilder.go @@ -0,0 +1,99 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// UpdateInstanceURL generates an URL for the update instance operation +type UpdateInstanceURL struct { + PreheatInstanceName string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdateInstanceURL) WithBasePath(bp string) *UpdateInstanceURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdateInstanceURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *UpdateInstanceURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/p2p/preheat/instances/{preheat_instance_name}" + + preheatInstanceName := o.PreheatInstanceName + if preheatInstanceName != "" { + _path = strings.Replace(_path, "{preheat_instance_name}", preheatInstanceName, -1) + } else { + return nil, errors.New("preheatInstanceName is required on UpdateInstanceURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *UpdateInstanceURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *UpdateInstanceURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *UpdateInstanceURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on UpdateInstanceURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on UpdateInstanceURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *UpdateInstanceURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/preheat/update_policy.go b/src/server/v2.0/restapi/operations/preheat/update_policy.go new file mode 100644 index 000000000..29a2ff365 --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/update_policy.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// UpdatePolicyHandlerFunc turns a function with the right signature into a update policy handler +type UpdatePolicyHandlerFunc func(UpdatePolicyParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn UpdatePolicyHandlerFunc) Handle(params UpdatePolicyParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// UpdatePolicyHandler interface for that can handle valid update policy params +type UpdatePolicyHandler interface { + Handle(UpdatePolicyParams, interface{}) middleware.Responder +} + +// NewUpdatePolicy creates a new http.Handler for the update policy operation +func NewUpdatePolicy(ctx *middleware.Context, handler UpdatePolicyHandler) *UpdatePolicy { + return &UpdatePolicy{Context: ctx, Handler: handler} +} + +/*UpdatePolicy swagger:route PUT /projects/{project_name}/preheat/policies/{preheat_policy_name} preheat updatePolicy + +Update preheat policy + +Update preheat policy + +*/ +type UpdatePolicy struct { + Context *middleware.Context + Handler UpdatePolicyHandler +} + +func (o *UpdatePolicy) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewUpdatePolicyParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/preheat/update_policy_parameters.go b/src/server/v2.0/restapi/operations/preheat/update_policy_parameters.go new file mode 100644 index 000000000..5baa151e0 --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/update_policy_parameters.go @@ -0,0 +1,170 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewUpdatePolicyParams creates a new UpdatePolicyParams object +// no default values defined in spec. +func NewUpdatePolicyParams() UpdatePolicyParams { + + return UpdatePolicyParams{} +} + +// UpdatePolicyParams contains all the bound params for the update policy operation +// typically these are obtained from a http.Request +// +// swagger:parameters UpdatePolicy +type UpdatePolicyParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The policy schema info + Required: true + In: body + */ + Policy *models.PreheatPolicy + /*Preheat Policy Name + Required: true + In: path + */ + PreheatPolicyName string + /*The name of the project + Required: true + In: path + */ + ProjectName string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewUpdatePolicyParams() beforehand. +func (o *UpdatePolicyParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.PreheatPolicy + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("policy", "body", "")) + } else { + res = append(res, errors.NewParseError("policy", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Policy = &body + } + } + } else { + res = append(res, errors.Required("policy", "body", "")) + } + rPreheatPolicyName, rhkPreheatPolicyName, _ := route.Params.GetOK("preheat_policy_name") + if err := o.bindPreheatPolicyName(rPreheatPolicyName, rhkPreheatPolicyName, route.Formats); err != nil { + res = append(res, err) + } + + rProjectName, rhkProjectName, _ := route.Params.GetOK("project_name") + if err := o.bindProjectName(rProjectName, rhkProjectName, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *UpdatePolicyParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *UpdatePolicyParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindPreheatPolicyName binds and validates parameter PreheatPolicyName from path. +func (o *UpdatePolicyParams) bindPreheatPolicyName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.PreheatPolicyName = raw + + return nil +} + +// bindProjectName binds and validates parameter ProjectName from path. +func (o *UpdatePolicyParams) bindProjectName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectName = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/preheat/update_policy_responses.go b/src/server/v2.0/restapi/operations/preheat/update_policy_responses.go new file mode 100644 index 000000000..940d457dd --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/update_policy_responses.go @@ -0,0 +1,456 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// UpdatePolicyOKCode is the HTTP code returned for type UpdatePolicyOK +const UpdatePolicyOKCode int = 200 + +/*UpdatePolicyOK Success + +swagger:response updatePolicyOK +*/ +type UpdatePolicyOK struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewUpdatePolicyOK creates UpdatePolicyOK with default headers values +func NewUpdatePolicyOK() *UpdatePolicyOK { + + return &UpdatePolicyOK{} +} + +// WithXRequestID adds the xRequestId to the update policy o k response +func (o *UpdatePolicyOK) WithXRequestID(xRequestID string) *UpdatePolicyOK { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update policy o k response +func (o *UpdatePolicyOK) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *UpdatePolicyOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// UpdatePolicyBadRequestCode is the HTTP code returned for type UpdatePolicyBadRequest +const UpdatePolicyBadRequestCode int = 400 + +/*UpdatePolicyBadRequest Bad request + +swagger:response updatePolicyBadRequest +*/ +type UpdatePolicyBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdatePolicyBadRequest creates UpdatePolicyBadRequest with default headers values +func NewUpdatePolicyBadRequest() *UpdatePolicyBadRequest { + + return &UpdatePolicyBadRequest{} +} + +// WithXRequestID adds the xRequestId to the update policy bad request response +func (o *UpdatePolicyBadRequest) WithXRequestID(xRequestID string) *UpdatePolicyBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update policy bad request response +func (o *UpdatePolicyBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update policy bad request response +func (o *UpdatePolicyBadRequest) WithPayload(payload *models.Errors) *UpdatePolicyBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update policy bad request response +func (o *UpdatePolicyBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdatePolicyBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdatePolicyUnauthorizedCode is the HTTP code returned for type UpdatePolicyUnauthorized +const UpdatePolicyUnauthorizedCode int = 401 + +/*UpdatePolicyUnauthorized Unauthorized + +swagger:response updatePolicyUnauthorized +*/ +type UpdatePolicyUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdatePolicyUnauthorized creates UpdatePolicyUnauthorized with default headers values +func NewUpdatePolicyUnauthorized() *UpdatePolicyUnauthorized { + + return &UpdatePolicyUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the update policy unauthorized response +func (o *UpdatePolicyUnauthorized) WithXRequestID(xRequestID string) *UpdatePolicyUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update policy unauthorized response +func (o *UpdatePolicyUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update policy unauthorized response +func (o *UpdatePolicyUnauthorized) WithPayload(payload *models.Errors) *UpdatePolicyUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update policy unauthorized response +func (o *UpdatePolicyUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdatePolicyUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdatePolicyForbiddenCode is the HTTP code returned for type UpdatePolicyForbidden +const UpdatePolicyForbiddenCode int = 403 + +/*UpdatePolicyForbidden Forbidden + +swagger:response updatePolicyForbidden +*/ +type UpdatePolicyForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdatePolicyForbidden creates UpdatePolicyForbidden with default headers values +func NewUpdatePolicyForbidden() *UpdatePolicyForbidden { + + return &UpdatePolicyForbidden{} +} + +// WithXRequestID adds the xRequestId to the update policy forbidden response +func (o *UpdatePolicyForbidden) WithXRequestID(xRequestID string) *UpdatePolicyForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update policy forbidden response +func (o *UpdatePolicyForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update policy forbidden response +func (o *UpdatePolicyForbidden) WithPayload(payload *models.Errors) *UpdatePolicyForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update policy forbidden response +func (o *UpdatePolicyForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdatePolicyForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdatePolicyNotFoundCode is the HTTP code returned for type UpdatePolicyNotFound +const UpdatePolicyNotFoundCode int = 404 + +/*UpdatePolicyNotFound Not found + +swagger:response updatePolicyNotFound +*/ +type UpdatePolicyNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdatePolicyNotFound creates UpdatePolicyNotFound with default headers values +func NewUpdatePolicyNotFound() *UpdatePolicyNotFound { + + return &UpdatePolicyNotFound{} +} + +// WithXRequestID adds the xRequestId to the update policy not found response +func (o *UpdatePolicyNotFound) WithXRequestID(xRequestID string) *UpdatePolicyNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update policy not found response +func (o *UpdatePolicyNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update policy not found response +func (o *UpdatePolicyNotFound) WithPayload(payload *models.Errors) *UpdatePolicyNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update policy not found response +func (o *UpdatePolicyNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdatePolicyNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdatePolicyConflictCode is the HTTP code returned for type UpdatePolicyConflict +const UpdatePolicyConflictCode int = 409 + +/*UpdatePolicyConflict Conflict + +swagger:response updatePolicyConflict +*/ +type UpdatePolicyConflict struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdatePolicyConflict creates UpdatePolicyConflict with default headers values +func NewUpdatePolicyConflict() *UpdatePolicyConflict { + + return &UpdatePolicyConflict{} +} + +// WithXRequestID adds the xRequestId to the update policy conflict response +func (o *UpdatePolicyConflict) WithXRequestID(xRequestID string) *UpdatePolicyConflict { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update policy conflict response +func (o *UpdatePolicyConflict) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update policy conflict response +func (o *UpdatePolicyConflict) WithPayload(payload *models.Errors) *UpdatePolicyConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update policy conflict response +func (o *UpdatePolicyConflict) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdatePolicyConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdatePolicyInternalServerErrorCode is the HTTP code returned for type UpdatePolicyInternalServerError +const UpdatePolicyInternalServerErrorCode int = 500 + +/*UpdatePolicyInternalServerError Internal server error + +swagger:response updatePolicyInternalServerError +*/ +type UpdatePolicyInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdatePolicyInternalServerError creates UpdatePolicyInternalServerError with default headers values +func NewUpdatePolicyInternalServerError() *UpdatePolicyInternalServerError { + + return &UpdatePolicyInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the update policy internal server error response +func (o *UpdatePolicyInternalServerError) WithXRequestID(xRequestID string) *UpdatePolicyInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update policy internal server error response +func (o *UpdatePolicyInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update policy internal server error response +func (o *UpdatePolicyInternalServerError) WithPayload(payload *models.Errors) *UpdatePolicyInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update policy internal server error response +func (o *UpdatePolicyInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdatePolicyInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/preheat/update_policy_urlbuilder.go b/src/server/v2.0/restapi/operations/preheat/update_policy_urlbuilder.go new file mode 100644 index 000000000..220ba345a --- /dev/null +++ b/src/server/v2.0/restapi/operations/preheat/update_policy_urlbuilder.go @@ -0,0 +1,107 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package preheat + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// UpdatePolicyURL generates an URL for the update policy operation +type UpdatePolicyURL struct { + PreheatPolicyName string + ProjectName string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdatePolicyURL) WithBasePath(bp string) *UpdatePolicyURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdatePolicyURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *UpdatePolicyURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name}/preheat/policies/{preheat_policy_name}" + + preheatPolicyName := o.PreheatPolicyName + if preheatPolicyName != "" { + _path = strings.Replace(_path, "{preheat_policy_name}", preheatPolicyName, -1) + } else { + return nil, errors.New("preheatPolicyName is required on UpdatePolicyURL") + } + + projectName := o.ProjectName + if projectName != "" { + _path = strings.Replace(_path, "{project_name}", projectName, -1) + } else { + return nil, errors.New("projectName is required on UpdatePolicyURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *UpdatePolicyURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *UpdatePolicyURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *UpdatePolicyURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on UpdatePolicyURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on UpdatePolicyURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *UpdatePolicyURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/project/create_project.go b/src/server/v2.0/restapi/operations/project/create_project.go new file mode 100644 index 000000000..9f08d2847 --- /dev/null +++ b/src/server/v2.0/restapi/operations/project/create_project.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateProjectHandlerFunc turns a function with the right signature into a create project handler +type CreateProjectHandlerFunc func(CreateProjectParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateProjectHandlerFunc) Handle(params CreateProjectParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateProjectHandler interface for that can handle valid create project params +type CreateProjectHandler interface { + Handle(CreateProjectParams, interface{}) middleware.Responder +} + +// NewCreateProject creates a new http.Handler for the create project operation +func NewCreateProject(ctx *middleware.Context, handler CreateProjectHandler) *CreateProject { + return &CreateProject{Context: ctx, Handler: handler} +} + +/*CreateProject swagger:route POST /projects project createProject + +Create a new project. + +This endpoint is for user to create a new project. + +*/ +type CreateProject struct { + Context *middleware.Context + Handler CreateProjectHandler +} + +func (o *CreateProject) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewCreateProjectParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/project/create_project_parameters.go b/src/server/v2.0/restapi/operations/project/create_project_parameters.go new file mode 100644 index 000000000..dae3169f6 --- /dev/null +++ b/src/server/v2.0/restapi/operations/project/create_project_parameters.go @@ -0,0 +1,161 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewCreateProjectParams creates a new CreateProjectParams object +// with the default values initialized. +func NewCreateProjectParams() CreateProjectParams { + + var ( + // initialize parameters with default values + + xResourceNameInLocationDefault = bool(false) + ) + + return CreateProjectParams{ + XResourceNameInLocation: &xResourceNameInLocationDefault, + } +} + +// CreateProjectParams contains all the bound params for the create project operation +// typically these are obtained from a http.Request +// +// swagger:parameters createProject +type CreateProjectParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The flag to indicate whether to return the name of the resource in Location. When X-Resource-Name-In-Location is true, the Location will return the name of the resource. + In: header + Default: false + */ + XResourceNameInLocation *bool + /*New created project. + Required: true + In: body + */ + Project *models.ProjectReq +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateProjectParams() beforehand. +func (o *CreateProjectParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if err := o.bindXResourceNameInLocation(r.Header[http.CanonicalHeaderKey("X-Resource-Name-In-Location")], true, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.ProjectReq + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("project", "body", "")) + } else { + res = append(res, errors.NewParseError("project", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Project = &body + } + } + } else { + res = append(res, errors.Required("project", "body", "")) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *CreateProjectParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *CreateProjectParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindXResourceNameInLocation binds and validates parameter XResourceNameInLocation from header. +func (o *CreateProjectParams) bindXResourceNameInLocation(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateProjectParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("X-Resource-Name-In-Location", "header", "bool", raw) + } + o.XResourceNameInLocation = &value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/project/create_project_responses.go b/src/server/v2.0/restapi/operations/project/create_project_responses.go new file mode 100644 index 000000000..d0b5addbc --- /dev/null +++ b/src/server/v2.0/restapi/operations/project/create_project_responses.go @@ -0,0 +1,346 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// CreateProjectCreatedCode is the HTTP code returned for type CreateProjectCreated +const CreateProjectCreatedCode int = 201 + +/*CreateProjectCreated Created + +swagger:response createProjectCreated +*/ +type CreateProjectCreated struct { + /*The location of the resource + + */ + Location string `json:"Location"` + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewCreateProjectCreated creates CreateProjectCreated with default headers values +func NewCreateProjectCreated() *CreateProjectCreated { + + return &CreateProjectCreated{} +} + +// WithLocation adds the location to the create project created response +func (o *CreateProjectCreated) WithLocation(location string) *CreateProjectCreated { + o.Location = location + return o +} + +// SetLocation sets the location to the create project created response +func (o *CreateProjectCreated) SetLocation(location string) { + o.Location = location +} + +// WithXRequestID adds the xRequestId to the create project created response +func (o *CreateProjectCreated) WithXRequestID(xRequestID string) *CreateProjectCreated { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create project created response +func (o *CreateProjectCreated) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *CreateProjectCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Location + + location := o.Location + if location != "" { + rw.Header().Set("Location", location) + } + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(201) +} + +// CreateProjectBadRequestCode is the HTTP code returned for type CreateProjectBadRequest +const CreateProjectBadRequestCode int = 400 + +/*CreateProjectBadRequest Bad request + +swagger:response createProjectBadRequest +*/ +type CreateProjectBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateProjectBadRequest creates CreateProjectBadRequest with default headers values +func NewCreateProjectBadRequest() *CreateProjectBadRequest { + + return &CreateProjectBadRequest{} +} + +// WithXRequestID adds the xRequestId to the create project bad request response +func (o *CreateProjectBadRequest) WithXRequestID(xRequestID string) *CreateProjectBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create project bad request response +func (o *CreateProjectBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create project bad request response +func (o *CreateProjectBadRequest) WithPayload(payload *models.Errors) *CreateProjectBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create project bad request response +func (o *CreateProjectBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateProjectBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateProjectUnauthorizedCode is the HTTP code returned for type CreateProjectUnauthorized +const CreateProjectUnauthorizedCode int = 401 + +/*CreateProjectUnauthorized Unauthorized + +swagger:response createProjectUnauthorized +*/ +type CreateProjectUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateProjectUnauthorized creates CreateProjectUnauthorized with default headers values +func NewCreateProjectUnauthorized() *CreateProjectUnauthorized { + + return &CreateProjectUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the create project unauthorized response +func (o *CreateProjectUnauthorized) WithXRequestID(xRequestID string) *CreateProjectUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create project unauthorized response +func (o *CreateProjectUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create project unauthorized response +func (o *CreateProjectUnauthorized) WithPayload(payload *models.Errors) *CreateProjectUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create project unauthorized response +func (o *CreateProjectUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateProjectUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateProjectConflictCode is the HTTP code returned for type CreateProjectConflict +const CreateProjectConflictCode int = 409 + +/*CreateProjectConflict Conflict + +swagger:response createProjectConflict +*/ +type CreateProjectConflict struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateProjectConflict creates CreateProjectConflict with default headers values +func NewCreateProjectConflict() *CreateProjectConflict { + + return &CreateProjectConflict{} +} + +// WithXRequestID adds the xRequestId to the create project conflict response +func (o *CreateProjectConflict) WithXRequestID(xRequestID string) *CreateProjectConflict { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create project conflict response +func (o *CreateProjectConflict) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create project conflict response +func (o *CreateProjectConflict) WithPayload(payload *models.Errors) *CreateProjectConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create project conflict response +func (o *CreateProjectConflict) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateProjectConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateProjectInternalServerErrorCode is the HTTP code returned for type CreateProjectInternalServerError +const CreateProjectInternalServerErrorCode int = 500 + +/*CreateProjectInternalServerError Internal server error + +swagger:response createProjectInternalServerError +*/ +type CreateProjectInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateProjectInternalServerError creates CreateProjectInternalServerError with default headers values +func NewCreateProjectInternalServerError() *CreateProjectInternalServerError { + + return &CreateProjectInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the create project internal server error response +func (o *CreateProjectInternalServerError) WithXRequestID(xRequestID string) *CreateProjectInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create project internal server error response +func (o *CreateProjectInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create project internal server error response +func (o *CreateProjectInternalServerError) WithPayload(payload *models.Errors) *CreateProjectInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create project internal server error response +func (o *CreateProjectInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateProjectInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/project/create_project_urlbuilder.go b/src/server/v2.0/restapi/operations/project/create_project_urlbuilder.go new file mode 100644 index 000000000..2a819d2fb --- /dev/null +++ b/src/server/v2.0/restapi/operations/project/create_project_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// CreateProjectURL generates an URL for the create project operation +type CreateProjectURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateProjectURL) WithBasePath(bp string) *CreateProjectURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateProjectURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateProjectURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateProjectURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateProjectURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateProjectURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateProjectURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateProjectURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateProjectURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/project/delete_project.go b/src/server/v2.0/restapi/operations/project/delete_project.go new file mode 100644 index 000000000..3a2a73887 --- /dev/null +++ b/src/server/v2.0/restapi/operations/project/delete_project.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteProjectHandlerFunc turns a function with the right signature into a delete project handler +type DeleteProjectHandlerFunc func(DeleteProjectParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteProjectHandlerFunc) Handle(params DeleteProjectParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteProjectHandler interface for that can handle valid delete project params +type DeleteProjectHandler interface { + Handle(DeleteProjectParams, interface{}) middleware.Responder +} + +// NewDeleteProject creates a new http.Handler for the delete project operation +func NewDeleteProject(ctx *middleware.Context, handler DeleteProjectHandler) *DeleteProject { + return &DeleteProject{Context: ctx, Handler: handler} +} + +/*DeleteProject swagger:route DELETE /projects/{project_name_or_id} project deleteProject + +Delete project by projectID + +This endpoint is aimed to delete project by project ID. + +*/ +type DeleteProject struct { + Context *middleware.Context + Handler DeleteProjectHandler +} + +func (o *DeleteProject) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewDeleteProjectParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/project/delete_project_parameters.go b/src/server/v2.0/restapi/operations/project/delete_project_parameters.go new file mode 100644 index 000000000..632ab6517 --- /dev/null +++ b/src/server/v2.0/restapi/operations/project/delete_project_parameters.go @@ -0,0 +1,155 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewDeleteProjectParams creates a new DeleteProjectParams object +// with the default values initialized. +func NewDeleteProjectParams() DeleteProjectParams { + + var ( + // initialize parameters with default values + + xIsResourceNameDefault = bool(false) + ) + + return DeleteProjectParams{ + XIsResourceName: &xIsResourceNameDefault, + } +} + +// DeleteProjectParams contains all the bound params for the delete project operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteProject +type DeleteProjectParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name. + In: header + Default: false + */ + XIsResourceName *bool + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The name or id of the project + Required: true + In: path + */ + ProjectNameOrID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteProjectParams() beforehand. +func (o *DeleteProjectParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXIsResourceName(r.Header[http.CanonicalHeaderKey("X-Is-Resource-Name")], true, route.Formats); err != nil { + res = append(res, err) + } + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rProjectNameOrID, rhkProjectNameOrID, _ := route.Params.GetOK("project_name_or_id") + if err := o.bindProjectNameOrID(rProjectNameOrID, rhkProjectNameOrID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXIsResourceName binds and validates parameter XIsResourceName from header. +func (o *DeleteProjectParams) bindXIsResourceName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteProjectParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("X-Is-Resource-Name", "header", "bool", raw) + } + o.XIsResourceName = &value + + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *DeleteProjectParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *DeleteProjectParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindProjectNameOrID binds and validates parameter ProjectNameOrID from path. +func (o *DeleteProjectParams) bindProjectNameOrID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectNameOrID = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/project/delete_project_responses.go b/src/server/v2.0/restapi/operations/project/delete_project_responses.go new file mode 100644 index 000000000..b33ac84d0 --- /dev/null +++ b/src/server/v2.0/restapi/operations/project/delete_project_responses.go @@ -0,0 +1,390 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// DeleteProjectOKCode is the HTTP code returned for type DeleteProjectOK +const DeleteProjectOKCode int = 200 + +/*DeleteProjectOK Success + +swagger:response deleteProjectOK +*/ +type DeleteProjectOK struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewDeleteProjectOK creates DeleteProjectOK with default headers values +func NewDeleteProjectOK() *DeleteProjectOK { + + return &DeleteProjectOK{} +} + +// WithXRequestID adds the xRequestId to the delete project o k response +func (o *DeleteProjectOK) WithXRequestID(xRequestID string) *DeleteProjectOK { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete project o k response +func (o *DeleteProjectOK) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *DeleteProjectOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// DeleteProjectBadRequestCode is the HTTP code returned for type DeleteProjectBadRequest +const DeleteProjectBadRequestCode int = 400 + +/*DeleteProjectBadRequest Bad request + +swagger:response deleteProjectBadRequest +*/ +type DeleteProjectBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteProjectBadRequest creates DeleteProjectBadRequest with default headers values +func NewDeleteProjectBadRequest() *DeleteProjectBadRequest { + + return &DeleteProjectBadRequest{} +} + +// WithXRequestID adds the xRequestId to the delete project bad request response +func (o *DeleteProjectBadRequest) WithXRequestID(xRequestID string) *DeleteProjectBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete project bad request response +func (o *DeleteProjectBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete project bad request response +func (o *DeleteProjectBadRequest) WithPayload(payload *models.Errors) *DeleteProjectBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete project bad request response +func (o *DeleteProjectBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteProjectBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteProjectForbiddenCode is the HTTP code returned for type DeleteProjectForbidden +const DeleteProjectForbiddenCode int = 403 + +/*DeleteProjectForbidden Forbidden + +swagger:response deleteProjectForbidden +*/ +type DeleteProjectForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteProjectForbidden creates DeleteProjectForbidden with default headers values +func NewDeleteProjectForbidden() *DeleteProjectForbidden { + + return &DeleteProjectForbidden{} +} + +// WithXRequestID adds the xRequestId to the delete project forbidden response +func (o *DeleteProjectForbidden) WithXRequestID(xRequestID string) *DeleteProjectForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete project forbidden response +func (o *DeleteProjectForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete project forbidden response +func (o *DeleteProjectForbidden) WithPayload(payload *models.Errors) *DeleteProjectForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete project forbidden response +func (o *DeleteProjectForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteProjectForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteProjectNotFoundCode is the HTTP code returned for type DeleteProjectNotFound +const DeleteProjectNotFoundCode int = 404 + +/*DeleteProjectNotFound Not found + +swagger:response deleteProjectNotFound +*/ +type DeleteProjectNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteProjectNotFound creates DeleteProjectNotFound with default headers values +func NewDeleteProjectNotFound() *DeleteProjectNotFound { + + return &DeleteProjectNotFound{} +} + +// WithXRequestID adds the xRequestId to the delete project not found response +func (o *DeleteProjectNotFound) WithXRequestID(xRequestID string) *DeleteProjectNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete project not found response +func (o *DeleteProjectNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete project not found response +func (o *DeleteProjectNotFound) WithPayload(payload *models.Errors) *DeleteProjectNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete project not found response +func (o *DeleteProjectNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteProjectNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteProjectPreconditionFailedCode is the HTTP code returned for type DeleteProjectPreconditionFailed +const DeleteProjectPreconditionFailedCode int = 412 + +/*DeleteProjectPreconditionFailed Precondition failed + +swagger:response deleteProjectPreconditionFailed +*/ +type DeleteProjectPreconditionFailed struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteProjectPreconditionFailed creates DeleteProjectPreconditionFailed with default headers values +func NewDeleteProjectPreconditionFailed() *DeleteProjectPreconditionFailed { + + return &DeleteProjectPreconditionFailed{} +} + +// WithXRequestID adds the xRequestId to the delete project precondition failed response +func (o *DeleteProjectPreconditionFailed) WithXRequestID(xRequestID string) *DeleteProjectPreconditionFailed { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete project precondition failed response +func (o *DeleteProjectPreconditionFailed) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete project precondition failed response +func (o *DeleteProjectPreconditionFailed) WithPayload(payload *models.Errors) *DeleteProjectPreconditionFailed { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete project precondition failed response +func (o *DeleteProjectPreconditionFailed) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteProjectPreconditionFailed) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(412) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteProjectInternalServerErrorCode is the HTTP code returned for type DeleteProjectInternalServerError +const DeleteProjectInternalServerErrorCode int = 500 + +/*DeleteProjectInternalServerError Internal server error + +swagger:response deleteProjectInternalServerError +*/ +type DeleteProjectInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteProjectInternalServerError creates DeleteProjectInternalServerError with default headers values +func NewDeleteProjectInternalServerError() *DeleteProjectInternalServerError { + + return &DeleteProjectInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the delete project internal server error response +func (o *DeleteProjectInternalServerError) WithXRequestID(xRequestID string) *DeleteProjectInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete project internal server error response +func (o *DeleteProjectInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete project internal server error response +func (o *DeleteProjectInternalServerError) WithPayload(payload *models.Errors) *DeleteProjectInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete project internal server error response +func (o *DeleteProjectInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteProjectInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/project/delete_project_urlbuilder.go b/src/server/v2.0/restapi/operations/project/delete_project_urlbuilder.go new file mode 100644 index 000000000..b4616b836 --- /dev/null +++ b/src/server/v2.0/restapi/operations/project/delete_project_urlbuilder.go @@ -0,0 +1,99 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// DeleteProjectURL generates an URL for the delete project operation +type DeleteProjectURL struct { + ProjectNameOrID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteProjectURL) WithBasePath(bp string) *DeleteProjectURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteProjectURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteProjectURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name_or_id}" + + projectNameOrID := o.ProjectNameOrID + if projectNameOrID != "" { + _path = strings.Replace(_path, "{project_name_or_id}", projectNameOrID, -1) + } else { + return nil, errors.New("projectNameOrId is required on DeleteProjectURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteProjectURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteProjectURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteProjectURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteProjectURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteProjectURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteProjectURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/project/get_logs.go b/src/server/v2.0/restapi/operations/project/get_logs.go new file mode 100644 index 000000000..d1afb9fee --- /dev/null +++ b/src/server/v2.0/restapi/operations/project/get_logs.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetLogsHandlerFunc turns a function with the right signature into a get logs handler +type GetLogsHandlerFunc func(GetLogsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetLogsHandlerFunc) Handle(params GetLogsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetLogsHandler interface for that can handle valid get logs params +type GetLogsHandler interface { + Handle(GetLogsParams, interface{}) middleware.Responder +} + +// NewGetLogs creates a new http.Handler for the get logs operation +func NewGetLogs(ctx *middleware.Context, handler GetLogsHandler) *GetLogs { + return &GetLogs{Context: ctx, Handler: handler} +} + +/*GetLogs swagger:route GET /projects/{project_name}/logs project getLogs + +Get recent logs of the projects + +Get recent logs of the projects + +*/ +type GetLogs struct { + Context *middleware.Context + Handler GetLogsHandler +} + +func (o *GetLogs) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetLogsParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/project/get_logs_parameters.go b/src/server/v2.0/restapi/operations/project/get_logs_parameters.go new file mode 100644 index 000000000..c9120e9b5 --- /dev/null +++ b/src/server/v2.0/restapi/operations/project/get_logs_parameters.go @@ -0,0 +1,264 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewGetLogsParams creates a new GetLogsParams object +// with the default values initialized. +func NewGetLogsParams() GetLogsParams { + + var ( + // initialize parameters with default values + + pageDefault = int64(1) + pageSizeDefault = int64(10) + ) + + return GetLogsParams{ + Page: &pageDefault, + + PageSize: &pageSizeDefault, + } +} + +// GetLogsParams contains all the bound params for the get logs operation +// typically these are obtained from a http.Request +// +// swagger:parameters getLogs +type GetLogsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The page number + In: query + Default: 1 + */ + Page *int64 + /*The size of per page + Maximum: 100 + In: query + Default: 10 + */ + PageSize *int64 + /*The name of the project + Required: true + In: path + */ + ProjectName string + /*Query string to query resources. Supported query patterns are "exact match(k=v)", "fuzzy match(k=~v)", "range(k=[min~max])", "list with union releationship(k={v1 v2 v3})" and "list with intersetion relationship(k=(v1 v2 v3))". The value of range and list can be string(enclosed by " or '), integer or time(in format "2020-04-09 02:36:00"). All of these query patterns should be put in the query string "q=xxx" and splitted by ",". e.g. q=k1=v1,k2=~v2,k3=[min~max] + In: query + */ + Q *string + /*Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + In: query + */ + Sort *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetLogsParams() beforehand. +func (o *GetLogsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + qPage, qhkPage, _ := qs.GetOK("page") + if err := o.bindPage(qPage, qhkPage, route.Formats); err != nil { + res = append(res, err) + } + + qPageSize, qhkPageSize, _ := qs.GetOK("page_size") + if err := o.bindPageSize(qPageSize, qhkPageSize, route.Formats); err != nil { + res = append(res, err) + } + + rProjectName, rhkProjectName, _ := route.Params.GetOK("project_name") + if err := o.bindProjectName(rProjectName, rhkProjectName, route.Formats); err != nil { + res = append(res, err) + } + + qQ, qhkQ, _ := qs.GetOK("q") + if err := o.bindQ(qQ, qhkQ, route.Formats); err != nil { + res = append(res, err) + } + + qSort, qhkSort, _ := qs.GetOK("sort") + if err := o.bindSort(qSort, qhkSort, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetLogsParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetLogsParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindPage binds and validates parameter Page from query. +func (o *GetLogsParams) bindPage(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewGetLogsParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page", "query", "int64", raw) + } + o.Page = &value + + return nil +} + +// bindPageSize binds and validates parameter PageSize from query. +func (o *GetLogsParams) bindPageSize(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewGetLogsParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page_size", "query", "int64", raw) + } + o.PageSize = &value + + if err := o.validatePageSize(formats); err != nil { + return err + } + + return nil +} + +// validatePageSize carries on validations for parameter PageSize +func (o *GetLogsParams) validatePageSize(formats strfmt.Registry) error { + + if err := validate.MaximumInt("page_size", "query", int64(*o.PageSize), 100, false); err != nil { + return err + } + + return nil +} + +// bindProjectName binds and validates parameter ProjectName from path. +func (o *GetLogsParams) bindProjectName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectName = raw + + return nil +} + +// bindQ binds and validates parameter Q from query. +func (o *GetLogsParams) bindQ(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Q = &raw + + return nil +} + +// bindSort binds and validates parameter Sort from query. +func (o *GetLogsParams) bindSort(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Sort = &raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/project/get_logs_responses.go b/src/server/v2.0/restapi/operations/project/get_logs_responses.go new file mode 100644 index 000000000..a7c12523b --- /dev/null +++ b/src/server/v2.0/restapi/operations/project/get_logs_responses.go @@ -0,0 +1,304 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/swag" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetLogsOKCode is the HTTP code returned for type GetLogsOK +const GetLogsOKCode int = 200 + +/*GetLogsOK Success + +swagger:response getLogsOK +*/ +type GetLogsOK struct { + /*Link refers to the previous page and next page + + */ + Link string `json:"Link"` + /*The total count of auditlogs + + */ + XTotalCount int64 `json:"X-Total-Count"` + + /* + In: Body + */ + Payload []*models.AuditLog `json:"body,omitempty"` +} + +// NewGetLogsOK creates GetLogsOK with default headers values +func NewGetLogsOK() *GetLogsOK { + + return &GetLogsOK{} +} + +// WithLink adds the link to the get logs o k response +func (o *GetLogsOK) WithLink(link string) *GetLogsOK { + o.Link = link + return o +} + +// SetLink sets the link to the get logs o k response +func (o *GetLogsOK) SetLink(link string) { + o.Link = link +} + +// WithXTotalCount adds the xTotalCount to the get logs o k response +func (o *GetLogsOK) WithXTotalCount(xTotalCount int64) *GetLogsOK { + o.XTotalCount = xTotalCount + return o +} + +// SetXTotalCount sets the xTotalCount to the get logs o k response +func (o *GetLogsOK) SetXTotalCount(xTotalCount int64) { + o.XTotalCount = xTotalCount +} + +// WithPayload adds the payload to the get logs o k response +func (o *GetLogsOK) WithPayload(payload []*models.AuditLog) *GetLogsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get logs o k response +func (o *GetLogsOK) SetPayload(payload []*models.AuditLog) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLogsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Link + + link := o.Link + if link != "" { + rw.Header().Set("Link", link) + } + + // response header X-Total-Count + + xTotalCount := swag.FormatInt64(o.XTotalCount) + if xTotalCount != "" { + rw.Header().Set("X-Total-Count", xTotalCount) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = make([]*models.AuditLog, 0, 50) + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// GetLogsBadRequestCode is the HTTP code returned for type GetLogsBadRequest +const GetLogsBadRequestCode int = 400 + +/*GetLogsBadRequest Bad request + +swagger:response getLogsBadRequest +*/ +type GetLogsBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetLogsBadRequest creates GetLogsBadRequest with default headers values +func NewGetLogsBadRequest() *GetLogsBadRequest { + + return &GetLogsBadRequest{} +} + +// WithXRequestID adds the xRequestId to the get logs bad request response +func (o *GetLogsBadRequest) WithXRequestID(xRequestID string) *GetLogsBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get logs bad request response +func (o *GetLogsBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get logs bad request response +func (o *GetLogsBadRequest) WithPayload(payload *models.Errors) *GetLogsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get logs bad request response +func (o *GetLogsBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLogsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetLogsUnauthorizedCode is the HTTP code returned for type GetLogsUnauthorized +const GetLogsUnauthorizedCode int = 401 + +/*GetLogsUnauthorized Unauthorized + +swagger:response getLogsUnauthorized +*/ +type GetLogsUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetLogsUnauthorized creates GetLogsUnauthorized with default headers values +func NewGetLogsUnauthorized() *GetLogsUnauthorized { + + return &GetLogsUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the get logs unauthorized response +func (o *GetLogsUnauthorized) WithXRequestID(xRequestID string) *GetLogsUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get logs unauthorized response +func (o *GetLogsUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get logs unauthorized response +func (o *GetLogsUnauthorized) WithPayload(payload *models.Errors) *GetLogsUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get logs unauthorized response +func (o *GetLogsUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLogsUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetLogsInternalServerErrorCode is the HTTP code returned for type GetLogsInternalServerError +const GetLogsInternalServerErrorCode int = 500 + +/*GetLogsInternalServerError Internal server error + +swagger:response getLogsInternalServerError +*/ +type GetLogsInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetLogsInternalServerError creates GetLogsInternalServerError with default headers values +func NewGetLogsInternalServerError() *GetLogsInternalServerError { + + return &GetLogsInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get logs internal server error response +func (o *GetLogsInternalServerError) WithXRequestID(xRequestID string) *GetLogsInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get logs internal server error response +func (o *GetLogsInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get logs internal server error response +func (o *GetLogsInternalServerError) WithPayload(payload *models.Errors) *GetLogsInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get logs internal server error response +func (o *GetLogsInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLogsInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/project/get_logs_urlbuilder.go b/src/server/v2.0/restapi/operations/project/get_logs_urlbuilder.go new file mode 100644 index 000000000..d2d9b862b --- /dev/null +++ b/src/server/v2.0/restapi/operations/project/get_logs_urlbuilder.go @@ -0,0 +1,142 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetLogsURL generates an URL for the get logs operation +type GetLogsURL struct { + ProjectName string + + Page *int64 + PageSize *int64 + Q *string + Sort *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetLogsURL) WithBasePath(bp string) *GetLogsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetLogsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetLogsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name}/logs" + + projectName := o.ProjectName + if projectName != "" { + _path = strings.Replace(_path, "{project_name}", projectName, -1) + } else { + return nil, errors.New("projectName is required on GetLogsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var pageQ string + if o.Page != nil { + pageQ = swag.FormatInt64(*o.Page) + } + if pageQ != "" { + qs.Set("page", pageQ) + } + + var pageSizeQ string + if o.PageSize != nil { + pageSizeQ = swag.FormatInt64(*o.PageSize) + } + if pageSizeQ != "" { + qs.Set("page_size", pageSizeQ) + } + + var qQ string + if o.Q != nil { + qQ = *o.Q + } + if qQ != "" { + qs.Set("q", qQ) + } + + var sortQ string + if o.Sort != nil { + sortQ = *o.Sort + } + if sortQ != "" { + qs.Set("sort", sortQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetLogsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetLogsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetLogsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetLogsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetLogsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetLogsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/project/get_project.go b/src/server/v2.0/restapi/operations/project/get_project.go new file mode 100644 index 000000000..31e029828 --- /dev/null +++ b/src/server/v2.0/restapi/operations/project/get_project.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetProjectHandlerFunc turns a function with the right signature into a get project handler +type GetProjectHandlerFunc func(GetProjectParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetProjectHandlerFunc) Handle(params GetProjectParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetProjectHandler interface for that can handle valid get project params +type GetProjectHandler interface { + Handle(GetProjectParams, interface{}) middleware.Responder +} + +// NewGetProject creates a new http.Handler for the get project operation +func NewGetProject(ctx *middleware.Context, handler GetProjectHandler) *GetProject { + return &GetProject{Context: ctx, Handler: handler} +} + +/*GetProject swagger:route GET /projects/{project_name_or_id} project getProject + +Return specific project detail information + +This endpoint returns specific project information by project ID. + +*/ +type GetProject struct { + Context *middleware.Context + Handler GetProjectHandler +} + +func (o *GetProject) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetProjectParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/project/get_project_deletable.go b/src/server/v2.0/restapi/operations/project/get_project_deletable.go new file mode 100644 index 000000000..06094ede9 --- /dev/null +++ b/src/server/v2.0/restapi/operations/project/get_project_deletable.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetProjectDeletableHandlerFunc turns a function with the right signature into a get project deletable handler +type GetProjectDeletableHandlerFunc func(GetProjectDeletableParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetProjectDeletableHandlerFunc) Handle(params GetProjectDeletableParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetProjectDeletableHandler interface for that can handle valid get project deletable params +type GetProjectDeletableHandler interface { + Handle(GetProjectDeletableParams, interface{}) middleware.Responder +} + +// NewGetProjectDeletable creates a new http.Handler for the get project deletable operation +func NewGetProjectDeletable(ctx *middleware.Context, handler GetProjectDeletableHandler) *GetProjectDeletable { + return &GetProjectDeletable{Context: ctx, Handler: handler} +} + +/*GetProjectDeletable swagger:route GET /projects/{project_name_or_id}/_deletable project getProjectDeletable + +Get the deletable status of the project + +Get the deletable status of the project + +*/ +type GetProjectDeletable struct { + Context *middleware.Context + Handler GetProjectDeletableHandler +} + +func (o *GetProjectDeletable) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetProjectDeletableParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/project/get_project_deletable_parameters.go b/src/server/v2.0/restapi/operations/project/get_project_deletable_parameters.go new file mode 100644 index 000000000..cf27d7e69 --- /dev/null +++ b/src/server/v2.0/restapi/operations/project/get_project_deletable_parameters.go @@ -0,0 +1,155 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewGetProjectDeletableParams creates a new GetProjectDeletableParams object +// with the default values initialized. +func NewGetProjectDeletableParams() GetProjectDeletableParams { + + var ( + // initialize parameters with default values + + xIsResourceNameDefault = bool(false) + ) + + return GetProjectDeletableParams{ + XIsResourceName: &xIsResourceNameDefault, + } +} + +// GetProjectDeletableParams contains all the bound params for the get project deletable operation +// typically these are obtained from a http.Request +// +// swagger:parameters getProjectDeletable +type GetProjectDeletableParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name. + In: header + Default: false + */ + XIsResourceName *bool + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The name or id of the project + Required: true + In: path + */ + ProjectNameOrID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetProjectDeletableParams() beforehand. +func (o *GetProjectDeletableParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXIsResourceName(r.Header[http.CanonicalHeaderKey("X-Is-Resource-Name")], true, route.Formats); err != nil { + res = append(res, err) + } + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rProjectNameOrID, rhkProjectNameOrID, _ := route.Params.GetOK("project_name_or_id") + if err := o.bindProjectNameOrID(rProjectNameOrID, rhkProjectNameOrID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXIsResourceName binds and validates parameter XIsResourceName from header. +func (o *GetProjectDeletableParams) bindXIsResourceName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewGetProjectDeletableParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("X-Is-Resource-Name", "header", "bool", raw) + } + o.XIsResourceName = &value + + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetProjectDeletableParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetProjectDeletableParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindProjectNameOrID binds and validates parameter ProjectNameOrID from path. +func (o *GetProjectDeletableParams) bindProjectNameOrID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectNameOrID = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/project/get_project_deletable_responses.go b/src/server/v2.0/restapi/operations/project/get_project_deletable_responses.go new file mode 100644 index 000000000..8fd9e99d3 --- /dev/null +++ b/src/server/v2.0/restapi/operations/project/get_project_deletable_responses.go @@ -0,0 +1,322 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetProjectDeletableOKCode is the HTTP code returned for type GetProjectDeletableOK +const GetProjectDeletableOKCode int = 200 + +/*GetProjectDeletableOK Return deletable status of the project. + +swagger:response getProjectDeletableOK +*/ +type GetProjectDeletableOK struct { + + /* + In: Body + */ + Payload *models.ProjectDeletable `json:"body,omitempty"` +} + +// NewGetProjectDeletableOK creates GetProjectDeletableOK with default headers values +func NewGetProjectDeletableOK() *GetProjectDeletableOK { + + return &GetProjectDeletableOK{} +} + +// WithPayload adds the payload to the get project deletable o k response +func (o *GetProjectDeletableOK) WithPayload(payload *models.ProjectDeletable) *GetProjectDeletableOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get project deletable o k response +func (o *GetProjectDeletableOK) SetPayload(payload *models.ProjectDeletable) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetProjectDeletableOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetProjectDeletableUnauthorizedCode is the HTTP code returned for type GetProjectDeletableUnauthorized +const GetProjectDeletableUnauthorizedCode int = 401 + +/*GetProjectDeletableUnauthorized Unauthorized + +swagger:response getProjectDeletableUnauthorized +*/ +type GetProjectDeletableUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetProjectDeletableUnauthorized creates GetProjectDeletableUnauthorized with default headers values +func NewGetProjectDeletableUnauthorized() *GetProjectDeletableUnauthorized { + + return &GetProjectDeletableUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the get project deletable unauthorized response +func (o *GetProjectDeletableUnauthorized) WithXRequestID(xRequestID string) *GetProjectDeletableUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get project deletable unauthorized response +func (o *GetProjectDeletableUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get project deletable unauthorized response +func (o *GetProjectDeletableUnauthorized) WithPayload(payload *models.Errors) *GetProjectDeletableUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get project deletable unauthorized response +func (o *GetProjectDeletableUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetProjectDeletableUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetProjectDeletableForbiddenCode is the HTTP code returned for type GetProjectDeletableForbidden +const GetProjectDeletableForbiddenCode int = 403 + +/*GetProjectDeletableForbidden Forbidden + +swagger:response getProjectDeletableForbidden +*/ +type GetProjectDeletableForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetProjectDeletableForbidden creates GetProjectDeletableForbidden with default headers values +func NewGetProjectDeletableForbidden() *GetProjectDeletableForbidden { + + return &GetProjectDeletableForbidden{} +} + +// WithXRequestID adds the xRequestId to the get project deletable forbidden response +func (o *GetProjectDeletableForbidden) WithXRequestID(xRequestID string) *GetProjectDeletableForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get project deletable forbidden response +func (o *GetProjectDeletableForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get project deletable forbidden response +func (o *GetProjectDeletableForbidden) WithPayload(payload *models.Errors) *GetProjectDeletableForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get project deletable forbidden response +func (o *GetProjectDeletableForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetProjectDeletableForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetProjectDeletableNotFoundCode is the HTTP code returned for type GetProjectDeletableNotFound +const GetProjectDeletableNotFoundCode int = 404 + +/*GetProjectDeletableNotFound Not found + +swagger:response getProjectDeletableNotFound +*/ +type GetProjectDeletableNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetProjectDeletableNotFound creates GetProjectDeletableNotFound with default headers values +func NewGetProjectDeletableNotFound() *GetProjectDeletableNotFound { + + return &GetProjectDeletableNotFound{} +} + +// WithXRequestID adds the xRequestId to the get project deletable not found response +func (o *GetProjectDeletableNotFound) WithXRequestID(xRequestID string) *GetProjectDeletableNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get project deletable not found response +func (o *GetProjectDeletableNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get project deletable not found response +func (o *GetProjectDeletableNotFound) WithPayload(payload *models.Errors) *GetProjectDeletableNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get project deletable not found response +func (o *GetProjectDeletableNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetProjectDeletableNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetProjectDeletableInternalServerErrorCode is the HTTP code returned for type GetProjectDeletableInternalServerError +const GetProjectDeletableInternalServerErrorCode int = 500 + +/*GetProjectDeletableInternalServerError Internal server error + +swagger:response getProjectDeletableInternalServerError +*/ +type GetProjectDeletableInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetProjectDeletableInternalServerError creates GetProjectDeletableInternalServerError with default headers values +func NewGetProjectDeletableInternalServerError() *GetProjectDeletableInternalServerError { + + return &GetProjectDeletableInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get project deletable internal server error response +func (o *GetProjectDeletableInternalServerError) WithXRequestID(xRequestID string) *GetProjectDeletableInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get project deletable internal server error response +func (o *GetProjectDeletableInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get project deletable internal server error response +func (o *GetProjectDeletableInternalServerError) WithPayload(payload *models.Errors) *GetProjectDeletableInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get project deletable internal server error response +func (o *GetProjectDeletableInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetProjectDeletableInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/project/get_project_deletable_urlbuilder.go b/src/server/v2.0/restapi/operations/project/get_project_deletable_urlbuilder.go new file mode 100644 index 000000000..36fbb6c74 --- /dev/null +++ b/src/server/v2.0/restapi/operations/project/get_project_deletable_urlbuilder.go @@ -0,0 +1,99 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetProjectDeletableURL generates an URL for the get project deletable operation +type GetProjectDeletableURL struct { + ProjectNameOrID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetProjectDeletableURL) WithBasePath(bp string) *GetProjectDeletableURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetProjectDeletableURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetProjectDeletableURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name_or_id}/_deletable" + + projectNameOrID := o.ProjectNameOrID + if projectNameOrID != "" { + _path = strings.Replace(_path, "{project_name_or_id}", projectNameOrID, -1) + } else { + return nil, errors.New("projectNameOrId is required on GetProjectDeletableURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetProjectDeletableURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetProjectDeletableURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetProjectDeletableURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetProjectDeletableURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetProjectDeletableURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetProjectDeletableURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/project/get_project_parameters.go b/src/server/v2.0/restapi/operations/project/get_project_parameters.go new file mode 100644 index 000000000..def9382ec --- /dev/null +++ b/src/server/v2.0/restapi/operations/project/get_project_parameters.go @@ -0,0 +1,155 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewGetProjectParams creates a new GetProjectParams object +// with the default values initialized. +func NewGetProjectParams() GetProjectParams { + + var ( + // initialize parameters with default values + + xIsResourceNameDefault = bool(false) + ) + + return GetProjectParams{ + XIsResourceName: &xIsResourceNameDefault, + } +} + +// GetProjectParams contains all the bound params for the get project operation +// typically these are obtained from a http.Request +// +// swagger:parameters getProject +type GetProjectParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name. + In: header + Default: false + */ + XIsResourceName *bool + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The name or id of the project + Required: true + In: path + */ + ProjectNameOrID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetProjectParams() beforehand. +func (o *GetProjectParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXIsResourceName(r.Header[http.CanonicalHeaderKey("X-Is-Resource-Name")], true, route.Formats); err != nil { + res = append(res, err) + } + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rProjectNameOrID, rhkProjectNameOrID, _ := route.Params.GetOK("project_name_or_id") + if err := o.bindProjectNameOrID(rProjectNameOrID, rhkProjectNameOrID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXIsResourceName binds and validates parameter XIsResourceName from header. +func (o *GetProjectParams) bindXIsResourceName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewGetProjectParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("X-Is-Resource-Name", "header", "bool", raw) + } + o.XIsResourceName = &value + + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetProjectParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetProjectParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindProjectNameOrID binds and validates parameter ProjectNameOrID from path. +func (o *GetProjectParams) bindProjectNameOrID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectNameOrID = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/project/get_project_responses.go b/src/server/v2.0/restapi/operations/project/get_project_responses.go new file mode 100644 index 000000000..1ed71842b --- /dev/null +++ b/src/server/v2.0/restapi/operations/project/get_project_responses.go @@ -0,0 +1,190 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetProjectOKCode is the HTTP code returned for type GetProjectOK +const GetProjectOKCode int = 200 + +/*GetProjectOK Return matched project information. + +swagger:response getProjectOK +*/ +type GetProjectOK struct { + + /* + In: Body + */ + Payload *models.Project `json:"body,omitempty"` +} + +// NewGetProjectOK creates GetProjectOK with default headers values +func NewGetProjectOK() *GetProjectOK { + + return &GetProjectOK{} +} + +// WithPayload adds the payload to the get project o k response +func (o *GetProjectOK) WithPayload(payload *models.Project) *GetProjectOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get project o k response +func (o *GetProjectOK) SetPayload(payload *models.Project) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetProjectOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetProjectUnauthorizedCode is the HTTP code returned for type GetProjectUnauthorized +const GetProjectUnauthorizedCode int = 401 + +/*GetProjectUnauthorized Unauthorized + +swagger:response getProjectUnauthorized +*/ +type GetProjectUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetProjectUnauthorized creates GetProjectUnauthorized with default headers values +func NewGetProjectUnauthorized() *GetProjectUnauthorized { + + return &GetProjectUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the get project unauthorized response +func (o *GetProjectUnauthorized) WithXRequestID(xRequestID string) *GetProjectUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get project unauthorized response +func (o *GetProjectUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get project unauthorized response +func (o *GetProjectUnauthorized) WithPayload(payload *models.Errors) *GetProjectUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get project unauthorized response +func (o *GetProjectUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetProjectUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetProjectInternalServerErrorCode is the HTTP code returned for type GetProjectInternalServerError +const GetProjectInternalServerErrorCode int = 500 + +/*GetProjectInternalServerError Internal server error + +swagger:response getProjectInternalServerError +*/ +type GetProjectInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetProjectInternalServerError creates GetProjectInternalServerError with default headers values +func NewGetProjectInternalServerError() *GetProjectInternalServerError { + + return &GetProjectInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get project internal server error response +func (o *GetProjectInternalServerError) WithXRequestID(xRequestID string) *GetProjectInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get project internal server error response +func (o *GetProjectInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get project internal server error response +func (o *GetProjectInternalServerError) WithPayload(payload *models.Errors) *GetProjectInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get project internal server error response +func (o *GetProjectInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetProjectInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/project/get_project_summary.go b/src/server/v2.0/restapi/operations/project/get_project_summary.go new file mode 100644 index 000000000..fa2ebd24d --- /dev/null +++ b/src/server/v2.0/restapi/operations/project/get_project_summary.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetProjectSummaryHandlerFunc turns a function with the right signature into a get project summary handler +type GetProjectSummaryHandlerFunc func(GetProjectSummaryParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetProjectSummaryHandlerFunc) Handle(params GetProjectSummaryParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetProjectSummaryHandler interface for that can handle valid get project summary params +type GetProjectSummaryHandler interface { + Handle(GetProjectSummaryParams, interface{}) middleware.Responder +} + +// NewGetProjectSummary creates a new http.Handler for the get project summary operation +func NewGetProjectSummary(ctx *middleware.Context, handler GetProjectSummaryHandler) *GetProjectSummary { + return &GetProjectSummary{Context: ctx, Handler: handler} +} + +/*GetProjectSummary swagger:route GET /projects/{project_name_or_id}/summary project getProjectSummary + +Get summary of the project. + +Get summary of the project. + +*/ +type GetProjectSummary struct { + Context *middleware.Context + Handler GetProjectSummaryHandler +} + +func (o *GetProjectSummary) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetProjectSummaryParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/project/get_project_summary_parameters.go b/src/server/v2.0/restapi/operations/project/get_project_summary_parameters.go new file mode 100644 index 000000000..9d7d652e0 --- /dev/null +++ b/src/server/v2.0/restapi/operations/project/get_project_summary_parameters.go @@ -0,0 +1,155 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewGetProjectSummaryParams creates a new GetProjectSummaryParams object +// with the default values initialized. +func NewGetProjectSummaryParams() GetProjectSummaryParams { + + var ( + // initialize parameters with default values + + xIsResourceNameDefault = bool(false) + ) + + return GetProjectSummaryParams{ + XIsResourceName: &xIsResourceNameDefault, + } +} + +// GetProjectSummaryParams contains all the bound params for the get project summary operation +// typically these are obtained from a http.Request +// +// swagger:parameters getProjectSummary +type GetProjectSummaryParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name. + In: header + Default: false + */ + XIsResourceName *bool + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The name or id of the project + Required: true + In: path + */ + ProjectNameOrID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetProjectSummaryParams() beforehand. +func (o *GetProjectSummaryParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXIsResourceName(r.Header[http.CanonicalHeaderKey("X-Is-Resource-Name")], true, route.Formats); err != nil { + res = append(res, err) + } + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rProjectNameOrID, rhkProjectNameOrID, _ := route.Params.GetOK("project_name_or_id") + if err := o.bindProjectNameOrID(rProjectNameOrID, rhkProjectNameOrID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXIsResourceName binds and validates parameter XIsResourceName from header. +func (o *GetProjectSummaryParams) bindXIsResourceName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewGetProjectSummaryParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("X-Is-Resource-Name", "header", "bool", raw) + } + o.XIsResourceName = &value + + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetProjectSummaryParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetProjectSummaryParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindProjectNameOrID binds and validates parameter ProjectNameOrID from path. +func (o *GetProjectSummaryParams) bindProjectNameOrID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectNameOrID = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/project/get_project_summary_responses.go b/src/server/v2.0/restapi/operations/project/get_project_summary_responses.go new file mode 100644 index 000000000..f25d199ef --- /dev/null +++ b/src/server/v2.0/restapi/operations/project/get_project_summary_responses.go @@ -0,0 +1,388 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetProjectSummaryOKCode is the HTTP code returned for type GetProjectSummaryOK +const GetProjectSummaryOKCode int = 200 + +/*GetProjectSummaryOK Get summary of the project successfully. + +swagger:response getProjectSummaryOK +*/ +type GetProjectSummaryOK struct { + + /* + In: Body + */ + Payload *models.ProjectSummary `json:"body,omitempty"` +} + +// NewGetProjectSummaryOK creates GetProjectSummaryOK with default headers values +func NewGetProjectSummaryOK() *GetProjectSummaryOK { + + return &GetProjectSummaryOK{} +} + +// WithPayload adds the payload to the get project summary o k response +func (o *GetProjectSummaryOK) WithPayload(payload *models.ProjectSummary) *GetProjectSummaryOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get project summary o k response +func (o *GetProjectSummaryOK) SetPayload(payload *models.ProjectSummary) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetProjectSummaryOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetProjectSummaryBadRequestCode is the HTTP code returned for type GetProjectSummaryBadRequest +const GetProjectSummaryBadRequestCode int = 400 + +/*GetProjectSummaryBadRequest Bad request + +swagger:response getProjectSummaryBadRequest +*/ +type GetProjectSummaryBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetProjectSummaryBadRequest creates GetProjectSummaryBadRequest with default headers values +func NewGetProjectSummaryBadRequest() *GetProjectSummaryBadRequest { + + return &GetProjectSummaryBadRequest{} +} + +// WithXRequestID adds the xRequestId to the get project summary bad request response +func (o *GetProjectSummaryBadRequest) WithXRequestID(xRequestID string) *GetProjectSummaryBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get project summary bad request response +func (o *GetProjectSummaryBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get project summary bad request response +func (o *GetProjectSummaryBadRequest) WithPayload(payload *models.Errors) *GetProjectSummaryBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get project summary bad request response +func (o *GetProjectSummaryBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetProjectSummaryBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetProjectSummaryUnauthorizedCode is the HTTP code returned for type GetProjectSummaryUnauthorized +const GetProjectSummaryUnauthorizedCode int = 401 + +/*GetProjectSummaryUnauthorized Unauthorized + +swagger:response getProjectSummaryUnauthorized +*/ +type GetProjectSummaryUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetProjectSummaryUnauthorized creates GetProjectSummaryUnauthorized with default headers values +func NewGetProjectSummaryUnauthorized() *GetProjectSummaryUnauthorized { + + return &GetProjectSummaryUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the get project summary unauthorized response +func (o *GetProjectSummaryUnauthorized) WithXRequestID(xRequestID string) *GetProjectSummaryUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get project summary unauthorized response +func (o *GetProjectSummaryUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get project summary unauthorized response +func (o *GetProjectSummaryUnauthorized) WithPayload(payload *models.Errors) *GetProjectSummaryUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get project summary unauthorized response +func (o *GetProjectSummaryUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetProjectSummaryUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetProjectSummaryForbiddenCode is the HTTP code returned for type GetProjectSummaryForbidden +const GetProjectSummaryForbiddenCode int = 403 + +/*GetProjectSummaryForbidden Forbidden + +swagger:response getProjectSummaryForbidden +*/ +type GetProjectSummaryForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetProjectSummaryForbidden creates GetProjectSummaryForbidden with default headers values +func NewGetProjectSummaryForbidden() *GetProjectSummaryForbidden { + + return &GetProjectSummaryForbidden{} +} + +// WithXRequestID adds the xRequestId to the get project summary forbidden response +func (o *GetProjectSummaryForbidden) WithXRequestID(xRequestID string) *GetProjectSummaryForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get project summary forbidden response +func (o *GetProjectSummaryForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get project summary forbidden response +func (o *GetProjectSummaryForbidden) WithPayload(payload *models.Errors) *GetProjectSummaryForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get project summary forbidden response +func (o *GetProjectSummaryForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetProjectSummaryForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetProjectSummaryNotFoundCode is the HTTP code returned for type GetProjectSummaryNotFound +const GetProjectSummaryNotFoundCode int = 404 + +/*GetProjectSummaryNotFound Not found + +swagger:response getProjectSummaryNotFound +*/ +type GetProjectSummaryNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetProjectSummaryNotFound creates GetProjectSummaryNotFound with default headers values +func NewGetProjectSummaryNotFound() *GetProjectSummaryNotFound { + + return &GetProjectSummaryNotFound{} +} + +// WithXRequestID adds the xRequestId to the get project summary not found response +func (o *GetProjectSummaryNotFound) WithXRequestID(xRequestID string) *GetProjectSummaryNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get project summary not found response +func (o *GetProjectSummaryNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get project summary not found response +func (o *GetProjectSummaryNotFound) WithPayload(payload *models.Errors) *GetProjectSummaryNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get project summary not found response +func (o *GetProjectSummaryNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetProjectSummaryNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetProjectSummaryInternalServerErrorCode is the HTTP code returned for type GetProjectSummaryInternalServerError +const GetProjectSummaryInternalServerErrorCode int = 500 + +/*GetProjectSummaryInternalServerError Internal server error + +swagger:response getProjectSummaryInternalServerError +*/ +type GetProjectSummaryInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetProjectSummaryInternalServerError creates GetProjectSummaryInternalServerError with default headers values +func NewGetProjectSummaryInternalServerError() *GetProjectSummaryInternalServerError { + + return &GetProjectSummaryInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get project summary internal server error response +func (o *GetProjectSummaryInternalServerError) WithXRequestID(xRequestID string) *GetProjectSummaryInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get project summary internal server error response +func (o *GetProjectSummaryInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get project summary internal server error response +func (o *GetProjectSummaryInternalServerError) WithPayload(payload *models.Errors) *GetProjectSummaryInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get project summary internal server error response +func (o *GetProjectSummaryInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetProjectSummaryInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/project/get_project_summary_urlbuilder.go b/src/server/v2.0/restapi/operations/project/get_project_summary_urlbuilder.go new file mode 100644 index 000000000..af9b7bf26 --- /dev/null +++ b/src/server/v2.0/restapi/operations/project/get_project_summary_urlbuilder.go @@ -0,0 +1,99 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetProjectSummaryURL generates an URL for the get project summary operation +type GetProjectSummaryURL struct { + ProjectNameOrID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetProjectSummaryURL) WithBasePath(bp string) *GetProjectSummaryURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetProjectSummaryURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetProjectSummaryURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name_or_id}/summary" + + projectNameOrID := o.ProjectNameOrID + if projectNameOrID != "" { + _path = strings.Replace(_path, "{project_name_or_id}", projectNameOrID, -1) + } else { + return nil, errors.New("projectNameOrId is required on GetProjectSummaryURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetProjectSummaryURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetProjectSummaryURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetProjectSummaryURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetProjectSummaryURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetProjectSummaryURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetProjectSummaryURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/project/get_project_urlbuilder.go b/src/server/v2.0/restapi/operations/project/get_project_urlbuilder.go new file mode 100644 index 000000000..8a8719836 --- /dev/null +++ b/src/server/v2.0/restapi/operations/project/get_project_urlbuilder.go @@ -0,0 +1,99 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetProjectURL generates an URL for the get project operation +type GetProjectURL struct { + ProjectNameOrID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetProjectURL) WithBasePath(bp string) *GetProjectURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetProjectURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetProjectURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name_or_id}" + + projectNameOrID := o.ProjectNameOrID + if projectNameOrID != "" { + _path = strings.Replace(_path, "{project_name_or_id}", projectNameOrID, -1) + } else { + return nil, errors.New("projectNameOrId is required on GetProjectURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetProjectURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetProjectURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetProjectURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetProjectURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetProjectURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetProjectURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/project/get_scanner_of_project.go b/src/server/v2.0/restapi/operations/project/get_scanner_of_project.go new file mode 100644 index 000000000..542a84cd5 --- /dev/null +++ b/src/server/v2.0/restapi/operations/project/get_scanner_of_project.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetScannerOfProjectHandlerFunc turns a function with the right signature into a get scanner of project handler +type GetScannerOfProjectHandlerFunc func(GetScannerOfProjectParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetScannerOfProjectHandlerFunc) Handle(params GetScannerOfProjectParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetScannerOfProjectHandler interface for that can handle valid get scanner of project params +type GetScannerOfProjectHandler interface { + Handle(GetScannerOfProjectParams, interface{}) middleware.Responder +} + +// NewGetScannerOfProject creates a new http.Handler for the get scanner of project operation +func NewGetScannerOfProject(ctx *middleware.Context, handler GetScannerOfProjectHandler) *GetScannerOfProject { + return &GetScannerOfProject{Context: ctx, Handler: handler} +} + +/*GetScannerOfProject swagger:route GET /projects/{project_name_or_id}/scanner project getScannerOfProject + +Get project level scanner + +Get the scanner registration of the specified project. If no scanner registration is configured for the specified project, the system default scanner registration will be returned. + +*/ +type GetScannerOfProject struct { + Context *middleware.Context + Handler GetScannerOfProjectHandler +} + +func (o *GetScannerOfProject) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetScannerOfProjectParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/project/get_scanner_of_project_parameters.go b/src/server/v2.0/restapi/operations/project/get_scanner_of_project_parameters.go new file mode 100644 index 000000000..834f50217 --- /dev/null +++ b/src/server/v2.0/restapi/operations/project/get_scanner_of_project_parameters.go @@ -0,0 +1,155 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewGetScannerOfProjectParams creates a new GetScannerOfProjectParams object +// with the default values initialized. +func NewGetScannerOfProjectParams() GetScannerOfProjectParams { + + var ( + // initialize parameters with default values + + xIsResourceNameDefault = bool(false) + ) + + return GetScannerOfProjectParams{ + XIsResourceName: &xIsResourceNameDefault, + } +} + +// GetScannerOfProjectParams contains all the bound params for the get scanner of project operation +// typically these are obtained from a http.Request +// +// swagger:parameters getScannerOfProject +type GetScannerOfProjectParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name. + In: header + Default: false + */ + XIsResourceName *bool + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The name or id of the project + Required: true + In: path + */ + ProjectNameOrID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetScannerOfProjectParams() beforehand. +func (o *GetScannerOfProjectParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXIsResourceName(r.Header[http.CanonicalHeaderKey("X-Is-Resource-Name")], true, route.Formats); err != nil { + res = append(res, err) + } + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rProjectNameOrID, rhkProjectNameOrID, _ := route.Params.GetOK("project_name_or_id") + if err := o.bindProjectNameOrID(rProjectNameOrID, rhkProjectNameOrID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXIsResourceName binds and validates parameter XIsResourceName from header. +func (o *GetScannerOfProjectParams) bindXIsResourceName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewGetScannerOfProjectParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("X-Is-Resource-Name", "header", "bool", raw) + } + o.XIsResourceName = &value + + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetScannerOfProjectParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetScannerOfProjectParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindProjectNameOrID binds and validates parameter ProjectNameOrID from path. +func (o *GetScannerOfProjectParams) bindProjectNameOrID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectNameOrID = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/project/get_scanner_of_project_responses.go b/src/server/v2.0/restapi/operations/project/get_scanner_of_project_responses.go new file mode 100644 index 000000000..c57a8ca0e --- /dev/null +++ b/src/server/v2.0/restapi/operations/project/get_scanner_of_project_responses.go @@ -0,0 +1,178 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetScannerOfProjectOKCode is the HTTP code returned for type GetScannerOfProjectOK +const GetScannerOfProjectOKCode int = 200 + +/*GetScannerOfProjectOK The details of the scanner registration. + +swagger:response getScannerOfProjectOK +*/ +type GetScannerOfProjectOK struct { + + /* + In: Body + */ + Payload *models.ScannerRegistration `json:"body,omitempty"` +} + +// NewGetScannerOfProjectOK creates GetScannerOfProjectOK with default headers values +func NewGetScannerOfProjectOK() *GetScannerOfProjectOK { + + return &GetScannerOfProjectOK{} +} + +// WithPayload adds the payload to the get scanner of project o k response +func (o *GetScannerOfProjectOK) WithPayload(payload *models.ScannerRegistration) *GetScannerOfProjectOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get scanner of project o k response +func (o *GetScannerOfProjectOK) SetPayload(payload *models.ScannerRegistration) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetScannerOfProjectOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetScannerOfProjectBadRequestCode is the HTTP code returned for type GetScannerOfProjectBadRequest +const GetScannerOfProjectBadRequestCode int = 400 + +/*GetScannerOfProjectBadRequest Bad project ID + +swagger:response getScannerOfProjectBadRequest +*/ +type GetScannerOfProjectBadRequest struct { +} + +// NewGetScannerOfProjectBadRequest creates GetScannerOfProjectBadRequest with default headers values +func NewGetScannerOfProjectBadRequest() *GetScannerOfProjectBadRequest { + + return &GetScannerOfProjectBadRequest{} +} + +// WriteResponse to the client +func (o *GetScannerOfProjectBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(400) +} + +// GetScannerOfProjectUnauthorizedCode is the HTTP code returned for type GetScannerOfProjectUnauthorized +const GetScannerOfProjectUnauthorizedCode int = 401 + +/*GetScannerOfProjectUnauthorized Unauthorized request + +swagger:response getScannerOfProjectUnauthorized +*/ +type GetScannerOfProjectUnauthorized struct { +} + +// NewGetScannerOfProjectUnauthorized creates GetScannerOfProjectUnauthorized with default headers values +func NewGetScannerOfProjectUnauthorized() *GetScannerOfProjectUnauthorized { + + return &GetScannerOfProjectUnauthorized{} +} + +// WriteResponse to the client +func (o *GetScannerOfProjectUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(401) +} + +// GetScannerOfProjectForbiddenCode is the HTTP code returned for type GetScannerOfProjectForbidden +const GetScannerOfProjectForbiddenCode int = 403 + +/*GetScannerOfProjectForbidden Request is not allowed + +swagger:response getScannerOfProjectForbidden +*/ +type GetScannerOfProjectForbidden struct { +} + +// NewGetScannerOfProjectForbidden creates GetScannerOfProjectForbidden with default headers values +func NewGetScannerOfProjectForbidden() *GetScannerOfProjectForbidden { + + return &GetScannerOfProjectForbidden{} +} + +// WriteResponse to the client +func (o *GetScannerOfProjectForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(403) +} + +// GetScannerOfProjectNotFoundCode is the HTTP code returned for type GetScannerOfProjectNotFound +const GetScannerOfProjectNotFoundCode int = 404 + +/*GetScannerOfProjectNotFound The requested object is not found + +swagger:response getScannerOfProjectNotFound +*/ +type GetScannerOfProjectNotFound struct { +} + +// NewGetScannerOfProjectNotFound creates GetScannerOfProjectNotFound with default headers values +func NewGetScannerOfProjectNotFound() *GetScannerOfProjectNotFound { + + return &GetScannerOfProjectNotFound{} +} + +// WriteResponse to the client +func (o *GetScannerOfProjectNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(404) +} + +// GetScannerOfProjectInternalServerErrorCode is the HTTP code returned for type GetScannerOfProjectInternalServerError +const GetScannerOfProjectInternalServerErrorCode int = 500 + +/*GetScannerOfProjectInternalServerError Internal server error happened + +swagger:response getScannerOfProjectInternalServerError +*/ +type GetScannerOfProjectInternalServerError struct { +} + +// NewGetScannerOfProjectInternalServerError creates GetScannerOfProjectInternalServerError with default headers values +func NewGetScannerOfProjectInternalServerError() *GetScannerOfProjectInternalServerError { + + return &GetScannerOfProjectInternalServerError{} +} + +// WriteResponse to the client +func (o *GetScannerOfProjectInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(500) +} diff --git a/src/server/v2.0/restapi/operations/project/get_scanner_of_project_urlbuilder.go b/src/server/v2.0/restapi/operations/project/get_scanner_of_project_urlbuilder.go new file mode 100644 index 000000000..c628d24de --- /dev/null +++ b/src/server/v2.0/restapi/operations/project/get_scanner_of_project_urlbuilder.go @@ -0,0 +1,99 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetScannerOfProjectURL generates an URL for the get scanner of project operation +type GetScannerOfProjectURL struct { + ProjectNameOrID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetScannerOfProjectURL) WithBasePath(bp string) *GetScannerOfProjectURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetScannerOfProjectURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetScannerOfProjectURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name_or_id}/scanner" + + projectNameOrID := o.ProjectNameOrID + if projectNameOrID != "" { + _path = strings.Replace(_path, "{project_name_or_id}", projectNameOrID, -1) + } else { + return nil, errors.New("projectNameOrId is required on GetScannerOfProjectURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetScannerOfProjectURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetScannerOfProjectURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetScannerOfProjectURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetScannerOfProjectURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetScannerOfProjectURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetScannerOfProjectURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/project/head_project.go b/src/server/v2.0/restapi/operations/project/head_project.go new file mode 100644 index 000000000..43f234aaf --- /dev/null +++ b/src/server/v2.0/restapi/operations/project/head_project.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// HeadProjectHandlerFunc turns a function with the right signature into a head project handler +type HeadProjectHandlerFunc func(HeadProjectParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn HeadProjectHandlerFunc) Handle(params HeadProjectParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// HeadProjectHandler interface for that can handle valid head project params +type HeadProjectHandler interface { + Handle(HeadProjectParams, interface{}) middleware.Responder +} + +// NewHeadProject creates a new http.Handler for the head project operation +func NewHeadProject(ctx *middleware.Context, handler HeadProjectHandler) *HeadProject { + return &HeadProject{Context: ctx, Handler: handler} +} + +/*HeadProject swagger:route HEAD /projects project headProject + +Check if the project name user provided already exists. + +This endpoint is used to check if the project name provided already exist. + +*/ +type HeadProject struct { + Context *middleware.Context + Handler HeadProjectHandler +} + +func (o *HeadProject) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewHeadProjectParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/project/head_project_parameters.go b/src/server/v2.0/restapi/operations/project/head_project_parameters.go new file mode 100644 index 000000000..9453d8cf8 --- /dev/null +++ b/src/server/v2.0/restapi/operations/project/head_project_parameters.go @@ -0,0 +1,123 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewHeadProjectParams creates a new HeadProjectParams object +// no default values defined in spec. +func NewHeadProjectParams() HeadProjectParams { + + return HeadProjectParams{} +} + +// HeadProjectParams contains all the bound params for the head project operation +// typically these are obtained from a http.Request +// +// swagger:parameters headProject +type HeadProjectParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*Project name for checking exists. + Required: true + In: query + */ + ProjectName string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewHeadProjectParams() beforehand. +func (o *HeadProjectParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + qProjectName, qhkProjectName, _ := qs.GetOK("project_name") + if err := o.bindProjectName(qProjectName, qhkProjectName, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *HeadProjectParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *HeadProjectParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindProjectName binds and validates parameter ProjectName from query. +func (o *HeadProjectParams) bindProjectName(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("project_name", "query", rawData) + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // AllowEmptyValue: false + if err := validate.RequiredString("project_name", "query", raw); err != nil { + return err + } + + o.ProjectName = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/project/head_project_responses.go b/src/server/v2.0/restapi/operations/project/head_project_responses.go new file mode 100644 index 000000000..b965a3fdb --- /dev/null +++ b/src/server/v2.0/restapi/operations/project/head_project_responses.go @@ -0,0 +1,192 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// HeadProjectOKCode is the HTTP code returned for type HeadProjectOK +const HeadProjectOKCode int = 200 + +/*HeadProjectOK Success + +swagger:response headProjectOK +*/ +type HeadProjectOK struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewHeadProjectOK creates HeadProjectOK with default headers values +func NewHeadProjectOK() *HeadProjectOK { + + return &HeadProjectOK{} +} + +// WithXRequestID adds the xRequestId to the head project o k response +func (o *HeadProjectOK) WithXRequestID(xRequestID string) *HeadProjectOK { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the head project o k response +func (o *HeadProjectOK) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *HeadProjectOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// HeadProjectNotFoundCode is the HTTP code returned for type HeadProjectNotFound +const HeadProjectNotFoundCode int = 404 + +/*HeadProjectNotFound Not found + +swagger:response headProjectNotFound +*/ +type HeadProjectNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewHeadProjectNotFound creates HeadProjectNotFound with default headers values +func NewHeadProjectNotFound() *HeadProjectNotFound { + + return &HeadProjectNotFound{} +} + +// WithXRequestID adds the xRequestId to the head project not found response +func (o *HeadProjectNotFound) WithXRequestID(xRequestID string) *HeadProjectNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the head project not found response +func (o *HeadProjectNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the head project not found response +func (o *HeadProjectNotFound) WithPayload(payload *models.Errors) *HeadProjectNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the head project not found response +func (o *HeadProjectNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *HeadProjectNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// HeadProjectInternalServerErrorCode is the HTTP code returned for type HeadProjectInternalServerError +const HeadProjectInternalServerErrorCode int = 500 + +/*HeadProjectInternalServerError Internal server error + +swagger:response headProjectInternalServerError +*/ +type HeadProjectInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewHeadProjectInternalServerError creates HeadProjectInternalServerError with default headers values +func NewHeadProjectInternalServerError() *HeadProjectInternalServerError { + + return &HeadProjectInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the head project internal server error response +func (o *HeadProjectInternalServerError) WithXRequestID(xRequestID string) *HeadProjectInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the head project internal server error response +func (o *HeadProjectInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the head project internal server error response +func (o *HeadProjectInternalServerError) WithPayload(payload *models.Errors) *HeadProjectInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the head project internal server error response +func (o *HeadProjectInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *HeadProjectInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/project/head_project_urlbuilder.go b/src/server/v2.0/restapi/operations/project/head_project_urlbuilder.go new file mode 100644 index 000000000..f7e8be383 --- /dev/null +++ b/src/server/v2.0/restapi/operations/project/head_project_urlbuilder.go @@ -0,0 +1,100 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// HeadProjectURL generates an URL for the head project operation +type HeadProjectURL struct { + ProjectName string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *HeadProjectURL) WithBasePath(bp string) *HeadProjectURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *HeadProjectURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *HeadProjectURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + projectNameQ := o.ProjectName + if projectNameQ != "" { + qs.Set("project_name", projectNameQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *HeadProjectURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *HeadProjectURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *HeadProjectURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on HeadProjectURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on HeadProjectURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *HeadProjectURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/project/list_projects.go b/src/server/v2.0/restapi/operations/project/list_projects.go new file mode 100644 index 000000000..186996a24 --- /dev/null +++ b/src/server/v2.0/restapi/operations/project/list_projects.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ListProjectsHandlerFunc turns a function with the right signature into a list projects handler +type ListProjectsHandlerFunc func(ListProjectsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ListProjectsHandlerFunc) Handle(params ListProjectsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ListProjectsHandler interface for that can handle valid list projects params +type ListProjectsHandler interface { + Handle(ListProjectsParams, interface{}) middleware.Responder +} + +// NewListProjects creates a new http.Handler for the list projects operation +func NewListProjects(ctx *middleware.Context, handler ListProjectsHandler) *ListProjects { + return &ListProjects{Context: ctx, Handler: handler} +} + +/*ListProjects swagger:route GET /projects project listProjects + +List projects + +This endpoint returns projects created by Harbor. + +*/ +type ListProjects struct { + Context *middleware.Context + Handler ListProjectsHandler +} + +func (o *ListProjects) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewListProjectsParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/project/list_projects_parameters.go b/src/server/v2.0/restapi/operations/project/list_projects_parameters.go new file mode 100644 index 000000000..203bdf786 --- /dev/null +++ b/src/server/v2.0/restapi/operations/project/list_projects_parameters.go @@ -0,0 +1,361 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewListProjectsParams creates a new ListProjectsParams object +// with the default values initialized. +func NewListProjectsParams() ListProjectsParams { + + var ( + // initialize parameters with default values + + pageDefault = int64(1) + pageSizeDefault = int64(10) + + withDetailDefault = bool(true) + ) + + return ListProjectsParams{ + Page: &pageDefault, + + PageSize: &pageSizeDefault, + + WithDetail: &withDetailDefault, + } +} + +// ListProjectsParams contains all the bound params for the list projects operation +// typically these are obtained from a http.Request +// +// swagger:parameters listProjects +type ListProjectsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The name of project. + In: query + */ + Name *string + /*The name of project owner. + In: query + */ + Owner *string + /*The page number + In: query + Default: 1 + */ + Page *int64 + /*The size of per page + Maximum: 100 + In: query + Default: 10 + */ + PageSize *int64 + /*The project is public or private. + In: query + */ + Public *bool + /*Query string to query resources. Supported query patterns are "exact match(k=v)", "fuzzy match(k=~v)", "range(k=[min~max])", "list with union releationship(k={v1 v2 v3})" and "list with intersetion relationship(k=(v1 v2 v3))". The value of range and list can be string(enclosed by " or '), integer or time(in format "2020-04-09 02:36:00"). All of these query patterns should be put in the query string "q=xxx" and splitted by ",". e.g. q=k1=v1,k2=~v2,k3=[min~max] + In: query + */ + Q *string + /*Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + In: query + */ + Sort *string + /*Bool value indicating whether return detailed information of the project + In: query + Default: true + */ + WithDetail *bool +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewListProjectsParams() beforehand. +func (o *ListProjectsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + qName, qhkName, _ := qs.GetOK("name") + if err := o.bindName(qName, qhkName, route.Formats); err != nil { + res = append(res, err) + } + + qOwner, qhkOwner, _ := qs.GetOK("owner") + if err := o.bindOwner(qOwner, qhkOwner, route.Formats); err != nil { + res = append(res, err) + } + + qPage, qhkPage, _ := qs.GetOK("page") + if err := o.bindPage(qPage, qhkPage, route.Formats); err != nil { + res = append(res, err) + } + + qPageSize, qhkPageSize, _ := qs.GetOK("page_size") + if err := o.bindPageSize(qPageSize, qhkPageSize, route.Formats); err != nil { + res = append(res, err) + } + + qPublic, qhkPublic, _ := qs.GetOK("public") + if err := o.bindPublic(qPublic, qhkPublic, route.Formats); err != nil { + res = append(res, err) + } + + qQ, qhkQ, _ := qs.GetOK("q") + if err := o.bindQ(qQ, qhkQ, route.Formats); err != nil { + res = append(res, err) + } + + qSort, qhkSort, _ := qs.GetOK("sort") + if err := o.bindSort(qSort, qhkSort, route.Formats); err != nil { + res = append(res, err) + } + + qWithDetail, qhkWithDetail, _ := qs.GetOK("with_detail") + if err := o.bindWithDetail(qWithDetail, qhkWithDetail, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *ListProjectsParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *ListProjectsParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindName binds and validates parameter Name from query. +func (o *ListProjectsParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Name = &raw + + return nil +} + +// bindOwner binds and validates parameter Owner from query. +func (o *ListProjectsParams) bindOwner(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Owner = &raw + + return nil +} + +// bindPage binds and validates parameter Page from query. +func (o *ListProjectsParams) bindPage(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListProjectsParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page", "query", "int64", raw) + } + o.Page = &value + + return nil +} + +// bindPageSize binds and validates parameter PageSize from query. +func (o *ListProjectsParams) bindPageSize(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListProjectsParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page_size", "query", "int64", raw) + } + o.PageSize = &value + + if err := o.validatePageSize(formats); err != nil { + return err + } + + return nil +} + +// validatePageSize carries on validations for parameter PageSize +func (o *ListProjectsParams) validatePageSize(formats strfmt.Registry) error { + + if err := validate.MaximumInt("page_size", "query", int64(*o.PageSize), 100, false); err != nil { + return err + } + + return nil +} + +// bindPublic binds and validates parameter Public from query. +func (o *ListProjectsParams) bindPublic(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("public", "query", "bool", raw) + } + o.Public = &value + + return nil +} + +// bindQ binds and validates parameter Q from query. +func (o *ListProjectsParams) bindQ(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Q = &raw + + return nil +} + +// bindSort binds and validates parameter Sort from query. +func (o *ListProjectsParams) bindSort(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Sort = &raw + + return nil +} + +// bindWithDetail binds and validates parameter WithDetail from query. +func (o *ListProjectsParams) bindWithDetail(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListProjectsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("with_detail", "query", "bool", raw) + } + o.WithDetail = &value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/project/list_projects_responses.go b/src/server/v2.0/restapi/operations/project/list_projects_responses.go new file mode 100644 index 000000000..644c5223a --- /dev/null +++ b/src/server/v2.0/restapi/operations/project/list_projects_responses.go @@ -0,0 +1,238 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/swag" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// ListProjectsOKCode is the HTTP code returned for type ListProjectsOK +const ListProjectsOKCode int = 200 + +/*ListProjectsOK Return all matched projects. + +swagger:response listProjectsOK +*/ +type ListProjectsOK struct { + /*Link refers to the previous page and next page + + */ + Link string `json:"Link"` + /*The total count of projects + + */ + XTotalCount int64 `json:"X-Total-Count"` + + /* + In: Body + */ + Payload []*models.Project `json:"body,omitempty"` +} + +// NewListProjectsOK creates ListProjectsOK with default headers values +func NewListProjectsOK() *ListProjectsOK { + + return &ListProjectsOK{} +} + +// WithLink adds the link to the list projects o k response +func (o *ListProjectsOK) WithLink(link string) *ListProjectsOK { + o.Link = link + return o +} + +// SetLink sets the link to the list projects o k response +func (o *ListProjectsOK) SetLink(link string) { + o.Link = link +} + +// WithXTotalCount adds the xTotalCount to the list projects o k response +func (o *ListProjectsOK) WithXTotalCount(xTotalCount int64) *ListProjectsOK { + o.XTotalCount = xTotalCount + return o +} + +// SetXTotalCount sets the xTotalCount to the list projects o k response +func (o *ListProjectsOK) SetXTotalCount(xTotalCount int64) { + o.XTotalCount = xTotalCount +} + +// WithPayload adds the payload to the list projects o k response +func (o *ListProjectsOK) WithPayload(payload []*models.Project) *ListProjectsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list projects o k response +func (o *ListProjectsOK) SetPayload(payload []*models.Project) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListProjectsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Link + + link := o.Link + if link != "" { + rw.Header().Set("Link", link) + } + + // response header X-Total-Count + + xTotalCount := swag.FormatInt64(o.XTotalCount) + if xTotalCount != "" { + rw.Header().Set("X-Total-Count", xTotalCount) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = make([]*models.Project, 0, 50) + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ListProjectsUnauthorizedCode is the HTTP code returned for type ListProjectsUnauthorized +const ListProjectsUnauthorizedCode int = 401 + +/*ListProjectsUnauthorized Unauthorized + +swagger:response listProjectsUnauthorized +*/ +type ListProjectsUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListProjectsUnauthorized creates ListProjectsUnauthorized with default headers values +func NewListProjectsUnauthorized() *ListProjectsUnauthorized { + + return &ListProjectsUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the list projects unauthorized response +func (o *ListProjectsUnauthorized) WithXRequestID(xRequestID string) *ListProjectsUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list projects unauthorized response +func (o *ListProjectsUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list projects unauthorized response +func (o *ListProjectsUnauthorized) WithPayload(payload *models.Errors) *ListProjectsUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list projects unauthorized response +func (o *ListProjectsUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListProjectsUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListProjectsInternalServerErrorCode is the HTTP code returned for type ListProjectsInternalServerError +const ListProjectsInternalServerErrorCode int = 500 + +/*ListProjectsInternalServerError Internal server error + +swagger:response listProjectsInternalServerError +*/ +type ListProjectsInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListProjectsInternalServerError creates ListProjectsInternalServerError with default headers values +func NewListProjectsInternalServerError() *ListProjectsInternalServerError { + + return &ListProjectsInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the list projects internal server error response +func (o *ListProjectsInternalServerError) WithXRequestID(xRequestID string) *ListProjectsInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list projects internal server error response +func (o *ListProjectsInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list projects internal server error response +func (o *ListProjectsInternalServerError) WithPayload(payload *models.Errors) *ListProjectsInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list projects internal server error response +func (o *ListProjectsInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListProjectsInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/project/list_projects_urlbuilder.go b/src/server/v2.0/restapi/operations/project/list_projects_urlbuilder.go new file mode 100644 index 000000000..34ad27b1d --- /dev/null +++ b/src/server/v2.0/restapi/operations/project/list_projects_urlbuilder.go @@ -0,0 +1,168 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// ListProjectsURL generates an URL for the list projects operation +type ListProjectsURL struct { + Name *string + Owner *string + Page *int64 + PageSize *int64 + Public *bool + Q *string + Sort *string + WithDetail *bool + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListProjectsURL) WithBasePath(bp string) *ListProjectsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListProjectsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ListProjectsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var nameQ string + if o.Name != nil { + nameQ = *o.Name + } + if nameQ != "" { + qs.Set("name", nameQ) + } + + var ownerQ string + if o.Owner != nil { + ownerQ = *o.Owner + } + if ownerQ != "" { + qs.Set("owner", ownerQ) + } + + var pageQ string + if o.Page != nil { + pageQ = swag.FormatInt64(*o.Page) + } + if pageQ != "" { + qs.Set("page", pageQ) + } + + var pageSizeQ string + if o.PageSize != nil { + pageSizeQ = swag.FormatInt64(*o.PageSize) + } + if pageSizeQ != "" { + qs.Set("page_size", pageSizeQ) + } + + var publicQ string + if o.Public != nil { + publicQ = swag.FormatBool(*o.Public) + } + if publicQ != "" { + qs.Set("public", publicQ) + } + + var qQ string + if o.Q != nil { + qQ = *o.Q + } + if qQ != "" { + qs.Set("q", qQ) + } + + var sortQ string + if o.Sort != nil { + sortQ = *o.Sort + } + if sortQ != "" { + qs.Set("sort", sortQ) + } + + var withDetailQ string + if o.WithDetail != nil { + withDetailQ = swag.FormatBool(*o.WithDetail) + } + if withDetailQ != "" { + qs.Set("with_detail", withDetailQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ListProjectsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ListProjectsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ListProjectsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ListProjectsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ListProjectsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ListProjectsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/project/list_scanner_candidates_of_project.go b/src/server/v2.0/restapi/operations/project/list_scanner_candidates_of_project.go new file mode 100644 index 000000000..058df5ac0 --- /dev/null +++ b/src/server/v2.0/restapi/operations/project/list_scanner_candidates_of_project.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ListScannerCandidatesOfProjectHandlerFunc turns a function with the right signature into a list scanner candidates of project handler +type ListScannerCandidatesOfProjectHandlerFunc func(ListScannerCandidatesOfProjectParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ListScannerCandidatesOfProjectHandlerFunc) Handle(params ListScannerCandidatesOfProjectParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ListScannerCandidatesOfProjectHandler interface for that can handle valid list scanner candidates of project params +type ListScannerCandidatesOfProjectHandler interface { + Handle(ListScannerCandidatesOfProjectParams, interface{}) middleware.Responder +} + +// NewListScannerCandidatesOfProject creates a new http.Handler for the list scanner candidates of project operation +func NewListScannerCandidatesOfProject(ctx *middleware.Context, handler ListScannerCandidatesOfProjectHandler) *ListScannerCandidatesOfProject { + return &ListScannerCandidatesOfProject{Context: ctx, Handler: handler} +} + +/*ListScannerCandidatesOfProject swagger:route GET /projects/{project_name_or_id}/scanner/candidates project listScannerCandidatesOfProject + +Get scanner registration candidates for configurating project level scanner + +Retrieve the system configured scanner registrations as candidates of setting project level scanner. + +*/ +type ListScannerCandidatesOfProject struct { + Context *middleware.Context + Handler ListScannerCandidatesOfProjectHandler +} + +func (o *ListScannerCandidatesOfProject) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewListScannerCandidatesOfProjectParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/project/list_scanner_candidates_of_project_parameters.go b/src/server/v2.0/restapi/operations/project/list_scanner_candidates_of_project_parameters.go new file mode 100644 index 000000000..dcde22324 --- /dev/null +++ b/src/server/v2.0/restapi/operations/project/list_scanner_candidates_of_project_parameters.go @@ -0,0 +1,300 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewListScannerCandidatesOfProjectParams creates a new ListScannerCandidatesOfProjectParams object +// with the default values initialized. +func NewListScannerCandidatesOfProjectParams() ListScannerCandidatesOfProjectParams { + + var ( + // initialize parameters with default values + + xIsResourceNameDefault = bool(false) + + pageDefault = int64(1) + pageSizeDefault = int64(10) + ) + + return ListScannerCandidatesOfProjectParams{ + XIsResourceName: &xIsResourceNameDefault, + + Page: &pageDefault, + + PageSize: &pageSizeDefault, + } +} + +// ListScannerCandidatesOfProjectParams contains all the bound params for the list scanner candidates of project operation +// typically these are obtained from a http.Request +// +// swagger:parameters listScannerCandidatesOfProject +type ListScannerCandidatesOfProjectParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name. + In: header + Default: false + */ + XIsResourceName *bool + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The page number + In: query + Default: 1 + */ + Page *int64 + /*The size of per page + Maximum: 100 + In: query + Default: 10 + */ + PageSize *int64 + /*The name or id of the project + Required: true + In: path + */ + ProjectNameOrID string + /*Query string to query resources. Supported query patterns are "exact match(k=v)", "fuzzy match(k=~v)", "range(k=[min~max])", "list with union releationship(k={v1 v2 v3})" and "list with intersetion relationship(k=(v1 v2 v3))". The value of range and list can be string(enclosed by " or '), integer or time(in format "2020-04-09 02:36:00"). All of these query patterns should be put in the query string "q=xxx" and splitted by ",". e.g. q=k1=v1,k2=~v2,k3=[min~max] + In: query + */ + Q *string + /*Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + In: query + */ + Sort *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewListScannerCandidatesOfProjectParams() beforehand. +func (o *ListScannerCandidatesOfProjectParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if err := o.bindXIsResourceName(r.Header[http.CanonicalHeaderKey("X-Is-Resource-Name")], true, route.Formats); err != nil { + res = append(res, err) + } + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + qPage, qhkPage, _ := qs.GetOK("page") + if err := o.bindPage(qPage, qhkPage, route.Formats); err != nil { + res = append(res, err) + } + + qPageSize, qhkPageSize, _ := qs.GetOK("page_size") + if err := o.bindPageSize(qPageSize, qhkPageSize, route.Formats); err != nil { + res = append(res, err) + } + + rProjectNameOrID, rhkProjectNameOrID, _ := route.Params.GetOK("project_name_or_id") + if err := o.bindProjectNameOrID(rProjectNameOrID, rhkProjectNameOrID, route.Formats); err != nil { + res = append(res, err) + } + + qQ, qhkQ, _ := qs.GetOK("q") + if err := o.bindQ(qQ, qhkQ, route.Formats); err != nil { + res = append(res, err) + } + + qSort, qhkSort, _ := qs.GetOK("sort") + if err := o.bindSort(qSort, qhkSort, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXIsResourceName binds and validates parameter XIsResourceName from header. +func (o *ListScannerCandidatesOfProjectParams) bindXIsResourceName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListScannerCandidatesOfProjectParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("X-Is-Resource-Name", "header", "bool", raw) + } + o.XIsResourceName = &value + + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *ListScannerCandidatesOfProjectParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *ListScannerCandidatesOfProjectParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindPage binds and validates parameter Page from query. +func (o *ListScannerCandidatesOfProjectParams) bindPage(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListScannerCandidatesOfProjectParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page", "query", "int64", raw) + } + o.Page = &value + + return nil +} + +// bindPageSize binds and validates parameter PageSize from query. +func (o *ListScannerCandidatesOfProjectParams) bindPageSize(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListScannerCandidatesOfProjectParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page_size", "query", "int64", raw) + } + o.PageSize = &value + + if err := o.validatePageSize(formats); err != nil { + return err + } + + return nil +} + +// validatePageSize carries on validations for parameter PageSize +func (o *ListScannerCandidatesOfProjectParams) validatePageSize(formats strfmt.Registry) error { + + if err := validate.MaximumInt("page_size", "query", int64(*o.PageSize), 100, false); err != nil { + return err + } + + return nil +} + +// bindProjectNameOrID binds and validates parameter ProjectNameOrID from path. +func (o *ListScannerCandidatesOfProjectParams) bindProjectNameOrID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectNameOrID = raw + + return nil +} + +// bindQ binds and validates parameter Q from query. +func (o *ListScannerCandidatesOfProjectParams) bindQ(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Q = &raw + + return nil +} + +// bindSort binds and validates parameter Sort from query. +func (o *ListScannerCandidatesOfProjectParams) bindSort(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Sort = &raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/project/list_scanner_candidates_of_project_responses.go b/src/server/v2.0/restapi/operations/project/list_scanner_candidates_of_project_responses.go new file mode 100644 index 000000000..8ff5bf15e --- /dev/null +++ b/src/server/v2.0/restapi/operations/project/list_scanner_candidates_of_project_responses.go @@ -0,0 +1,370 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/swag" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// ListScannerCandidatesOfProjectOKCode is the HTTP code returned for type ListScannerCandidatesOfProjectOK +const ListScannerCandidatesOfProjectOKCode int = 200 + +/*ListScannerCandidatesOfProjectOK A list of scanner registrations. + +swagger:response listScannerCandidatesOfProjectOK +*/ +type ListScannerCandidatesOfProjectOK struct { + /*Link to previous page and next page + + */ + Link string `json:"Link"` + /*The total count of available items + + */ + XTotalCount int64 `json:"X-Total-Count"` + + /* + In: Body + */ + Payload []*models.ScannerRegistration `json:"body,omitempty"` +} + +// NewListScannerCandidatesOfProjectOK creates ListScannerCandidatesOfProjectOK with default headers values +func NewListScannerCandidatesOfProjectOK() *ListScannerCandidatesOfProjectOK { + + return &ListScannerCandidatesOfProjectOK{} +} + +// WithLink adds the link to the list scanner candidates of project o k response +func (o *ListScannerCandidatesOfProjectOK) WithLink(link string) *ListScannerCandidatesOfProjectOK { + o.Link = link + return o +} + +// SetLink sets the link to the list scanner candidates of project o k response +func (o *ListScannerCandidatesOfProjectOK) SetLink(link string) { + o.Link = link +} + +// WithXTotalCount adds the xTotalCount to the list scanner candidates of project o k response +func (o *ListScannerCandidatesOfProjectOK) WithXTotalCount(xTotalCount int64) *ListScannerCandidatesOfProjectOK { + o.XTotalCount = xTotalCount + return o +} + +// SetXTotalCount sets the xTotalCount to the list scanner candidates of project o k response +func (o *ListScannerCandidatesOfProjectOK) SetXTotalCount(xTotalCount int64) { + o.XTotalCount = xTotalCount +} + +// WithPayload adds the payload to the list scanner candidates of project o k response +func (o *ListScannerCandidatesOfProjectOK) WithPayload(payload []*models.ScannerRegistration) *ListScannerCandidatesOfProjectOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list scanner candidates of project o k response +func (o *ListScannerCandidatesOfProjectOK) SetPayload(payload []*models.ScannerRegistration) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListScannerCandidatesOfProjectOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Link + + link := o.Link + if link != "" { + rw.Header().Set("Link", link) + } + + // response header X-Total-Count + + xTotalCount := swag.FormatInt64(o.XTotalCount) + if xTotalCount != "" { + rw.Header().Set("X-Total-Count", xTotalCount) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = make([]*models.ScannerRegistration, 0, 50) + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ListScannerCandidatesOfProjectBadRequestCode is the HTTP code returned for type ListScannerCandidatesOfProjectBadRequest +const ListScannerCandidatesOfProjectBadRequestCode int = 400 + +/*ListScannerCandidatesOfProjectBadRequest Bad request + +swagger:response listScannerCandidatesOfProjectBadRequest +*/ +type ListScannerCandidatesOfProjectBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListScannerCandidatesOfProjectBadRequest creates ListScannerCandidatesOfProjectBadRequest with default headers values +func NewListScannerCandidatesOfProjectBadRequest() *ListScannerCandidatesOfProjectBadRequest { + + return &ListScannerCandidatesOfProjectBadRequest{} +} + +// WithXRequestID adds the xRequestId to the list scanner candidates of project bad request response +func (o *ListScannerCandidatesOfProjectBadRequest) WithXRequestID(xRequestID string) *ListScannerCandidatesOfProjectBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list scanner candidates of project bad request response +func (o *ListScannerCandidatesOfProjectBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list scanner candidates of project bad request response +func (o *ListScannerCandidatesOfProjectBadRequest) WithPayload(payload *models.Errors) *ListScannerCandidatesOfProjectBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list scanner candidates of project bad request response +func (o *ListScannerCandidatesOfProjectBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListScannerCandidatesOfProjectBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListScannerCandidatesOfProjectUnauthorizedCode is the HTTP code returned for type ListScannerCandidatesOfProjectUnauthorized +const ListScannerCandidatesOfProjectUnauthorizedCode int = 401 + +/*ListScannerCandidatesOfProjectUnauthorized Unauthorized + +swagger:response listScannerCandidatesOfProjectUnauthorized +*/ +type ListScannerCandidatesOfProjectUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListScannerCandidatesOfProjectUnauthorized creates ListScannerCandidatesOfProjectUnauthorized with default headers values +func NewListScannerCandidatesOfProjectUnauthorized() *ListScannerCandidatesOfProjectUnauthorized { + + return &ListScannerCandidatesOfProjectUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the list scanner candidates of project unauthorized response +func (o *ListScannerCandidatesOfProjectUnauthorized) WithXRequestID(xRequestID string) *ListScannerCandidatesOfProjectUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list scanner candidates of project unauthorized response +func (o *ListScannerCandidatesOfProjectUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list scanner candidates of project unauthorized response +func (o *ListScannerCandidatesOfProjectUnauthorized) WithPayload(payload *models.Errors) *ListScannerCandidatesOfProjectUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list scanner candidates of project unauthorized response +func (o *ListScannerCandidatesOfProjectUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListScannerCandidatesOfProjectUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListScannerCandidatesOfProjectForbiddenCode is the HTTP code returned for type ListScannerCandidatesOfProjectForbidden +const ListScannerCandidatesOfProjectForbiddenCode int = 403 + +/*ListScannerCandidatesOfProjectForbidden Forbidden + +swagger:response listScannerCandidatesOfProjectForbidden +*/ +type ListScannerCandidatesOfProjectForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListScannerCandidatesOfProjectForbidden creates ListScannerCandidatesOfProjectForbidden with default headers values +func NewListScannerCandidatesOfProjectForbidden() *ListScannerCandidatesOfProjectForbidden { + + return &ListScannerCandidatesOfProjectForbidden{} +} + +// WithXRequestID adds the xRequestId to the list scanner candidates of project forbidden response +func (o *ListScannerCandidatesOfProjectForbidden) WithXRequestID(xRequestID string) *ListScannerCandidatesOfProjectForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list scanner candidates of project forbidden response +func (o *ListScannerCandidatesOfProjectForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list scanner candidates of project forbidden response +func (o *ListScannerCandidatesOfProjectForbidden) WithPayload(payload *models.Errors) *ListScannerCandidatesOfProjectForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list scanner candidates of project forbidden response +func (o *ListScannerCandidatesOfProjectForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListScannerCandidatesOfProjectForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListScannerCandidatesOfProjectInternalServerErrorCode is the HTTP code returned for type ListScannerCandidatesOfProjectInternalServerError +const ListScannerCandidatesOfProjectInternalServerErrorCode int = 500 + +/*ListScannerCandidatesOfProjectInternalServerError Internal server error + +swagger:response listScannerCandidatesOfProjectInternalServerError +*/ +type ListScannerCandidatesOfProjectInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListScannerCandidatesOfProjectInternalServerError creates ListScannerCandidatesOfProjectInternalServerError with default headers values +func NewListScannerCandidatesOfProjectInternalServerError() *ListScannerCandidatesOfProjectInternalServerError { + + return &ListScannerCandidatesOfProjectInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the list scanner candidates of project internal server error response +func (o *ListScannerCandidatesOfProjectInternalServerError) WithXRequestID(xRequestID string) *ListScannerCandidatesOfProjectInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list scanner candidates of project internal server error response +func (o *ListScannerCandidatesOfProjectInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list scanner candidates of project internal server error response +func (o *ListScannerCandidatesOfProjectInternalServerError) WithPayload(payload *models.Errors) *ListScannerCandidatesOfProjectInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list scanner candidates of project internal server error response +func (o *ListScannerCandidatesOfProjectInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListScannerCandidatesOfProjectInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/project/list_scanner_candidates_of_project_urlbuilder.go b/src/server/v2.0/restapi/operations/project/list_scanner_candidates_of_project_urlbuilder.go new file mode 100644 index 000000000..36214579f --- /dev/null +++ b/src/server/v2.0/restapi/operations/project/list_scanner_candidates_of_project_urlbuilder.go @@ -0,0 +1,142 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ListScannerCandidatesOfProjectURL generates an URL for the list scanner candidates of project operation +type ListScannerCandidatesOfProjectURL struct { + ProjectNameOrID string + + Page *int64 + PageSize *int64 + Q *string + Sort *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListScannerCandidatesOfProjectURL) WithBasePath(bp string) *ListScannerCandidatesOfProjectURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListScannerCandidatesOfProjectURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ListScannerCandidatesOfProjectURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name_or_id}/scanner/candidates" + + projectNameOrID := o.ProjectNameOrID + if projectNameOrID != "" { + _path = strings.Replace(_path, "{project_name_or_id}", projectNameOrID, -1) + } else { + return nil, errors.New("projectNameOrId is required on ListScannerCandidatesOfProjectURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var pageQ string + if o.Page != nil { + pageQ = swag.FormatInt64(*o.Page) + } + if pageQ != "" { + qs.Set("page", pageQ) + } + + var pageSizeQ string + if o.PageSize != nil { + pageSizeQ = swag.FormatInt64(*o.PageSize) + } + if pageSizeQ != "" { + qs.Set("page_size", pageSizeQ) + } + + var qQ string + if o.Q != nil { + qQ = *o.Q + } + if qQ != "" { + qs.Set("q", qQ) + } + + var sortQ string + if o.Sort != nil { + sortQ = *o.Sort + } + if sortQ != "" { + qs.Set("sort", sortQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ListScannerCandidatesOfProjectURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ListScannerCandidatesOfProjectURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ListScannerCandidatesOfProjectURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ListScannerCandidatesOfProjectURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ListScannerCandidatesOfProjectURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ListScannerCandidatesOfProjectURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/project/set_scanner_of_project.go b/src/server/v2.0/restapi/operations/project/set_scanner_of_project.go new file mode 100644 index 000000000..bc22e5208 --- /dev/null +++ b/src/server/v2.0/restapi/operations/project/set_scanner_of_project.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// SetScannerOfProjectHandlerFunc turns a function with the right signature into a set scanner of project handler +type SetScannerOfProjectHandlerFunc func(SetScannerOfProjectParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn SetScannerOfProjectHandlerFunc) Handle(params SetScannerOfProjectParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// SetScannerOfProjectHandler interface for that can handle valid set scanner of project params +type SetScannerOfProjectHandler interface { + Handle(SetScannerOfProjectParams, interface{}) middleware.Responder +} + +// NewSetScannerOfProject creates a new http.Handler for the set scanner of project operation +func NewSetScannerOfProject(ctx *middleware.Context, handler SetScannerOfProjectHandler) *SetScannerOfProject { + return &SetScannerOfProject{Context: ctx, Handler: handler} +} + +/*SetScannerOfProject swagger:route PUT /projects/{project_name_or_id}/scanner project setScannerOfProject + +Configure scanner for the specified project + +Set one of the system configured scanner registration as the indepndent scanner of the specified project. + +*/ +type SetScannerOfProject struct { + Context *middleware.Context + Handler SetScannerOfProjectHandler +} + +func (o *SetScannerOfProject) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewSetScannerOfProjectParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/project/set_scanner_of_project_parameters.go b/src/server/v2.0/restapi/operations/project/set_scanner_of_project_parameters.go new file mode 100644 index 000000000..047b2d882 --- /dev/null +++ b/src/server/v2.0/restapi/operations/project/set_scanner_of_project_parameters.go @@ -0,0 +1,186 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewSetScannerOfProjectParams creates a new SetScannerOfProjectParams object +// with the default values initialized. +func NewSetScannerOfProjectParams() SetScannerOfProjectParams { + + var ( + // initialize parameters with default values + + xIsResourceNameDefault = bool(false) + ) + + return SetScannerOfProjectParams{ + XIsResourceName: &xIsResourceNameDefault, + } +} + +// SetScannerOfProjectParams contains all the bound params for the set scanner of project operation +// typically these are obtained from a http.Request +// +// swagger:parameters setScannerOfProject +type SetScannerOfProjectParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name. + In: header + Default: false + */ + XIsResourceName *bool + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /* + Required: true + In: body + */ + Payload *models.ProjectScanner + /*The name or id of the project + Required: true + In: path + */ + ProjectNameOrID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewSetScannerOfProjectParams() beforehand. +func (o *SetScannerOfProjectParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXIsResourceName(r.Header[http.CanonicalHeaderKey("X-Is-Resource-Name")], true, route.Formats); err != nil { + res = append(res, err) + } + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.ProjectScanner + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("payload", "body", "")) + } else { + res = append(res, errors.NewParseError("payload", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Payload = &body + } + } + } else { + res = append(res, errors.Required("payload", "body", "")) + } + rProjectNameOrID, rhkProjectNameOrID, _ := route.Params.GetOK("project_name_or_id") + if err := o.bindProjectNameOrID(rProjectNameOrID, rhkProjectNameOrID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXIsResourceName binds and validates parameter XIsResourceName from header. +func (o *SetScannerOfProjectParams) bindXIsResourceName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewSetScannerOfProjectParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("X-Is-Resource-Name", "header", "bool", raw) + } + o.XIsResourceName = &value + + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *SetScannerOfProjectParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *SetScannerOfProjectParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindProjectNameOrID binds and validates parameter ProjectNameOrID from path. +func (o *SetScannerOfProjectParams) bindProjectNameOrID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectNameOrID = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/project/set_scanner_of_project_responses.go b/src/server/v2.0/restapi/operations/project/set_scanner_of_project_responses.go new file mode 100644 index 000000000..f9f4c6215 --- /dev/null +++ b/src/server/v2.0/restapi/operations/project/set_scanner_of_project_responses.go @@ -0,0 +1,390 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// SetScannerOfProjectOKCode is the HTTP code returned for type SetScannerOfProjectOK +const SetScannerOfProjectOKCode int = 200 + +/*SetScannerOfProjectOK Success + +swagger:response setScannerOfProjectOK +*/ +type SetScannerOfProjectOK struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewSetScannerOfProjectOK creates SetScannerOfProjectOK with default headers values +func NewSetScannerOfProjectOK() *SetScannerOfProjectOK { + + return &SetScannerOfProjectOK{} +} + +// WithXRequestID adds the xRequestId to the set scanner of project o k response +func (o *SetScannerOfProjectOK) WithXRequestID(xRequestID string) *SetScannerOfProjectOK { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the set scanner of project o k response +func (o *SetScannerOfProjectOK) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *SetScannerOfProjectOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// SetScannerOfProjectBadRequestCode is the HTTP code returned for type SetScannerOfProjectBadRequest +const SetScannerOfProjectBadRequestCode int = 400 + +/*SetScannerOfProjectBadRequest Bad request + +swagger:response setScannerOfProjectBadRequest +*/ +type SetScannerOfProjectBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewSetScannerOfProjectBadRequest creates SetScannerOfProjectBadRequest with default headers values +func NewSetScannerOfProjectBadRequest() *SetScannerOfProjectBadRequest { + + return &SetScannerOfProjectBadRequest{} +} + +// WithXRequestID adds the xRequestId to the set scanner of project bad request response +func (o *SetScannerOfProjectBadRequest) WithXRequestID(xRequestID string) *SetScannerOfProjectBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the set scanner of project bad request response +func (o *SetScannerOfProjectBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the set scanner of project bad request response +func (o *SetScannerOfProjectBadRequest) WithPayload(payload *models.Errors) *SetScannerOfProjectBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the set scanner of project bad request response +func (o *SetScannerOfProjectBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *SetScannerOfProjectBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// SetScannerOfProjectUnauthorizedCode is the HTTP code returned for type SetScannerOfProjectUnauthorized +const SetScannerOfProjectUnauthorizedCode int = 401 + +/*SetScannerOfProjectUnauthorized Unauthorized + +swagger:response setScannerOfProjectUnauthorized +*/ +type SetScannerOfProjectUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewSetScannerOfProjectUnauthorized creates SetScannerOfProjectUnauthorized with default headers values +func NewSetScannerOfProjectUnauthorized() *SetScannerOfProjectUnauthorized { + + return &SetScannerOfProjectUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the set scanner of project unauthorized response +func (o *SetScannerOfProjectUnauthorized) WithXRequestID(xRequestID string) *SetScannerOfProjectUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the set scanner of project unauthorized response +func (o *SetScannerOfProjectUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the set scanner of project unauthorized response +func (o *SetScannerOfProjectUnauthorized) WithPayload(payload *models.Errors) *SetScannerOfProjectUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the set scanner of project unauthorized response +func (o *SetScannerOfProjectUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *SetScannerOfProjectUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// SetScannerOfProjectForbiddenCode is the HTTP code returned for type SetScannerOfProjectForbidden +const SetScannerOfProjectForbiddenCode int = 403 + +/*SetScannerOfProjectForbidden Forbidden + +swagger:response setScannerOfProjectForbidden +*/ +type SetScannerOfProjectForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewSetScannerOfProjectForbidden creates SetScannerOfProjectForbidden with default headers values +func NewSetScannerOfProjectForbidden() *SetScannerOfProjectForbidden { + + return &SetScannerOfProjectForbidden{} +} + +// WithXRequestID adds the xRequestId to the set scanner of project forbidden response +func (o *SetScannerOfProjectForbidden) WithXRequestID(xRequestID string) *SetScannerOfProjectForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the set scanner of project forbidden response +func (o *SetScannerOfProjectForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the set scanner of project forbidden response +func (o *SetScannerOfProjectForbidden) WithPayload(payload *models.Errors) *SetScannerOfProjectForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the set scanner of project forbidden response +func (o *SetScannerOfProjectForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *SetScannerOfProjectForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// SetScannerOfProjectNotFoundCode is the HTTP code returned for type SetScannerOfProjectNotFound +const SetScannerOfProjectNotFoundCode int = 404 + +/*SetScannerOfProjectNotFound Not found + +swagger:response setScannerOfProjectNotFound +*/ +type SetScannerOfProjectNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewSetScannerOfProjectNotFound creates SetScannerOfProjectNotFound with default headers values +func NewSetScannerOfProjectNotFound() *SetScannerOfProjectNotFound { + + return &SetScannerOfProjectNotFound{} +} + +// WithXRequestID adds the xRequestId to the set scanner of project not found response +func (o *SetScannerOfProjectNotFound) WithXRequestID(xRequestID string) *SetScannerOfProjectNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the set scanner of project not found response +func (o *SetScannerOfProjectNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the set scanner of project not found response +func (o *SetScannerOfProjectNotFound) WithPayload(payload *models.Errors) *SetScannerOfProjectNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the set scanner of project not found response +func (o *SetScannerOfProjectNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *SetScannerOfProjectNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// SetScannerOfProjectInternalServerErrorCode is the HTTP code returned for type SetScannerOfProjectInternalServerError +const SetScannerOfProjectInternalServerErrorCode int = 500 + +/*SetScannerOfProjectInternalServerError Internal server error + +swagger:response setScannerOfProjectInternalServerError +*/ +type SetScannerOfProjectInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewSetScannerOfProjectInternalServerError creates SetScannerOfProjectInternalServerError with default headers values +func NewSetScannerOfProjectInternalServerError() *SetScannerOfProjectInternalServerError { + + return &SetScannerOfProjectInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the set scanner of project internal server error response +func (o *SetScannerOfProjectInternalServerError) WithXRequestID(xRequestID string) *SetScannerOfProjectInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the set scanner of project internal server error response +func (o *SetScannerOfProjectInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the set scanner of project internal server error response +func (o *SetScannerOfProjectInternalServerError) WithPayload(payload *models.Errors) *SetScannerOfProjectInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the set scanner of project internal server error response +func (o *SetScannerOfProjectInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *SetScannerOfProjectInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/project/set_scanner_of_project_urlbuilder.go b/src/server/v2.0/restapi/operations/project/set_scanner_of_project_urlbuilder.go new file mode 100644 index 000000000..978c7daa8 --- /dev/null +++ b/src/server/v2.0/restapi/operations/project/set_scanner_of_project_urlbuilder.go @@ -0,0 +1,99 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// SetScannerOfProjectURL generates an URL for the set scanner of project operation +type SetScannerOfProjectURL struct { + ProjectNameOrID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *SetScannerOfProjectURL) WithBasePath(bp string) *SetScannerOfProjectURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *SetScannerOfProjectURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *SetScannerOfProjectURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name_or_id}/scanner" + + projectNameOrID := o.ProjectNameOrID + if projectNameOrID != "" { + _path = strings.Replace(_path, "{project_name_or_id}", projectNameOrID, -1) + } else { + return nil, errors.New("projectNameOrId is required on SetScannerOfProjectURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *SetScannerOfProjectURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *SetScannerOfProjectURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *SetScannerOfProjectURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on SetScannerOfProjectURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on SetScannerOfProjectURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *SetScannerOfProjectURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/project/update_project.go b/src/server/v2.0/restapi/operations/project/update_project.go new file mode 100644 index 000000000..e47678a7a --- /dev/null +++ b/src/server/v2.0/restapi/operations/project/update_project.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// UpdateProjectHandlerFunc turns a function with the right signature into a update project handler +type UpdateProjectHandlerFunc func(UpdateProjectParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn UpdateProjectHandlerFunc) Handle(params UpdateProjectParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// UpdateProjectHandler interface for that can handle valid update project params +type UpdateProjectHandler interface { + Handle(UpdateProjectParams, interface{}) middleware.Responder +} + +// NewUpdateProject creates a new http.Handler for the update project operation +func NewUpdateProject(ctx *middleware.Context, handler UpdateProjectHandler) *UpdateProject { + return &UpdateProject{Context: ctx, Handler: handler} +} + +/*UpdateProject swagger:route PUT /projects/{project_name_or_id} project updateProject + +Update properties for a selected project. + +This endpoint is aimed to update the properties of a project. + +*/ +type UpdateProject struct { + Context *middleware.Context + Handler UpdateProjectHandler +} + +func (o *UpdateProject) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewUpdateProjectParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/project/update_project_parameters.go b/src/server/v2.0/restapi/operations/project/update_project_parameters.go new file mode 100644 index 000000000..75b38cdab --- /dev/null +++ b/src/server/v2.0/restapi/operations/project/update_project_parameters.go @@ -0,0 +1,186 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewUpdateProjectParams creates a new UpdateProjectParams object +// with the default values initialized. +func NewUpdateProjectParams() UpdateProjectParams { + + var ( + // initialize parameters with default values + + xIsResourceNameDefault = bool(false) + ) + + return UpdateProjectParams{ + XIsResourceName: &xIsResourceNameDefault, + } +} + +// UpdateProjectParams contains all the bound params for the update project operation +// typically these are obtained from a http.Request +// +// swagger:parameters updateProject +type UpdateProjectParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name. + In: header + Default: false + */ + XIsResourceName *bool + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*Updates of project. + Required: true + In: body + */ + Project *models.ProjectReq + /*The name or id of the project + Required: true + In: path + */ + ProjectNameOrID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewUpdateProjectParams() beforehand. +func (o *UpdateProjectParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXIsResourceName(r.Header[http.CanonicalHeaderKey("X-Is-Resource-Name")], true, route.Formats); err != nil { + res = append(res, err) + } + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.ProjectReq + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("project", "body", "")) + } else { + res = append(res, errors.NewParseError("project", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Project = &body + } + } + } else { + res = append(res, errors.Required("project", "body", "")) + } + rProjectNameOrID, rhkProjectNameOrID, _ := route.Params.GetOK("project_name_or_id") + if err := o.bindProjectNameOrID(rProjectNameOrID, rhkProjectNameOrID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXIsResourceName binds and validates parameter XIsResourceName from header. +func (o *UpdateProjectParams) bindXIsResourceName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewUpdateProjectParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("X-Is-Resource-Name", "header", "bool", raw) + } + o.XIsResourceName = &value + + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *UpdateProjectParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *UpdateProjectParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindProjectNameOrID binds and validates parameter ProjectNameOrID from path. +func (o *UpdateProjectParams) bindProjectNameOrID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectNameOrID = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/project/update_project_responses.go b/src/server/v2.0/restapi/operations/project/update_project_responses.go new file mode 100644 index 000000000..488e2e6be --- /dev/null +++ b/src/server/v2.0/restapi/operations/project/update_project_responses.go @@ -0,0 +1,390 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// UpdateProjectOKCode is the HTTP code returned for type UpdateProjectOK +const UpdateProjectOKCode int = 200 + +/*UpdateProjectOK Success + +swagger:response updateProjectOK +*/ +type UpdateProjectOK struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewUpdateProjectOK creates UpdateProjectOK with default headers values +func NewUpdateProjectOK() *UpdateProjectOK { + + return &UpdateProjectOK{} +} + +// WithXRequestID adds the xRequestId to the update project o k response +func (o *UpdateProjectOK) WithXRequestID(xRequestID string) *UpdateProjectOK { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update project o k response +func (o *UpdateProjectOK) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *UpdateProjectOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// UpdateProjectBadRequestCode is the HTTP code returned for type UpdateProjectBadRequest +const UpdateProjectBadRequestCode int = 400 + +/*UpdateProjectBadRequest Bad request + +swagger:response updateProjectBadRequest +*/ +type UpdateProjectBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateProjectBadRequest creates UpdateProjectBadRequest with default headers values +func NewUpdateProjectBadRequest() *UpdateProjectBadRequest { + + return &UpdateProjectBadRequest{} +} + +// WithXRequestID adds the xRequestId to the update project bad request response +func (o *UpdateProjectBadRequest) WithXRequestID(xRequestID string) *UpdateProjectBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update project bad request response +func (o *UpdateProjectBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update project bad request response +func (o *UpdateProjectBadRequest) WithPayload(payload *models.Errors) *UpdateProjectBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update project bad request response +func (o *UpdateProjectBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateProjectBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateProjectUnauthorizedCode is the HTTP code returned for type UpdateProjectUnauthorized +const UpdateProjectUnauthorizedCode int = 401 + +/*UpdateProjectUnauthorized Unauthorized + +swagger:response updateProjectUnauthorized +*/ +type UpdateProjectUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateProjectUnauthorized creates UpdateProjectUnauthorized with default headers values +func NewUpdateProjectUnauthorized() *UpdateProjectUnauthorized { + + return &UpdateProjectUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the update project unauthorized response +func (o *UpdateProjectUnauthorized) WithXRequestID(xRequestID string) *UpdateProjectUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update project unauthorized response +func (o *UpdateProjectUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update project unauthorized response +func (o *UpdateProjectUnauthorized) WithPayload(payload *models.Errors) *UpdateProjectUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update project unauthorized response +func (o *UpdateProjectUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateProjectUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateProjectForbiddenCode is the HTTP code returned for type UpdateProjectForbidden +const UpdateProjectForbiddenCode int = 403 + +/*UpdateProjectForbidden Forbidden + +swagger:response updateProjectForbidden +*/ +type UpdateProjectForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateProjectForbidden creates UpdateProjectForbidden with default headers values +func NewUpdateProjectForbidden() *UpdateProjectForbidden { + + return &UpdateProjectForbidden{} +} + +// WithXRequestID adds the xRequestId to the update project forbidden response +func (o *UpdateProjectForbidden) WithXRequestID(xRequestID string) *UpdateProjectForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update project forbidden response +func (o *UpdateProjectForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update project forbidden response +func (o *UpdateProjectForbidden) WithPayload(payload *models.Errors) *UpdateProjectForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update project forbidden response +func (o *UpdateProjectForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateProjectForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateProjectNotFoundCode is the HTTP code returned for type UpdateProjectNotFound +const UpdateProjectNotFoundCode int = 404 + +/*UpdateProjectNotFound Not found + +swagger:response updateProjectNotFound +*/ +type UpdateProjectNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateProjectNotFound creates UpdateProjectNotFound with default headers values +func NewUpdateProjectNotFound() *UpdateProjectNotFound { + + return &UpdateProjectNotFound{} +} + +// WithXRequestID adds the xRequestId to the update project not found response +func (o *UpdateProjectNotFound) WithXRequestID(xRequestID string) *UpdateProjectNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update project not found response +func (o *UpdateProjectNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update project not found response +func (o *UpdateProjectNotFound) WithPayload(payload *models.Errors) *UpdateProjectNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update project not found response +func (o *UpdateProjectNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateProjectNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateProjectInternalServerErrorCode is the HTTP code returned for type UpdateProjectInternalServerError +const UpdateProjectInternalServerErrorCode int = 500 + +/*UpdateProjectInternalServerError Internal server error + +swagger:response updateProjectInternalServerError +*/ +type UpdateProjectInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateProjectInternalServerError creates UpdateProjectInternalServerError with default headers values +func NewUpdateProjectInternalServerError() *UpdateProjectInternalServerError { + + return &UpdateProjectInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the update project internal server error response +func (o *UpdateProjectInternalServerError) WithXRequestID(xRequestID string) *UpdateProjectInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update project internal server error response +func (o *UpdateProjectInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update project internal server error response +func (o *UpdateProjectInternalServerError) WithPayload(payload *models.Errors) *UpdateProjectInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update project internal server error response +func (o *UpdateProjectInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateProjectInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/project/update_project_urlbuilder.go b/src/server/v2.0/restapi/operations/project/update_project_urlbuilder.go new file mode 100644 index 000000000..2986e0540 --- /dev/null +++ b/src/server/v2.0/restapi/operations/project/update_project_urlbuilder.go @@ -0,0 +1,99 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// UpdateProjectURL generates an URL for the update project operation +type UpdateProjectURL struct { + ProjectNameOrID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdateProjectURL) WithBasePath(bp string) *UpdateProjectURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdateProjectURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *UpdateProjectURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name_or_id}" + + projectNameOrID := o.ProjectNameOrID + if projectNameOrID != "" { + _path = strings.Replace(_path, "{project_name_or_id}", projectNameOrID, -1) + } else { + return nil, errors.New("projectNameOrId is required on UpdateProjectURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *UpdateProjectURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *UpdateProjectURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *UpdateProjectURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on UpdateProjectURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on UpdateProjectURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *UpdateProjectURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/project_metadata/add_project_metadatas.go b/src/server/v2.0/restapi/operations/project_metadata/add_project_metadatas.go new file mode 100644 index 000000000..4299508c4 --- /dev/null +++ b/src/server/v2.0/restapi/operations/project_metadata/add_project_metadatas.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project_metadata + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// AddProjectMetadatasHandlerFunc turns a function with the right signature into a add project metadatas handler +type AddProjectMetadatasHandlerFunc func(AddProjectMetadatasParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn AddProjectMetadatasHandlerFunc) Handle(params AddProjectMetadatasParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// AddProjectMetadatasHandler interface for that can handle valid add project metadatas params +type AddProjectMetadatasHandler interface { + Handle(AddProjectMetadatasParams, interface{}) middleware.Responder +} + +// NewAddProjectMetadatas creates a new http.Handler for the add project metadatas operation +func NewAddProjectMetadatas(ctx *middleware.Context, handler AddProjectMetadatasHandler) *AddProjectMetadatas { + return &AddProjectMetadatas{Context: ctx, Handler: handler} +} + +/*AddProjectMetadatas swagger:route POST /projects/{project_name_or_id}/metadatas/ projectMetadata addProjectMetadatas + +Add metadata for the specific project + +Add metadata for the specific project + +*/ +type AddProjectMetadatas struct { + Context *middleware.Context + Handler AddProjectMetadatasHandler +} + +func (o *AddProjectMetadatas) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewAddProjectMetadatasParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/project_metadata/add_project_metadatas_parameters.go b/src/server/v2.0/restapi/operations/project_metadata/add_project_metadatas_parameters.go new file mode 100644 index 000000000..16ac63304 --- /dev/null +++ b/src/server/v2.0/restapi/operations/project_metadata/add_project_metadatas_parameters.go @@ -0,0 +1,170 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project_metadata + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewAddProjectMetadatasParams creates a new AddProjectMetadatasParams object +// with the default values initialized. +func NewAddProjectMetadatasParams() AddProjectMetadatasParams { + + var ( + // initialize parameters with default values + + xIsResourceNameDefault = bool(false) + ) + + return AddProjectMetadatasParams{ + XIsResourceName: &xIsResourceNameDefault, + } +} + +// AddProjectMetadatasParams contains all the bound params for the add project metadatas operation +// typically these are obtained from a http.Request +// +// swagger:parameters addProjectMetadatas +type AddProjectMetadatasParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name. + In: header + Default: false + */ + XIsResourceName *bool + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /* + In: body + */ + Metadata map[string]string + /*The name or id of the project + Required: true + In: path + */ + ProjectNameOrID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewAddProjectMetadatasParams() beforehand. +func (o *AddProjectMetadatasParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXIsResourceName(r.Header[http.CanonicalHeaderKey("X-Is-Resource-Name")], true, route.Formats); err != nil { + res = append(res, err) + } + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body map[string]string + if err := route.Consumer.Consume(r.Body, &body); err != nil { + res = append(res, errors.NewParseError("metadata", "body", "", err)) + } else { + // no validation required on inline body + o.Metadata = body + } + } + rProjectNameOrID, rhkProjectNameOrID, _ := route.Params.GetOK("project_name_or_id") + if err := o.bindProjectNameOrID(rProjectNameOrID, rhkProjectNameOrID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXIsResourceName binds and validates parameter XIsResourceName from header. +func (o *AddProjectMetadatasParams) bindXIsResourceName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewAddProjectMetadatasParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("X-Is-Resource-Name", "header", "bool", raw) + } + o.XIsResourceName = &value + + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *AddProjectMetadatasParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *AddProjectMetadatasParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindProjectNameOrID binds and validates parameter ProjectNameOrID from path. +func (o *AddProjectMetadatasParams) bindProjectNameOrID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectNameOrID = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/project_metadata/add_project_metadatas_responses.go b/src/server/v2.0/restapi/operations/project_metadata/add_project_metadatas_responses.go new file mode 100644 index 000000000..74ea921af --- /dev/null +++ b/src/server/v2.0/restapi/operations/project_metadata/add_project_metadatas_responses.go @@ -0,0 +1,456 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project_metadata + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// AddProjectMetadatasOKCode is the HTTP code returned for type AddProjectMetadatasOK +const AddProjectMetadatasOKCode int = 200 + +/*AddProjectMetadatasOK Success + +swagger:response addProjectMetadatasOK +*/ +type AddProjectMetadatasOK struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewAddProjectMetadatasOK creates AddProjectMetadatasOK with default headers values +func NewAddProjectMetadatasOK() *AddProjectMetadatasOK { + + return &AddProjectMetadatasOK{} +} + +// WithXRequestID adds the xRequestId to the add project metadatas o k response +func (o *AddProjectMetadatasOK) WithXRequestID(xRequestID string) *AddProjectMetadatasOK { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the add project metadatas o k response +func (o *AddProjectMetadatasOK) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *AddProjectMetadatasOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// AddProjectMetadatasBadRequestCode is the HTTP code returned for type AddProjectMetadatasBadRequest +const AddProjectMetadatasBadRequestCode int = 400 + +/*AddProjectMetadatasBadRequest Bad request + +swagger:response addProjectMetadatasBadRequest +*/ +type AddProjectMetadatasBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewAddProjectMetadatasBadRequest creates AddProjectMetadatasBadRequest with default headers values +func NewAddProjectMetadatasBadRequest() *AddProjectMetadatasBadRequest { + + return &AddProjectMetadatasBadRequest{} +} + +// WithXRequestID adds the xRequestId to the add project metadatas bad request response +func (o *AddProjectMetadatasBadRequest) WithXRequestID(xRequestID string) *AddProjectMetadatasBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the add project metadatas bad request response +func (o *AddProjectMetadatasBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the add project metadatas bad request response +func (o *AddProjectMetadatasBadRequest) WithPayload(payload *models.Errors) *AddProjectMetadatasBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the add project metadatas bad request response +func (o *AddProjectMetadatasBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *AddProjectMetadatasBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// AddProjectMetadatasUnauthorizedCode is the HTTP code returned for type AddProjectMetadatasUnauthorized +const AddProjectMetadatasUnauthorizedCode int = 401 + +/*AddProjectMetadatasUnauthorized Unauthorized + +swagger:response addProjectMetadatasUnauthorized +*/ +type AddProjectMetadatasUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewAddProjectMetadatasUnauthorized creates AddProjectMetadatasUnauthorized with default headers values +func NewAddProjectMetadatasUnauthorized() *AddProjectMetadatasUnauthorized { + + return &AddProjectMetadatasUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the add project metadatas unauthorized response +func (o *AddProjectMetadatasUnauthorized) WithXRequestID(xRequestID string) *AddProjectMetadatasUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the add project metadatas unauthorized response +func (o *AddProjectMetadatasUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the add project metadatas unauthorized response +func (o *AddProjectMetadatasUnauthorized) WithPayload(payload *models.Errors) *AddProjectMetadatasUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the add project metadatas unauthorized response +func (o *AddProjectMetadatasUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *AddProjectMetadatasUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// AddProjectMetadatasForbiddenCode is the HTTP code returned for type AddProjectMetadatasForbidden +const AddProjectMetadatasForbiddenCode int = 403 + +/*AddProjectMetadatasForbidden Forbidden + +swagger:response addProjectMetadatasForbidden +*/ +type AddProjectMetadatasForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewAddProjectMetadatasForbidden creates AddProjectMetadatasForbidden with default headers values +func NewAddProjectMetadatasForbidden() *AddProjectMetadatasForbidden { + + return &AddProjectMetadatasForbidden{} +} + +// WithXRequestID adds the xRequestId to the add project metadatas forbidden response +func (o *AddProjectMetadatasForbidden) WithXRequestID(xRequestID string) *AddProjectMetadatasForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the add project metadatas forbidden response +func (o *AddProjectMetadatasForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the add project metadatas forbidden response +func (o *AddProjectMetadatasForbidden) WithPayload(payload *models.Errors) *AddProjectMetadatasForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the add project metadatas forbidden response +func (o *AddProjectMetadatasForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *AddProjectMetadatasForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// AddProjectMetadatasNotFoundCode is the HTTP code returned for type AddProjectMetadatasNotFound +const AddProjectMetadatasNotFoundCode int = 404 + +/*AddProjectMetadatasNotFound Not found + +swagger:response addProjectMetadatasNotFound +*/ +type AddProjectMetadatasNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewAddProjectMetadatasNotFound creates AddProjectMetadatasNotFound with default headers values +func NewAddProjectMetadatasNotFound() *AddProjectMetadatasNotFound { + + return &AddProjectMetadatasNotFound{} +} + +// WithXRequestID adds the xRequestId to the add project metadatas not found response +func (o *AddProjectMetadatasNotFound) WithXRequestID(xRequestID string) *AddProjectMetadatasNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the add project metadatas not found response +func (o *AddProjectMetadatasNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the add project metadatas not found response +func (o *AddProjectMetadatasNotFound) WithPayload(payload *models.Errors) *AddProjectMetadatasNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the add project metadatas not found response +func (o *AddProjectMetadatasNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *AddProjectMetadatasNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// AddProjectMetadatasConflictCode is the HTTP code returned for type AddProjectMetadatasConflict +const AddProjectMetadatasConflictCode int = 409 + +/*AddProjectMetadatasConflict Conflict + +swagger:response addProjectMetadatasConflict +*/ +type AddProjectMetadatasConflict struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewAddProjectMetadatasConflict creates AddProjectMetadatasConflict with default headers values +func NewAddProjectMetadatasConflict() *AddProjectMetadatasConflict { + + return &AddProjectMetadatasConflict{} +} + +// WithXRequestID adds the xRequestId to the add project metadatas conflict response +func (o *AddProjectMetadatasConflict) WithXRequestID(xRequestID string) *AddProjectMetadatasConflict { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the add project metadatas conflict response +func (o *AddProjectMetadatasConflict) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the add project metadatas conflict response +func (o *AddProjectMetadatasConflict) WithPayload(payload *models.Errors) *AddProjectMetadatasConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the add project metadatas conflict response +func (o *AddProjectMetadatasConflict) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *AddProjectMetadatasConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// AddProjectMetadatasInternalServerErrorCode is the HTTP code returned for type AddProjectMetadatasInternalServerError +const AddProjectMetadatasInternalServerErrorCode int = 500 + +/*AddProjectMetadatasInternalServerError Internal server error + +swagger:response addProjectMetadatasInternalServerError +*/ +type AddProjectMetadatasInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewAddProjectMetadatasInternalServerError creates AddProjectMetadatasInternalServerError with default headers values +func NewAddProjectMetadatasInternalServerError() *AddProjectMetadatasInternalServerError { + + return &AddProjectMetadatasInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the add project metadatas internal server error response +func (o *AddProjectMetadatasInternalServerError) WithXRequestID(xRequestID string) *AddProjectMetadatasInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the add project metadatas internal server error response +func (o *AddProjectMetadatasInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the add project metadatas internal server error response +func (o *AddProjectMetadatasInternalServerError) WithPayload(payload *models.Errors) *AddProjectMetadatasInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the add project metadatas internal server error response +func (o *AddProjectMetadatasInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *AddProjectMetadatasInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/project_metadata/add_project_metadatas_urlbuilder.go b/src/server/v2.0/restapi/operations/project_metadata/add_project_metadatas_urlbuilder.go new file mode 100644 index 000000000..794a0057c --- /dev/null +++ b/src/server/v2.0/restapi/operations/project_metadata/add_project_metadatas_urlbuilder.go @@ -0,0 +1,99 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project_metadata + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// AddProjectMetadatasURL generates an URL for the add project metadatas operation +type AddProjectMetadatasURL struct { + ProjectNameOrID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *AddProjectMetadatasURL) WithBasePath(bp string) *AddProjectMetadatasURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *AddProjectMetadatasURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *AddProjectMetadatasURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name_or_id}/metadatas/" + + projectNameOrID := o.ProjectNameOrID + if projectNameOrID != "" { + _path = strings.Replace(_path, "{project_name_or_id}", projectNameOrID, -1) + } else { + return nil, errors.New("projectNameOrId is required on AddProjectMetadatasURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *AddProjectMetadatasURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *AddProjectMetadatasURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *AddProjectMetadatasURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on AddProjectMetadatasURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on AddProjectMetadatasURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *AddProjectMetadatasURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/project_metadata/delete_project_metadata.go b/src/server/v2.0/restapi/operations/project_metadata/delete_project_metadata.go new file mode 100644 index 000000000..dc2fbe9cc --- /dev/null +++ b/src/server/v2.0/restapi/operations/project_metadata/delete_project_metadata.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project_metadata + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteProjectMetadataHandlerFunc turns a function with the right signature into a delete project metadata handler +type DeleteProjectMetadataHandlerFunc func(DeleteProjectMetadataParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteProjectMetadataHandlerFunc) Handle(params DeleteProjectMetadataParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteProjectMetadataHandler interface for that can handle valid delete project metadata params +type DeleteProjectMetadataHandler interface { + Handle(DeleteProjectMetadataParams, interface{}) middleware.Responder +} + +// NewDeleteProjectMetadata creates a new http.Handler for the delete project metadata operation +func NewDeleteProjectMetadata(ctx *middleware.Context, handler DeleteProjectMetadataHandler) *DeleteProjectMetadata { + return &DeleteProjectMetadata{Context: ctx, Handler: handler} +} + +/*DeleteProjectMetadata swagger:route DELETE /projects/{project_name_or_id}/metadatas/{meta_name} projectMetadata deleteProjectMetadata + +Delete the specific metadata for the specific project + +Delete the specific metadata for the specific project + +*/ +type DeleteProjectMetadata struct { + Context *middleware.Context + Handler DeleteProjectMetadataHandler +} + +func (o *DeleteProjectMetadata) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewDeleteProjectMetadataParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/project_metadata/delete_project_metadata_parameters.go b/src/server/v2.0/restapi/operations/project_metadata/delete_project_metadata_parameters.go new file mode 100644 index 000000000..7fd91e689 --- /dev/null +++ b/src/server/v2.0/restapi/operations/project_metadata/delete_project_metadata_parameters.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project_metadata + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewDeleteProjectMetadataParams creates a new DeleteProjectMetadataParams object +// with the default values initialized. +func NewDeleteProjectMetadataParams() DeleteProjectMetadataParams { + + var ( + // initialize parameters with default values + + xIsResourceNameDefault = bool(false) + ) + + return DeleteProjectMetadataParams{ + XIsResourceName: &xIsResourceNameDefault, + } +} + +// DeleteProjectMetadataParams contains all the bound params for the delete project metadata operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteProjectMetadata +type DeleteProjectMetadataParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name. + In: header + Default: false + */ + XIsResourceName *bool + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The name of metadata. + Required: true + In: path + */ + MetaName string + /*The name or id of the project + Required: true + In: path + */ + ProjectNameOrID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteProjectMetadataParams() beforehand. +func (o *DeleteProjectMetadataParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXIsResourceName(r.Header[http.CanonicalHeaderKey("X-Is-Resource-Name")], true, route.Formats); err != nil { + res = append(res, err) + } + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rMetaName, rhkMetaName, _ := route.Params.GetOK("meta_name") + if err := o.bindMetaName(rMetaName, rhkMetaName, route.Formats); err != nil { + res = append(res, err) + } + + rProjectNameOrID, rhkProjectNameOrID, _ := route.Params.GetOK("project_name_or_id") + if err := o.bindProjectNameOrID(rProjectNameOrID, rhkProjectNameOrID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXIsResourceName binds and validates parameter XIsResourceName from header. +func (o *DeleteProjectMetadataParams) bindXIsResourceName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteProjectMetadataParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("X-Is-Resource-Name", "header", "bool", raw) + } + o.XIsResourceName = &value + + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *DeleteProjectMetadataParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *DeleteProjectMetadataParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindMetaName binds and validates parameter MetaName from path. +func (o *DeleteProjectMetadataParams) bindMetaName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.MetaName = raw + + return nil +} + +// bindProjectNameOrID binds and validates parameter ProjectNameOrID from path. +func (o *DeleteProjectMetadataParams) bindProjectNameOrID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectNameOrID = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/project_metadata/delete_project_metadata_responses.go b/src/server/v2.0/restapi/operations/project_metadata/delete_project_metadata_responses.go new file mode 100644 index 000000000..b7cbdc599 --- /dev/null +++ b/src/server/v2.0/restapi/operations/project_metadata/delete_project_metadata_responses.go @@ -0,0 +1,456 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project_metadata + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// DeleteProjectMetadataOKCode is the HTTP code returned for type DeleteProjectMetadataOK +const DeleteProjectMetadataOKCode int = 200 + +/*DeleteProjectMetadataOK Success + +swagger:response deleteProjectMetadataOK +*/ +type DeleteProjectMetadataOK struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewDeleteProjectMetadataOK creates DeleteProjectMetadataOK with default headers values +func NewDeleteProjectMetadataOK() *DeleteProjectMetadataOK { + + return &DeleteProjectMetadataOK{} +} + +// WithXRequestID adds the xRequestId to the delete project metadata o k response +func (o *DeleteProjectMetadataOK) WithXRequestID(xRequestID string) *DeleteProjectMetadataOK { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete project metadata o k response +func (o *DeleteProjectMetadataOK) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *DeleteProjectMetadataOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// DeleteProjectMetadataBadRequestCode is the HTTP code returned for type DeleteProjectMetadataBadRequest +const DeleteProjectMetadataBadRequestCode int = 400 + +/*DeleteProjectMetadataBadRequest Bad request + +swagger:response deleteProjectMetadataBadRequest +*/ +type DeleteProjectMetadataBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteProjectMetadataBadRequest creates DeleteProjectMetadataBadRequest with default headers values +func NewDeleteProjectMetadataBadRequest() *DeleteProjectMetadataBadRequest { + + return &DeleteProjectMetadataBadRequest{} +} + +// WithXRequestID adds the xRequestId to the delete project metadata bad request response +func (o *DeleteProjectMetadataBadRequest) WithXRequestID(xRequestID string) *DeleteProjectMetadataBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete project metadata bad request response +func (o *DeleteProjectMetadataBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete project metadata bad request response +func (o *DeleteProjectMetadataBadRequest) WithPayload(payload *models.Errors) *DeleteProjectMetadataBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete project metadata bad request response +func (o *DeleteProjectMetadataBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteProjectMetadataBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteProjectMetadataUnauthorizedCode is the HTTP code returned for type DeleteProjectMetadataUnauthorized +const DeleteProjectMetadataUnauthorizedCode int = 401 + +/*DeleteProjectMetadataUnauthorized Unauthorized + +swagger:response deleteProjectMetadataUnauthorized +*/ +type DeleteProjectMetadataUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteProjectMetadataUnauthorized creates DeleteProjectMetadataUnauthorized with default headers values +func NewDeleteProjectMetadataUnauthorized() *DeleteProjectMetadataUnauthorized { + + return &DeleteProjectMetadataUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the delete project metadata unauthorized response +func (o *DeleteProjectMetadataUnauthorized) WithXRequestID(xRequestID string) *DeleteProjectMetadataUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete project metadata unauthorized response +func (o *DeleteProjectMetadataUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete project metadata unauthorized response +func (o *DeleteProjectMetadataUnauthorized) WithPayload(payload *models.Errors) *DeleteProjectMetadataUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete project metadata unauthorized response +func (o *DeleteProjectMetadataUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteProjectMetadataUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteProjectMetadataForbiddenCode is the HTTP code returned for type DeleteProjectMetadataForbidden +const DeleteProjectMetadataForbiddenCode int = 403 + +/*DeleteProjectMetadataForbidden Forbidden + +swagger:response deleteProjectMetadataForbidden +*/ +type DeleteProjectMetadataForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteProjectMetadataForbidden creates DeleteProjectMetadataForbidden with default headers values +func NewDeleteProjectMetadataForbidden() *DeleteProjectMetadataForbidden { + + return &DeleteProjectMetadataForbidden{} +} + +// WithXRequestID adds the xRequestId to the delete project metadata forbidden response +func (o *DeleteProjectMetadataForbidden) WithXRequestID(xRequestID string) *DeleteProjectMetadataForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete project metadata forbidden response +func (o *DeleteProjectMetadataForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete project metadata forbidden response +func (o *DeleteProjectMetadataForbidden) WithPayload(payload *models.Errors) *DeleteProjectMetadataForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete project metadata forbidden response +func (o *DeleteProjectMetadataForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteProjectMetadataForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteProjectMetadataNotFoundCode is the HTTP code returned for type DeleteProjectMetadataNotFound +const DeleteProjectMetadataNotFoundCode int = 404 + +/*DeleteProjectMetadataNotFound Not found + +swagger:response deleteProjectMetadataNotFound +*/ +type DeleteProjectMetadataNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteProjectMetadataNotFound creates DeleteProjectMetadataNotFound with default headers values +func NewDeleteProjectMetadataNotFound() *DeleteProjectMetadataNotFound { + + return &DeleteProjectMetadataNotFound{} +} + +// WithXRequestID adds the xRequestId to the delete project metadata not found response +func (o *DeleteProjectMetadataNotFound) WithXRequestID(xRequestID string) *DeleteProjectMetadataNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete project metadata not found response +func (o *DeleteProjectMetadataNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete project metadata not found response +func (o *DeleteProjectMetadataNotFound) WithPayload(payload *models.Errors) *DeleteProjectMetadataNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete project metadata not found response +func (o *DeleteProjectMetadataNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteProjectMetadataNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteProjectMetadataConflictCode is the HTTP code returned for type DeleteProjectMetadataConflict +const DeleteProjectMetadataConflictCode int = 409 + +/*DeleteProjectMetadataConflict Conflict + +swagger:response deleteProjectMetadataConflict +*/ +type DeleteProjectMetadataConflict struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteProjectMetadataConflict creates DeleteProjectMetadataConflict with default headers values +func NewDeleteProjectMetadataConflict() *DeleteProjectMetadataConflict { + + return &DeleteProjectMetadataConflict{} +} + +// WithXRequestID adds the xRequestId to the delete project metadata conflict response +func (o *DeleteProjectMetadataConflict) WithXRequestID(xRequestID string) *DeleteProjectMetadataConflict { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete project metadata conflict response +func (o *DeleteProjectMetadataConflict) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete project metadata conflict response +func (o *DeleteProjectMetadataConflict) WithPayload(payload *models.Errors) *DeleteProjectMetadataConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete project metadata conflict response +func (o *DeleteProjectMetadataConflict) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteProjectMetadataConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteProjectMetadataInternalServerErrorCode is the HTTP code returned for type DeleteProjectMetadataInternalServerError +const DeleteProjectMetadataInternalServerErrorCode int = 500 + +/*DeleteProjectMetadataInternalServerError Internal server error + +swagger:response deleteProjectMetadataInternalServerError +*/ +type DeleteProjectMetadataInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteProjectMetadataInternalServerError creates DeleteProjectMetadataInternalServerError with default headers values +func NewDeleteProjectMetadataInternalServerError() *DeleteProjectMetadataInternalServerError { + + return &DeleteProjectMetadataInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the delete project metadata internal server error response +func (o *DeleteProjectMetadataInternalServerError) WithXRequestID(xRequestID string) *DeleteProjectMetadataInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete project metadata internal server error response +func (o *DeleteProjectMetadataInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete project metadata internal server error response +func (o *DeleteProjectMetadataInternalServerError) WithPayload(payload *models.Errors) *DeleteProjectMetadataInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete project metadata internal server error response +func (o *DeleteProjectMetadataInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteProjectMetadataInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/project_metadata/delete_project_metadata_urlbuilder.go b/src/server/v2.0/restapi/operations/project_metadata/delete_project_metadata_urlbuilder.go new file mode 100644 index 000000000..82c40e05d --- /dev/null +++ b/src/server/v2.0/restapi/operations/project_metadata/delete_project_metadata_urlbuilder.go @@ -0,0 +1,107 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project_metadata + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// DeleteProjectMetadataURL generates an URL for the delete project metadata operation +type DeleteProjectMetadataURL struct { + MetaName string + ProjectNameOrID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteProjectMetadataURL) WithBasePath(bp string) *DeleteProjectMetadataURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteProjectMetadataURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteProjectMetadataURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name_or_id}/metadatas/{meta_name}" + + metaName := o.MetaName + if metaName != "" { + _path = strings.Replace(_path, "{meta_name}", metaName, -1) + } else { + return nil, errors.New("metaName is required on DeleteProjectMetadataURL") + } + + projectNameOrID := o.ProjectNameOrID + if projectNameOrID != "" { + _path = strings.Replace(_path, "{project_name_or_id}", projectNameOrID, -1) + } else { + return nil, errors.New("projectNameOrId is required on DeleteProjectMetadataURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteProjectMetadataURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteProjectMetadataURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteProjectMetadataURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteProjectMetadataURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteProjectMetadataURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteProjectMetadataURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/project_metadata/get_project_metadata.go b/src/server/v2.0/restapi/operations/project_metadata/get_project_metadata.go new file mode 100644 index 000000000..f30796b9e --- /dev/null +++ b/src/server/v2.0/restapi/operations/project_metadata/get_project_metadata.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project_metadata + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetProjectMetadataHandlerFunc turns a function with the right signature into a get project metadata handler +type GetProjectMetadataHandlerFunc func(GetProjectMetadataParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetProjectMetadataHandlerFunc) Handle(params GetProjectMetadataParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetProjectMetadataHandler interface for that can handle valid get project metadata params +type GetProjectMetadataHandler interface { + Handle(GetProjectMetadataParams, interface{}) middleware.Responder +} + +// NewGetProjectMetadata creates a new http.Handler for the get project metadata operation +func NewGetProjectMetadata(ctx *middleware.Context, handler GetProjectMetadataHandler) *GetProjectMetadata { + return &GetProjectMetadata{Context: ctx, Handler: handler} +} + +/*GetProjectMetadata swagger:route GET /projects/{project_name_or_id}/metadatas/{meta_name} projectMetadata getProjectMetadata + +Get the specific metadata of the specific project + +Get the specific metadata of the specific project + +*/ +type GetProjectMetadata struct { + Context *middleware.Context + Handler GetProjectMetadataHandler +} + +func (o *GetProjectMetadata) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetProjectMetadataParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/project_metadata/get_project_metadata_parameters.go b/src/server/v2.0/restapi/operations/project_metadata/get_project_metadata_parameters.go new file mode 100644 index 000000000..e2395012e --- /dev/null +++ b/src/server/v2.0/restapi/operations/project_metadata/get_project_metadata_parameters.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project_metadata + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewGetProjectMetadataParams creates a new GetProjectMetadataParams object +// with the default values initialized. +func NewGetProjectMetadataParams() GetProjectMetadataParams { + + var ( + // initialize parameters with default values + + xIsResourceNameDefault = bool(false) + ) + + return GetProjectMetadataParams{ + XIsResourceName: &xIsResourceNameDefault, + } +} + +// GetProjectMetadataParams contains all the bound params for the get project metadata operation +// typically these are obtained from a http.Request +// +// swagger:parameters getProjectMetadata +type GetProjectMetadataParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name. + In: header + Default: false + */ + XIsResourceName *bool + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The name of metadata. + Required: true + In: path + */ + MetaName string + /*The name or id of the project + Required: true + In: path + */ + ProjectNameOrID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetProjectMetadataParams() beforehand. +func (o *GetProjectMetadataParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXIsResourceName(r.Header[http.CanonicalHeaderKey("X-Is-Resource-Name")], true, route.Formats); err != nil { + res = append(res, err) + } + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rMetaName, rhkMetaName, _ := route.Params.GetOK("meta_name") + if err := o.bindMetaName(rMetaName, rhkMetaName, route.Formats); err != nil { + res = append(res, err) + } + + rProjectNameOrID, rhkProjectNameOrID, _ := route.Params.GetOK("project_name_or_id") + if err := o.bindProjectNameOrID(rProjectNameOrID, rhkProjectNameOrID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXIsResourceName binds and validates parameter XIsResourceName from header. +func (o *GetProjectMetadataParams) bindXIsResourceName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewGetProjectMetadataParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("X-Is-Resource-Name", "header", "bool", raw) + } + o.XIsResourceName = &value + + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetProjectMetadataParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetProjectMetadataParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindMetaName binds and validates parameter MetaName from path. +func (o *GetProjectMetadataParams) bindMetaName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.MetaName = raw + + return nil +} + +// bindProjectNameOrID binds and validates parameter ProjectNameOrID from path. +func (o *GetProjectMetadataParams) bindProjectNameOrID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectNameOrID = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/project_metadata/get_project_metadata_responses.go b/src/server/v2.0/restapi/operations/project_metadata/get_project_metadata_responses.go new file mode 100644 index 000000000..d1ace9071 --- /dev/null +++ b/src/server/v2.0/restapi/operations/project_metadata/get_project_metadata_responses.go @@ -0,0 +1,391 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project_metadata + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetProjectMetadataOKCode is the HTTP code returned for type GetProjectMetadataOK +const GetProjectMetadataOKCode int = 200 + +/*GetProjectMetadataOK Success + +swagger:response getProjectMetadataOK +*/ +type GetProjectMetadataOK struct { + + /* + In: Body + */ + Payload map[string]string `json:"body,omitempty"` +} + +// NewGetProjectMetadataOK creates GetProjectMetadataOK with default headers values +func NewGetProjectMetadataOK() *GetProjectMetadataOK { + + return &GetProjectMetadataOK{} +} + +// WithPayload adds the payload to the get project metadata o k response +func (o *GetProjectMetadataOK) WithPayload(payload map[string]string) *GetProjectMetadataOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get project metadata o k response +func (o *GetProjectMetadataOK) SetPayload(payload map[string]string) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetProjectMetadataOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty map + payload = make(map[string]string, 50) + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// GetProjectMetadataBadRequestCode is the HTTP code returned for type GetProjectMetadataBadRequest +const GetProjectMetadataBadRequestCode int = 400 + +/*GetProjectMetadataBadRequest Bad request + +swagger:response getProjectMetadataBadRequest +*/ +type GetProjectMetadataBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetProjectMetadataBadRequest creates GetProjectMetadataBadRequest with default headers values +func NewGetProjectMetadataBadRequest() *GetProjectMetadataBadRequest { + + return &GetProjectMetadataBadRequest{} +} + +// WithXRequestID adds the xRequestId to the get project metadata bad request response +func (o *GetProjectMetadataBadRequest) WithXRequestID(xRequestID string) *GetProjectMetadataBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get project metadata bad request response +func (o *GetProjectMetadataBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get project metadata bad request response +func (o *GetProjectMetadataBadRequest) WithPayload(payload *models.Errors) *GetProjectMetadataBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get project metadata bad request response +func (o *GetProjectMetadataBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetProjectMetadataBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetProjectMetadataUnauthorizedCode is the HTTP code returned for type GetProjectMetadataUnauthorized +const GetProjectMetadataUnauthorizedCode int = 401 + +/*GetProjectMetadataUnauthorized Unauthorized + +swagger:response getProjectMetadataUnauthorized +*/ +type GetProjectMetadataUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetProjectMetadataUnauthorized creates GetProjectMetadataUnauthorized with default headers values +func NewGetProjectMetadataUnauthorized() *GetProjectMetadataUnauthorized { + + return &GetProjectMetadataUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the get project metadata unauthorized response +func (o *GetProjectMetadataUnauthorized) WithXRequestID(xRequestID string) *GetProjectMetadataUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get project metadata unauthorized response +func (o *GetProjectMetadataUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get project metadata unauthorized response +func (o *GetProjectMetadataUnauthorized) WithPayload(payload *models.Errors) *GetProjectMetadataUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get project metadata unauthorized response +func (o *GetProjectMetadataUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetProjectMetadataUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetProjectMetadataForbiddenCode is the HTTP code returned for type GetProjectMetadataForbidden +const GetProjectMetadataForbiddenCode int = 403 + +/*GetProjectMetadataForbidden Forbidden + +swagger:response getProjectMetadataForbidden +*/ +type GetProjectMetadataForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetProjectMetadataForbidden creates GetProjectMetadataForbidden with default headers values +func NewGetProjectMetadataForbidden() *GetProjectMetadataForbidden { + + return &GetProjectMetadataForbidden{} +} + +// WithXRequestID adds the xRequestId to the get project metadata forbidden response +func (o *GetProjectMetadataForbidden) WithXRequestID(xRequestID string) *GetProjectMetadataForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get project metadata forbidden response +func (o *GetProjectMetadataForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get project metadata forbidden response +func (o *GetProjectMetadataForbidden) WithPayload(payload *models.Errors) *GetProjectMetadataForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get project metadata forbidden response +func (o *GetProjectMetadataForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetProjectMetadataForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetProjectMetadataNotFoundCode is the HTTP code returned for type GetProjectMetadataNotFound +const GetProjectMetadataNotFoundCode int = 404 + +/*GetProjectMetadataNotFound Not found + +swagger:response getProjectMetadataNotFound +*/ +type GetProjectMetadataNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetProjectMetadataNotFound creates GetProjectMetadataNotFound with default headers values +func NewGetProjectMetadataNotFound() *GetProjectMetadataNotFound { + + return &GetProjectMetadataNotFound{} +} + +// WithXRequestID adds the xRequestId to the get project metadata not found response +func (o *GetProjectMetadataNotFound) WithXRequestID(xRequestID string) *GetProjectMetadataNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get project metadata not found response +func (o *GetProjectMetadataNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get project metadata not found response +func (o *GetProjectMetadataNotFound) WithPayload(payload *models.Errors) *GetProjectMetadataNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get project metadata not found response +func (o *GetProjectMetadataNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetProjectMetadataNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetProjectMetadataInternalServerErrorCode is the HTTP code returned for type GetProjectMetadataInternalServerError +const GetProjectMetadataInternalServerErrorCode int = 500 + +/*GetProjectMetadataInternalServerError Internal server error + +swagger:response getProjectMetadataInternalServerError +*/ +type GetProjectMetadataInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetProjectMetadataInternalServerError creates GetProjectMetadataInternalServerError with default headers values +func NewGetProjectMetadataInternalServerError() *GetProjectMetadataInternalServerError { + + return &GetProjectMetadataInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get project metadata internal server error response +func (o *GetProjectMetadataInternalServerError) WithXRequestID(xRequestID string) *GetProjectMetadataInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get project metadata internal server error response +func (o *GetProjectMetadataInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get project metadata internal server error response +func (o *GetProjectMetadataInternalServerError) WithPayload(payload *models.Errors) *GetProjectMetadataInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get project metadata internal server error response +func (o *GetProjectMetadataInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetProjectMetadataInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/project_metadata/get_project_metadata_urlbuilder.go b/src/server/v2.0/restapi/operations/project_metadata/get_project_metadata_urlbuilder.go new file mode 100644 index 000000000..e448d5ae1 --- /dev/null +++ b/src/server/v2.0/restapi/operations/project_metadata/get_project_metadata_urlbuilder.go @@ -0,0 +1,107 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project_metadata + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetProjectMetadataURL generates an URL for the get project metadata operation +type GetProjectMetadataURL struct { + MetaName string + ProjectNameOrID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetProjectMetadataURL) WithBasePath(bp string) *GetProjectMetadataURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetProjectMetadataURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetProjectMetadataURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name_or_id}/metadatas/{meta_name}" + + metaName := o.MetaName + if metaName != "" { + _path = strings.Replace(_path, "{meta_name}", metaName, -1) + } else { + return nil, errors.New("metaName is required on GetProjectMetadataURL") + } + + projectNameOrID := o.ProjectNameOrID + if projectNameOrID != "" { + _path = strings.Replace(_path, "{project_name_or_id}", projectNameOrID, -1) + } else { + return nil, errors.New("projectNameOrId is required on GetProjectMetadataURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetProjectMetadataURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetProjectMetadataURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetProjectMetadataURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetProjectMetadataURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetProjectMetadataURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetProjectMetadataURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/project_metadata/list_project_metadatas.go b/src/server/v2.0/restapi/operations/project_metadata/list_project_metadatas.go new file mode 100644 index 000000000..b0759555e --- /dev/null +++ b/src/server/v2.0/restapi/operations/project_metadata/list_project_metadatas.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project_metadata + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ListProjectMetadatasHandlerFunc turns a function with the right signature into a list project metadatas handler +type ListProjectMetadatasHandlerFunc func(ListProjectMetadatasParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ListProjectMetadatasHandlerFunc) Handle(params ListProjectMetadatasParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ListProjectMetadatasHandler interface for that can handle valid list project metadatas params +type ListProjectMetadatasHandler interface { + Handle(ListProjectMetadatasParams, interface{}) middleware.Responder +} + +// NewListProjectMetadatas creates a new http.Handler for the list project metadatas operation +func NewListProjectMetadatas(ctx *middleware.Context, handler ListProjectMetadatasHandler) *ListProjectMetadatas { + return &ListProjectMetadatas{Context: ctx, Handler: handler} +} + +/*ListProjectMetadatas swagger:route GET /projects/{project_name_or_id}/metadatas/ projectMetadata listProjectMetadatas + +Get the metadata of the specific project + +Get the metadata of the specific project + +*/ +type ListProjectMetadatas struct { + Context *middleware.Context + Handler ListProjectMetadatasHandler +} + +func (o *ListProjectMetadatas) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewListProjectMetadatasParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/project_metadata/list_project_metadatas_parameters.go b/src/server/v2.0/restapi/operations/project_metadata/list_project_metadatas_parameters.go new file mode 100644 index 000000000..ce3a47339 --- /dev/null +++ b/src/server/v2.0/restapi/operations/project_metadata/list_project_metadatas_parameters.go @@ -0,0 +1,155 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project_metadata + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewListProjectMetadatasParams creates a new ListProjectMetadatasParams object +// with the default values initialized. +func NewListProjectMetadatasParams() ListProjectMetadatasParams { + + var ( + // initialize parameters with default values + + xIsResourceNameDefault = bool(false) + ) + + return ListProjectMetadatasParams{ + XIsResourceName: &xIsResourceNameDefault, + } +} + +// ListProjectMetadatasParams contains all the bound params for the list project metadatas operation +// typically these are obtained from a http.Request +// +// swagger:parameters listProjectMetadatas +type ListProjectMetadatasParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name. + In: header + Default: false + */ + XIsResourceName *bool + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The name or id of the project + Required: true + In: path + */ + ProjectNameOrID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewListProjectMetadatasParams() beforehand. +func (o *ListProjectMetadatasParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXIsResourceName(r.Header[http.CanonicalHeaderKey("X-Is-Resource-Name")], true, route.Formats); err != nil { + res = append(res, err) + } + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rProjectNameOrID, rhkProjectNameOrID, _ := route.Params.GetOK("project_name_or_id") + if err := o.bindProjectNameOrID(rProjectNameOrID, rhkProjectNameOrID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXIsResourceName binds and validates parameter XIsResourceName from header. +func (o *ListProjectMetadatasParams) bindXIsResourceName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListProjectMetadatasParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("X-Is-Resource-Name", "header", "bool", raw) + } + o.XIsResourceName = &value + + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *ListProjectMetadatasParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *ListProjectMetadatasParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindProjectNameOrID binds and validates parameter ProjectNameOrID from path. +func (o *ListProjectMetadatasParams) bindProjectNameOrID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectNameOrID = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/project_metadata/list_project_metadatas_responses.go b/src/server/v2.0/restapi/operations/project_metadata/list_project_metadatas_responses.go new file mode 100644 index 000000000..e77b78d48 --- /dev/null +++ b/src/server/v2.0/restapi/operations/project_metadata/list_project_metadatas_responses.go @@ -0,0 +1,391 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project_metadata + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// ListProjectMetadatasOKCode is the HTTP code returned for type ListProjectMetadatasOK +const ListProjectMetadatasOKCode int = 200 + +/*ListProjectMetadatasOK Success + +swagger:response listProjectMetadatasOK +*/ +type ListProjectMetadatasOK struct { + + /* + In: Body + */ + Payload map[string]string `json:"body,omitempty"` +} + +// NewListProjectMetadatasOK creates ListProjectMetadatasOK with default headers values +func NewListProjectMetadatasOK() *ListProjectMetadatasOK { + + return &ListProjectMetadatasOK{} +} + +// WithPayload adds the payload to the list project metadatas o k response +func (o *ListProjectMetadatasOK) WithPayload(payload map[string]string) *ListProjectMetadatasOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list project metadatas o k response +func (o *ListProjectMetadatasOK) SetPayload(payload map[string]string) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListProjectMetadatasOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty map + payload = make(map[string]string, 50) + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ListProjectMetadatasBadRequestCode is the HTTP code returned for type ListProjectMetadatasBadRequest +const ListProjectMetadatasBadRequestCode int = 400 + +/*ListProjectMetadatasBadRequest Bad request + +swagger:response listProjectMetadatasBadRequest +*/ +type ListProjectMetadatasBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListProjectMetadatasBadRequest creates ListProjectMetadatasBadRequest with default headers values +func NewListProjectMetadatasBadRequest() *ListProjectMetadatasBadRequest { + + return &ListProjectMetadatasBadRequest{} +} + +// WithXRequestID adds the xRequestId to the list project metadatas bad request response +func (o *ListProjectMetadatasBadRequest) WithXRequestID(xRequestID string) *ListProjectMetadatasBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list project metadatas bad request response +func (o *ListProjectMetadatasBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list project metadatas bad request response +func (o *ListProjectMetadatasBadRequest) WithPayload(payload *models.Errors) *ListProjectMetadatasBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list project metadatas bad request response +func (o *ListProjectMetadatasBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListProjectMetadatasBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListProjectMetadatasUnauthorizedCode is the HTTP code returned for type ListProjectMetadatasUnauthorized +const ListProjectMetadatasUnauthorizedCode int = 401 + +/*ListProjectMetadatasUnauthorized Unauthorized + +swagger:response listProjectMetadatasUnauthorized +*/ +type ListProjectMetadatasUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListProjectMetadatasUnauthorized creates ListProjectMetadatasUnauthorized with default headers values +func NewListProjectMetadatasUnauthorized() *ListProjectMetadatasUnauthorized { + + return &ListProjectMetadatasUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the list project metadatas unauthorized response +func (o *ListProjectMetadatasUnauthorized) WithXRequestID(xRequestID string) *ListProjectMetadatasUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list project metadatas unauthorized response +func (o *ListProjectMetadatasUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list project metadatas unauthorized response +func (o *ListProjectMetadatasUnauthorized) WithPayload(payload *models.Errors) *ListProjectMetadatasUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list project metadatas unauthorized response +func (o *ListProjectMetadatasUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListProjectMetadatasUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListProjectMetadatasForbiddenCode is the HTTP code returned for type ListProjectMetadatasForbidden +const ListProjectMetadatasForbiddenCode int = 403 + +/*ListProjectMetadatasForbidden Forbidden + +swagger:response listProjectMetadatasForbidden +*/ +type ListProjectMetadatasForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListProjectMetadatasForbidden creates ListProjectMetadatasForbidden with default headers values +func NewListProjectMetadatasForbidden() *ListProjectMetadatasForbidden { + + return &ListProjectMetadatasForbidden{} +} + +// WithXRequestID adds the xRequestId to the list project metadatas forbidden response +func (o *ListProjectMetadatasForbidden) WithXRequestID(xRequestID string) *ListProjectMetadatasForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list project metadatas forbidden response +func (o *ListProjectMetadatasForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list project metadatas forbidden response +func (o *ListProjectMetadatasForbidden) WithPayload(payload *models.Errors) *ListProjectMetadatasForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list project metadatas forbidden response +func (o *ListProjectMetadatasForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListProjectMetadatasForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListProjectMetadatasNotFoundCode is the HTTP code returned for type ListProjectMetadatasNotFound +const ListProjectMetadatasNotFoundCode int = 404 + +/*ListProjectMetadatasNotFound Not found + +swagger:response listProjectMetadatasNotFound +*/ +type ListProjectMetadatasNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListProjectMetadatasNotFound creates ListProjectMetadatasNotFound with default headers values +func NewListProjectMetadatasNotFound() *ListProjectMetadatasNotFound { + + return &ListProjectMetadatasNotFound{} +} + +// WithXRequestID adds the xRequestId to the list project metadatas not found response +func (o *ListProjectMetadatasNotFound) WithXRequestID(xRequestID string) *ListProjectMetadatasNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list project metadatas not found response +func (o *ListProjectMetadatasNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list project metadatas not found response +func (o *ListProjectMetadatasNotFound) WithPayload(payload *models.Errors) *ListProjectMetadatasNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list project metadatas not found response +func (o *ListProjectMetadatasNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListProjectMetadatasNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListProjectMetadatasInternalServerErrorCode is the HTTP code returned for type ListProjectMetadatasInternalServerError +const ListProjectMetadatasInternalServerErrorCode int = 500 + +/*ListProjectMetadatasInternalServerError Internal server error + +swagger:response listProjectMetadatasInternalServerError +*/ +type ListProjectMetadatasInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListProjectMetadatasInternalServerError creates ListProjectMetadatasInternalServerError with default headers values +func NewListProjectMetadatasInternalServerError() *ListProjectMetadatasInternalServerError { + + return &ListProjectMetadatasInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the list project metadatas internal server error response +func (o *ListProjectMetadatasInternalServerError) WithXRequestID(xRequestID string) *ListProjectMetadatasInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list project metadatas internal server error response +func (o *ListProjectMetadatasInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list project metadatas internal server error response +func (o *ListProjectMetadatasInternalServerError) WithPayload(payload *models.Errors) *ListProjectMetadatasInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list project metadatas internal server error response +func (o *ListProjectMetadatasInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListProjectMetadatasInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/project_metadata/list_project_metadatas_urlbuilder.go b/src/server/v2.0/restapi/operations/project_metadata/list_project_metadatas_urlbuilder.go new file mode 100644 index 000000000..b7d0307ed --- /dev/null +++ b/src/server/v2.0/restapi/operations/project_metadata/list_project_metadatas_urlbuilder.go @@ -0,0 +1,99 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project_metadata + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// ListProjectMetadatasURL generates an URL for the list project metadatas operation +type ListProjectMetadatasURL struct { + ProjectNameOrID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListProjectMetadatasURL) WithBasePath(bp string) *ListProjectMetadatasURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListProjectMetadatasURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ListProjectMetadatasURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name_or_id}/metadatas/" + + projectNameOrID := o.ProjectNameOrID + if projectNameOrID != "" { + _path = strings.Replace(_path, "{project_name_or_id}", projectNameOrID, -1) + } else { + return nil, errors.New("projectNameOrId is required on ListProjectMetadatasURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ListProjectMetadatasURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ListProjectMetadatasURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ListProjectMetadatasURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ListProjectMetadatasURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ListProjectMetadatasURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ListProjectMetadatasURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/project_metadata/update_project_metadata.go b/src/server/v2.0/restapi/operations/project_metadata/update_project_metadata.go new file mode 100644 index 000000000..e179ddf55 --- /dev/null +++ b/src/server/v2.0/restapi/operations/project_metadata/update_project_metadata.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project_metadata + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// UpdateProjectMetadataHandlerFunc turns a function with the right signature into a update project metadata handler +type UpdateProjectMetadataHandlerFunc func(UpdateProjectMetadataParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn UpdateProjectMetadataHandlerFunc) Handle(params UpdateProjectMetadataParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// UpdateProjectMetadataHandler interface for that can handle valid update project metadata params +type UpdateProjectMetadataHandler interface { + Handle(UpdateProjectMetadataParams, interface{}) middleware.Responder +} + +// NewUpdateProjectMetadata creates a new http.Handler for the update project metadata operation +func NewUpdateProjectMetadata(ctx *middleware.Context, handler UpdateProjectMetadataHandler) *UpdateProjectMetadata { + return &UpdateProjectMetadata{Context: ctx, Handler: handler} +} + +/*UpdateProjectMetadata swagger:route PUT /projects/{project_name_or_id}/metadatas/{meta_name} projectMetadata updateProjectMetadata + +Update the specific metadata for the specific project + +Update the specific metadata for the specific project + +*/ +type UpdateProjectMetadata struct { + Context *middleware.Context + Handler UpdateProjectMetadataHandler +} + +func (o *UpdateProjectMetadata) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewUpdateProjectMetadataParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/project_metadata/update_project_metadata_parameters.go b/src/server/v2.0/restapi/operations/project_metadata/update_project_metadata_parameters.go new file mode 100644 index 000000000..928db0cf9 --- /dev/null +++ b/src/server/v2.0/restapi/operations/project_metadata/update_project_metadata_parameters.go @@ -0,0 +1,195 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project_metadata + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewUpdateProjectMetadataParams creates a new UpdateProjectMetadataParams object +// with the default values initialized. +func NewUpdateProjectMetadataParams() UpdateProjectMetadataParams { + + var ( + // initialize parameters with default values + + xIsResourceNameDefault = bool(false) + ) + + return UpdateProjectMetadataParams{ + XIsResourceName: &xIsResourceNameDefault, + } +} + +// UpdateProjectMetadataParams contains all the bound params for the update project metadata operation +// typically these are obtained from a http.Request +// +// swagger:parameters updateProjectMetadata +type UpdateProjectMetadataParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name. + In: header + Default: false + */ + XIsResourceName *bool + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The name of metadata. + Required: true + In: path + */ + MetaName string + /* + In: body + */ + Metadata map[string]string + /*The name or id of the project + Required: true + In: path + */ + ProjectNameOrID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewUpdateProjectMetadataParams() beforehand. +func (o *UpdateProjectMetadataParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXIsResourceName(r.Header[http.CanonicalHeaderKey("X-Is-Resource-Name")], true, route.Formats); err != nil { + res = append(res, err) + } + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rMetaName, rhkMetaName, _ := route.Params.GetOK("meta_name") + if err := o.bindMetaName(rMetaName, rhkMetaName, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body map[string]string + if err := route.Consumer.Consume(r.Body, &body); err != nil { + res = append(res, errors.NewParseError("metadata", "body", "", err)) + } else { + // no validation required on inline body + o.Metadata = body + } + } + rProjectNameOrID, rhkProjectNameOrID, _ := route.Params.GetOK("project_name_or_id") + if err := o.bindProjectNameOrID(rProjectNameOrID, rhkProjectNameOrID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXIsResourceName binds and validates parameter XIsResourceName from header. +func (o *UpdateProjectMetadataParams) bindXIsResourceName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewUpdateProjectMetadataParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("X-Is-Resource-Name", "header", "bool", raw) + } + o.XIsResourceName = &value + + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *UpdateProjectMetadataParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *UpdateProjectMetadataParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindMetaName binds and validates parameter MetaName from path. +func (o *UpdateProjectMetadataParams) bindMetaName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.MetaName = raw + + return nil +} + +// bindProjectNameOrID binds and validates parameter ProjectNameOrID from path. +func (o *UpdateProjectMetadataParams) bindProjectNameOrID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectNameOrID = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/project_metadata/update_project_metadata_responses.go b/src/server/v2.0/restapi/operations/project_metadata/update_project_metadata_responses.go new file mode 100644 index 000000000..7b196481e --- /dev/null +++ b/src/server/v2.0/restapi/operations/project_metadata/update_project_metadata_responses.go @@ -0,0 +1,456 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project_metadata + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// UpdateProjectMetadataOKCode is the HTTP code returned for type UpdateProjectMetadataOK +const UpdateProjectMetadataOKCode int = 200 + +/*UpdateProjectMetadataOK Success + +swagger:response updateProjectMetadataOK +*/ +type UpdateProjectMetadataOK struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewUpdateProjectMetadataOK creates UpdateProjectMetadataOK with default headers values +func NewUpdateProjectMetadataOK() *UpdateProjectMetadataOK { + + return &UpdateProjectMetadataOK{} +} + +// WithXRequestID adds the xRequestId to the update project metadata o k response +func (o *UpdateProjectMetadataOK) WithXRequestID(xRequestID string) *UpdateProjectMetadataOK { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update project metadata o k response +func (o *UpdateProjectMetadataOK) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *UpdateProjectMetadataOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// UpdateProjectMetadataBadRequestCode is the HTTP code returned for type UpdateProjectMetadataBadRequest +const UpdateProjectMetadataBadRequestCode int = 400 + +/*UpdateProjectMetadataBadRequest Bad request + +swagger:response updateProjectMetadataBadRequest +*/ +type UpdateProjectMetadataBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateProjectMetadataBadRequest creates UpdateProjectMetadataBadRequest with default headers values +func NewUpdateProjectMetadataBadRequest() *UpdateProjectMetadataBadRequest { + + return &UpdateProjectMetadataBadRequest{} +} + +// WithXRequestID adds the xRequestId to the update project metadata bad request response +func (o *UpdateProjectMetadataBadRequest) WithXRequestID(xRequestID string) *UpdateProjectMetadataBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update project metadata bad request response +func (o *UpdateProjectMetadataBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update project metadata bad request response +func (o *UpdateProjectMetadataBadRequest) WithPayload(payload *models.Errors) *UpdateProjectMetadataBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update project metadata bad request response +func (o *UpdateProjectMetadataBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateProjectMetadataBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateProjectMetadataUnauthorizedCode is the HTTP code returned for type UpdateProjectMetadataUnauthorized +const UpdateProjectMetadataUnauthorizedCode int = 401 + +/*UpdateProjectMetadataUnauthorized Unauthorized + +swagger:response updateProjectMetadataUnauthorized +*/ +type UpdateProjectMetadataUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateProjectMetadataUnauthorized creates UpdateProjectMetadataUnauthorized with default headers values +func NewUpdateProjectMetadataUnauthorized() *UpdateProjectMetadataUnauthorized { + + return &UpdateProjectMetadataUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the update project metadata unauthorized response +func (o *UpdateProjectMetadataUnauthorized) WithXRequestID(xRequestID string) *UpdateProjectMetadataUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update project metadata unauthorized response +func (o *UpdateProjectMetadataUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update project metadata unauthorized response +func (o *UpdateProjectMetadataUnauthorized) WithPayload(payload *models.Errors) *UpdateProjectMetadataUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update project metadata unauthorized response +func (o *UpdateProjectMetadataUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateProjectMetadataUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateProjectMetadataForbiddenCode is the HTTP code returned for type UpdateProjectMetadataForbidden +const UpdateProjectMetadataForbiddenCode int = 403 + +/*UpdateProjectMetadataForbidden Forbidden + +swagger:response updateProjectMetadataForbidden +*/ +type UpdateProjectMetadataForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateProjectMetadataForbidden creates UpdateProjectMetadataForbidden with default headers values +func NewUpdateProjectMetadataForbidden() *UpdateProjectMetadataForbidden { + + return &UpdateProjectMetadataForbidden{} +} + +// WithXRequestID adds the xRequestId to the update project metadata forbidden response +func (o *UpdateProjectMetadataForbidden) WithXRequestID(xRequestID string) *UpdateProjectMetadataForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update project metadata forbidden response +func (o *UpdateProjectMetadataForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update project metadata forbidden response +func (o *UpdateProjectMetadataForbidden) WithPayload(payload *models.Errors) *UpdateProjectMetadataForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update project metadata forbidden response +func (o *UpdateProjectMetadataForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateProjectMetadataForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateProjectMetadataNotFoundCode is the HTTP code returned for type UpdateProjectMetadataNotFound +const UpdateProjectMetadataNotFoundCode int = 404 + +/*UpdateProjectMetadataNotFound Not found + +swagger:response updateProjectMetadataNotFound +*/ +type UpdateProjectMetadataNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateProjectMetadataNotFound creates UpdateProjectMetadataNotFound with default headers values +func NewUpdateProjectMetadataNotFound() *UpdateProjectMetadataNotFound { + + return &UpdateProjectMetadataNotFound{} +} + +// WithXRequestID adds the xRequestId to the update project metadata not found response +func (o *UpdateProjectMetadataNotFound) WithXRequestID(xRequestID string) *UpdateProjectMetadataNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update project metadata not found response +func (o *UpdateProjectMetadataNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update project metadata not found response +func (o *UpdateProjectMetadataNotFound) WithPayload(payload *models.Errors) *UpdateProjectMetadataNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update project metadata not found response +func (o *UpdateProjectMetadataNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateProjectMetadataNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateProjectMetadataConflictCode is the HTTP code returned for type UpdateProjectMetadataConflict +const UpdateProjectMetadataConflictCode int = 409 + +/*UpdateProjectMetadataConflict Conflict + +swagger:response updateProjectMetadataConflict +*/ +type UpdateProjectMetadataConflict struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateProjectMetadataConflict creates UpdateProjectMetadataConflict with default headers values +func NewUpdateProjectMetadataConflict() *UpdateProjectMetadataConflict { + + return &UpdateProjectMetadataConflict{} +} + +// WithXRequestID adds the xRequestId to the update project metadata conflict response +func (o *UpdateProjectMetadataConflict) WithXRequestID(xRequestID string) *UpdateProjectMetadataConflict { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update project metadata conflict response +func (o *UpdateProjectMetadataConflict) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update project metadata conflict response +func (o *UpdateProjectMetadataConflict) WithPayload(payload *models.Errors) *UpdateProjectMetadataConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update project metadata conflict response +func (o *UpdateProjectMetadataConflict) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateProjectMetadataConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateProjectMetadataInternalServerErrorCode is the HTTP code returned for type UpdateProjectMetadataInternalServerError +const UpdateProjectMetadataInternalServerErrorCode int = 500 + +/*UpdateProjectMetadataInternalServerError Internal server error + +swagger:response updateProjectMetadataInternalServerError +*/ +type UpdateProjectMetadataInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateProjectMetadataInternalServerError creates UpdateProjectMetadataInternalServerError with default headers values +func NewUpdateProjectMetadataInternalServerError() *UpdateProjectMetadataInternalServerError { + + return &UpdateProjectMetadataInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the update project metadata internal server error response +func (o *UpdateProjectMetadataInternalServerError) WithXRequestID(xRequestID string) *UpdateProjectMetadataInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update project metadata internal server error response +func (o *UpdateProjectMetadataInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update project metadata internal server error response +func (o *UpdateProjectMetadataInternalServerError) WithPayload(payload *models.Errors) *UpdateProjectMetadataInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update project metadata internal server error response +func (o *UpdateProjectMetadataInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateProjectMetadataInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/project_metadata/update_project_metadata_urlbuilder.go b/src/server/v2.0/restapi/operations/project_metadata/update_project_metadata_urlbuilder.go new file mode 100644 index 000000000..6b7155abd --- /dev/null +++ b/src/server/v2.0/restapi/operations/project_metadata/update_project_metadata_urlbuilder.go @@ -0,0 +1,107 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package project_metadata + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// UpdateProjectMetadataURL generates an URL for the update project metadata operation +type UpdateProjectMetadataURL struct { + MetaName string + ProjectNameOrID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdateProjectMetadataURL) WithBasePath(bp string) *UpdateProjectMetadataURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdateProjectMetadataURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *UpdateProjectMetadataURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name_or_id}/metadatas/{meta_name}" + + metaName := o.MetaName + if metaName != "" { + _path = strings.Replace(_path, "{meta_name}", metaName, -1) + } else { + return nil, errors.New("metaName is required on UpdateProjectMetadataURL") + } + + projectNameOrID := o.ProjectNameOrID + if projectNameOrID != "" { + _path = strings.Replace(_path, "{project_name_or_id}", projectNameOrID, -1) + } else { + return nil, errors.New("projectNameOrId is required on UpdateProjectMetadataURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *UpdateProjectMetadataURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *UpdateProjectMetadataURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *UpdateProjectMetadataURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on UpdateProjectMetadataURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on UpdateProjectMetadataURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *UpdateProjectMetadataURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/purge/create_purge_schedule.go b/src/server/v2.0/restapi/operations/purge/create_purge_schedule.go new file mode 100644 index 000000000..21cb8272f --- /dev/null +++ b/src/server/v2.0/restapi/operations/purge/create_purge_schedule.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package purge + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreatePurgeScheduleHandlerFunc turns a function with the right signature into a create purge schedule handler +type CreatePurgeScheduleHandlerFunc func(CreatePurgeScheduleParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreatePurgeScheduleHandlerFunc) Handle(params CreatePurgeScheduleParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreatePurgeScheduleHandler interface for that can handle valid create purge schedule params +type CreatePurgeScheduleHandler interface { + Handle(CreatePurgeScheduleParams, interface{}) middleware.Responder +} + +// NewCreatePurgeSchedule creates a new http.Handler for the create purge schedule operation +func NewCreatePurgeSchedule(ctx *middleware.Context, handler CreatePurgeScheduleHandler) *CreatePurgeSchedule { + return &CreatePurgeSchedule{Context: ctx, Handler: handler} +} + +/*CreatePurgeSchedule swagger:route POST /system/purgeaudit/schedule purge createPurgeSchedule + +Create a purge job schedule. + +This endpoint is for update purge job schedule. + + +*/ +type CreatePurgeSchedule struct { + Context *middleware.Context + Handler CreatePurgeScheduleHandler +} + +func (o *CreatePurgeSchedule) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewCreatePurgeScheduleParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/purge/create_purge_schedule_parameters.go b/src/server/v2.0/restapi/operations/purge/create_purge_schedule_parameters.go new file mode 100644 index 000000000..c478231d8 --- /dev/null +++ b/src/server/v2.0/restapi/operations/purge/create_purge_schedule_parameters.go @@ -0,0 +1,124 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package purge + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewCreatePurgeScheduleParams creates a new CreatePurgeScheduleParams object +// no default values defined in spec. +func NewCreatePurgeScheduleParams() CreatePurgeScheduleParams { + + return CreatePurgeScheduleParams{} +} + +// CreatePurgeScheduleParams contains all the bound params for the create purge schedule operation +// typically these are obtained from a http.Request +// +// swagger:parameters createPurgeSchedule +type CreatePurgeScheduleParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The purge job's schedule, it is a json object. | + The sample format is | + {"parameters":{"audit_retention_hour":168,"dry_run":true, "include_operations":"create,delete,pull"},"schedule":{"type":"Hourly","cron":"0 0 * * * *"}} | + the include_operation should be a comma separated string, e.g. create,delete,pull, if it is empty, no operation will be purged. + + Required: true + In: body + */ + Schedule *models.Schedule +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreatePurgeScheduleParams() beforehand. +func (o *CreatePurgeScheduleParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Schedule + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("schedule", "body", "")) + } else { + res = append(res, errors.NewParseError("schedule", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Schedule = &body + } + } + } else { + res = append(res, errors.Required("schedule", "body", "")) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *CreatePurgeScheduleParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *CreatePurgeScheduleParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} diff --git a/src/server/v2.0/restapi/operations/purge/create_purge_schedule_responses.go b/src/server/v2.0/restapi/operations/purge/create_purge_schedule_responses.go new file mode 100644 index 000000000..d5e41258a --- /dev/null +++ b/src/server/v2.0/restapi/operations/purge/create_purge_schedule_responses.go @@ -0,0 +1,346 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package purge + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// CreatePurgeScheduleCreatedCode is the HTTP code returned for type CreatePurgeScheduleCreated +const CreatePurgeScheduleCreatedCode int = 201 + +/*CreatePurgeScheduleCreated Created + +swagger:response createPurgeScheduleCreated +*/ +type CreatePurgeScheduleCreated struct { + /*The location of the resource + + */ + Location string `json:"Location"` + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewCreatePurgeScheduleCreated creates CreatePurgeScheduleCreated with default headers values +func NewCreatePurgeScheduleCreated() *CreatePurgeScheduleCreated { + + return &CreatePurgeScheduleCreated{} +} + +// WithLocation adds the location to the create purge schedule created response +func (o *CreatePurgeScheduleCreated) WithLocation(location string) *CreatePurgeScheduleCreated { + o.Location = location + return o +} + +// SetLocation sets the location to the create purge schedule created response +func (o *CreatePurgeScheduleCreated) SetLocation(location string) { + o.Location = location +} + +// WithXRequestID adds the xRequestId to the create purge schedule created response +func (o *CreatePurgeScheduleCreated) WithXRequestID(xRequestID string) *CreatePurgeScheduleCreated { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create purge schedule created response +func (o *CreatePurgeScheduleCreated) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *CreatePurgeScheduleCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Location + + location := o.Location + if location != "" { + rw.Header().Set("Location", location) + } + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(201) +} + +// CreatePurgeScheduleBadRequestCode is the HTTP code returned for type CreatePurgeScheduleBadRequest +const CreatePurgeScheduleBadRequestCode int = 400 + +/*CreatePurgeScheduleBadRequest Bad request + +swagger:response createPurgeScheduleBadRequest +*/ +type CreatePurgeScheduleBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreatePurgeScheduleBadRequest creates CreatePurgeScheduleBadRequest with default headers values +func NewCreatePurgeScheduleBadRequest() *CreatePurgeScheduleBadRequest { + + return &CreatePurgeScheduleBadRequest{} +} + +// WithXRequestID adds the xRequestId to the create purge schedule bad request response +func (o *CreatePurgeScheduleBadRequest) WithXRequestID(xRequestID string) *CreatePurgeScheduleBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create purge schedule bad request response +func (o *CreatePurgeScheduleBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create purge schedule bad request response +func (o *CreatePurgeScheduleBadRequest) WithPayload(payload *models.Errors) *CreatePurgeScheduleBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create purge schedule bad request response +func (o *CreatePurgeScheduleBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreatePurgeScheduleBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreatePurgeScheduleUnauthorizedCode is the HTTP code returned for type CreatePurgeScheduleUnauthorized +const CreatePurgeScheduleUnauthorizedCode int = 401 + +/*CreatePurgeScheduleUnauthorized Unauthorized + +swagger:response createPurgeScheduleUnauthorized +*/ +type CreatePurgeScheduleUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreatePurgeScheduleUnauthorized creates CreatePurgeScheduleUnauthorized with default headers values +func NewCreatePurgeScheduleUnauthorized() *CreatePurgeScheduleUnauthorized { + + return &CreatePurgeScheduleUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the create purge schedule unauthorized response +func (o *CreatePurgeScheduleUnauthorized) WithXRequestID(xRequestID string) *CreatePurgeScheduleUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create purge schedule unauthorized response +func (o *CreatePurgeScheduleUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create purge schedule unauthorized response +func (o *CreatePurgeScheduleUnauthorized) WithPayload(payload *models.Errors) *CreatePurgeScheduleUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create purge schedule unauthorized response +func (o *CreatePurgeScheduleUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreatePurgeScheduleUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreatePurgeScheduleForbiddenCode is the HTTP code returned for type CreatePurgeScheduleForbidden +const CreatePurgeScheduleForbiddenCode int = 403 + +/*CreatePurgeScheduleForbidden Forbidden + +swagger:response createPurgeScheduleForbidden +*/ +type CreatePurgeScheduleForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreatePurgeScheduleForbidden creates CreatePurgeScheduleForbidden with default headers values +func NewCreatePurgeScheduleForbidden() *CreatePurgeScheduleForbidden { + + return &CreatePurgeScheduleForbidden{} +} + +// WithXRequestID adds the xRequestId to the create purge schedule forbidden response +func (o *CreatePurgeScheduleForbidden) WithXRequestID(xRequestID string) *CreatePurgeScheduleForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create purge schedule forbidden response +func (o *CreatePurgeScheduleForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create purge schedule forbidden response +func (o *CreatePurgeScheduleForbidden) WithPayload(payload *models.Errors) *CreatePurgeScheduleForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create purge schedule forbidden response +func (o *CreatePurgeScheduleForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreatePurgeScheduleForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreatePurgeScheduleInternalServerErrorCode is the HTTP code returned for type CreatePurgeScheduleInternalServerError +const CreatePurgeScheduleInternalServerErrorCode int = 500 + +/*CreatePurgeScheduleInternalServerError Internal server error + +swagger:response createPurgeScheduleInternalServerError +*/ +type CreatePurgeScheduleInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreatePurgeScheduleInternalServerError creates CreatePurgeScheduleInternalServerError with default headers values +func NewCreatePurgeScheduleInternalServerError() *CreatePurgeScheduleInternalServerError { + + return &CreatePurgeScheduleInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the create purge schedule internal server error response +func (o *CreatePurgeScheduleInternalServerError) WithXRequestID(xRequestID string) *CreatePurgeScheduleInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create purge schedule internal server error response +func (o *CreatePurgeScheduleInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create purge schedule internal server error response +func (o *CreatePurgeScheduleInternalServerError) WithPayload(payload *models.Errors) *CreatePurgeScheduleInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create purge schedule internal server error response +func (o *CreatePurgeScheduleInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreatePurgeScheduleInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/purge/create_purge_schedule_urlbuilder.go b/src/server/v2.0/restapi/operations/purge/create_purge_schedule_urlbuilder.go new file mode 100644 index 000000000..35d74a791 --- /dev/null +++ b/src/server/v2.0/restapi/operations/purge/create_purge_schedule_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package purge + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// CreatePurgeScheduleURL generates an URL for the create purge schedule operation +type CreatePurgeScheduleURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreatePurgeScheduleURL) WithBasePath(bp string) *CreatePurgeScheduleURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreatePurgeScheduleURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreatePurgeScheduleURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/system/purgeaudit/schedule" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreatePurgeScheduleURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreatePurgeScheduleURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreatePurgeScheduleURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreatePurgeScheduleURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreatePurgeScheduleURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreatePurgeScheduleURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/purge/get_purge_history.go b/src/server/v2.0/restapi/operations/purge/get_purge_history.go new file mode 100644 index 000000000..43c33eaa0 --- /dev/null +++ b/src/server/v2.0/restapi/operations/purge/get_purge_history.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package purge + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetPurgeHistoryHandlerFunc turns a function with the right signature into a get purge history handler +type GetPurgeHistoryHandlerFunc func(GetPurgeHistoryParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetPurgeHistoryHandlerFunc) Handle(params GetPurgeHistoryParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetPurgeHistoryHandler interface for that can handle valid get purge history params +type GetPurgeHistoryHandler interface { + Handle(GetPurgeHistoryParams, interface{}) middleware.Responder +} + +// NewGetPurgeHistory creates a new http.Handler for the get purge history operation +func NewGetPurgeHistory(ctx *middleware.Context, handler GetPurgeHistoryHandler) *GetPurgeHistory { + return &GetPurgeHistory{Context: ctx, Handler: handler} +} + +/*GetPurgeHistory swagger:route GET /system/purgeaudit purge getPurgeHistory + +Get purge job results. + +get purge job execution history. + +*/ +type GetPurgeHistory struct { + Context *middleware.Context + Handler GetPurgeHistoryHandler +} + +func (o *GetPurgeHistory) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetPurgeHistoryParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/purge/get_purge_history_parameters.go b/src/server/v2.0/restapi/operations/purge/get_purge_history_parameters.go new file mode 100644 index 000000000..4176d88f6 --- /dev/null +++ b/src/server/v2.0/restapi/operations/purge/get_purge_history_parameters.go @@ -0,0 +1,239 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package purge + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewGetPurgeHistoryParams creates a new GetPurgeHistoryParams object +// with the default values initialized. +func NewGetPurgeHistoryParams() GetPurgeHistoryParams { + + var ( + // initialize parameters with default values + + pageDefault = int64(1) + pageSizeDefault = int64(10) + ) + + return GetPurgeHistoryParams{ + Page: &pageDefault, + + PageSize: &pageSizeDefault, + } +} + +// GetPurgeHistoryParams contains all the bound params for the get purge history operation +// typically these are obtained from a http.Request +// +// swagger:parameters getPurgeHistory +type GetPurgeHistoryParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The page number + In: query + Default: 1 + */ + Page *int64 + /*The size of per page + Maximum: 100 + In: query + Default: 10 + */ + PageSize *int64 + /*Query string to query resources. Supported query patterns are "exact match(k=v)", "fuzzy match(k=~v)", "range(k=[min~max])", "list with union releationship(k={v1 v2 v3})" and "list with intersetion relationship(k=(v1 v2 v3))". The value of range and list can be string(enclosed by " or '), integer or time(in format "2020-04-09 02:36:00"). All of these query patterns should be put in the query string "q=xxx" and splitted by ",". e.g. q=k1=v1,k2=~v2,k3=[min~max] + In: query + */ + Q *string + /*Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + In: query + */ + Sort *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetPurgeHistoryParams() beforehand. +func (o *GetPurgeHistoryParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + qPage, qhkPage, _ := qs.GetOK("page") + if err := o.bindPage(qPage, qhkPage, route.Formats); err != nil { + res = append(res, err) + } + + qPageSize, qhkPageSize, _ := qs.GetOK("page_size") + if err := o.bindPageSize(qPageSize, qhkPageSize, route.Formats); err != nil { + res = append(res, err) + } + + qQ, qhkQ, _ := qs.GetOK("q") + if err := o.bindQ(qQ, qhkQ, route.Formats); err != nil { + res = append(res, err) + } + + qSort, qhkSort, _ := qs.GetOK("sort") + if err := o.bindSort(qSort, qhkSort, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetPurgeHistoryParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetPurgeHistoryParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindPage binds and validates parameter Page from query. +func (o *GetPurgeHistoryParams) bindPage(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewGetPurgeHistoryParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page", "query", "int64", raw) + } + o.Page = &value + + return nil +} + +// bindPageSize binds and validates parameter PageSize from query. +func (o *GetPurgeHistoryParams) bindPageSize(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewGetPurgeHistoryParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page_size", "query", "int64", raw) + } + o.PageSize = &value + + if err := o.validatePageSize(formats); err != nil { + return err + } + + return nil +} + +// validatePageSize carries on validations for parameter PageSize +func (o *GetPurgeHistoryParams) validatePageSize(formats strfmt.Registry) error { + + if err := validate.MaximumInt("page_size", "query", int64(*o.PageSize), 100, false); err != nil { + return err + } + + return nil +} + +// bindQ binds and validates parameter Q from query. +func (o *GetPurgeHistoryParams) bindQ(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Q = &raw + + return nil +} + +// bindSort binds and validates parameter Sort from query. +func (o *GetPurgeHistoryParams) bindSort(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Sort = &raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/purge/get_purge_history_responses.go b/src/server/v2.0/restapi/operations/purge/get_purge_history_responses.go new file mode 100644 index 000000000..f240607b1 --- /dev/null +++ b/src/server/v2.0/restapi/operations/purge/get_purge_history_responses.go @@ -0,0 +1,304 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package purge + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/swag" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetPurgeHistoryOKCode is the HTTP code returned for type GetPurgeHistoryOK +const GetPurgeHistoryOKCode int = 200 + +/*GetPurgeHistoryOK Get purge job results successfully. + +swagger:response getPurgeHistoryOK +*/ +type GetPurgeHistoryOK struct { + /*Link refers to the previous page and next page + + */ + Link string `json:"Link"` + /*The total count of history + + */ + XTotalCount int64 `json:"X-Total-Count"` + + /* + In: Body + */ + Payload []*models.ExecHistory `json:"body,omitempty"` +} + +// NewGetPurgeHistoryOK creates GetPurgeHistoryOK with default headers values +func NewGetPurgeHistoryOK() *GetPurgeHistoryOK { + + return &GetPurgeHistoryOK{} +} + +// WithLink adds the link to the get purge history o k response +func (o *GetPurgeHistoryOK) WithLink(link string) *GetPurgeHistoryOK { + o.Link = link + return o +} + +// SetLink sets the link to the get purge history o k response +func (o *GetPurgeHistoryOK) SetLink(link string) { + o.Link = link +} + +// WithXTotalCount adds the xTotalCount to the get purge history o k response +func (o *GetPurgeHistoryOK) WithXTotalCount(xTotalCount int64) *GetPurgeHistoryOK { + o.XTotalCount = xTotalCount + return o +} + +// SetXTotalCount sets the xTotalCount to the get purge history o k response +func (o *GetPurgeHistoryOK) SetXTotalCount(xTotalCount int64) { + o.XTotalCount = xTotalCount +} + +// WithPayload adds the payload to the get purge history o k response +func (o *GetPurgeHistoryOK) WithPayload(payload []*models.ExecHistory) *GetPurgeHistoryOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get purge history o k response +func (o *GetPurgeHistoryOK) SetPayload(payload []*models.ExecHistory) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetPurgeHistoryOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Link + + link := o.Link + if link != "" { + rw.Header().Set("Link", link) + } + + // response header X-Total-Count + + xTotalCount := swag.FormatInt64(o.XTotalCount) + if xTotalCount != "" { + rw.Header().Set("X-Total-Count", xTotalCount) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = make([]*models.ExecHistory, 0, 50) + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// GetPurgeHistoryUnauthorizedCode is the HTTP code returned for type GetPurgeHistoryUnauthorized +const GetPurgeHistoryUnauthorizedCode int = 401 + +/*GetPurgeHistoryUnauthorized Unauthorized + +swagger:response getPurgeHistoryUnauthorized +*/ +type GetPurgeHistoryUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetPurgeHistoryUnauthorized creates GetPurgeHistoryUnauthorized with default headers values +func NewGetPurgeHistoryUnauthorized() *GetPurgeHistoryUnauthorized { + + return &GetPurgeHistoryUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the get purge history unauthorized response +func (o *GetPurgeHistoryUnauthorized) WithXRequestID(xRequestID string) *GetPurgeHistoryUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get purge history unauthorized response +func (o *GetPurgeHistoryUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get purge history unauthorized response +func (o *GetPurgeHistoryUnauthorized) WithPayload(payload *models.Errors) *GetPurgeHistoryUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get purge history unauthorized response +func (o *GetPurgeHistoryUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetPurgeHistoryUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetPurgeHistoryForbiddenCode is the HTTP code returned for type GetPurgeHistoryForbidden +const GetPurgeHistoryForbiddenCode int = 403 + +/*GetPurgeHistoryForbidden Forbidden + +swagger:response getPurgeHistoryForbidden +*/ +type GetPurgeHistoryForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetPurgeHistoryForbidden creates GetPurgeHistoryForbidden with default headers values +func NewGetPurgeHistoryForbidden() *GetPurgeHistoryForbidden { + + return &GetPurgeHistoryForbidden{} +} + +// WithXRequestID adds the xRequestId to the get purge history forbidden response +func (o *GetPurgeHistoryForbidden) WithXRequestID(xRequestID string) *GetPurgeHistoryForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get purge history forbidden response +func (o *GetPurgeHistoryForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get purge history forbidden response +func (o *GetPurgeHistoryForbidden) WithPayload(payload *models.Errors) *GetPurgeHistoryForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get purge history forbidden response +func (o *GetPurgeHistoryForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetPurgeHistoryForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetPurgeHistoryInternalServerErrorCode is the HTTP code returned for type GetPurgeHistoryInternalServerError +const GetPurgeHistoryInternalServerErrorCode int = 500 + +/*GetPurgeHistoryInternalServerError Internal server error + +swagger:response getPurgeHistoryInternalServerError +*/ +type GetPurgeHistoryInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetPurgeHistoryInternalServerError creates GetPurgeHistoryInternalServerError with default headers values +func NewGetPurgeHistoryInternalServerError() *GetPurgeHistoryInternalServerError { + + return &GetPurgeHistoryInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get purge history internal server error response +func (o *GetPurgeHistoryInternalServerError) WithXRequestID(xRequestID string) *GetPurgeHistoryInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get purge history internal server error response +func (o *GetPurgeHistoryInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get purge history internal server error response +func (o *GetPurgeHistoryInternalServerError) WithPayload(payload *models.Errors) *GetPurgeHistoryInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get purge history internal server error response +func (o *GetPurgeHistoryInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetPurgeHistoryInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/purge/get_purge_history_urlbuilder.go b/src/server/v2.0/restapi/operations/purge/get_purge_history_urlbuilder.go new file mode 100644 index 000000000..dae664b21 --- /dev/null +++ b/src/server/v2.0/restapi/operations/purge/get_purge_history_urlbuilder.go @@ -0,0 +1,132 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package purge + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// GetPurgeHistoryURL generates an URL for the get purge history operation +type GetPurgeHistoryURL struct { + Page *int64 + PageSize *int64 + Q *string + Sort *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetPurgeHistoryURL) WithBasePath(bp string) *GetPurgeHistoryURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetPurgeHistoryURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetPurgeHistoryURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/system/purgeaudit" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var pageQ string + if o.Page != nil { + pageQ = swag.FormatInt64(*o.Page) + } + if pageQ != "" { + qs.Set("page", pageQ) + } + + var pageSizeQ string + if o.PageSize != nil { + pageSizeQ = swag.FormatInt64(*o.PageSize) + } + if pageSizeQ != "" { + qs.Set("page_size", pageSizeQ) + } + + var qQ string + if o.Q != nil { + qQ = *o.Q + } + if qQ != "" { + qs.Set("q", qQ) + } + + var sortQ string + if o.Sort != nil { + sortQ = *o.Sort + } + if sortQ != "" { + qs.Set("sort", sortQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetPurgeHistoryURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetPurgeHistoryURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetPurgeHistoryURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetPurgeHistoryURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetPurgeHistoryURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetPurgeHistoryURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/purge/get_purge_job.go b/src/server/v2.0/restapi/operations/purge/get_purge_job.go new file mode 100644 index 000000000..1ab8263c9 --- /dev/null +++ b/src/server/v2.0/restapi/operations/purge/get_purge_job.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package purge + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetPurgeJobHandlerFunc turns a function with the right signature into a get purge job handler +type GetPurgeJobHandlerFunc func(GetPurgeJobParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetPurgeJobHandlerFunc) Handle(params GetPurgeJobParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetPurgeJobHandler interface for that can handle valid get purge job params +type GetPurgeJobHandler interface { + Handle(GetPurgeJobParams, interface{}) middleware.Responder +} + +// NewGetPurgeJob creates a new http.Handler for the get purge job operation +func NewGetPurgeJob(ctx *middleware.Context, handler GetPurgeJobHandler) *GetPurgeJob { + return &GetPurgeJob{Context: ctx, Handler: handler} +} + +/*GetPurgeJob swagger:route GET /system/purgeaudit/{purge_id} purge getPurgeJob + +Get purge job status. + +This endpoint let user get purge job status filtered by specific ID. + +*/ +type GetPurgeJob struct { + Context *middleware.Context + Handler GetPurgeJobHandler +} + +func (o *GetPurgeJob) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetPurgeJobParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/purge/get_purge_job_log.go b/src/server/v2.0/restapi/operations/purge/get_purge_job_log.go new file mode 100644 index 000000000..f9689bf5e --- /dev/null +++ b/src/server/v2.0/restapi/operations/purge/get_purge_job_log.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package purge + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetPurgeJobLogHandlerFunc turns a function with the right signature into a get purge job log handler +type GetPurgeJobLogHandlerFunc func(GetPurgeJobLogParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetPurgeJobLogHandlerFunc) Handle(params GetPurgeJobLogParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetPurgeJobLogHandler interface for that can handle valid get purge job log params +type GetPurgeJobLogHandler interface { + Handle(GetPurgeJobLogParams, interface{}) middleware.Responder +} + +// NewGetPurgeJobLog creates a new http.Handler for the get purge job log operation +func NewGetPurgeJobLog(ctx *middleware.Context, handler GetPurgeJobLogHandler) *GetPurgeJobLog { + return &GetPurgeJobLog{Context: ctx, Handler: handler} +} + +/*GetPurgeJobLog swagger:route GET /system/purgeaudit/{purge_id}/log purge getPurgeJobLog + +Get purge job log. + +This endpoint let user get purge job logs filtered by specific ID. + +*/ +type GetPurgeJobLog struct { + Context *middleware.Context + Handler GetPurgeJobLogHandler +} + +func (o *GetPurgeJobLog) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetPurgeJobLogParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/purge/get_purge_job_log_parameters.go b/src/server/v2.0/restapi/operations/purge/get_purge_job_log_parameters.go new file mode 100644 index 000000000..ba18becc1 --- /dev/null +++ b/src/server/v2.0/restapi/operations/purge/get_purge_job_log_parameters.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package purge + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewGetPurgeJobLogParams creates a new GetPurgeJobLogParams object +// no default values defined in spec. +func NewGetPurgeJobLogParams() GetPurgeJobLogParams { + + return GetPurgeJobLogParams{} +} + +// GetPurgeJobLogParams contains all the bound params for the get purge job log operation +// typically these are obtained from a http.Request +// +// swagger:parameters getPurgeJobLog +type GetPurgeJobLogParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The ID of the purge log + Required: true + In: path + */ + PurgeID int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetPurgeJobLogParams() beforehand. +func (o *GetPurgeJobLogParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rPurgeID, rhkPurgeID, _ := route.Params.GetOK("purge_id") + if err := o.bindPurgeID(rPurgeID, rhkPurgeID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetPurgeJobLogParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetPurgeJobLogParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindPurgeID binds and validates parameter PurgeID from path. +func (o *GetPurgeJobLogParams) bindPurgeID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("purge_id", "path", "int64", raw) + } + o.PurgeID = value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/purge/get_purge_job_log_responses.go b/src/server/v2.0/restapi/operations/purge/get_purge_job_log_responses.go new file mode 100644 index 000000000..1b581c83c --- /dev/null +++ b/src/server/v2.0/restapi/operations/purge/get_purge_job_log_responses.go @@ -0,0 +1,386 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package purge + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetPurgeJobLogOKCode is the HTTP code returned for type GetPurgeJobLogOK +const GetPurgeJobLogOKCode int = 200 + +/*GetPurgeJobLogOK Get successfully. + +swagger:response getPurgeJobLogOK +*/ +type GetPurgeJobLogOK struct { + + /* + In: Body + */ + Payload string `json:"body,omitempty"` +} + +// NewGetPurgeJobLogOK creates GetPurgeJobLogOK with default headers values +func NewGetPurgeJobLogOK() *GetPurgeJobLogOK { + + return &GetPurgeJobLogOK{} +} + +// WithPayload adds the payload to the get purge job log o k response +func (o *GetPurgeJobLogOK) WithPayload(payload string) *GetPurgeJobLogOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get purge job log o k response +func (o *GetPurgeJobLogOK) SetPayload(payload string) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetPurgeJobLogOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// GetPurgeJobLogBadRequestCode is the HTTP code returned for type GetPurgeJobLogBadRequest +const GetPurgeJobLogBadRequestCode int = 400 + +/*GetPurgeJobLogBadRequest Bad request + +swagger:response getPurgeJobLogBadRequest +*/ +type GetPurgeJobLogBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetPurgeJobLogBadRequest creates GetPurgeJobLogBadRequest with default headers values +func NewGetPurgeJobLogBadRequest() *GetPurgeJobLogBadRequest { + + return &GetPurgeJobLogBadRequest{} +} + +// WithXRequestID adds the xRequestId to the get purge job log bad request response +func (o *GetPurgeJobLogBadRequest) WithXRequestID(xRequestID string) *GetPurgeJobLogBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get purge job log bad request response +func (o *GetPurgeJobLogBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get purge job log bad request response +func (o *GetPurgeJobLogBadRequest) WithPayload(payload *models.Errors) *GetPurgeJobLogBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get purge job log bad request response +func (o *GetPurgeJobLogBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetPurgeJobLogBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetPurgeJobLogUnauthorizedCode is the HTTP code returned for type GetPurgeJobLogUnauthorized +const GetPurgeJobLogUnauthorizedCode int = 401 + +/*GetPurgeJobLogUnauthorized Unauthorized + +swagger:response getPurgeJobLogUnauthorized +*/ +type GetPurgeJobLogUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetPurgeJobLogUnauthorized creates GetPurgeJobLogUnauthorized with default headers values +func NewGetPurgeJobLogUnauthorized() *GetPurgeJobLogUnauthorized { + + return &GetPurgeJobLogUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the get purge job log unauthorized response +func (o *GetPurgeJobLogUnauthorized) WithXRequestID(xRequestID string) *GetPurgeJobLogUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get purge job log unauthorized response +func (o *GetPurgeJobLogUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get purge job log unauthorized response +func (o *GetPurgeJobLogUnauthorized) WithPayload(payload *models.Errors) *GetPurgeJobLogUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get purge job log unauthorized response +func (o *GetPurgeJobLogUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetPurgeJobLogUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetPurgeJobLogForbiddenCode is the HTTP code returned for type GetPurgeJobLogForbidden +const GetPurgeJobLogForbiddenCode int = 403 + +/*GetPurgeJobLogForbidden Forbidden + +swagger:response getPurgeJobLogForbidden +*/ +type GetPurgeJobLogForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetPurgeJobLogForbidden creates GetPurgeJobLogForbidden with default headers values +func NewGetPurgeJobLogForbidden() *GetPurgeJobLogForbidden { + + return &GetPurgeJobLogForbidden{} +} + +// WithXRequestID adds the xRequestId to the get purge job log forbidden response +func (o *GetPurgeJobLogForbidden) WithXRequestID(xRequestID string) *GetPurgeJobLogForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get purge job log forbidden response +func (o *GetPurgeJobLogForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get purge job log forbidden response +func (o *GetPurgeJobLogForbidden) WithPayload(payload *models.Errors) *GetPurgeJobLogForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get purge job log forbidden response +func (o *GetPurgeJobLogForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetPurgeJobLogForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetPurgeJobLogNotFoundCode is the HTTP code returned for type GetPurgeJobLogNotFound +const GetPurgeJobLogNotFoundCode int = 404 + +/*GetPurgeJobLogNotFound Not found + +swagger:response getPurgeJobLogNotFound +*/ +type GetPurgeJobLogNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetPurgeJobLogNotFound creates GetPurgeJobLogNotFound with default headers values +func NewGetPurgeJobLogNotFound() *GetPurgeJobLogNotFound { + + return &GetPurgeJobLogNotFound{} +} + +// WithXRequestID adds the xRequestId to the get purge job log not found response +func (o *GetPurgeJobLogNotFound) WithXRequestID(xRequestID string) *GetPurgeJobLogNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get purge job log not found response +func (o *GetPurgeJobLogNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get purge job log not found response +func (o *GetPurgeJobLogNotFound) WithPayload(payload *models.Errors) *GetPurgeJobLogNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get purge job log not found response +func (o *GetPurgeJobLogNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetPurgeJobLogNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetPurgeJobLogInternalServerErrorCode is the HTTP code returned for type GetPurgeJobLogInternalServerError +const GetPurgeJobLogInternalServerErrorCode int = 500 + +/*GetPurgeJobLogInternalServerError Internal server error + +swagger:response getPurgeJobLogInternalServerError +*/ +type GetPurgeJobLogInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetPurgeJobLogInternalServerError creates GetPurgeJobLogInternalServerError with default headers values +func NewGetPurgeJobLogInternalServerError() *GetPurgeJobLogInternalServerError { + + return &GetPurgeJobLogInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get purge job log internal server error response +func (o *GetPurgeJobLogInternalServerError) WithXRequestID(xRequestID string) *GetPurgeJobLogInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get purge job log internal server error response +func (o *GetPurgeJobLogInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get purge job log internal server error response +func (o *GetPurgeJobLogInternalServerError) WithPayload(payload *models.Errors) *GetPurgeJobLogInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get purge job log internal server error response +func (o *GetPurgeJobLogInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetPurgeJobLogInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/purge/get_purge_job_log_urlbuilder.go b/src/server/v2.0/restapi/operations/purge/get_purge_job_log_urlbuilder.go new file mode 100644 index 000000000..a4d3cd689 --- /dev/null +++ b/src/server/v2.0/restapi/operations/purge/get_purge_job_log_urlbuilder.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package purge + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetPurgeJobLogURL generates an URL for the get purge job log operation +type GetPurgeJobLogURL struct { + PurgeID int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetPurgeJobLogURL) WithBasePath(bp string) *GetPurgeJobLogURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetPurgeJobLogURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetPurgeJobLogURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/system/purgeaudit/{purge_id}/log" + + purgeID := swag.FormatInt64(o.PurgeID) + if purgeID != "" { + _path = strings.Replace(_path, "{purge_id}", purgeID, -1) + } else { + return nil, errors.New("purgeId is required on GetPurgeJobLogURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetPurgeJobLogURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetPurgeJobLogURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetPurgeJobLogURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetPurgeJobLogURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetPurgeJobLogURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetPurgeJobLogURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/purge/get_purge_job_parameters.go b/src/server/v2.0/restapi/operations/purge/get_purge_job_parameters.go new file mode 100644 index 000000000..10795f8bb --- /dev/null +++ b/src/server/v2.0/restapi/operations/purge/get_purge_job_parameters.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package purge + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewGetPurgeJobParams creates a new GetPurgeJobParams object +// no default values defined in spec. +func NewGetPurgeJobParams() GetPurgeJobParams { + + return GetPurgeJobParams{} +} + +// GetPurgeJobParams contains all the bound params for the get purge job operation +// typically these are obtained from a http.Request +// +// swagger:parameters getPurgeJob +type GetPurgeJobParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The ID of the purge log + Required: true + In: path + */ + PurgeID int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetPurgeJobParams() beforehand. +func (o *GetPurgeJobParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rPurgeID, rhkPurgeID, _ := route.Params.GetOK("purge_id") + if err := o.bindPurgeID(rPurgeID, rhkPurgeID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetPurgeJobParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetPurgeJobParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindPurgeID binds and validates parameter PurgeID from path. +func (o *GetPurgeJobParams) bindPurgeID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("purge_id", "path", "int64", raw) + } + o.PurgeID = value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/purge/get_purge_job_responses.go b/src/server/v2.0/restapi/operations/purge/get_purge_job_responses.go new file mode 100644 index 000000000..3d313e11b --- /dev/null +++ b/src/server/v2.0/restapi/operations/purge/get_purge_job_responses.go @@ -0,0 +1,322 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package purge + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetPurgeJobOKCode is the HTTP code returned for type GetPurgeJobOK +const GetPurgeJobOKCode int = 200 + +/*GetPurgeJobOK Get purge job results successfully. + +swagger:response getPurgeJobOK +*/ +type GetPurgeJobOK struct { + + /* + In: Body + */ + Payload *models.ExecHistory `json:"body,omitempty"` +} + +// NewGetPurgeJobOK creates GetPurgeJobOK with default headers values +func NewGetPurgeJobOK() *GetPurgeJobOK { + + return &GetPurgeJobOK{} +} + +// WithPayload adds the payload to the get purge job o k response +func (o *GetPurgeJobOK) WithPayload(payload *models.ExecHistory) *GetPurgeJobOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get purge job o k response +func (o *GetPurgeJobOK) SetPayload(payload *models.ExecHistory) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetPurgeJobOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetPurgeJobUnauthorizedCode is the HTTP code returned for type GetPurgeJobUnauthorized +const GetPurgeJobUnauthorizedCode int = 401 + +/*GetPurgeJobUnauthorized Unauthorized + +swagger:response getPurgeJobUnauthorized +*/ +type GetPurgeJobUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetPurgeJobUnauthorized creates GetPurgeJobUnauthorized with default headers values +func NewGetPurgeJobUnauthorized() *GetPurgeJobUnauthorized { + + return &GetPurgeJobUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the get purge job unauthorized response +func (o *GetPurgeJobUnauthorized) WithXRequestID(xRequestID string) *GetPurgeJobUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get purge job unauthorized response +func (o *GetPurgeJobUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get purge job unauthorized response +func (o *GetPurgeJobUnauthorized) WithPayload(payload *models.Errors) *GetPurgeJobUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get purge job unauthorized response +func (o *GetPurgeJobUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetPurgeJobUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetPurgeJobForbiddenCode is the HTTP code returned for type GetPurgeJobForbidden +const GetPurgeJobForbiddenCode int = 403 + +/*GetPurgeJobForbidden Forbidden + +swagger:response getPurgeJobForbidden +*/ +type GetPurgeJobForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetPurgeJobForbidden creates GetPurgeJobForbidden with default headers values +func NewGetPurgeJobForbidden() *GetPurgeJobForbidden { + + return &GetPurgeJobForbidden{} +} + +// WithXRequestID adds the xRequestId to the get purge job forbidden response +func (o *GetPurgeJobForbidden) WithXRequestID(xRequestID string) *GetPurgeJobForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get purge job forbidden response +func (o *GetPurgeJobForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get purge job forbidden response +func (o *GetPurgeJobForbidden) WithPayload(payload *models.Errors) *GetPurgeJobForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get purge job forbidden response +func (o *GetPurgeJobForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetPurgeJobForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetPurgeJobNotFoundCode is the HTTP code returned for type GetPurgeJobNotFound +const GetPurgeJobNotFoundCode int = 404 + +/*GetPurgeJobNotFound Not found + +swagger:response getPurgeJobNotFound +*/ +type GetPurgeJobNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetPurgeJobNotFound creates GetPurgeJobNotFound with default headers values +func NewGetPurgeJobNotFound() *GetPurgeJobNotFound { + + return &GetPurgeJobNotFound{} +} + +// WithXRequestID adds the xRequestId to the get purge job not found response +func (o *GetPurgeJobNotFound) WithXRequestID(xRequestID string) *GetPurgeJobNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get purge job not found response +func (o *GetPurgeJobNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get purge job not found response +func (o *GetPurgeJobNotFound) WithPayload(payload *models.Errors) *GetPurgeJobNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get purge job not found response +func (o *GetPurgeJobNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetPurgeJobNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetPurgeJobInternalServerErrorCode is the HTTP code returned for type GetPurgeJobInternalServerError +const GetPurgeJobInternalServerErrorCode int = 500 + +/*GetPurgeJobInternalServerError Internal server error + +swagger:response getPurgeJobInternalServerError +*/ +type GetPurgeJobInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetPurgeJobInternalServerError creates GetPurgeJobInternalServerError with default headers values +func NewGetPurgeJobInternalServerError() *GetPurgeJobInternalServerError { + + return &GetPurgeJobInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get purge job internal server error response +func (o *GetPurgeJobInternalServerError) WithXRequestID(xRequestID string) *GetPurgeJobInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get purge job internal server error response +func (o *GetPurgeJobInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get purge job internal server error response +func (o *GetPurgeJobInternalServerError) WithPayload(payload *models.Errors) *GetPurgeJobInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get purge job internal server error response +func (o *GetPurgeJobInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetPurgeJobInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/purge/get_purge_job_urlbuilder.go b/src/server/v2.0/restapi/operations/purge/get_purge_job_urlbuilder.go new file mode 100644 index 000000000..e128b66e3 --- /dev/null +++ b/src/server/v2.0/restapi/operations/purge/get_purge_job_urlbuilder.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package purge + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetPurgeJobURL generates an URL for the get purge job operation +type GetPurgeJobURL struct { + PurgeID int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetPurgeJobURL) WithBasePath(bp string) *GetPurgeJobURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetPurgeJobURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetPurgeJobURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/system/purgeaudit/{purge_id}" + + purgeID := swag.FormatInt64(o.PurgeID) + if purgeID != "" { + _path = strings.Replace(_path, "{purge_id}", purgeID, -1) + } else { + return nil, errors.New("purgeId is required on GetPurgeJobURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetPurgeJobURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetPurgeJobURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetPurgeJobURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetPurgeJobURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetPurgeJobURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetPurgeJobURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/purge/get_purge_schedule.go b/src/server/v2.0/restapi/operations/purge/get_purge_schedule.go new file mode 100644 index 000000000..923c8fbb9 --- /dev/null +++ b/src/server/v2.0/restapi/operations/purge/get_purge_schedule.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package purge + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetPurgeScheduleHandlerFunc turns a function with the right signature into a get purge schedule handler +type GetPurgeScheduleHandlerFunc func(GetPurgeScheduleParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetPurgeScheduleHandlerFunc) Handle(params GetPurgeScheduleParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetPurgeScheduleHandler interface for that can handle valid get purge schedule params +type GetPurgeScheduleHandler interface { + Handle(GetPurgeScheduleParams, interface{}) middleware.Responder +} + +// NewGetPurgeSchedule creates a new http.Handler for the get purge schedule operation +func NewGetPurgeSchedule(ctx *middleware.Context, handler GetPurgeScheduleHandler) *GetPurgeSchedule { + return &GetPurgeSchedule{Context: ctx, Handler: handler} +} + +/*GetPurgeSchedule swagger:route GET /system/purgeaudit/schedule purge getPurgeSchedule + +Get purge's schedule. + +This endpoint is for get schedule of purge job. + +*/ +type GetPurgeSchedule struct { + Context *middleware.Context + Handler GetPurgeScheduleHandler +} + +func (o *GetPurgeSchedule) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetPurgeScheduleParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/purge/get_purge_schedule_parameters.go b/src/server/v2.0/restapi/operations/purge/get_purge_schedule_parameters.go new file mode 100644 index 000000000..6a2a12540 --- /dev/null +++ b/src/server/v2.0/restapi/operations/purge/get_purge_schedule_parameters.go @@ -0,0 +1,89 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package purge + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewGetPurgeScheduleParams creates a new GetPurgeScheduleParams object +// no default values defined in spec. +func NewGetPurgeScheduleParams() GetPurgeScheduleParams { + + return GetPurgeScheduleParams{} +} + +// GetPurgeScheduleParams contains all the bound params for the get purge schedule operation +// typically these are obtained from a http.Request +// +// swagger:parameters getPurgeSchedule +type GetPurgeScheduleParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetPurgeScheduleParams() beforehand. +func (o *GetPurgeScheduleParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetPurgeScheduleParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetPurgeScheduleParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} diff --git a/src/server/v2.0/restapi/operations/purge/get_purge_schedule_responses.go b/src/server/v2.0/restapi/operations/purge/get_purge_schedule_responses.go new file mode 100644 index 000000000..bb75c680c --- /dev/null +++ b/src/server/v2.0/restapi/operations/purge/get_purge_schedule_responses.go @@ -0,0 +1,256 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package purge + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetPurgeScheduleOKCode is the HTTP code returned for type GetPurgeScheduleOK +const GetPurgeScheduleOKCode int = 200 + +/*GetPurgeScheduleOK Get purge job's schedule. + +swagger:response getPurgeScheduleOK +*/ +type GetPurgeScheduleOK struct { + + /* + In: Body + */ + Payload *models.ExecHistory `json:"body,omitempty"` +} + +// NewGetPurgeScheduleOK creates GetPurgeScheduleOK with default headers values +func NewGetPurgeScheduleOK() *GetPurgeScheduleOK { + + return &GetPurgeScheduleOK{} +} + +// WithPayload adds the payload to the get purge schedule o k response +func (o *GetPurgeScheduleOK) WithPayload(payload *models.ExecHistory) *GetPurgeScheduleOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get purge schedule o k response +func (o *GetPurgeScheduleOK) SetPayload(payload *models.ExecHistory) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetPurgeScheduleOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetPurgeScheduleUnauthorizedCode is the HTTP code returned for type GetPurgeScheduleUnauthorized +const GetPurgeScheduleUnauthorizedCode int = 401 + +/*GetPurgeScheduleUnauthorized Unauthorized + +swagger:response getPurgeScheduleUnauthorized +*/ +type GetPurgeScheduleUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetPurgeScheduleUnauthorized creates GetPurgeScheduleUnauthorized with default headers values +func NewGetPurgeScheduleUnauthorized() *GetPurgeScheduleUnauthorized { + + return &GetPurgeScheduleUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the get purge schedule unauthorized response +func (o *GetPurgeScheduleUnauthorized) WithXRequestID(xRequestID string) *GetPurgeScheduleUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get purge schedule unauthorized response +func (o *GetPurgeScheduleUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get purge schedule unauthorized response +func (o *GetPurgeScheduleUnauthorized) WithPayload(payload *models.Errors) *GetPurgeScheduleUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get purge schedule unauthorized response +func (o *GetPurgeScheduleUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetPurgeScheduleUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetPurgeScheduleForbiddenCode is the HTTP code returned for type GetPurgeScheduleForbidden +const GetPurgeScheduleForbiddenCode int = 403 + +/*GetPurgeScheduleForbidden Forbidden + +swagger:response getPurgeScheduleForbidden +*/ +type GetPurgeScheduleForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetPurgeScheduleForbidden creates GetPurgeScheduleForbidden with default headers values +func NewGetPurgeScheduleForbidden() *GetPurgeScheduleForbidden { + + return &GetPurgeScheduleForbidden{} +} + +// WithXRequestID adds the xRequestId to the get purge schedule forbidden response +func (o *GetPurgeScheduleForbidden) WithXRequestID(xRequestID string) *GetPurgeScheduleForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get purge schedule forbidden response +func (o *GetPurgeScheduleForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get purge schedule forbidden response +func (o *GetPurgeScheduleForbidden) WithPayload(payload *models.Errors) *GetPurgeScheduleForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get purge schedule forbidden response +func (o *GetPurgeScheduleForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetPurgeScheduleForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetPurgeScheduleInternalServerErrorCode is the HTTP code returned for type GetPurgeScheduleInternalServerError +const GetPurgeScheduleInternalServerErrorCode int = 500 + +/*GetPurgeScheduleInternalServerError Internal server error + +swagger:response getPurgeScheduleInternalServerError +*/ +type GetPurgeScheduleInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetPurgeScheduleInternalServerError creates GetPurgeScheduleInternalServerError with default headers values +func NewGetPurgeScheduleInternalServerError() *GetPurgeScheduleInternalServerError { + + return &GetPurgeScheduleInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get purge schedule internal server error response +func (o *GetPurgeScheduleInternalServerError) WithXRequestID(xRequestID string) *GetPurgeScheduleInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get purge schedule internal server error response +func (o *GetPurgeScheduleInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get purge schedule internal server error response +func (o *GetPurgeScheduleInternalServerError) WithPayload(payload *models.Errors) *GetPurgeScheduleInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get purge schedule internal server error response +func (o *GetPurgeScheduleInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetPurgeScheduleInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/purge/get_purge_schedule_urlbuilder.go b/src/server/v2.0/restapi/operations/purge/get_purge_schedule_urlbuilder.go new file mode 100644 index 000000000..5ffbda9ec --- /dev/null +++ b/src/server/v2.0/restapi/operations/purge/get_purge_schedule_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package purge + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetPurgeScheduleURL generates an URL for the get purge schedule operation +type GetPurgeScheduleURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetPurgeScheduleURL) WithBasePath(bp string) *GetPurgeScheduleURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetPurgeScheduleURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetPurgeScheduleURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/system/purgeaudit/schedule" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetPurgeScheduleURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetPurgeScheduleURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetPurgeScheduleURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetPurgeScheduleURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetPurgeScheduleURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetPurgeScheduleURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/purge/stop_purge.go b/src/server/v2.0/restapi/operations/purge/stop_purge.go new file mode 100644 index 000000000..a96828035 --- /dev/null +++ b/src/server/v2.0/restapi/operations/purge/stop_purge.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package purge + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// StopPurgeHandlerFunc turns a function with the right signature into a stop purge handler +type StopPurgeHandlerFunc func(StopPurgeParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn StopPurgeHandlerFunc) Handle(params StopPurgeParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// StopPurgeHandler interface for that can handle valid stop purge params +type StopPurgeHandler interface { + Handle(StopPurgeParams, interface{}) middleware.Responder +} + +// NewStopPurge creates a new http.Handler for the stop purge operation +func NewStopPurge(ctx *middleware.Context, handler StopPurgeHandler) *StopPurge { + return &StopPurge{Context: ctx, Handler: handler} +} + +/*StopPurge swagger:route PUT /system/purgeaudit/{purge_id} purge stopPurge + +Stop the specific purge audit log execution + +Stop the purge audit log execution specified by ID + +*/ +type StopPurge struct { + Context *middleware.Context + Handler StopPurgeHandler +} + +func (o *StopPurge) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewStopPurgeParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/purge/stop_purge_parameters.go b/src/server/v2.0/restapi/operations/purge/stop_purge_parameters.go new file mode 100644 index 000000000..362f77872 --- /dev/null +++ b/src/server/v2.0/restapi/operations/purge/stop_purge_parameters.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package purge + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewStopPurgeParams creates a new StopPurgeParams object +// no default values defined in spec. +func NewStopPurgeParams() StopPurgeParams { + + return StopPurgeParams{} +} + +// StopPurgeParams contains all the bound params for the stop purge operation +// typically these are obtained from a http.Request +// +// swagger:parameters stopPurge +type StopPurgeParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The ID of the purge log + Required: true + In: path + */ + PurgeID int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewStopPurgeParams() beforehand. +func (o *StopPurgeParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rPurgeID, rhkPurgeID, _ := route.Params.GetOK("purge_id") + if err := o.bindPurgeID(rPurgeID, rhkPurgeID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *StopPurgeParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *StopPurgeParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindPurgeID binds and validates parameter PurgeID from path. +func (o *StopPurgeParams) bindPurgeID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("purge_id", "path", "int64", raw) + } + o.PurgeID = value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/purge/stop_purge_responses.go b/src/server/v2.0/restapi/operations/purge/stop_purge_responses.go new file mode 100644 index 000000000..01b5401f0 --- /dev/null +++ b/src/server/v2.0/restapi/operations/purge/stop_purge_responses.go @@ -0,0 +1,324 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package purge + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// StopPurgeOKCode is the HTTP code returned for type StopPurgeOK +const StopPurgeOKCode int = 200 + +/*StopPurgeOK Success + +swagger:response stopPurgeOK +*/ +type StopPurgeOK struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewStopPurgeOK creates StopPurgeOK with default headers values +func NewStopPurgeOK() *StopPurgeOK { + + return &StopPurgeOK{} +} + +// WithXRequestID adds the xRequestId to the stop purge o k response +func (o *StopPurgeOK) WithXRequestID(xRequestID string) *StopPurgeOK { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the stop purge o k response +func (o *StopPurgeOK) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *StopPurgeOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// StopPurgeUnauthorizedCode is the HTTP code returned for type StopPurgeUnauthorized +const StopPurgeUnauthorizedCode int = 401 + +/*StopPurgeUnauthorized Unauthorized + +swagger:response stopPurgeUnauthorized +*/ +type StopPurgeUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewStopPurgeUnauthorized creates StopPurgeUnauthorized with default headers values +func NewStopPurgeUnauthorized() *StopPurgeUnauthorized { + + return &StopPurgeUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the stop purge unauthorized response +func (o *StopPurgeUnauthorized) WithXRequestID(xRequestID string) *StopPurgeUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the stop purge unauthorized response +func (o *StopPurgeUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the stop purge unauthorized response +func (o *StopPurgeUnauthorized) WithPayload(payload *models.Errors) *StopPurgeUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the stop purge unauthorized response +func (o *StopPurgeUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *StopPurgeUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// StopPurgeForbiddenCode is the HTTP code returned for type StopPurgeForbidden +const StopPurgeForbiddenCode int = 403 + +/*StopPurgeForbidden Forbidden + +swagger:response stopPurgeForbidden +*/ +type StopPurgeForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewStopPurgeForbidden creates StopPurgeForbidden with default headers values +func NewStopPurgeForbidden() *StopPurgeForbidden { + + return &StopPurgeForbidden{} +} + +// WithXRequestID adds the xRequestId to the stop purge forbidden response +func (o *StopPurgeForbidden) WithXRequestID(xRequestID string) *StopPurgeForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the stop purge forbidden response +func (o *StopPurgeForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the stop purge forbidden response +func (o *StopPurgeForbidden) WithPayload(payload *models.Errors) *StopPurgeForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the stop purge forbidden response +func (o *StopPurgeForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *StopPurgeForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// StopPurgeNotFoundCode is the HTTP code returned for type StopPurgeNotFound +const StopPurgeNotFoundCode int = 404 + +/*StopPurgeNotFound Not found + +swagger:response stopPurgeNotFound +*/ +type StopPurgeNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewStopPurgeNotFound creates StopPurgeNotFound with default headers values +func NewStopPurgeNotFound() *StopPurgeNotFound { + + return &StopPurgeNotFound{} +} + +// WithXRequestID adds the xRequestId to the stop purge not found response +func (o *StopPurgeNotFound) WithXRequestID(xRequestID string) *StopPurgeNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the stop purge not found response +func (o *StopPurgeNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the stop purge not found response +func (o *StopPurgeNotFound) WithPayload(payload *models.Errors) *StopPurgeNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the stop purge not found response +func (o *StopPurgeNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *StopPurgeNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// StopPurgeInternalServerErrorCode is the HTTP code returned for type StopPurgeInternalServerError +const StopPurgeInternalServerErrorCode int = 500 + +/*StopPurgeInternalServerError Internal server error + +swagger:response stopPurgeInternalServerError +*/ +type StopPurgeInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewStopPurgeInternalServerError creates StopPurgeInternalServerError with default headers values +func NewStopPurgeInternalServerError() *StopPurgeInternalServerError { + + return &StopPurgeInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the stop purge internal server error response +func (o *StopPurgeInternalServerError) WithXRequestID(xRequestID string) *StopPurgeInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the stop purge internal server error response +func (o *StopPurgeInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the stop purge internal server error response +func (o *StopPurgeInternalServerError) WithPayload(payload *models.Errors) *StopPurgeInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the stop purge internal server error response +func (o *StopPurgeInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *StopPurgeInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/purge/stop_purge_urlbuilder.go b/src/server/v2.0/restapi/operations/purge/stop_purge_urlbuilder.go new file mode 100644 index 000000000..467f51fdc --- /dev/null +++ b/src/server/v2.0/restapi/operations/purge/stop_purge_urlbuilder.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package purge + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// StopPurgeURL generates an URL for the stop purge operation +type StopPurgeURL struct { + PurgeID int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *StopPurgeURL) WithBasePath(bp string) *StopPurgeURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *StopPurgeURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *StopPurgeURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/system/purgeaudit/{purge_id}" + + purgeID := swag.FormatInt64(o.PurgeID) + if purgeID != "" { + _path = strings.Replace(_path, "{purge_id}", purgeID, -1) + } else { + return nil, errors.New("purgeId is required on StopPurgeURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *StopPurgeURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *StopPurgeURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *StopPurgeURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on StopPurgeURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on StopPurgeURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *StopPurgeURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/purge/update_purge_schedule.go b/src/server/v2.0/restapi/operations/purge/update_purge_schedule.go new file mode 100644 index 000000000..daab86579 --- /dev/null +++ b/src/server/v2.0/restapi/operations/purge/update_purge_schedule.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package purge + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// UpdatePurgeScheduleHandlerFunc turns a function with the right signature into a update purge schedule handler +type UpdatePurgeScheduleHandlerFunc func(UpdatePurgeScheduleParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn UpdatePurgeScheduleHandlerFunc) Handle(params UpdatePurgeScheduleParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// UpdatePurgeScheduleHandler interface for that can handle valid update purge schedule params +type UpdatePurgeScheduleHandler interface { + Handle(UpdatePurgeScheduleParams, interface{}) middleware.Responder +} + +// NewUpdatePurgeSchedule creates a new http.Handler for the update purge schedule operation +func NewUpdatePurgeSchedule(ctx *middleware.Context, handler UpdatePurgeScheduleHandler) *UpdatePurgeSchedule { + return &UpdatePurgeSchedule{Context: ctx, Handler: handler} +} + +/*UpdatePurgeSchedule swagger:route PUT /system/purgeaudit/schedule purge updatePurgeSchedule + +Update purge job's schedule. + +This endpoint is for update purge job schedule. + + +*/ +type UpdatePurgeSchedule struct { + Context *middleware.Context + Handler UpdatePurgeScheduleHandler +} + +func (o *UpdatePurgeSchedule) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewUpdatePurgeScheduleParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/purge/update_purge_schedule_parameters.go b/src/server/v2.0/restapi/operations/purge/update_purge_schedule_parameters.go new file mode 100644 index 000000000..1717a5c39 --- /dev/null +++ b/src/server/v2.0/restapi/operations/purge/update_purge_schedule_parameters.go @@ -0,0 +1,124 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package purge + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewUpdatePurgeScheduleParams creates a new UpdatePurgeScheduleParams object +// no default values defined in spec. +func NewUpdatePurgeScheduleParams() UpdatePurgeScheduleParams { + + return UpdatePurgeScheduleParams{} +} + +// UpdatePurgeScheduleParams contains all the bound params for the update purge schedule operation +// typically these are obtained from a http.Request +// +// swagger:parameters updatePurgeSchedule +type UpdatePurgeScheduleParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The purge job's schedule, it is a json object. | + The sample format is | + {"parameters":{"audit_retention_hour":168,"dry_run":true, "include_operations":"create,delete,pull"},"schedule":{"type":"Hourly","cron":"0 0 * * * *"}} | + the include_operation should be a comma separated string, e.g. create,delete,pull, if it is empty, no operation will be purged. + + Required: true + In: body + */ + Schedule *models.Schedule +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewUpdatePurgeScheduleParams() beforehand. +func (o *UpdatePurgeScheduleParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Schedule + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("schedule", "body", "")) + } else { + res = append(res, errors.NewParseError("schedule", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Schedule = &body + } + } + } else { + res = append(res, errors.Required("schedule", "body", "")) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *UpdatePurgeScheduleParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *UpdatePurgeScheduleParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} diff --git a/src/server/v2.0/restapi/operations/purge/update_purge_schedule_responses.go b/src/server/v2.0/restapi/operations/purge/update_purge_schedule_responses.go new file mode 100644 index 000000000..ba8e5c56c --- /dev/null +++ b/src/server/v2.0/restapi/operations/purge/update_purge_schedule_responses.go @@ -0,0 +1,302 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package purge + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// UpdatePurgeScheduleOKCode is the HTTP code returned for type UpdatePurgeScheduleOK +const UpdatePurgeScheduleOKCode int = 200 + +/*UpdatePurgeScheduleOK Updated purge's schedule successfully. + +swagger:response updatePurgeScheduleOK +*/ +type UpdatePurgeScheduleOK struct { +} + +// NewUpdatePurgeScheduleOK creates UpdatePurgeScheduleOK with default headers values +func NewUpdatePurgeScheduleOK() *UpdatePurgeScheduleOK { + + return &UpdatePurgeScheduleOK{} +} + +// WriteResponse to the client +func (o *UpdatePurgeScheduleOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// UpdatePurgeScheduleBadRequestCode is the HTTP code returned for type UpdatePurgeScheduleBadRequest +const UpdatePurgeScheduleBadRequestCode int = 400 + +/*UpdatePurgeScheduleBadRequest Bad request + +swagger:response updatePurgeScheduleBadRequest +*/ +type UpdatePurgeScheduleBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdatePurgeScheduleBadRequest creates UpdatePurgeScheduleBadRequest with default headers values +func NewUpdatePurgeScheduleBadRequest() *UpdatePurgeScheduleBadRequest { + + return &UpdatePurgeScheduleBadRequest{} +} + +// WithXRequestID adds the xRequestId to the update purge schedule bad request response +func (o *UpdatePurgeScheduleBadRequest) WithXRequestID(xRequestID string) *UpdatePurgeScheduleBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update purge schedule bad request response +func (o *UpdatePurgeScheduleBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update purge schedule bad request response +func (o *UpdatePurgeScheduleBadRequest) WithPayload(payload *models.Errors) *UpdatePurgeScheduleBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update purge schedule bad request response +func (o *UpdatePurgeScheduleBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdatePurgeScheduleBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdatePurgeScheduleUnauthorizedCode is the HTTP code returned for type UpdatePurgeScheduleUnauthorized +const UpdatePurgeScheduleUnauthorizedCode int = 401 + +/*UpdatePurgeScheduleUnauthorized Unauthorized + +swagger:response updatePurgeScheduleUnauthorized +*/ +type UpdatePurgeScheduleUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdatePurgeScheduleUnauthorized creates UpdatePurgeScheduleUnauthorized with default headers values +func NewUpdatePurgeScheduleUnauthorized() *UpdatePurgeScheduleUnauthorized { + + return &UpdatePurgeScheduleUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the update purge schedule unauthorized response +func (o *UpdatePurgeScheduleUnauthorized) WithXRequestID(xRequestID string) *UpdatePurgeScheduleUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update purge schedule unauthorized response +func (o *UpdatePurgeScheduleUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update purge schedule unauthorized response +func (o *UpdatePurgeScheduleUnauthorized) WithPayload(payload *models.Errors) *UpdatePurgeScheduleUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update purge schedule unauthorized response +func (o *UpdatePurgeScheduleUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdatePurgeScheduleUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdatePurgeScheduleForbiddenCode is the HTTP code returned for type UpdatePurgeScheduleForbidden +const UpdatePurgeScheduleForbiddenCode int = 403 + +/*UpdatePurgeScheduleForbidden Forbidden + +swagger:response updatePurgeScheduleForbidden +*/ +type UpdatePurgeScheduleForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdatePurgeScheduleForbidden creates UpdatePurgeScheduleForbidden with default headers values +func NewUpdatePurgeScheduleForbidden() *UpdatePurgeScheduleForbidden { + + return &UpdatePurgeScheduleForbidden{} +} + +// WithXRequestID adds the xRequestId to the update purge schedule forbidden response +func (o *UpdatePurgeScheduleForbidden) WithXRequestID(xRequestID string) *UpdatePurgeScheduleForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update purge schedule forbidden response +func (o *UpdatePurgeScheduleForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update purge schedule forbidden response +func (o *UpdatePurgeScheduleForbidden) WithPayload(payload *models.Errors) *UpdatePurgeScheduleForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update purge schedule forbidden response +func (o *UpdatePurgeScheduleForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdatePurgeScheduleForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdatePurgeScheduleInternalServerErrorCode is the HTTP code returned for type UpdatePurgeScheduleInternalServerError +const UpdatePurgeScheduleInternalServerErrorCode int = 500 + +/*UpdatePurgeScheduleInternalServerError Internal server error + +swagger:response updatePurgeScheduleInternalServerError +*/ +type UpdatePurgeScheduleInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdatePurgeScheduleInternalServerError creates UpdatePurgeScheduleInternalServerError with default headers values +func NewUpdatePurgeScheduleInternalServerError() *UpdatePurgeScheduleInternalServerError { + + return &UpdatePurgeScheduleInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the update purge schedule internal server error response +func (o *UpdatePurgeScheduleInternalServerError) WithXRequestID(xRequestID string) *UpdatePurgeScheduleInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update purge schedule internal server error response +func (o *UpdatePurgeScheduleInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update purge schedule internal server error response +func (o *UpdatePurgeScheduleInternalServerError) WithPayload(payload *models.Errors) *UpdatePurgeScheduleInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update purge schedule internal server error response +func (o *UpdatePurgeScheduleInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdatePurgeScheduleInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/purge/update_purge_schedule_urlbuilder.go b/src/server/v2.0/restapi/operations/purge/update_purge_schedule_urlbuilder.go new file mode 100644 index 000000000..34ff79833 --- /dev/null +++ b/src/server/v2.0/restapi/operations/purge/update_purge_schedule_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package purge + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// UpdatePurgeScheduleURL generates an URL for the update purge schedule operation +type UpdatePurgeScheduleURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdatePurgeScheduleURL) WithBasePath(bp string) *UpdatePurgeScheduleURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdatePurgeScheduleURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *UpdatePurgeScheduleURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/system/purgeaudit/schedule" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *UpdatePurgeScheduleURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *UpdatePurgeScheduleURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *UpdatePurgeScheduleURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on UpdatePurgeScheduleURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on UpdatePurgeScheduleURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *UpdatePurgeScheduleURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/quota/get_quota.go b/src/server/v2.0/restapi/operations/quota/get_quota.go new file mode 100644 index 000000000..89b858ddc --- /dev/null +++ b/src/server/v2.0/restapi/operations/quota/get_quota.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package quota + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetQuotaHandlerFunc turns a function with the right signature into a get quota handler +type GetQuotaHandlerFunc func(GetQuotaParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetQuotaHandlerFunc) Handle(params GetQuotaParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetQuotaHandler interface for that can handle valid get quota params +type GetQuotaHandler interface { + Handle(GetQuotaParams, interface{}) middleware.Responder +} + +// NewGetQuota creates a new http.Handler for the get quota operation +func NewGetQuota(ctx *middleware.Context, handler GetQuotaHandler) *GetQuota { + return &GetQuota{Context: ctx, Handler: handler} +} + +/*GetQuota swagger:route GET /quotas/{id} quota getQuota + +Get the specified quota + +Get the specified quota + +*/ +type GetQuota struct { + Context *middleware.Context + Handler GetQuotaHandler +} + +func (o *GetQuota) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetQuotaParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/quota/get_quota_parameters.go b/src/server/v2.0/restapi/operations/quota/get_quota_parameters.go new file mode 100644 index 000000000..171b6c904 --- /dev/null +++ b/src/server/v2.0/restapi/operations/quota/get_quota_parameters.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package quota + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewGetQuotaParams creates a new GetQuotaParams object +// no default values defined in spec. +func NewGetQuotaParams() GetQuotaParams { + + return GetQuotaParams{} +} + +// GetQuotaParams contains all the bound params for the get quota operation +// typically these are obtained from a http.Request +// +// swagger:parameters getQuota +type GetQuotaParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*Quota ID + Required: true + In: path + */ + ID int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetQuotaParams() beforehand. +func (o *GetQuotaParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetQuotaParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetQuotaParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *GetQuotaParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("id", "path", "int64", raw) + } + o.ID = value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/quota/get_quota_responses.go b/src/server/v2.0/restapi/operations/quota/get_quota_responses.go new file mode 100644 index 000000000..7949a17c5 --- /dev/null +++ b/src/server/v2.0/restapi/operations/quota/get_quota_responses.go @@ -0,0 +1,322 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package quota + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetQuotaOKCode is the HTTP code returned for type GetQuotaOK +const GetQuotaOKCode int = 200 + +/*GetQuotaOK Successfully retrieved the quota. + +swagger:response getQuotaOK +*/ +type GetQuotaOK struct { + + /* + In: Body + */ + Payload *models.Quota `json:"body,omitempty"` +} + +// NewGetQuotaOK creates GetQuotaOK with default headers values +func NewGetQuotaOK() *GetQuotaOK { + + return &GetQuotaOK{} +} + +// WithPayload adds the payload to the get quota o k response +func (o *GetQuotaOK) WithPayload(payload *models.Quota) *GetQuotaOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get quota o k response +func (o *GetQuotaOK) SetPayload(payload *models.Quota) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetQuotaOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetQuotaUnauthorizedCode is the HTTP code returned for type GetQuotaUnauthorized +const GetQuotaUnauthorizedCode int = 401 + +/*GetQuotaUnauthorized Unauthorized + +swagger:response getQuotaUnauthorized +*/ +type GetQuotaUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetQuotaUnauthorized creates GetQuotaUnauthorized with default headers values +func NewGetQuotaUnauthorized() *GetQuotaUnauthorized { + + return &GetQuotaUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the get quota unauthorized response +func (o *GetQuotaUnauthorized) WithXRequestID(xRequestID string) *GetQuotaUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get quota unauthorized response +func (o *GetQuotaUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get quota unauthorized response +func (o *GetQuotaUnauthorized) WithPayload(payload *models.Errors) *GetQuotaUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get quota unauthorized response +func (o *GetQuotaUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetQuotaUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetQuotaForbiddenCode is the HTTP code returned for type GetQuotaForbidden +const GetQuotaForbiddenCode int = 403 + +/*GetQuotaForbidden Forbidden + +swagger:response getQuotaForbidden +*/ +type GetQuotaForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetQuotaForbidden creates GetQuotaForbidden with default headers values +func NewGetQuotaForbidden() *GetQuotaForbidden { + + return &GetQuotaForbidden{} +} + +// WithXRequestID adds the xRequestId to the get quota forbidden response +func (o *GetQuotaForbidden) WithXRequestID(xRequestID string) *GetQuotaForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get quota forbidden response +func (o *GetQuotaForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get quota forbidden response +func (o *GetQuotaForbidden) WithPayload(payload *models.Errors) *GetQuotaForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get quota forbidden response +func (o *GetQuotaForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetQuotaForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetQuotaNotFoundCode is the HTTP code returned for type GetQuotaNotFound +const GetQuotaNotFoundCode int = 404 + +/*GetQuotaNotFound Not found + +swagger:response getQuotaNotFound +*/ +type GetQuotaNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetQuotaNotFound creates GetQuotaNotFound with default headers values +func NewGetQuotaNotFound() *GetQuotaNotFound { + + return &GetQuotaNotFound{} +} + +// WithXRequestID adds the xRequestId to the get quota not found response +func (o *GetQuotaNotFound) WithXRequestID(xRequestID string) *GetQuotaNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get quota not found response +func (o *GetQuotaNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get quota not found response +func (o *GetQuotaNotFound) WithPayload(payload *models.Errors) *GetQuotaNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get quota not found response +func (o *GetQuotaNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetQuotaNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetQuotaInternalServerErrorCode is the HTTP code returned for type GetQuotaInternalServerError +const GetQuotaInternalServerErrorCode int = 500 + +/*GetQuotaInternalServerError Internal server error + +swagger:response getQuotaInternalServerError +*/ +type GetQuotaInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetQuotaInternalServerError creates GetQuotaInternalServerError with default headers values +func NewGetQuotaInternalServerError() *GetQuotaInternalServerError { + + return &GetQuotaInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get quota internal server error response +func (o *GetQuotaInternalServerError) WithXRequestID(xRequestID string) *GetQuotaInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get quota internal server error response +func (o *GetQuotaInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get quota internal server error response +func (o *GetQuotaInternalServerError) WithPayload(payload *models.Errors) *GetQuotaInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get quota internal server error response +func (o *GetQuotaInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetQuotaInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/quota/get_quota_urlbuilder.go b/src/server/v2.0/restapi/operations/quota/get_quota_urlbuilder.go new file mode 100644 index 000000000..01fb801c9 --- /dev/null +++ b/src/server/v2.0/restapi/operations/quota/get_quota_urlbuilder.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package quota + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetQuotaURL generates an URL for the get quota operation +type GetQuotaURL struct { + ID int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetQuotaURL) WithBasePath(bp string) *GetQuotaURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetQuotaURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetQuotaURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/quotas/{id}" + + id := swag.FormatInt64(o.ID) + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on GetQuotaURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetQuotaURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetQuotaURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetQuotaURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetQuotaURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetQuotaURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetQuotaURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/quota/list_quotas.go b/src/server/v2.0/restapi/operations/quota/list_quotas.go new file mode 100644 index 000000000..19f084d07 --- /dev/null +++ b/src/server/v2.0/restapi/operations/quota/list_quotas.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package quota + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ListQuotasHandlerFunc turns a function with the right signature into a list quotas handler +type ListQuotasHandlerFunc func(ListQuotasParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ListQuotasHandlerFunc) Handle(params ListQuotasParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ListQuotasHandler interface for that can handle valid list quotas params +type ListQuotasHandler interface { + Handle(ListQuotasParams, interface{}) middleware.Responder +} + +// NewListQuotas creates a new http.Handler for the list quotas operation +func NewListQuotas(ctx *middleware.Context, handler ListQuotasHandler) *ListQuotas { + return &ListQuotas{Context: ctx, Handler: handler} +} + +/*ListQuotas swagger:route GET /quotas quota listQuotas + +List quotas + +List quotas + +*/ +type ListQuotas struct { + Context *middleware.Context + Handler ListQuotasHandler +} + +func (o *ListQuotas) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewListQuotasParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/quota/list_quotas_parameters.go b/src/server/v2.0/restapi/operations/quota/list_quotas_parameters.go new file mode 100644 index 000000000..47b8b563a --- /dev/null +++ b/src/server/v2.0/restapi/operations/quota/list_quotas_parameters.go @@ -0,0 +1,269 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package quota + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewListQuotasParams creates a new ListQuotasParams object +// with the default values initialized. +func NewListQuotasParams() ListQuotasParams { + + var ( + // initialize parameters with default values + + pageDefault = int64(1) + pageSizeDefault = int64(10) + ) + + return ListQuotasParams{ + Page: &pageDefault, + + PageSize: &pageSizeDefault, + } +} + +// ListQuotasParams contains all the bound params for the list quotas operation +// typically these are obtained from a http.Request +// +// swagger:parameters listQuotas +type ListQuotasParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The page number + In: query + Default: 1 + */ + Page *int64 + /*The size of per page + Maximum: 100 + In: query + Default: 10 + */ + PageSize *int64 + /*The reference type of quota. + In: query + */ + Reference *string + /*The reference id of quota. + In: query + */ + ReferenceID *string + /*Sort method, valid values include: + 'hard.resource_name', '-hard.resource_name', 'used.resource_name', '-used.resource_name'. + Here '-' stands for descending order, resource_name should be the real resource name of the quota. + + In: query + */ + Sort *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewListQuotasParams() beforehand. +func (o *ListQuotasParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + qPage, qhkPage, _ := qs.GetOK("page") + if err := o.bindPage(qPage, qhkPage, route.Formats); err != nil { + res = append(res, err) + } + + qPageSize, qhkPageSize, _ := qs.GetOK("page_size") + if err := o.bindPageSize(qPageSize, qhkPageSize, route.Formats); err != nil { + res = append(res, err) + } + + qReference, qhkReference, _ := qs.GetOK("reference") + if err := o.bindReference(qReference, qhkReference, route.Formats); err != nil { + res = append(res, err) + } + + qReferenceID, qhkReferenceID, _ := qs.GetOK("reference_id") + if err := o.bindReferenceID(qReferenceID, qhkReferenceID, route.Formats); err != nil { + res = append(res, err) + } + + qSort, qhkSort, _ := qs.GetOK("sort") + if err := o.bindSort(qSort, qhkSort, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *ListQuotasParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *ListQuotasParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindPage binds and validates parameter Page from query. +func (o *ListQuotasParams) bindPage(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListQuotasParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page", "query", "int64", raw) + } + o.Page = &value + + return nil +} + +// bindPageSize binds and validates parameter PageSize from query. +func (o *ListQuotasParams) bindPageSize(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListQuotasParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page_size", "query", "int64", raw) + } + o.PageSize = &value + + if err := o.validatePageSize(formats); err != nil { + return err + } + + return nil +} + +// validatePageSize carries on validations for parameter PageSize +func (o *ListQuotasParams) validatePageSize(formats strfmt.Registry) error { + + if err := validate.MaximumInt("page_size", "query", int64(*o.PageSize), 100, false); err != nil { + return err + } + + return nil +} + +// bindReference binds and validates parameter Reference from query. +func (o *ListQuotasParams) bindReference(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Reference = &raw + + return nil +} + +// bindReferenceID binds and validates parameter ReferenceID from query. +func (o *ListQuotasParams) bindReferenceID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.ReferenceID = &raw + + return nil +} + +// bindSort binds and validates parameter Sort from query. +func (o *ListQuotasParams) bindSort(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Sort = &raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/quota/list_quotas_responses.go b/src/server/v2.0/restapi/operations/quota/list_quotas_responses.go new file mode 100644 index 000000000..eda4ed8d9 --- /dev/null +++ b/src/server/v2.0/restapi/operations/quota/list_quotas_responses.go @@ -0,0 +1,304 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package quota + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/swag" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// ListQuotasOKCode is the HTTP code returned for type ListQuotasOK +const ListQuotasOKCode int = 200 + +/*ListQuotasOK Successfully retrieved the quotas. + +swagger:response listQuotasOK +*/ +type ListQuotasOK struct { + /*Link refers to the previous page and next page + + */ + Link string `json:"Link"` + /*The total count of access logs + + */ + XTotalCount int64 `json:"X-Total-Count"` + + /* + In: Body + */ + Payload []*models.Quota `json:"body,omitempty"` +} + +// NewListQuotasOK creates ListQuotasOK with default headers values +func NewListQuotasOK() *ListQuotasOK { + + return &ListQuotasOK{} +} + +// WithLink adds the link to the list quotas o k response +func (o *ListQuotasOK) WithLink(link string) *ListQuotasOK { + o.Link = link + return o +} + +// SetLink sets the link to the list quotas o k response +func (o *ListQuotasOK) SetLink(link string) { + o.Link = link +} + +// WithXTotalCount adds the xTotalCount to the list quotas o k response +func (o *ListQuotasOK) WithXTotalCount(xTotalCount int64) *ListQuotasOK { + o.XTotalCount = xTotalCount + return o +} + +// SetXTotalCount sets the xTotalCount to the list quotas o k response +func (o *ListQuotasOK) SetXTotalCount(xTotalCount int64) { + o.XTotalCount = xTotalCount +} + +// WithPayload adds the payload to the list quotas o k response +func (o *ListQuotasOK) WithPayload(payload []*models.Quota) *ListQuotasOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list quotas o k response +func (o *ListQuotasOK) SetPayload(payload []*models.Quota) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListQuotasOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Link + + link := o.Link + if link != "" { + rw.Header().Set("Link", link) + } + + // response header X-Total-Count + + xTotalCount := swag.FormatInt64(o.XTotalCount) + if xTotalCount != "" { + rw.Header().Set("X-Total-Count", xTotalCount) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = make([]*models.Quota, 0, 50) + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ListQuotasUnauthorizedCode is the HTTP code returned for type ListQuotasUnauthorized +const ListQuotasUnauthorizedCode int = 401 + +/*ListQuotasUnauthorized Unauthorized + +swagger:response listQuotasUnauthorized +*/ +type ListQuotasUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListQuotasUnauthorized creates ListQuotasUnauthorized with default headers values +func NewListQuotasUnauthorized() *ListQuotasUnauthorized { + + return &ListQuotasUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the list quotas unauthorized response +func (o *ListQuotasUnauthorized) WithXRequestID(xRequestID string) *ListQuotasUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list quotas unauthorized response +func (o *ListQuotasUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list quotas unauthorized response +func (o *ListQuotasUnauthorized) WithPayload(payload *models.Errors) *ListQuotasUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list quotas unauthorized response +func (o *ListQuotasUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListQuotasUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListQuotasForbiddenCode is the HTTP code returned for type ListQuotasForbidden +const ListQuotasForbiddenCode int = 403 + +/*ListQuotasForbidden Forbidden + +swagger:response listQuotasForbidden +*/ +type ListQuotasForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListQuotasForbidden creates ListQuotasForbidden with default headers values +func NewListQuotasForbidden() *ListQuotasForbidden { + + return &ListQuotasForbidden{} +} + +// WithXRequestID adds the xRequestId to the list quotas forbidden response +func (o *ListQuotasForbidden) WithXRequestID(xRequestID string) *ListQuotasForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list quotas forbidden response +func (o *ListQuotasForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list quotas forbidden response +func (o *ListQuotasForbidden) WithPayload(payload *models.Errors) *ListQuotasForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list quotas forbidden response +func (o *ListQuotasForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListQuotasForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListQuotasInternalServerErrorCode is the HTTP code returned for type ListQuotasInternalServerError +const ListQuotasInternalServerErrorCode int = 500 + +/*ListQuotasInternalServerError Internal server error + +swagger:response listQuotasInternalServerError +*/ +type ListQuotasInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListQuotasInternalServerError creates ListQuotasInternalServerError with default headers values +func NewListQuotasInternalServerError() *ListQuotasInternalServerError { + + return &ListQuotasInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the list quotas internal server error response +func (o *ListQuotasInternalServerError) WithXRequestID(xRequestID string) *ListQuotasInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list quotas internal server error response +func (o *ListQuotasInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list quotas internal server error response +func (o *ListQuotasInternalServerError) WithPayload(payload *models.Errors) *ListQuotasInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list quotas internal server error response +func (o *ListQuotasInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListQuotasInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/quota/list_quotas_urlbuilder.go b/src/server/v2.0/restapi/operations/quota/list_quotas_urlbuilder.go new file mode 100644 index 000000000..6c8a031cf --- /dev/null +++ b/src/server/v2.0/restapi/operations/quota/list_quotas_urlbuilder.go @@ -0,0 +1,141 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package quota + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// ListQuotasURL generates an URL for the list quotas operation +type ListQuotasURL struct { + Page *int64 + PageSize *int64 + Reference *string + ReferenceID *string + Sort *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListQuotasURL) WithBasePath(bp string) *ListQuotasURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListQuotasURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ListQuotasURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/quotas" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var pageQ string + if o.Page != nil { + pageQ = swag.FormatInt64(*o.Page) + } + if pageQ != "" { + qs.Set("page", pageQ) + } + + var pageSizeQ string + if o.PageSize != nil { + pageSizeQ = swag.FormatInt64(*o.PageSize) + } + if pageSizeQ != "" { + qs.Set("page_size", pageSizeQ) + } + + var referenceQ string + if o.Reference != nil { + referenceQ = *o.Reference + } + if referenceQ != "" { + qs.Set("reference", referenceQ) + } + + var referenceIDQ string + if o.ReferenceID != nil { + referenceIDQ = *o.ReferenceID + } + if referenceIDQ != "" { + qs.Set("reference_id", referenceIDQ) + } + + var sortQ string + if o.Sort != nil { + sortQ = *o.Sort + } + if sortQ != "" { + qs.Set("sort", sortQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ListQuotasURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ListQuotasURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ListQuotasURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ListQuotasURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ListQuotasURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ListQuotasURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/quota/update_quota.go b/src/server/v2.0/restapi/operations/quota/update_quota.go new file mode 100644 index 000000000..0560ea5fc --- /dev/null +++ b/src/server/v2.0/restapi/operations/quota/update_quota.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package quota + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// UpdateQuotaHandlerFunc turns a function with the right signature into a update quota handler +type UpdateQuotaHandlerFunc func(UpdateQuotaParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn UpdateQuotaHandlerFunc) Handle(params UpdateQuotaParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// UpdateQuotaHandler interface for that can handle valid update quota params +type UpdateQuotaHandler interface { + Handle(UpdateQuotaParams, interface{}) middleware.Responder +} + +// NewUpdateQuota creates a new http.Handler for the update quota operation +func NewUpdateQuota(ctx *middleware.Context, handler UpdateQuotaHandler) *UpdateQuota { + return &UpdateQuota{Context: ctx, Handler: handler} +} + +/*UpdateQuota swagger:route PUT /quotas/{id} quota updateQuota + +Update the specified quota + +Update hard limits of the specified quota + +*/ +type UpdateQuota struct { + Context *middleware.Context + Handler UpdateQuotaHandler +} + +func (o *UpdateQuota) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewUpdateQuotaParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/quota/update_quota_parameters.go b/src/server/v2.0/restapi/operations/quota/update_quota_parameters.go new file mode 100644 index 000000000..6262473c1 --- /dev/null +++ b/src/server/v2.0/restapi/operations/quota/update_quota_parameters.go @@ -0,0 +1,150 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package quota + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewUpdateQuotaParams creates a new UpdateQuotaParams object +// no default values defined in spec. +func NewUpdateQuotaParams() UpdateQuotaParams { + + return UpdateQuotaParams{} +} + +// UpdateQuotaParams contains all the bound params for the update quota operation +// typically these are obtained from a http.Request +// +// swagger:parameters updateQuota +type UpdateQuotaParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The new hard limits for the quota + Required: true + In: body + */ + Hard *models.QuotaUpdateReq + /*Quota ID + Required: true + In: path + */ + ID int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewUpdateQuotaParams() beforehand. +func (o *UpdateQuotaParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.QuotaUpdateReq + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("hard", "body", "")) + } else { + res = append(res, errors.NewParseError("hard", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Hard = &body + } + } + } else { + res = append(res, errors.Required("hard", "body", "")) + } + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *UpdateQuotaParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *UpdateQuotaParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *UpdateQuotaParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("id", "path", "int64", raw) + } + o.ID = value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/quota/update_quota_responses.go b/src/server/v2.0/restapi/operations/quota/update_quota_responses.go new file mode 100644 index 000000000..98d55a860 --- /dev/null +++ b/src/server/v2.0/restapi/operations/quota/update_quota_responses.go @@ -0,0 +1,390 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package quota + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// UpdateQuotaOKCode is the HTTP code returned for type UpdateQuotaOK +const UpdateQuotaOKCode int = 200 + +/*UpdateQuotaOK Success + +swagger:response updateQuotaOK +*/ +type UpdateQuotaOK struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewUpdateQuotaOK creates UpdateQuotaOK with default headers values +func NewUpdateQuotaOK() *UpdateQuotaOK { + + return &UpdateQuotaOK{} +} + +// WithXRequestID adds the xRequestId to the update quota o k response +func (o *UpdateQuotaOK) WithXRequestID(xRequestID string) *UpdateQuotaOK { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update quota o k response +func (o *UpdateQuotaOK) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *UpdateQuotaOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// UpdateQuotaBadRequestCode is the HTTP code returned for type UpdateQuotaBadRequest +const UpdateQuotaBadRequestCode int = 400 + +/*UpdateQuotaBadRequest Bad request + +swagger:response updateQuotaBadRequest +*/ +type UpdateQuotaBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateQuotaBadRequest creates UpdateQuotaBadRequest with default headers values +func NewUpdateQuotaBadRequest() *UpdateQuotaBadRequest { + + return &UpdateQuotaBadRequest{} +} + +// WithXRequestID adds the xRequestId to the update quota bad request response +func (o *UpdateQuotaBadRequest) WithXRequestID(xRequestID string) *UpdateQuotaBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update quota bad request response +func (o *UpdateQuotaBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update quota bad request response +func (o *UpdateQuotaBadRequest) WithPayload(payload *models.Errors) *UpdateQuotaBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update quota bad request response +func (o *UpdateQuotaBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateQuotaBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateQuotaUnauthorizedCode is the HTTP code returned for type UpdateQuotaUnauthorized +const UpdateQuotaUnauthorizedCode int = 401 + +/*UpdateQuotaUnauthorized Unauthorized + +swagger:response updateQuotaUnauthorized +*/ +type UpdateQuotaUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateQuotaUnauthorized creates UpdateQuotaUnauthorized with default headers values +func NewUpdateQuotaUnauthorized() *UpdateQuotaUnauthorized { + + return &UpdateQuotaUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the update quota unauthorized response +func (o *UpdateQuotaUnauthorized) WithXRequestID(xRequestID string) *UpdateQuotaUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update quota unauthorized response +func (o *UpdateQuotaUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update quota unauthorized response +func (o *UpdateQuotaUnauthorized) WithPayload(payload *models.Errors) *UpdateQuotaUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update quota unauthorized response +func (o *UpdateQuotaUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateQuotaUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateQuotaForbiddenCode is the HTTP code returned for type UpdateQuotaForbidden +const UpdateQuotaForbiddenCode int = 403 + +/*UpdateQuotaForbidden Forbidden + +swagger:response updateQuotaForbidden +*/ +type UpdateQuotaForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateQuotaForbidden creates UpdateQuotaForbidden with default headers values +func NewUpdateQuotaForbidden() *UpdateQuotaForbidden { + + return &UpdateQuotaForbidden{} +} + +// WithXRequestID adds the xRequestId to the update quota forbidden response +func (o *UpdateQuotaForbidden) WithXRequestID(xRequestID string) *UpdateQuotaForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update quota forbidden response +func (o *UpdateQuotaForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update quota forbidden response +func (o *UpdateQuotaForbidden) WithPayload(payload *models.Errors) *UpdateQuotaForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update quota forbidden response +func (o *UpdateQuotaForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateQuotaForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateQuotaNotFoundCode is the HTTP code returned for type UpdateQuotaNotFound +const UpdateQuotaNotFoundCode int = 404 + +/*UpdateQuotaNotFound Not found + +swagger:response updateQuotaNotFound +*/ +type UpdateQuotaNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateQuotaNotFound creates UpdateQuotaNotFound with default headers values +func NewUpdateQuotaNotFound() *UpdateQuotaNotFound { + + return &UpdateQuotaNotFound{} +} + +// WithXRequestID adds the xRequestId to the update quota not found response +func (o *UpdateQuotaNotFound) WithXRequestID(xRequestID string) *UpdateQuotaNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update quota not found response +func (o *UpdateQuotaNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update quota not found response +func (o *UpdateQuotaNotFound) WithPayload(payload *models.Errors) *UpdateQuotaNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update quota not found response +func (o *UpdateQuotaNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateQuotaNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateQuotaInternalServerErrorCode is the HTTP code returned for type UpdateQuotaInternalServerError +const UpdateQuotaInternalServerErrorCode int = 500 + +/*UpdateQuotaInternalServerError Internal server error + +swagger:response updateQuotaInternalServerError +*/ +type UpdateQuotaInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateQuotaInternalServerError creates UpdateQuotaInternalServerError with default headers values +func NewUpdateQuotaInternalServerError() *UpdateQuotaInternalServerError { + + return &UpdateQuotaInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the update quota internal server error response +func (o *UpdateQuotaInternalServerError) WithXRequestID(xRequestID string) *UpdateQuotaInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update quota internal server error response +func (o *UpdateQuotaInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update quota internal server error response +func (o *UpdateQuotaInternalServerError) WithPayload(payload *models.Errors) *UpdateQuotaInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update quota internal server error response +func (o *UpdateQuotaInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateQuotaInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/quota/update_quota_urlbuilder.go b/src/server/v2.0/restapi/operations/quota/update_quota_urlbuilder.go new file mode 100644 index 000000000..edeff24c1 --- /dev/null +++ b/src/server/v2.0/restapi/operations/quota/update_quota_urlbuilder.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package quota + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// UpdateQuotaURL generates an URL for the update quota operation +type UpdateQuotaURL struct { + ID int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdateQuotaURL) WithBasePath(bp string) *UpdateQuotaURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdateQuotaURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *UpdateQuotaURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/quotas/{id}" + + id := swag.FormatInt64(o.ID) + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on UpdateQuotaURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *UpdateQuotaURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *UpdateQuotaURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *UpdateQuotaURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on UpdateQuotaURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on UpdateQuotaURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *UpdateQuotaURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/registry/create_registry.go b/src/server/v2.0/restapi/operations/registry/create_registry.go new file mode 100644 index 000000000..969dc8845 --- /dev/null +++ b/src/server/v2.0/restapi/operations/registry/create_registry.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package registry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateRegistryHandlerFunc turns a function with the right signature into a create registry handler +type CreateRegistryHandlerFunc func(CreateRegistryParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateRegistryHandlerFunc) Handle(params CreateRegistryParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateRegistryHandler interface for that can handle valid create registry params +type CreateRegistryHandler interface { + Handle(CreateRegistryParams, interface{}) middleware.Responder +} + +// NewCreateRegistry creates a new http.Handler for the create registry operation +func NewCreateRegistry(ctx *middleware.Context, handler CreateRegistryHandler) *CreateRegistry { + return &CreateRegistry{Context: ctx, Handler: handler} +} + +/*CreateRegistry swagger:route POST /registries registry createRegistry + +Create a registry + +Create a registry + +*/ +type CreateRegistry struct { + Context *middleware.Context + Handler CreateRegistryHandler +} + +func (o *CreateRegistry) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewCreateRegistryParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/registry/create_registry_parameters.go b/src/server/v2.0/restapi/operations/registry/create_registry_parameters.go new file mode 100644 index 000000000..2f6d6facb --- /dev/null +++ b/src/server/v2.0/restapi/operations/registry/create_registry_parameters.go @@ -0,0 +1,120 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package registry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewCreateRegistryParams creates a new CreateRegistryParams object +// no default values defined in spec. +func NewCreateRegistryParams() CreateRegistryParams { + + return CreateRegistryParams{} +} + +// CreateRegistryParams contains all the bound params for the create registry operation +// typically these are obtained from a http.Request +// +// swagger:parameters createRegistry +type CreateRegistryParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The registry + Required: true + In: body + */ + Registry *models.Registry +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateRegistryParams() beforehand. +func (o *CreateRegistryParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Registry + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("registry", "body", "")) + } else { + res = append(res, errors.NewParseError("registry", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Registry = &body + } + } + } else { + res = append(res, errors.Required("registry", "body", "")) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *CreateRegistryParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *CreateRegistryParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} diff --git a/src/server/v2.0/restapi/operations/registry/create_registry_responses.go b/src/server/v2.0/restapi/operations/registry/create_registry_responses.go new file mode 100644 index 000000000..657246f2b --- /dev/null +++ b/src/server/v2.0/restapi/operations/registry/create_registry_responses.go @@ -0,0 +1,412 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package registry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// CreateRegistryCreatedCode is the HTTP code returned for type CreateRegistryCreated +const CreateRegistryCreatedCode int = 201 + +/*CreateRegistryCreated Created + +swagger:response createRegistryCreated +*/ +type CreateRegistryCreated struct { + /*The location of the resource + + */ + Location string `json:"Location"` + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewCreateRegistryCreated creates CreateRegistryCreated with default headers values +func NewCreateRegistryCreated() *CreateRegistryCreated { + + return &CreateRegistryCreated{} +} + +// WithLocation adds the location to the create registry created response +func (o *CreateRegistryCreated) WithLocation(location string) *CreateRegistryCreated { + o.Location = location + return o +} + +// SetLocation sets the location to the create registry created response +func (o *CreateRegistryCreated) SetLocation(location string) { + o.Location = location +} + +// WithXRequestID adds the xRequestId to the create registry created response +func (o *CreateRegistryCreated) WithXRequestID(xRequestID string) *CreateRegistryCreated { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create registry created response +func (o *CreateRegistryCreated) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *CreateRegistryCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Location + + location := o.Location + if location != "" { + rw.Header().Set("Location", location) + } + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(201) +} + +// CreateRegistryBadRequestCode is the HTTP code returned for type CreateRegistryBadRequest +const CreateRegistryBadRequestCode int = 400 + +/*CreateRegistryBadRequest Bad request + +swagger:response createRegistryBadRequest +*/ +type CreateRegistryBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateRegistryBadRequest creates CreateRegistryBadRequest with default headers values +func NewCreateRegistryBadRequest() *CreateRegistryBadRequest { + + return &CreateRegistryBadRequest{} +} + +// WithXRequestID adds the xRequestId to the create registry bad request response +func (o *CreateRegistryBadRequest) WithXRequestID(xRequestID string) *CreateRegistryBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create registry bad request response +func (o *CreateRegistryBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create registry bad request response +func (o *CreateRegistryBadRequest) WithPayload(payload *models.Errors) *CreateRegistryBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create registry bad request response +func (o *CreateRegistryBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateRegistryBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateRegistryUnauthorizedCode is the HTTP code returned for type CreateRegistryUnauthorized +const CreateRegistryUnauthorizedCode int = 401 + +/*CreateRegistryUnauthorized Unauthorized + +swagger:response createRegistryUnauthorized +*/ +type CreateRegistryUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateRegistryUnauthorized creates CreateRegistryUnauthorized with default headers values +func NewCreateRegistryUnauthorized() *CreateRegistryUnauthorized { + + return &CreateRegistryUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the create registry unauthorized response +func (o *CreateRegistryUnauthorized) WithXRequestID(xRequestID string) *CreateRegistryUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create registry unauthorized response +func (o *CreateRegistryUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create registry unauthorized response +func (o *CreateRegistryUnauthorized) WithPayload(payload *models.Errors) *CreateRegistryUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create registry unauthorized response +func (o *CreateRegistryUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateRegistryUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateRegistryForbiddenCode is the HTTP code returned for type CreateRegistryForbidden +const CreateRegistryForbiddenCode int = 403 + +/*CreateRegistryForbidden Forbidden + +swagger:response createRegistryForbidden +*/ +type CreateRegistryForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateRegistryForbidden creates CreateRegistryForbidden with default headers values +func NewCreateRegistryForbidden() *CreateRegistryForbidden { + + return &CreateRegistryForbidden{} +} + +// WithXRequestID adds the xRequestId to the create registry forbidden response +func (o *CreateRegistryForbidden) WithXRequestID(xRequestID string) *CreateRegistryForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create registry forbidden response +func (o *CreateRegistryForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create registry forbidden response +func (o *CreateRegistryForbidden) WithPayload(payload *models.Errors) *CreateRegistryForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create registry forbidden response +func (o *CreateRegistryForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateRegistryForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateRegistryConflictCode is the HTTP code returned for type CreateRegistryConflict +const CreateRegistryConflictCode int = 409 + +/*CreateRegistryConflict Conflict + +swagger:response createRegistryConflict +*/ +type CreateRegistryConflict struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateRegistryConflict creates CreateRegistryConflict with default headers values +func NewCreateRegistryConflict() *CreateRegistryConflict { + + return &CreateRegistryConflict{} +} + +// WithXRequestID adds the xRequestId to the create registry conflict response +func (o *CreateRegistryConflict) WithXRequestID(xRequestID string) *CreateRegistryConflict { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create registry conflict response +func (o *CreateRegistryConflict) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create registry conflict response +func (o *CreateRegistryConflict) WithPayload(payload *models.Errors) *CreateRegistryConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create registry conflict response +func (o *CreateRegistryConflict) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateRegistryConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateRegistryInternalServerErrorCode is the HTTP code returned for type CreateRegistryInternalServerError +const CreateRegistryInternalServerErrorCode int = 500 + +/*CreateRegistryInternalServerError Internal server error + +swagger:response createRegistryInternalServerError +*/ +type CreateRegistryInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateRegistryInternalServerError creates CreateRegistryInternalServerError with default headers values +func NewCreateRegistryInternalServerError() *CreateRegistryInternalServerError { + + return &CreateRegistryInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the create registry internal server error response +func (o *CreateRegistryInternalServerError) WithXRequestID(xRequestID string) *CreateRegistryInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create registry internal server error response +func (o *CreateRegistryInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create registry internal server error response +func (o *CreateRegistryInternalServerError) WithPayload(payload *models.Errors) *CreateRegistryInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create registry internal server error response +func (o *CreateRegistryInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateRegistryInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/registry/create_registry_urlbuilder.go b/src/server/v2.0/restapi/operations/registry/create_registry_urlbuilder.go new file mode 100644 index 000000000..b23e2b667 --- /dev/null +++ b/src/server/v2.0/restapi/operations/registry/create_registry_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package registry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// CreateRegistryURL generates an URL for the create registry operation +type CreateRegistryURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateRegistryURL) WithBasePath(bp string) *CreateRegistryURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateRegistryURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateRegistryURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/registries" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateRegistryURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateRegistryURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateRegistryURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateRegistryURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateRegistryURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateRegistryURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/registry/delete_registry.go b/src/server/v2.0/restapi/operations/registry/delete_registry.go new file mode 100644 index 000000000..a9d6d9ba9 --- /dev/null +++ b/src/server/v2.0/restapi/operations/registry/delete_registry.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package registry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteRegistryHandlerFunc turns a function with the right signature into a delete registry handler +type DeleteRegistryHandlerFunc func(DeleteRegistryParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteRegistryHandlerFunc) Handle(params DeleteRegistryParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteRegistryHandler interface for that can handle valid delete registry params +type DeleteRegistryHandler interface { + Handle(DeleteRegistryParams, interface{}) middleware.Responder +} + +// NewDeleteRegistry creates a new http.Handler for the delete registry operation +func NewDeleteRegistry(ctx *middleware.Context, handler DeleteRegistryHandler) *DeleteRegistry { + return &DeleteRegistry{Context: ctx, Handler: handler} +} + +/*DeleteRegistry swagger:route DELETE /registries/{id} registry deleteRegistry + +Delete the specific registry + +Delete the specific registry + +*/ +type DeleteRegistry struct { + Context *middleware.Context + Handler DeleteRegistryHandler +} + +func (o *DeleteRegistry) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewDeleteRegistryParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/registry/delete_registry_parameters.go b/src/server/v2.0/restapi/operations/registry/delete_registry_parameters.go new file mode 100644 index 000000000..2cca8ea94 --- /dev/null +++ b/src/server/v2.0/restapi/operations/registry/delete_registry_parameters.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package registry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewDeleteRegistryParams creates a new DeleteRegistryParams object +// no default values defined in spec. +func NewDeleteRegistryParams() DeleteRegistryParams { + + return DeleteRegistryParams{} +} + +// DeleteRegistryParams contains all the bound params for the delete registry operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteRegistry +type DeleteRegistryParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*Registry ID + Required: true + In: path + */ + ID int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteRegistryParams() beforehand. +func (o *DeleteRegistryParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *DeleteRegistryParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *DeleteRegistryParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *DeleteRegistryParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("id", "path", "int64", raw) + } + o.ID = value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/registry/delete_registry_responses.go b/src/server/v2.0/restapi/operations/registry/delete_registry_responses.go new file mode 100644 index 000000000..ea7cf8c3d --- /dev/null +++ b/src/server/v2.0/restapi/operations/registry/delete_registry_responses.go @@ -0,0 +1,390 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package registry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// DeleteRegistryOKCode is the HTTP code returned for type DeleteRegistryOK +const DeleteRegistryOKCode int = 200 + +/*DeleteRegistryOK Success + +swagger:response deleteRegistryOK +*/ +type DeleteRegistryOK struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewDeleteRegistryOK creates DeleteRegistryOK with default headers values +func NewDeleteRegistryOK() *DeleteRegistryOK { + + return &DeleteRegistryOK{} +} + +// WithXRequestID adds the xRequestId to the delete registry o k response +func (o *DeleteRegistryOK) WithXRequestID(xRequestID string) *DeleteRegistryOK { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete registry o k response +func (o *DeleteRegistryOK) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *DeleteRegistryOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// DeleteRegistryUnauthorizedCode is the HTTP code returned for type DeleteRegistryUnauthorized +const DeleteRegistryUnauthorizedCode int = 401 + +/*DeleteRegistryUnauthorized Unauthorized + +swagger:response deleteRegistryUnauthorized +*/ +type DeleteRegistryUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteRegistryUnauthorized creates DeleteRegistryUnauthorized with default headers values +func NewDeleteRegistryUnauthorized() *DeleteRegistryUnauthorized { + + return &DeleteRegistryUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the delete registry unauthorized response +func (o *DeleteRegistryUnauthorized) WithXRequestID(xRequestID string) *DeleteRegistryUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete registry unauthorized response +func (o *DeleteRegistryUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete registry unauthorized response +func (o *DeleteRegistryUnauthorized) WithPayload(payload *models.Errors) *DeleteRegistryUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete registry unauthorized response +func (o *DeleteRegistryUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteRegistryUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteRegistryForbiddenCode is the HTTP code returned for type DeleteRegistryForbidden +const DeleteRegistryForbiddenCode int = 403 + +/*DeleteRegistryForbidden Forbidden + +swagger:response deleteRegistryForbidden +*/ +type DeleteRegistryForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteRegistryForbidden creates DeleteRegistryForbidden with default headers values +func NewDeleteRegistryForbidden() *DeleteRegistryForbidden { + + return &DeleteRegistryForbidden{} +} + +// WithXRequestID adds the xRequestId to the delete registry forbidden response +func (o *DeleteRegistryForbidden) WithXRequestID(xRequestID string) *DeleteRegistryForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete registry forbidden response +func (o *DeleteRegistryForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete registry forbidden response +func (o *DeleteRegistryForbidden) WithPayload(payload *models.Errors) *DeleteRegistryForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete registry forbidden response +func (o *DeleteRegistryForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteRegistryForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteRegistryNotFoundCode is the HTTP code returned for type DeleteRegistryNotFound +const DeleteRegistryNotFoundCode int = 404 + +/*DeleteRegistryNotFound Not found + +swagger:response deleteRegistryNotFound +*/ +type DeleteRegistryNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteRegistryNotFound creates DeleteRegistryNotFound with default headers values +func NewDeleteRegistryNotFound() *DeleteRegistryNotFound { + + return &DeleteRegistryNotFound{} +} + +// WithXRequestID adds the xRequestId to the delete registry not found response +func (o *DeleteRegistryNotFound) WithXRequestID(xRequestID string) *DeleteRegistryNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete registry not found response +func (o *DeleteRegistryNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete registry not found response +func (o *DeleteRegistryNotFound) WithPayload(payload *models.Errors) *DeleteRegistryNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete registry not found response +func (o *DeleteRegistryNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteRegistryNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteRegistryPreconditionFailedCode is the HTTP code returned for type DeleteRegistryPreconditionFailed +const DeleteRegistryPreconditionFailedCode int = 412 + +/*DeleteRegistryPreconditionFailed Precondition failed + +swagger:response deleteRegistryPreconditionFailed +*/ +type DeleteRegistryPreconditionFailed struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteRegistryPreconditionFailed creates DeleteRegistryPreconditionFailed with default headers values +func NewDeleteRegistryPreconditionFailed() *DeleteRegistryPreconditionFailed { + + return &DeleteRegistryPreconditionFailed{} +} + +// WithXRequestID adds the xRequestId to the delete registry precondition failed response +func (o *DeleteRegistryPreconditionFailed) WithXRequestID(xRequestID string) *DeleteRegistryPreconditionFailed { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete registry precondition failed response +func (o *DeleteRegistryPreconditionFailed) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete registry precondition failed response +func (o *DeleteRegistryPreconditionFailed) WithPayload(payload *models.Errors) *DeleteRegistryPreconditionFailed { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete registry precondition failed response +func (o *DeleteRegistryPreconditionFailed) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteRegistryPreconditionFailed) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(412) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteRegistryInternalServerErrorCode is the HTTP code returned for type DeleteRegistryInternalServerError +const DeleteRegistryInternalServerErrorCode int = 500 + +/*DeleteRegistryInternalServerError Internal server error + +swagger:response deleteRegistryInternalServerError +*/ +type DeleteRegistryInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteRegistryInternalServerError creates DeleteRegistryInternalServerError with default headers values +func NewDeleteRegistryInternalServerError() *DeleteRegistryInternalServerError { + + return &DeleteRegistryInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the delete registry internal server error response +func (o *DeleteRegistryInternalServerError) WithXRequestID(xRequestID string) *DeleteRegistryInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete registry internal server error response +func (o *DeleteRegistryInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete registry internal server error response +func (o *DeleteRegistryInternalServerError) WithPayload(payload *models.Errors) *DeleteRegistryInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete registry internal server error response +func (o *DeleteRegistryInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteRegistryInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/registry/delete_registry_urlbuilder.go b/src/server/v2.0/restapi/operations/registry/delete_registry_urlbuilder.go new file mode 100644 index 000000000..ab0aa42ed --- /dev/null +++ b/src/server/v2.0/restapi/operations/registry/delete_registry_urlbuilder.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package registry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteRegistryURL generates an URL for the delete registry operation +type DeleteRegistryURL struct { + ID int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteRegistryURL) WithBasePath(bp string) *DeleteRegistryURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteRegistryURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteRegistryURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/registries/{id}" + + id := swag.FormatInt64(o.ID) + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on DeleteRegistryURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteRegistryURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteRegistryURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteRegistryURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteRegistryURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteRegistryURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteRegistryURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/registry/get_registry.go b/src/server/v2.0/restapi/operations/registry/get_registry.go new file mode 100644 index 000000000..970264fc0 --- /dev/null +++ b/src/server/v2.0/restapi/operations/registry/get_registry.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package registry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetRegistryHandlerFunc turns a function with the right signature into a get registry handler +type GetRegistryHandlerFunc func(GetRegistryParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetRegistryHandlerFunc) Handle(params GetRegistryParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetRegistryHandler interface for that can handle valid get registry params +type GetRegistryHandler interface { + Handle(GetRegistryParams, interface{}) middleware.Responder +} + +// NewGetRegistry creates a new http.Handler for the get registry operation +func NewGetRegistry(ctx *middleware.Context, handler GetRegistryHandler) *GetRegistry { + return &GetRegistry{Context: ctx, Handler: handler} +} + +/*GetRegistry swagger:route GET /registries/{id} registry getRegistry + +Get the specific registry + +Get the specific registry + +*/ +type GetRegistry struct { + Context *middleware.Context + Handler GetRegistryHandler +} + +func (o *GetRegistry) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetRegistryParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/registry/get_registry_info.go b/src/server/v2.0/restapi/operations/registry/get_registry_info.go new file mode 100644 index 000000000..0c4043f09 --- /dev/null +++ b/src/server/v2.0/restapi/operations/registry/get_registry_info.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package registry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetRegistryInfoHandlerFunc turns a function with the right signature into a get registry info handler +type GetRegistryInfoHandlerFunc func(GetRegistryInfoParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetRegistryInfoHandlerFunc) Handle(params GetRegistryInfoParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetRegistryInfoHandler interface for that can handle valid get registry info params +type GetRegistryInfoHandler interface { + Handle(GetRegistryInfoParams, interface{}) middleware.Responder +} + +// NewGetRegistryInfo creates a new http.Handler for the get registry info operation +func NewGetRegistryInfo(ctx *middleware.Context, handler GetRegistryInfoHandler) *GetRegistryInfo { + return &GetRegistryInfo{Context: ctx, Handler: handler} +} + +/*GetRegistryInfo swagger:route GET /registries/{id}/info registry getRegistryInfo + +Get the registry info + +Get the registry info + +*/ +type GetRegistryInfo struct { + Context *middleware.Context + Handler GetRegistryInfoHandler +} + +func (o *GetRegistryInfo) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetRegistryInfoParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/registry/get_registry_info_parameters.go b/src/server/v2.0/restapi/operations/registry/get_registry_info_parameters.go new file mode 100644 index 000000000..4acc59bd8 --- /dev/null +++ b/src/server/v2.0/restapi/operations/registry/get_registry_info_parameters.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package registry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewGetRegistryInfoParams creates a new GetRegistryInfoParams object +// no default values defined in spec. +func NewGetRegistryInfoParams() GetRegistryInfoParams { + + return GetRegistryInfoParams{} +} + +// GetRegistryInfoParams contains all the bound params for the get registry info operation +// typically these are obtained from a http.Request +// +// swagger:parameters getRegistryInfo +type GetRegistryInfoParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*Registry ID + Required: true + In: path + */ + ID int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetRegistryInfoParams() beforehand. +func (o *GetRegistryInfoParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetRegistryInfoParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetRegistryInfoParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *GetRegistryInfoParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("id", "path", "int64", raw) + } + o.ID = value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/registry/get_registry_info_responses.go b/src/server/v2.0/restapi/operations/registry/get_registry_info_responses.go new file mode 100644 index 000000000..b5ad4bc53 --- /dev/null +++ b/src/server/v2.0/restapi/operations/registry/get_registry_info_responses.go @@ -0,0 +1,322 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package registry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetRegistryInfoOKCode is the HTTP code returned for type GetRegistryInfoOK +const GetRegistryInfoOKCode int = 200 + +/*GetRegistryInfoOK Success + +swagger:response getRegistryInfoOK +*/ +type GetRegistryInfoOK struct { + + /* + In: Body + */ + Payload *models.RegistryInfo `json:"body,omitempty"` +} + +// NewGetRegistryInfoOK creates GetRegistryInfoOK with default headers values +func NewGetRegistryInfoOK() *GetRegistryInfoOK { + + return &GetRegistryInfoOK{} +} + +// WithPayload adds the payload to the get registry info o k response +func (o *GetRegistryInfoOK) WithPayload(payload *models.RegistryInfo) *GetRegistryInfoOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get registry info o k response +func (o *GetRegistryInfoOK) SetPayload(payload *models.RegistryInfo) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetRegistryInfoOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetRegistryInfoUnauthorizedCode is the HTTP code returned for type GetRegistryInfoUnauthorized +const GetRegistryInfoUnauthorizedCode int = 401 + +/*GetRegistryInfoUnauthorized Unauthorized + +swagger:response getRegistryInfoUnauthorized +*/ +type GetRegistryInfoUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetRegistryInfoUnauthorized creates GetRegistryInfoUnauthorized with default headers values +func NewGetRegistryInfoUnauthorized() *GetRegistryInfoUnauthorized { + + return &GetRegistryInfoUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the get registry info unauthorized response +func (o *GetRegistryInfoUnauthorized) WithXRequestID(xRequestID string) *GetRegistryInfoUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get registry info unauthorized response +func (o *GetRegistryInfoUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get registry info unauthorized response +func (o *GetRegistryInfoUnauthorized) WithPayload(payload *models.Errors) *GetRegistryInfoUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get registry info unauthorized response +func (o *GetRegistryInfoUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetRegistryInfoUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetRegistryInfoForbiddenCode is the HTTP code returned for type GetRegistryInfoForbidden +const GetRegistryInfoForbiddenCode int = 403 + +/*GetRegistryInfoForbidden Forbidden + +swagger:response getRegistryInfoForbidden +*/ +type GetRegistryInfoForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetRegistryInfoForbidden creates GetRegistryInfoForbidden with default headers values +func NewGetRegistryInfoForbidden() *GetRegistryInfoForbidden { + + return &GetRegistryInfoForbidden{} +} + +// WithXRequestID adds the xRequestId to the get registry info forbidden response +func (o *GetRegistryInfoForbidden) WithXRequestID(xRequestID string) *GetRegistryInfoForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get registry info forbidden response +func (o *GetRegistryInfoForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get registry info forbidden response +func (o *GetRegistryInfoForbidden) WithPayload(payload *models.Errors) *GetRegistryInfoForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get registry info forbidden response +func (o *GetRegistryInfoForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetRegistryInfoForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetRegistryInfoNotFoundCode is the HTTP code returned for type GetRegistryInfoNotFound +const GetRegistryInfoNotFoundCode int = 404 + +/*GetRegistryInfoNotFound Not found + +swagger:response getRegistryInfoNotFound +*/ +type GetRegistryInfoNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetRegistryInfoNotFound creates GetRegistryInfoNotFound with default headers values +func NewGetRegistryInfoNotFound() *GetRegistryInfoNotFound { + + return &GetRegistryInfoNotFound{} +} + +// WithXRequestID adds the xRequestId to the get registry info not found response +func (o *GetRegistryInfoNotFound) WithXRequestID(xRequestID string) *GetRegistryInfoNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get registry info not found response +func (o *GetRegistryInfoNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get registry info not found response +func (o *GetRegistryInfoNotFound) WithPayload(payload *models.Errors) *GetRegistryInfoNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get registry info not found response +func (o *GetRegistryInfoNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetRegistryInfoNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetRegistryInfoInternalServerErrorCode is the HTTP code returned for type GetRegistryInfoInternalServerError +const GetRegistryInfoInternalServerErrorCode int = 500 + +/*GetRegistryInfoInternalServerError Internal server error + +swagger:response getRegistryInfoInternalServerError +*/ +type GetRegistryInfoInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetRegistryInfoInternalServerError creates GetRegistryInfoInternalServerError with default headers values +func NewGetRegistryInfoInternalServerError() *GetRegistryInfoInternalServerError { + + return &GetRegistryInfoInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get registry info internal server error response +func (o *GetRegistryInfoInternalServerError) WithXRequestID(xRequestID string) *GetRegistryInfoInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get registry info internal server error response +func (o *GetRegistryInfoInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get registry info internal server error response +func (o *GetRegistryInfoInternalServerError) WithPayload(payload *models.Errors) *GetRegistryInfoInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get registry info internal server error response +func (o *GetRegistryInfoInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetRegistryInfoInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/registry/get_registry_info_urlbuilder.go b/src/server/v2.0/restapi/operations/registry/get_registry_info_urlbuilder.go new file mode 100644 index 000000000..74e06e3d4 --- /dev/null +++ b/src/server/v2.0/restapi/operations/registry/get_registry_info_urlbuilder.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package registry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetRegistryInfoURL generates an URL for the get registry info operation +type GetRegistryInfoURL struct { + ID int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetRegistryInfoURL) WithBasePath(bp string) *GetRegistryInfoURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetRegistryInfoURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetRegistryInfoURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/registries/{id}/info" + + id := swag.FormatInt64(o.ID) + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on GetRegistryInfoURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetRegistryInfoURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetRegistryInfoURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetRegistryInfoURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetRegistryInfoURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetRegistryInfoURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetRegistryInfoURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/registry/get_registry_parameters.go b/src/server/v2.0/restapi/operations/registry/get_registry_parameters.go new file mode 100644 index 000000000..305bb7fef --- /dev/null +++ b/src/server/v2.0/restapi/operations/registry/get_registry_parameters.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package registry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewGetRegistryParams creates a new GetRegistryParams object +// no default values defined in spec. +func NewGetRegistryParams() GetRegistryParams { + + return GetRegistryParams{} +} + +// GetRegistryParams contains all the bound params for the get registry operation +// typically these are obtained from a http.Request +// +// swagger:parameters getRegistry +type GetRegistryParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*Registry ID + Required: true + In: path + */ + ID int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetRegistryParams() beforehand. +func (o *GetRegistryParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetRegistryParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetRegistryParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *GetRegistryParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("id", "path", "int64", raw) + } + o.ID = value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/registry/get_registry_responses.go b/src/server/v2.0/restapi/operations/registry/get_registry_responses.go new file mode 100644 index 000000000..d3449ffd1 --- /dev/null +++ b/src/server/v2.0/restapi/operations/registry/get_registry_responses.go @@ -0,0 +1,322 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package registry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetRegistryOKCode is the HTTP code returned for type GetRegistryOK +const GetRegistryOKCode int = 200 + +/*GetRegistryOK Success + +swagger:response getRegistryOK +*/ +type GetRegistryOK struct { + + /* + In: Body + */ + Payload *models.Registry `json:"body,omitempty"` +} + +// NewGetRegistryOK creates GetRegistryOK with default headers values +func NewGetRegistryOK() *GetRegistryOK { + + return &GetRegistryOK{} +} + +// WithPayload adds the payload to the get registry o k response +func (o *GetRegistryOK) WithPayload(payload *models.Registry) *GetRegistryOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get registry o k response +func (o *GetRegistryOK) SetPayload(payload *models.Registry) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetRegistryOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetRegistryUnauthorizedCode is the HTTP code returned for type GetRegistryUnauthorized +const GetRegistryUnauthorizedCode int = 401 + +/*GetRegistryUnauthorized Unauthorized + +swagger:response getRegistryUnauthorized +*/ +type GetRegistryUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetRegistryUnauthorized creates GetRegistryUnauthorized with default headers values +func NewGetRegistryUnauthorized() *GetRegistryUnauthorized { + + return &GetRegistryUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the get registry unauthorized response +func (o *GetRegistryUnauthorized) WithXRequestID(xRequestID string) *GetRegistryUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get registry unauthorized response +func (o *GetRegistryUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get registry unauthorized response +func (o *GetRegistryUnauthorized) WithPayload(payload *models.Errors) *GetRegistryUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get registry unauthorized response +func (o *GetRegistryUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetRegistryUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetRegistryForbiddenCode is the HTTP code returned for type GetRegistryForbidden +const GetRegistryForbiddenCode int = 403 + +/*GetRegistryForbidden Forbidden + +swagger:response getRegistryForbidden +*/ +type GetRegistryForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetRegistryForbidden creates GetRegistryForbidden with default headers values +func NewGetRegistryForbidden() *GetRegistryForbidden { + + return &GetRegistryForbidden{} +} + +// WithXRequestID adds the xRequestId to the get registry forbidden response +func (o *GetRegistryForbidden) WithXRequestID(xRequestID string) *GetRegistryForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get registry forbidden response +func (o *GetRegistryForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get registry forbidden response +func (o *GetRegistryForbidden) WithPayload(payload *models.Errors) *GetRegistryForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get registry forbidden response +func (o *GetRegistryForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetRegistryForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetRegistryNotFoundCode is the HTTP code returned for type GetRegistryNotFound +const GetRegistryNotFoundCode int = 404 + +/*GetRegistryNotFound Not found + +swagger:response getRegistryNotFound +*/ +type GetRegistryNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetRegistryNotFound creates GetRegistryNotFound with default headers values +func NewGetRegistryNotFound() *GetRegistryNotFound { + + return &GetRegistryNotFound{} +} + +// WithXRequestID adds the xRequestId to the get registry not found response +func (o *GetRegistryNotFound) WithXRequestID(xRequestID string) *GetRegistryNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get registry not found response +func (o *GetRegistryNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get registry not found response +func (o *GetRegistryNotFound) WithPayload(payload *models.Errors) *GetRegistryNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get registry not found response +func (o *GetRegistryNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetRegistryNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetRegistryInternalServerErrorCode is the HTTP code returned for type GetRegistryInternalServerError +const GetRegistryInternalServerErrorCode int = 500 + +/*GetRegistryInternalServerError Internal server error + +swagger:response getRegistryInternalServerError +*/ +type GetRegistryInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetRegistryInternalServerError creates GetRegistryInternalServerError with default headers values +func NewGetRegistryInternalServerError() *GetRegistryInternalServerError { + + return &GetRegistryInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get registry internal server error response +func (o *GetRegistryInternalServerError) WithXRequestID(xRequestID string) *GetRegistryInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get registry internal server error response +func (o *GetRegistryInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get registry internal server error response +func (o *GetRegistryInternalServerError) WithPayload(payload *models.Errors) *GetRegistryInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get registry internal server error response +func (o *GetRegistryInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetRegistryInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/registry/get_registry_urlbuilder.go b/src/server/v2.0/restapi/operations/registry/get_registry_urlbuilder.go new file mode 100644 index 000000000..3c37ab62e --- /dev/null +++ b/src/server/v2.0/restapi/operations/registry/get_registry_urlbuilder.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package registry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetRegistryURL generates an URL for the get registry operation +type GetRegistryURL struct { + ID int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetRegistryURL) WithBasePath(bp string) *GetRegistryURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetRegistryURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetRegistryURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/registries/{id}" + + id := swag.FormatInt64(o.ID) + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on GetRegistryURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetRegistryURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetRegistryURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetRegistryURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetRegistryURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetRegistryURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetRegistryURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/registry/list_registries.go b/src/server/v2.0/restapi/operations/registry/list_registries.go new file mode 100644 index 000000000..3f8c8533b --- /dev/null +++ b/src/server/v2.0/restapi/operations/registry/list_registries.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package registry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ListRegistriesHandlerFunc turns a function with the right signature into a list registries handler +type ListRegistriesHandlerFunc func(ListRegistriesParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ListRegistriesHandlerFunc) Handle(params ListRegistriesParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ListRegistriesHandler interface for that can handle valid list registries params +type ListRegistriesHandler interface { + Handle(ListRegistriesParams, interface{}) middleware.Responder +} + +// NewListRegistries creates a new http.Handler for the list registries operation +func NewListRegistries(ctx *middleware.Context, handler ListRegistriesHandler) *ListRegistries { + return &ListRegistries{Context: ctx, Handler: handler} +} + +/*ListRegistries swagger:route GET /registries registry listRegistries + +List the registries + +List the registries + +*/ +type ListRegistries struct { + Context *middleware.Context + Handler ListRegistriesHandler +} + +func (o *ListRegistries) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewListRegistriesParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/registry/list_registries_parameters.go b/src/server/v2.0/restapi/operations/registry/list_registries_parameters.go new file mode 100644 index 000000000..4dbe163c6 --- /dev/null +++ b/src/server/v2.0/restapi/operations/registry/list_registries_parameters.go @@ -0,0 +1,266 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package registry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewListRegistriesParams creates a new ListRegistriesParams object +// with the default values initialized. +func NewListRegistriesParams() ListRegistriesParams { + + var ( + // initialize parameters with default values + + pageDefault = int64(1) + pageSizeDefault = int64(10) + ) + + return ListRegistriesParams{ + Page: &pageDefault, + + PageSize: &pageSizeDefault, + } +} + +// ListRegistriesParams contains all the bound params for the list registries operation +// typically these are obtained from a http.Request +// +// swagger:parameters listRegistries +type ListRegistriesParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*Deprecated, use `q` instead. + In: query + */ + Name *string + /*The page number + In: query + Default: 1 + */ + Page *int64 + /*The size of per page + Maximum: 100 + In: query + Default: 10 + */ + PageSize *int64 + /*Query string to query resources. Supported query patterns are "exact match(k=v)", "fuzzy match(k=~v)", "range(k=[min~max])", "list with union releationship(k={v1 v2 v3})" and "list with intersetion relationship(k=(v1 v2 v3))". The value of range and list can be string(enclosed by " or '), integer or time(in format "2020-04-09 02:36:00"). All of these query patterns should be put in the query string "q=xxx" and splitted by ",". e.g. q=k1=v1,k2=~v2,k3=[min~max] + In: query + */ + Q *string + /*Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + In: query + */ + Sort *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewListRegistriesParams() beforehand. +func (o *ListRegistriesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + qName, qhkName, _ := qs.GetOK("name") + if err := o.bindName(qName, qhkName, route.Formats); err != nil { + res = append(res, err) + } + + qPage, qhkPage, _ := qs.GetOK("page") + if err := o.bindPage(qPage, qhkPage, route.Formats); err != nil { + res = append(res, err) + } + + qPageSize, qhkPageSize, _ := qs.GetOK("page_size") + if err := o.bindPageSize(qPageSize, qhkPageSize, route.Formats); err != nil { + res = append(res, err) + } + + qQ, qhkQ, _ := qs.GetOK("q") + if err := o.bindQ(qQ, qhkQ, route.Formats); err != nil { + res = append(res, err) + } + + qSort, qhkSort, _ := qs.GetOK("sort") + if err := o.bindSort(qSort, qhkSort, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *ListRegistriesParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *ListRegistriesParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindName binds and validates parameter Name from query. +func (o *ListRegistriesParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Name = &raw + + return nil +} + +// bindPage binds and validates parameter Page from query. +func (o *ListRegistriesParams) bindPage(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListRegistriesParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page", "query", "int64", raw) + } + o.Page = &value + + return nil +} + +// bindPageSize binds and validates parameter PageSize from query. +func (o *ListRegistriesParams) bindPageSize(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListRegistriesParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page_size", "query", "int64", raw) + } + o.PageSize = &value + + if err := o.validatePageSize(formats); err != nil { + return err + } + + return nil +} + +// validatePageSize carries on validations for parameter PageSize +func (o *ListRegistriesParams) validatePageSize(formats strfmt.Registry) error { + + if err := validate.MaximumInt("page_size", "query", int64(*o.PageSize), 100, false); err != nil { + return err + } + + return nil +} + +// bindQ binds and validates parameter Q from query. +func (o *ListRegistriesParams) bindQ(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Q = &raw + + return nil +} + +// bindSort binds and validates parameter Sort from query. +func (o *ListRegistriesParams) bindSort(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Sort = &raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/registry/list_registries_responses.go b/src/server/v2.0/restapi/operations/registry/list_registries_responses.go new file mode 100644 index 000000000..f5658907f --- /dev/null +++ b/src/server/v2.0/restapi/operations/registry/list_registries_responses.go @@ -0,0 +1,304 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package registry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/swag" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// ListRegistriesOKCode is the HTTP code returned for type ListRegistriesOK +const ListRegistriesOKCode int = 200 + +/*ListRegistriesOK Success + +swagger:response listRegistriesOK +*/ +type ListRegistriesOK struct { + /*Link refers to the previous page and next page + + */ + Link string `json:"Link"` + /*The total count of the resources + + */ + XTotalCount int64 `json:"X-Total-Count"` + + /* + In: Body + */ + Payload []*models.Registry `json:"body,omitempty"` +} + +// NewListRegistriesOK creates ListRegistriesOK with default headers values +func NewListRegistriesOK() *ListRegistriesOK { + + return &ListRegistriesOK{} +} + +// WithLink adds the link to the list registries o k response +func (o *ListRegistriesOK) WithLink(link string) *ListRegistriesOK { + o.Link = link + return o +} + +// SetLink sets the link to the list registries o k response +func (o *ListRegistriesOK) SetLink(link string) { + o.Link = link +} + +// WithXTotalCount adds the xTotalCount to the list registries o k response +func (o *ListRegistriesOK) WithXTotalCount(xTotalCount int64) *ListRegistriesOK { + o.XTotalCount = xTotalCount + return o +} + +// SetXTotalCount sets the xTotalCount to the list registries o k response +func (o *ListRegistriesOK) SetXTotalCount(xTotalCount int64) { + o.XTotalCount = xTotalCount +} + +// WithPayload adds the payload to the list registries o k response +func (o *ListRegistriesOK) WithPayload(payload []*models.Registry) *ListRegistriesOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list registries o k response +func (o *ListRegistriesOK) SetPayload(payload []*models.Registry) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListRegistriesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Link + + link := o.Link + if link != "" { + rw.Header().Set("Link", link) + } + + // response header X-Total-Count + + xTotalCount := swag.FormatInt64(o.XTotalCount) + if xTotalCount != "" { + rw.Header().Set("X-Total-Count", xTotalCount) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = make([]*models.Registry, 0, 50) + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ListRegistriesUnauthorizedCode is the HTTP code returned for type ListRegistriesUnauthorized +const ListRegistriesUnauthorizedCode int = 401 + +/*ListRegistriesUnauthorized Unauthorized + +swagger:response listRegistriesUnauthorized +*/ +type ListRegistriesUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListRegistriesUnauthorized creates ListRegistriesUnauthorized with default headers values +func NewListRegistriesUnauthorized() *ListRegistriesUnauthorized { + + return &ListRegistriesUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the list registries unauthorized response +func (o *ListRegistriesUnauthorized) WithXRequestID(xRequestID string) *ListRegistriesUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list registries unauthorized response +func (o *ListRegistriesUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list registries unauthorized response +func (o *ListRegistriesUnauthorized) WithPayload(payload *models.Errors) *ListRegistriesUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list registries unauthorized response +func (o *ListRegistriesUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListRegistriesUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListRegistriesForbiddenCode is the HTTP code returned for type ListRegistriesForbidden +const ListRegistriesForbiddenCode int = 403 + +/*ListRegistriesForbidden Forbidden + +swagger:response listRegistriesForbidden +*/ +type ListRegistriesForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListRegistriesForbidden creates ListRegistriesForbidden with default headers values +func NewListRegistriesForbidden() *ListRegistriesForbidden { + + return &ListRegistriesForbidden{} +} + +// WithXRequestID adds the xRequestId to the list registries forbidden response +func (o *ListRegistriesForbidden) WithXRequestID(xRequestID string) *ListRegistriesForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list registries forbidden response +func (o *ListRegistriesForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list registries forbidden response +func (o *ListRegistriesForbidden) WithPayload(payload *models.Errors) *ListRegistriesForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list registries forbidden response +func (o *ListRegistriesForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListRegistriesForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListRegistriesInternalServerErrorCode is the HTTP code returned for type ListRegistriesInternalServerError +const ListRegistriesInternalServerErrorCode int = 500 + +/*ListRegistriesInternalServerError Internal server error + +swagger:response listRegistriesInternalServerError +*/ +type ListRegistriesInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListRegistriesInternalServerError creates ListRegistriesInternalServerError with default headers values +func NewListRegistriesInternalServerError() *ListRegistriesInternalServerError { + + return &ListRegistriesInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the list registries internal server error response +func (o *ListRegistriesInternalServerError) WithXRequestID(xRequestID string) *ListRegistriesInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list registries internal server error response +func (o *ListRegistriesInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list registries internal server error response +func (o *ListRegistriesInternalServerError) WithPayload(payload *models.Errors) *ListRegistriesInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list registries internal server error response +func (o *ListRegistriesInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListRegistriesInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/registry/list_registries_urlbuilder.go b/src/server/v2.0/restapi/operations/registry/list_registries_urlbuilder.go new file mode 100644 index 000000000..221d40a3f --- /dev/null +++ b/src/server/v2.0/restapi/operations/registry/list_registries_urlbuilder.go @@ -0,0 +1,141 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package registry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// ListRegistriesURL generates an URL for the list registries operation +type ListRegistriesURL struct { + Name *string + Page *int64 + PageSize *int64 + Q *string + Sort *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListRegistriesURL) WithBasePath(bp string) *ListRegistriesURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListRegistriesURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ListRegistriesURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/registries" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var nameQ string + if o.Name != nil { + nameQ = *o.Name + } + if nameQ != "" { + qs.Set("name", nameQ) + } + + var pageQ string + if o.Page != nil { + pageQ = swag.FormatInt64(*o.Page) + } + if pageQ != "" { + qs.Set("page", pageQ) + } + + var pageSizeQ string + if o.PageSize != nil { + pageSizeQ = swag.FormatInt64(*o.PageSize) + } + if pageSizeQ != "" { + qs.Set("page_size", pageSizeQ) + } + + var qQ string + if o.Q != nil { + qQ = *o.Q + } + if qQ != "" { + qs.Set("q", qQ) + } + + var sortQ string + if o.Sort != nil { + sortQ = *o.Sort + } + if sortQ != "" { + qs.Set("sort", sortQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ListRegistriesURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ListRegistriesURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ListRegistriesURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ListRegistriesURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ListRegistriesURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ListRegistriesURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/registry/list_registry_provider_infos.go b/src/server/v2.0/restapi/operations/registry/list_registry_provider_infos.go new file mode 100644 index 000000000..08ab2c020 --- /dev/null +++ b/src/server/v2.0/restapi/operations/registry/list_registry_provider_infos.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package registry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ListRegistryProviderInfosHandlerFunc turns a function with the right signature into a list registry provider infos handler +type ListRegistryProviderInfosHandlerFunc func(ListRegistryProviderInfosParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ListRegistryProviderInfosHandlerFunc) Handle(params ListRegistryProviderInfosParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ListRegistryProviderInfosHandler interface for that can handle valid list registry provider infos params +type ListRegistryProviderInfosHandler interface { + Handle(ListRegistryProviderInfosParams, interface{}) middleware.Responder +} + +// NewListRegistryProviderInfos creates a new http.Handler for the list registry provider infos operation +func NewListRegistryProviderInfos(ctx *middleware.Context, handler ListRegistryProviderInfosHandler) *ListRegistryProviderInfos { + return &ListRegistryProviderInfos{Context: ctx, Handler: handler} +} + +/*ListRegistryProviderInfos swagger:route GET /replication/adapterinfos registry listRegistryProviderInfos + +List all registered registry provider information + +List all registered registry provider information + +*/ +type ListRegistryProviderInfos struct { + Context *middleware.Context + Handler ListRegistryProviderInfosHandler +} + +func (o *ListRegistryProviderInfos) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewListRegistryProviderInfosParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/registry/list_registry_provider_infos_parameters.go b/src/server/v2.0/restapi/operations/registry/list_registry_provider_infos_parameters.go new file mode 100644 index 000000000..4e035bf2b --- /dev/null +++ b/src/server/v2.0/restapi/operations/registry/list_registry_provider_infos_parameters.go @@ -0,0 +1,89 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package registry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewListRegistryProviderInfosParams creates a new ListRegistryProviderInfosParams object +// no default values defined in spec. +func NewListRegistryProviderInfosParams() ListRegistryProviderInfosParams { + + return ListRegistryProviderInfosParams{} +} + +// ListRegistryProviderInfosParams contains all the bound params for the list registry provider infos operation +// typically these are obtained from a http.Request +// +// swagger:parameters listRegistryProviderInfos +type ListRegistryProviderInfosParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewListRegistryProviderInfosParams() beforehand. +func (o *ListRegistryProviderInfosParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *ListRegistryProviderInfosParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *ListRegistryProviderInfosParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} diff --git a/src/server/v2.0/restapi/operations/registry/list_registry_provider_infos_responses.go b/src/server/v2.0/restapi/operations/registry/list_registry_provider_infos_responses.go new file mode 100644 index 000000000..be1282fad --- /dev/null +++ b/src/server/v2.0/restapi/operations/registry/list_registry_provider_infos_responses.go @@ -0,0 +1,259 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package registry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// ListRegistryProviderInfosOKCode is the HTTP code returned for type ListRegistryProviderInfosOK +const ListRegistryProviderInfosOKCode int = 200 + +/*ListRegistryProviderInfosOK Success. + +swagger:response listRegistryProviderInfosOK +*/ +type ListRegistryProviderInfosOK struct { + + /* + In: Body + */ + Payload map[string]models.RegistryProviderInfo `json:"body,omitempty"` +} + +// NewListRegistryProviderInfosOK creates ListRegistryProviderInfosOK with default headers values +func NewListRegistryProviderInfosOK() *ListRegistryProviderInfosOK { + + return &ListRegistryProviderInfosOK{} +} + +// WithPayload adds the payload to the list registry provider infos o k response +func (o *ListRegistryProviderInfosOK) WithPayload(payload map[string]models.RegistryProviderInfo) *ListRegistryProviderInfosOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list registry provider infos o k response +func (o *ListRegistryProviderInfosOK) SetPayload(payload map[string]models.RegistryProviderInfo) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListRegistryProviderInfosOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty map + payload = make(map[string]models.RegistryProviderInfo, 50) + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ListRegistryProviderInfosUnauthorizedCode is the HTTP code returned for type ListRegistryProviderInfosUnauthorized +const ListRegistryProviderInfosUnauthorizedCode int = 401 + +/*ListRegistryProviderInfosUnauthorized Unauthorized + +swagger:response listRegistryProviderInfosUnauthorized +*/ +type ListRegistryProviderInfosUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListRegistryProviderInfosUnauthorized creates ListRegistryProviderInfosUnauthorized with default headers values +func NewListRegistryProviderInfosUnauthorized() *ListRegistryProviderInfosUnauthorized { + + return &ListRegistryProviderInfosUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the list registry provider infos unauthorized response +func (o *ListRegistryProviderInfosUnauthorized) WithXRequestID(xRequestID string) *ListRegistryProviderInfosUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list registry provider infos unauthorized response +func (o *ListRegistryProviderInfosUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list registry provider infos unauthorized response +func (o *ListRegistryProviderInfosUnauthorized) WithPayload(payload *models.Errors) *ListRegistryProviderInfosUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list registry provider infos unauthorized response +func (o *ListRegistryProviderInfosUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListRegistryProviderInfosUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListRegistryProviderInfosForbiddenCode is the HTTP code returned for type ListRegistryProviderInfosForbidden +const ListRegistryProviderInfosForbiddenCode int = 403 + +/*ListRegistryProviderInfosForbidden Forbidden + +swagger:response listRegistryProviderInfosForbidden +*/ +type ListRegistryProviderInfosForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListRegistryProviderInfosForbidden creates ListRegistryProviderInfosForbidden with default headers values +func NewListRegistryProviderInfosForbidden() *ListRegistryProviderInfosForbidden { + + return &ListRegistryProviderInfosForbidden{} +} + +// WithXRequestID adds the xRequestId to the list registry provider infos forbidden response +func (o *ListRegistryProviderInfosForbidden) WithXRequestID(xRequestID string) *ListRegistryProviderInfosForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list registry provider infos forbidden response +func (o *ListRegistryProviderInfosForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list registry provider infos forbidden response +func (o *ListRegistryProviderInfosForbidden) WithPayload(payload *models.Errors) *ListRegistryProviderInfosForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list registry provider infos forbidden response +func (o *ListRegistryProviderInfosForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListRegistryProviderInfosForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListRegistryProviderInfosInternalServerErrorCode is the HTTP code returned for type ListRegistryProviderInfosInternalServerError +const ListRegistryProviderInfosInternalServerErrorCode int = 500 + +/*ListRegistryProviderInfosInternalServerError Internal server error + +swagger:response listRegistryProviderInfosInternalServerError +*/ +type ListRegistryProviderInfosInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListRegistryProviderInfosInternalServerError creates ListRegistryProviderInfosInternalServerError with default headers values +func NewListRegistryProviderInfosInternalServerError() *ListRegistryProviderInfosInternalServerError { + + return &ListRegistryProviderInfosInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the list registry provider infos internal server error response +func (o *ListRegistryProviderInfosInternalServerError) WithXRequestID(xRequestID string) *ListRegistryProviderInfosInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list registry provider infos internal server error response +func (o *ListRegistryProviderInfosInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list registry provider infos internal server error response +func (o *ListRegistryProviderInfosInternalServerError) WithPayload(payload *models.Errors) *ListRegistryProviderInfosInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list registry provider infos internal server error response +func (o *ListRegistryProviderInfosInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListRegistryProviderInfosInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/registry/list_registry_provider_infos_urlbuilder.go b/src/server/v2.0/restapi/operations/registry/list_registry_provider_infos_urlbuilder.go new file mode 100644 index 000000000..c262c2f57 --- /dev/null +++ b/src/server/v2.0/restapi/operations/registry/list_registry_provider_infos_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package registry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// ListRegistryProviderInfosURL generates an URL for the list registry provider infos operation +type ListRegistryProviderInfosURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListRegistryProviderInfosURL) WithBasePath(bp string) *ListRegistryProviderInfosURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListRegistryProviderInfosURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ListRegistryProviderInfosURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/replication/adapterinfos" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ListRegistryProviderInfosURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ListRegistryProviderInfosURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ListRegistryProviderInfosURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ListRegistryProviderInfosURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ListRegistryProviderInfosURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ListRegistryProviderInfosURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/registry/list_registry_provider_types.go b/src/server/v2.0/restapi/operations/registry/list_registry_provider_types.go new file mode 100644 index 000000000..43d928ca4 --- /dev/null +++ b/src/server/v2.0/restapi/operations/registry/list_registry_provider_types.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package registry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ListRegistryProviderTypesHandlerFunc turns a function with the right signature into a list registry provider types handler +type ListRegistryProviderTypesHandlerFunc func(ListRegistryProviderTypesParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ListRegistryProviderTypesHandlerFunc) Handle(params ListRegistryProviderTypesParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ListRegistryProviderTypesHandler interface for that can handle valid list registry provider types params +type ListRegistryProviderTypesHandler interface { + Handle(ListRegistryProviderTypesParams, interface{}) middleware.Responder +} + +// NewListRegistryProviderTypes creates a new http.Handler for the list registry provider types operation +func NewListRegistryProviderTypes(ctx *middleware.Context, handler ListRegistryProviderTypesHandler) *ListRegistryProviderTypes { + return &ListRegistryProviderTypes{Context: ctx, Handler: handler} +} + +/*ListRegistryProviderTypes swagger:route GET /replication/adapters registry listRegistryProviderTypes + +List registry adapters + +List registry adapters + +*/ +type ListRegistryProviderTypes struct { + Context *middleware.Context + Handler ListRegistryProviderTypesHandler +} + +func (o *ListRegistryProviderTypes) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewListRegistryProviderTypesParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/registry/list_registry_provider_types_parameters.go b/src/server/v2.0/restapi/operations/registry/list_registry_provider_types_parameters.go new file mode 100644 index 000000000..a31eb86ca --- /dev/null +++ b/src/server/v2.0/restapi/operations/registry/list_registry_provider_types_parameters.go @@ -0,0 +1,89 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package registry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewListRegistryProviderTypesParams creates a new ListRegistryProviderTypesParams object +// no default values defined in spec. +func NewListRegistryProviderTypesParams() ListRegistryProviderTypesParams { + + return ListRegistryProviderTypesParams{} +} + +// ListRegistryProviderTypesParams contains all the bound params for the list registry provider types operation +// typically these are obtained from a http.Request +// +// swagger:parameters listRegistryProviderTypes +type ListRegistryProviderTypesParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewListRegistryProviderTypesParams() beforehand. +func (o *ListRegistryProviderTypesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *ListRegistryProviderTypesParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *ListRegistryProviderTypesParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} diff --git a/src/server/v2.0/restapi/operations/registry/list_registry_provider_types_responses.go b/src/server/v2.0/restapi/operations/registry/list_registry_provider_types_responses.go new file mode 100644 index 000000000..52e333a43 --- /dev/null +++ b/src/server/v2.0/restapi/operations/registry/list_registry_provider_types_responses.go @@ -0,0 +1,259 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package registry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// ListRegistryProviderTypesOKCode is the HTTP code returned for type ListRegistryProviderTypesOK +const ListRegistryProviderTypesOKCode int = 200 + +/*ListRegistryProviderTypesOK Success. + +swagger:response listRegistryProviderTypesOK +*/ +type ListRegistryProviderTypesOK struct { + + /* + In: Body + */ + Payload []string `json:"body,omitempty"` +} + +// NewListRegistryProviderTypesOK creates ListRegistryProviderTypesOK with default headers values +func NewListRegistryProviderTypesOK() *ListRegistryProviderTypesOK { + + return &ListRegistryProviderTypesOK{} +} + +// WithPayload adds the payload to the list registry provider types o k response +func (o *ListRegistryProviderTypesOK) WithPayload(payload []string) *ListRegistryProviderTypesOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list registry provider types o k response +func (o *ListRegistryProviderTypesOK) SetPayload(payload []string) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListRegistryProviderTypesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = make([]string, 0, 50) + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ListRegistryProviderTypesUnauthorizedCode is the HTTP code returned for type ListRegistryProviderTypesUnauthorized +const ListRegistryProviderTypesUnauthorizedCode int = 401 + +/*ListRegistryProviderTypesUnauthorized Unauthorized + +swagger:response listRegistryProviderTypesUnauthorized +*/ +type ListRegistryProviderTypesUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListRegistryProviderTypesUnauthorized creates ListRegistryProviderTypesUnauthorized with default headers values +func NewListRegistryProviderTypesUnauthorized() *ListRegistryProviderTypesUnauthorized { + + return &ListRegistryProviderTypesUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the list registry provider types unauthorized response +func (o *ListRegistryProviderTypesUnauthorized) WithXRequestID(xRequestID string) *ListRegistryProviderTypesUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list registry provider types unauthorized response +func (o *ListRegistryProviderTypesUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list registry provider types unauthorized response +func (o *ListRegistryProviderTypesUnauthorized) WithPayload(payload *models.Errors) *ListRegistryProviderTypesUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list registry provider types unauthorized response +func (o *ListRegistryProviderTypesUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListRegistryProviderTypesUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListRegistryProviderTypesForbiddenCode is the HTTP code returned for type ListRegistryProviderTypesForbidden +const ListRegistryProviderTypesForbiddenCode int = 403 + +/*ListRegistryProviderTypesForbidden Forbidden + +swagger:response listRegistryProviderTypesForbidden +*/ +type ListRegistryProviderTypesForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListRegistryProviderTypesForbidden creates ListRegistryProviderTypesForbidden with default headers values +func NewListRegistryProviderTypesForbidden() *ListRegistryProviderTypesForbidden { + + return &ListRegistryProviderTypesForbidden{} +} + +// WithXRequestID adds the xRequestId to the list registry provider types forbidden response +func (o *ListRegistryProviderTypesForbidden) WithXRequestID(xRequestID string) *ListRegistryProviderTypesForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list registry provider types forbidden response +func (o *ListRegistryProviderTypesForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list registry provider types forbidden response +func (o *ListRegistryProviderTypesForbidden) WithPayload(payload *models.Errors) *ListRegistryProviderTypesForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list registry provider types forbidden response +func (o *ListRegistryProviderTypesForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListRegistryProviderTypesForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListRegistryProviderTypesInternalServerErrorCode is the HTTP code returned for type ListRegistryProviderTypesInternalServerError +const ListRegistryProviderTypesInternalServerErrorCode int = 500 + +/*ListRegistryProviderTypesInternalServerError Internal server error + +swagger:response listRegistryProviderTypesInternalServerError +*/ +type ListRegistryProviderTypesInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListRegistryProviderTypesInternalServerError creates ListRegistryProviderTypesInternalServerError with default headers values +func NewListRegistryProviderTypesInternalServerError() *ListRegistryProviderTypesInternalServerError { + + return &ListRegistryProviderTypesInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the list registry provider types internal server error response +func (o *ListRegistryProviderTypesInternalServerError) WithXRequestID(xRequestID string) *ListRegistryProviderTypesInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list registry provider types internal server error response +func (o *ListRegistryProviderTypesInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list registry provider types internal server error response +func (o *ListRegistryProviderTypesInternalServerError) WithPayload(payload *models.Errors) *ListRegistryProviderTypesInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list registry provider types internal server error response +func (o *ListRegistryProviderTypesInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListRegistryProviderTypesInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/registry/list_registry_provider_types_urlbuilder.go b/src/server/v2.0/restapi/operations/registry/list_registry_provider_types_urlbuilder.go new file mode 100644 index 000000000..09e4bfba1 --- /dev/null +++ b/src/server/v2.0/restapi/operations/registry/list_registry_provider_types_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package registry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// ListRegistryProviderTypesURL generates an URL for the list registry provider types operation +type ListRegistryProviderTypesURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListRegistryProviderTypesURL) WithBasePath(bp string) *ListRegistryProviderTypesURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListRegistryProviderTypesURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ListRegistryProviderTypesURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/replication/adapters" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ListRegistryProviderTypesURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ListRegistryProviderTypesURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ListRegistryProviderTypesURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ListRegistryProviderTypesURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ListRegistryProviderTypesURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ListRegistryProviderTypesURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/registry/ping_registry.go b/src/server/v2.0/restapi/operations/registry/ping_registry.go new file mode 100644 index 000000000..1a5053291 --- /dev/null +++ b/src/server/v2.0/restapi/operations/registry/ping_registry.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package registry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// PingRegistryHandlerFunc turns a function with the right signature into a ping registry handler +type PingRegistryHandlerFunc func(PingRegistryParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn PingRegistryHandlerFunc) Handle(params PingRegistryParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// PingRegistryHandler interface for that can handle valid ping registry params +type PingRegistryHandler interface { + Handle(PingRegistryParams, interface{}) middleware.Responder +} + +// NewPingRegistry creates a new http.Handler for the ping registry operation +func NewPingRegistry(ctx *middleware.Context, handler PingRegistryHandler) *PingRegistry { + return &PingRegistry{Context: ctx, Handler: handler} +} + +/*PingRegistry swagger:route POST /registries/ping registry pingRegistry + +Check status of a registry + +Check status of a registry + +*/ +type PingRegistry struct { + Context *middleware.Context + Handler PingRegistryHandler +} + +func (o *PingRegistry) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewPingRegistryParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/registry/ping_registry_parameters.go b/src/server/v2.0/restapi/operations/registry/ping_registry_parameters.go new file mode 100644 index 000000000..9f5ec2f76 --- /dev/null +++ b/src/server/v2.0/restapi/operations/registry/ping_registry_parameters.go @@ -0,0 +1,120 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package registry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewPingRegistryParams creates a new PingRegistryParams object +// no default values defined in spec. +func NewPingRegistryParams() PingRegistryParams { + + return PingRegistryParams{} +} + +// PingRegistryParams contains all the bound params for the ping registry operation +// typically these are obtained from a http.Request +// +// swagger:parameters pingRegistry +type PingRegistryParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The registry + Required: true + In: body + */ + Registry *models.RegistryPing +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewPingRegistryParams() beforehand. +func (o *PingRegistryParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.RegistryPing + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("registry", "body", "")) + } else { + res = append(res, errors.NewParseError("registry", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Registry = &body + } + } + } else { + res = append(res, errors.Required("registry", "body", "")) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *PingRegistryParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *PingRegistryParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} diff --git a/src/server/v2.0/restapi/operations/registry/ping_registry_responses.go b/src/server/v2.0/restapi/operations/registry/ping_registry_responses.go new file mode 100644 index 000000000..147466aeb --- /dev/null +++ b/src/server/v2.0/restapi/operations/registry/ping_registry_responses.go @@ -0,0 +1,390 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package registry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// PingRegistryOKCode is the HTTP code returned for type PingRegistryOK +const PingRegistryOKCode int = 200 + +/*PingRegistryOK Success + +swagger:response pingRegistryOK +*/ +type PingRegistryOK struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewPingRegistryOK creates PingRegistryOK with default headers values +func NewPingRegistryOK() *PingRegistryOK { + + return &PingRegistryOK{} +} + +// WithXRequestID adds the xRequestId to the ping registry o k response +func (o *PingRegistryOK) WithXRequestID(xRequestID string) *PingRegistryOK { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the ping registry o k response +func (o *PingRegistryOK) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *PingRegistryOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// PingRegistryBadRequestCode is the HTTP code returned for type PingRegistryBadRequest +const PingRegistryBadRequestCode int = 400 + +/*PingRegistryBadRequest Bad request + +swagger:response pingRegistryBadRequest +*/ +type PingRegistryBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewPingRegistryBadRequest creates PingRegistryBadRequest with default headers values +func NewPingRegistryBadRequest() *PingRegistryBadRequest { + + return &PingRegistryBadRequest{} +} + +// WithXRequestID adds the xRequestId to the ping registry bad request response +func (o *PingRegistryBadRequest) WithXRequestID(xRequestID string) *PingRegistryBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the ping registry bad request response +func (o *PingRegistryBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the ping registry bad request response +func (o *PingRegistryBadRequest) WithPayload(payload *models.Errors) *PingRegistryBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the ping registry bad request response +func (o *PingRegistryBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PingRegistryBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PingRegistryUnauthorizedCode is the HTTP code returned for type PingRegistryUnauthorized +const PingRegistryUnauthorizedCode int = 401 + +/*PingRegistryUnauthorized Unauthorized + +swagger:response pingRegistryUnauthorized +*/ +type PingRegistryUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewPingRegistryUnauthorized creates PingRegistryUnauthorized with default headers values +func NewPingRegistryUnauthorized() *PingRegistryUnauthorized { + + return &PingRegistryUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the ping registry unauthorized response +func (o *PingRegistryUnauthorized) WithXRequestID(xRequestID string) *PingRegistryUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the ping registry unauthorized response +func (o *PingRegistryUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the ping registry unauthorized response +func (o *PingRegistryUnauthorized) WithPayload(payload *models.Errors) *PingRegistryUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the ping registry unauthorized response +func (o *PingRegistryUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PingRegistryUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PingRegistryForbiddenCode is the HTTP code returned for type PingRegistryForbidden +const PingRegistryForbiddenCode int = 403 + +/*PingRegistryForbidden Forbidden + +swagger:response pingRegistryForbidden +*/ +type PingRegistryForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewPingRegistryForbidden creates PingRegistryForbidden with default headers values +func NewPingRegistryForbidden() *PingRegistryForbidden { + + return &PingRegistryForbidden{} +} + +// WithXRequestID adds the xRequestId to the ping registry forbidden response +func (o *PingRegistryForbidden) WithXRequestID(xRequestID string) *PingRegistryForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the ping registry forbidden response +func (o *PingRegistryForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the ping registry forbidden response +func (o *PingRegistryForbidden) WithPayload(payload *models.Errors) *PingRegistryForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the ping registry forbidden response +func (o *PingRegistryForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PingRegistryForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PingRegistryNotFoundCode is the HTTP code returned for type PingRegistryNotFound +const PingRegistryNotFoundCode int = 404 + +/*PingRegistryNotFound Not found + +swagger:response pingRegistryNotFound +*/ +type PingRegistryNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewPingRegistryNotFound creates PingRegistryNotFound with default headers values +func NewPingRegistryNotFound() *PingRegistryNotFound { + + return &PingRegistryNotFound{} +} + +// WithXRequestID adds the xRequestId to the ping registry not found response +func (o *PingRegistryNotFound) WithXRequestID(xRequestID string) *PingRegistryNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the ping registry not found response +func (o *PingRegistryNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the ping registry not found response +func (o *PingRegistryNotFound) WithPayload(payload *models.Errors) *PingRegistryNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the ping registry not found response +func (o *PingRegistryNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PingRegistryNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PingRegistryInternalServerErrorCode is the HTTP code returned for type PingRegistryInternalServerError +const PingRegistryInternalServerErrorCode int = 500 + +/*PingRegistryInternalServerError Internal server error + +swagger:response pingRegistryInternalServerError +*/ +type PingRegistryInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewPingRegistryInternalServerError creates PingRegistryInternalServerError with default headers values +func NewPingRegistryInternalServerError() *PingRegistryInternalServerError { + + return &PingRegistryInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the ping registry internal server error response +func (o *PingRegistryInternalServerError) WithXRequestID(xRequestID string) *PingRegistryInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the ping registry internal server error response +func (o *PingRegistryInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the ping registry internal server error response +func (o *PingRegistryInternalServerError) WithPayload(payload *models.Errors) *PingRegistryInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the ping registry internal server error response +func (o *PingRegistryInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PingRegistryInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/registry/ping_registry_urlbuilder.go b/src/server/v2.0/restapi/operations/registry/ping_registry_urlbuilder.go new file mode 100644 index 000000000..30b0ba8e4 --- /dev/null +++ b/src/server/v2.0/restapi/operations/registry/ping_registry_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package registry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// PingRegistryURL generates an URL for the ping registry operation +type PingRegistryURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *PingRegistryURL) WithBasePath(bp string) *PingRegistryURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *PingRegistryURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *PingRegistryURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/registries/ping" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *PingRegistryURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *PingRegistryURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *PingRegistryURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on PingRegistryURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on PingRegistryURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *PingRegistryURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/registry/update_registry.go b/src/server/v2.0/restapi/operations/registry/update_registry.go new file mode 100644 index 000000000..bc1eb3b85 --- /dev/null +++ b/src/server/v2.0/restapi/operations/registry/update_registry.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package registry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// UpdateRegistryHandlerFunc turns a function with the right signature into a update registry handler +type UpdateRegistryHandlerFunc func(UpdateRegistryParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn UpdateRegistryHandlerFunc) Handle(params UpdateRegistryParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// UpdateRegistryHandler interface for that can handle valid update registry params +type UpdateRegistryHandler interface { + Handle(UpdateRegistryParams, interface{}) middleware.Responder +} + +// NewUpdateRegistry creates a new http.Handler for the update registry operation +func NewUpdateRegistry(ctx *middleware.Context, handler UpdateRegistryHandler) *UpdateRegistry { + return &UpdateRegistry{Context: ctx, Handler: handler} +} + +/*UpdateRegistry swagger:route PUT /registries/{id} registry updateRegistry + +Update the registry + +Update the registry + +*/ +type UpdateRegistry struct { + Context *middleware.Context + Handler UpdateRegistryHandler +} + +func (o *UpdateRegistry) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewUpdateRegistryParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/registry/update_registry_parameters.go b/src/server/v2.0/restapi/operations/registry/update_registry_parameters.go new file mode 100644 index 000000000..b9da94144 --- /dev/null +++ b/src/server/v2.0/restapi/operations/registry/update_registry_parameters.go @@ -0,0 +1,150 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package registry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewUpdateRegistryParams creates a new UpdateRegistryParams object +// no default values defined in spec. +func NewUpdateRegistryParams() UpdateRegistryParams { + + return UpdateRegistryParams{} +} + +// UpdateRegistryParams contains all the bound params for the update registry operation +// typically these are obtained from a http.Request +// +// swagger:parameters updateRegistry +type UpdateRegistryParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The registry ID + Required: true + In: path + */ + ID int64 + /*The registry + Required: true + In: body + */ + Registry *models.RegistryUpdate +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewUpdateRegistryParams() beforehand. +func (o *UpdateRegistryParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.RegistryUpdate + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("registry", "body", "")) + } else { + res = append(res, errors.NewParseError("registry", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Registry = &body + } + } + } else { + res = append(res, errors.Required("registry", "body", "")) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *UpdateRegistryParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *UpdateRegistryParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *UpdateRegistryParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("id", "path", "int64", raw) + } + o.ID = value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/registry/update_registry_responses.go b/src/server/v2.0/restapi/operations/registry/update_registry_responses.go new file mode 100644 index 000000000..196a6754b --- /dev/null +++ b/src/server/v2.0/restapi/operations/registry/update_registry_responses.go @@ -0,0 +1,390 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package registry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// UpdateRegistryOKCode is the HTTP code returned for type UpdateRegistryOK +const UpdateRegistryOKCode int = 200 + +/*UpdateRegistryOK Success + +swagger:response updateRegistryOK +*/ +type UpdateRegistryOK struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewUpdateRegistryOK creates UpdateRegistryOK with default headers values +func NewUpdateRegistryOK() *UpdateRegistryOK { + + return &UpdateRegistryOK{} +} + +// WithXRequestID adds the xRequestId to the update registry o k response +func (o *UpdateRegistryOK) WithXRequestID(xRequestID string) *UpdateRegistryOK { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update registry o k response +func (o *UpdateRegistryOK) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *UpdateRegistryOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// UpdateRegistryUnauthorizedCode is the HTTP code returned for type UpdateRegistryUnauthorized +const UpdateRegistryUnauthorizedCode int = 401 + +/*UpdateRegistryUnauthorized Unauthorized + +swagger:response updateRegistryUnauthorized +*/ +type UpdateRegistryUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateRegistryUnauthorized creates UpdateRegistryUnauthorized with default headers values +func NewUpdateRegistryUnauthorized() *UpdateRegistryUnauthorized { + + return &UpdateRegistryUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the update registry unauthorized response +func (o *UpdateRegistryUnauthorized) WithXRequestID(xRequestID string) *UpdateRegistryUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update registry unauthorized response +func (o *UpdateRegistryUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update registry unauthorized response +func (o *UpdateRegistryUnauthorized) WithPayload(payload *models.Errors) *UpdateRegistryUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update registry unauthorized response +func (o *UpdateRegistryUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateRegistryUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateRegistryForbiddenCode is the HTTP code returned for type UpdateRegistryForbidden +const UpdateRegistryForbiddenCode int = 403 + +/*UpdateRegistryForbidden Forbidden + +swagger:response updateRegistryForbidden +*/ +type UpdateRegistryForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateRegistryForbidden creates UpdateRegistryForbidden with default headers values +func NewUpdateRegistryForbidden() *UpdateRegistryForbidden { + + return &UpdateRegistryForbidden{} +} + +// WithXRequestID adds the xRequestId to the update registry forbidden response +func (o *UpdateRegistryForbidden) WithXRequestID(xRequestID string) *UpdateRegistryForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update registry forbidden response +func (o *UpdateRegistryForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update registry forbidden response +func (o *UpdateRegistryForbidden) WithPayload(payload *models.Errors) *UpdateRegistryForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update registry forbidden response +func (o *UpdateRegistryForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateRegistryForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateRegistryNotFoundCode is the HTTP code returned for type UpdateRegistryNotFound +const UpdateRegistryNotFoundCode int = 404 + +/*UpdateRegistryNotFound Not found + +swagger:response updateRegistryNotFound +*/ +type UpdateRegistryNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateRegistryNotFound creates UpdateRegistryNotFound with default headers values +func NewUpdateRegistryNotFound() *UpdateRegistryNotFound { + + return &UpdateRegistryNotFound{} +} + +// WithXRequestID adds the xRequestId to the update registry not found response +func (o *UpdateRegistryNotFound) WithXRequestID(xRequestID string) *UpdateRegistryNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update registry not found response +func (o *UpdateRegistryNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update registry not found response +func (o *UpdateRegistryNotFound) WithPayload(payload *models.Errors) *UpdateRegistryNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update registry not found response +func (o *UpdateRegistryNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateRegistryNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateRegistryConflictCode is the HTTP code returned for type UpdateRegistryConflict +const UpdateRegistryConflictCode int = 409 + +/*UpdateRegistryConflict Conflict + +swagger:response updateRegistryConflict +*/ +type UpdateRegistryConflict struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateRegistryConflict creates UpdateRegistryConflict with default headers values +func NewUpdateRegistryConflict() *UpdateRegistryConflict { + + return &UpdateRegistryConflict{} +} + +// WithXRequestID adds the xRequestId to the update registry conflict response +func (o *UpdateRegistryConflict) WithXRequestID(xRequestID string) *UpdateRegistryConflict { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update registry conflict response +func (o *UpdateRegistryConflict) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update registry conflict response +func (o *UpdateRegistryConflict) WithPayload(payload *models.Errors) *UpdateRegistryConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update registry conflict response +func (o *UpdateRegistryConflict) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateRegistryConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateRegistryInternalServerErrorCode is the HTTP code returned for type UpdateRegistryInternalServerError +const UpdateRegistryInternalServerErrorCode int = 500 + +/*UpdateRegistryInternalServerError Internal server error + +swagger:response updateRegistryInternalServerError +*/ +type UpdateRegistryInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateRegistryInternalServerError creates UpdateRegistryInternalServerError with default headers values +func NewUpdateRegistryInternalServerError() *UpdateRegistryInternalServerError { + + return &UpdateRegistryInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the update registry internal server error response +func (o *UpdateRegistryInternalServerError) WithXRequestID(xRequestID string) *UpdateRegistryInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update registry internal server error response +func (o *UpdateRegistryInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update registry internal server error response +func (o *UpdateRegistryInternalServerError) WithPayload(payload *models.Errors) *UpdateRegistryInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update registry internal server error response +func (o *UpdateRegistryInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateRegistryInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/registry/update_registry_urlbuilder.go b/src/server/v2.0/restapi/operations/registry/update_registry_urlbuilder.go new file mode 100644 index 000000000..180140130 --- /dev/null +++ b/src/server/v2.0/restapi/operations/registry/update_registry_urlbuilder.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package registry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// UpdateRegistryURL generates an URL for the update registry operation +type UpdateRegistryURL struct { + ID int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdateRegistryURL) WithBasePath(bp string) *UpdateRegistryURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdateRegistryURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *UpdateRegistryURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/registries/{id}" + + id := swag.FormatInt64(o.ID) + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on UpdateRegistryURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *UpdateRegistryURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *UpdateRegistryURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *UpdateRegistryURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on UpdateRegistryURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on UpdateRegistryURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *UpdateRegistryURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/replication/create_replication_policy.go b/src/server/v2.0/restapi/operations/replication/create_replication_policy.go new file mode 100644 index 000000000..cdb5738be --- /dev/null +++ b/src/server/v2.0/restapi/operations/replication/create_replication_policy.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package replication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateReplicationPolicyHandlerFunc turns a function with the right signature into a create replication policy handler +type CreateReplicationPolicyHandlerFunc func(CreateReplicationPolicyParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateReplicationPolicyHandlerFunc) Handle(params CreateReplicationPolicyParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateReplicationPolicyHandler interface for that can handle valid create replication policy params +type CreateReplicationPolicyHandler interface { + Handle(CreateReplicationPolicyParams, interface{}) middleware.Responder +} + +// NewCreateReplicationPolicy creates a new http.Handler for the create replication policy operation +func NewCreateReplicationPolicy(ctx *middleware.Context, handler CreateReplicationPolicyHandler) *CreateReplicationPolicy { + return &CreateReplicationPolicy{Context: ctx, Handler: handler} +} + +/*CreateReplicationPolicy swagger:route POST /replication/policies replication createReplicationPolicy + +Create a replication policy + +Create a replication policy + +*/ +type CreateReplicationPolicy struct { + Context *middleware.Context + Handler CreateReplicationPolicyHandler +} + +func (o *CreateReplicationPolicy) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewCreateReplicationPolicyParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/replication/create_replication_policy_parameters.go b/src/server/v2.0/restapi/operations/replication/create_replication_policy_parameters.go new file mode 100644 index 000000000..d8d6d05fc --- /dev/null +++ b/src/server/v2.0/restapi/operations/replication/create_replication_policy_parameters.go @@ -0,0 +1,120 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package replication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewCreateReplicationPolicyParams creates a new CreateReplicationPolicyParams object +// no default values defined in spec. +func NewCreateReplicationPolicyParams() CreateReplicationPolicyParams { + + return CreateReplicationPolicyParams{} +} + +// CreateReplicationPolicyParams contains all the bound params for the create replication policy operation +// typically these are obtained from a http.Request +// +// swagger:parameters createReplicationPolicy +type CreateReplicationPolicyParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The replication policy + Required: true + In: body + */ + Policy *models.ReplicationPolicy +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateReplicationPolicyParams() beforehand. +func (o *CreateReplicationPolicyParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.ReplicationPolicy + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("policy", "body", "")) + } else { + res = append(res, errors.NewParseError("policy", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Policy = &body + } + } + } else { + res = append(res, errors.Required("policy", "body", "")) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *CreateReplicationPolicyParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *CreateReplicationPolicyParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} diff --git a/src/server/v2.0/restapi/operations/replication/create_replication_policy_responses.go b/src/server/v2.0/restapi/operations/replication/create_replication_policy_responses.go new file mode 100644 index 000000000..9b72c0075 --- /dev/null +++ b/src/server/v2.0/restapi/operations/replication/create_replication_policy_responses.go @@ -0,0 +1,412 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package replication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// CreateReplicationPolicyCreatedCode is the HTTP code returned for type CreateReplicationPolicyCreated +const CreateReplicationPolicyCreatedCode int = 201 + +/*CreateReplicationPolicyCreated Created + +swagger:response createReplicationPolicyCreated +*/ +type CreateReplicationPolicyCreated struct { + /*The location of the resource + + */ + Location string `json:"Location"` + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewCreateReplicationPolicyCreated creates CreateReplicationPolicyCreated with default headers values +func NewCreateReplicationPolicyCreated() *CreateReplicationPolicyCreated { + + return &CreateReplicationPolicyCreated{} +} + +// WithLocation adds the location to the create replication policy created response +func (o *CreateReplicationPolicyCreated) WithLocation(location string) *CreateReplicationPolicyCreated { + o.Location = location + return o +} + +// SetLocation sets the location to the create replication policy created response +func (o *CreateReplicationPolicyCreated) SetLocation(location string) { + o.Location = location +} + +// WithXRequestID adds the xRequestId to the create replication policy created response +func (o *CreateReplicationPolicyCreated) WithXRequestID(xRequestID string) *CreateReplicationPolicyCreated { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create replication policy created response +func (o *CreateReplicationPolicyCreated) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *CreateReplicationPolicyCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Location + + location := o.Location + if location != "" { + rw.Header().Set("Location", location) + } + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(201) +} + +// CreateReplicationPolicyBadRequestCode is the HTTP code returned for type CreateReplicationPolicyBadRequest +const CreateReplicationPolicyBadRequestCode int = 400 + +/*CreateReplicationPolicyBadRequest Bad request + +swagger:response createReplicationPolicyBadRequest +*/ +type CreateReplicationPolicyBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateReplicationPolicyBadRequest creates CreateReplicationPolicyBadRequest with default headers values +func NewCreateReplicationPolicyBadRequest() *CreateReplicationPolicyBadRequest { + + return &CreateReplicationPolicyBadRequest{} +} + +// WithXRequestID adds the xRequestId to the create replication policy bad request response +func (o *CreateReplicationPolicyBadRequest) WithXRequestID(xRequestID string) *CreateReplicationPolicyBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create replication policy bad request response +func (o *CreateReplicationPolicyBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create replication policy bad request response +func (o *CreateReplicationPolicyBadRequest) WithPayload(payload *models.Errors) *CreateReplicationPolicyBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create replication policy bad request response +func (o *CreateReplicationPolicyBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateReplicationPolicyBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateReplicationPolicyUnauthorizedCode is the HTTP code returned for type CreateReplicationPolicyUnauthorized +const CreateReplicationPolicyUnauthorizedCode int = 401 + +/*CreateReplicationPolicyUnauthorized Unauthorized + +swagger:response createReplicationPolicyUnauthorized +*/ +type CreateReplicationPolicyUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateReplicationPolicyUnauthorized creates CreateReplicationPolicyUnauthorized with default headers values +func NewCreateReplicationPolicyUnauthorized() *CreateReplicationPolicyUnauthorized { + + return &CreateReplicationPolicyUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the create replication policy unauthorized response +func (o *CreateReplicationPolicyUnauthorized) WithXRequestID(xRequestID string) *CreateReplicationPolicyUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create replication policy unauthorized response +func (o *CreateReplicationPolicyUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create replication policy unauthorized response +func (o *CreateReplicationPolicyUnauthorized) WithPayload(payload *models.Errors) *CreateReplicationPolicyUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create replication policy unauthorized response +func (o *CreateReplicationPolicyUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateReplicationPolicyUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateReplicationPolicyForbiddenCode is the HTTP code returned for type CreateReplicationPolicyForbidden +const CreateReplicationPolicyForbiddenCode int = 403 + +/*CreateReplicationPolicyForbidden Forbidden + +swagger:response createReplicationPolicyForbidden +*/ +type CreateReplicationPolicyForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateReplicationPolicyForbidden creates CreateReplicationPolicyForbidden with default headers values +func NewCreateReplicationPolicyForbidden() *CreateReplicationPolicyForbidden { + + return &CreateReplicationPolicyForbidden{} +} + +// WithXRequestID adds the xRequestId to the create replication policy forbidden response +func (o *CreateReplicationPolicyForbidden) WithXRequestID(xRequestID string) *CreateReplicationPolicyForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create replication policy forbidden response +func (o *CreateReplicationPolicyForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create replication policy forbidden response +func (o *CreateReplicationPolicyForbidden) WithPayload(payload *models.Errors) *CreateReplicationPolicyForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create replication policy forbidden response +func (o *CreateReplicationPolicyForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateReplicationPolicyForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateReplicationPolicyConflictCode is the HTTP code returned for type CreateReplicationPolicyConflict +const CreateReplicationPolicyConflictCode int = 409 + +/*CreateReplicationPolicyConflict Conflict + +swagger:response createReplicationPolicyConflict +*/ +type CreateReplicationPolicyConflict struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateReplicationPolicyConflict creates CreateReplicationPolicyConflict with default headers values +func NewCreateReplicationPolicyConflict() *CreateReplicationPolicyConflict { + + return &CreateReplicationPolicyConflict{} +} + +// WithXRequestID adds the xRequestId to the create replication policy conflict response +func (o *CreateReplicationPolicyConflict) WithXRequestID(xRequestID string) *CreateReplicationPolicyConflict { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create replication policy conflict response +func (o *CreateReplicationPolicyConflict) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create replication policy conflict response +func (o *CreateReplicationPolicyConflict) WithPayload(payload *models.Errors) *CreateReplicationPolicyConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create replication policy conflict response +func (o *CreateReplicationPolicyConflict) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateReplicationPolicyConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateReplicationPolicyInternalServerErrorCode is the HTTP code returned for type CreateReplicationPolicyInternalServerError +const CreateReplicationPolicyInternalServerErrorCode int = 500 + +/*CreateReplicationPolicyInternalServerError Internal server error + +swagger:response createReplicationPolicyInternalServerError +*/ +type CreateReplicationPolicyInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateReplicationPolicyInternalServerError creates CreateReplicationPolicyInternalServerError with default headers values +func NewCreateReplicationPolicyInternalServerError() *CreateReplicationPolicyInternalServerError { + + return &CreateReplicationPolicyInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the create replication policy internal server error response +func (o *CreateReplicationPolicyInternalServerError) WithXRequestID(xRequestID string) *CreateReplicationPolicyInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create replication policy internal server error response +func (o *CreateReplicationPolicyInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create replication policy internal server error response +func (o *CreateReplicationPolicyInternalServerError) WithPayload(payload *models.Errors) *CreateReplicationPolicyInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create replication policy internal server error response +func (o *CreateReplicationPolicyInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateReplicationPolicyInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/replication/create_replication_policy_urlbuilder.go b/src/server/v2.0/restapi/operations/replication/create_replication_policy_urlbuilder.go new file mode 100644 index 000000000..6f1077e40 --- /dev/null +++ b/src/server/v2.0/restapi/operations/replication/create_replication_policy_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package replication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// CreateReplicationPolicyURL generates an URL for the create replication policy operation +type CreateReplicationPolicyURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateReplicationPolicyURL) WithBasePath(bp string) *CreateReplicationPolicyURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateReplicationPolicyURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateReplicationPolicyURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/replication/policies" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateReplicationPolicyURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateReplicationPolicyURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateReplicationPolicyURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateReplicationPolicyURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateReplicationPolicyURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateReplicationPolicyURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/replication/delete_replication_policy.go b/src/server/v2.0/restapi/operations/replication/delete_replication_policy.go new file mode 100644 index 000000000..6619b4a5a --- /dev/null +++ b/src/server/v2.0/restapi/operations/replication/delete_replication_policy.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package replication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteReplicationPolicyHandlerFunc turns a function with the right signature into a delete replication policy handler +type DeleteReplicationPolicyHandlerFunc func(DeleteReplicationPolicyParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteReplicationPolicyHandlerFunc) Handle(params DeleteReplicationPolicyParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteReplicationPolicyHandler interface for that can handle valid delete replication policy params +type DeleteReplicationPolicyHandler interface { + Handle(DeleteReplicationPolicyParams, interface{}) middleware.Responder +} + +// NewDeleteReplicationPolicy creates a new http.Handler for the delete replication policy operation +func NewDeleteReplicationPolicy(ctx *middleware.Context, handler DeleteReplicationPolicyHandler) *DeleteReplicationPolicy { + return &DeleteReplicationPolicy{Context: ctx, Handler: handler} +} + +/*DeleteReplicationPolicy swagger:route DELETE /replication/policies/{id} replication deleteReplicationPolicy + +Delete the specific replication policy + +Delete the specific replication policy + +*/ +type DeleteReplicationPolicy struct { + Context *middleware.Context + Handler DeleteReplicationPolicyHandler +} + +func (o *DeleteReplicationPolicy) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewDeleteReplicationPolicyParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/replication/delete_replication_policy_parameters.go b/src/server/v2.0/restapi/operations/replication/delete_replication_policy_parameters.go new file mode 100644 index 000000000..40c63f163 --- /dev/null +++ b/src/server/v2.0/restapi/operations/replication/delete_replication_policy_parameters.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package replication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewDeleteReplicationPolicyParams creates a new DeleteReplicationPolicyParams object +// no default values defined in spec. +func NewDeleteReplicationPolicyParams() DeleteReplicationPolicyParams { + + return DeleteReplicationPolicyParams{} +} + +// DeleteReplicationPolicyParams contains all the bound params for the delete replication policy operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteReplicationPolicy +type DeleteReplicationPolicyParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*Replication policy ID + Required: true + In: path + */ + ID int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteReplicationPolicyParams() beforehand. +func (o *DeleteReplicationPolicyParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *DeleteReplicationPolicyParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *DeleteReplicationPolicyParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *DeleteReplicationPolicyParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("id", "path", "int64", raw) + } + o.ID = value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/replication/delete_replication_policy_responses.go b/src/server/v2.0/restapi/operations/replication/delete_replication_policy_responses.go new file mode 100644 index 000000000..ab1fbf723 --- /dev/null +++ b/src/server/v2.0/restapi/operations/replication/delete_replication_policy_responses.go @@ -0,0 +1,390 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package replication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// DeleteReplicationPolicyOKCode is the HTTP code returned for type DeleteReplicationPolicyOK +const DeleteReplicationPolicyOKCode int = 200 + +/*DeleteReplicationPolicyOK Success + +swagger:response deleteReplicationPolicyOK +*/ +type DeleteReplicationPolicyOK struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewDeleteReplicationPolicyOK creates DeleteReplicationPolicyOK with default headers values +func NewDeleteReplicationPolicyOK() *DeleteReplicationPolicyOK { + + return &DeleteReplicationPolicyOK{} +} + +// WithXRequestID adds the xRequestId to the delete replication policy o k response +func (o *DeleteReplicationPolicyOK) WithXRequestID(xRequestID string) *DeleteReplicationPolicyOK { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete replication policy o k response +func (o *DeleteReplicationPolicyOK) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *DeleteReplicationPolicyOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// DeleteReplicationPolicyUnauthorizedCode is the HTTP code returned for type DeleteReplicationPolicyUnauthorized +const DeleteReplicationPolicyUnauthorizedCode int = 401 + +/*DeleteReplicationPolicyUnauthorized Unauthorized + +swagger:response deleteReplicationPolicyUnauthorized +*/ +type DeleteReplicationPolicyUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteReplicationPolicyUnauthorized creates DeleteReplicationPolicyUnauthorized with default headers values +func NewDeleteReplicationPolicyUnauthorized() *DeleteReplicationPolicyUnauthorized { + + return &DeleteReplicationPolicyUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the delete replication policy unauthorized response +func (o *DeleteReplicationPolicyUnauthorized) WithXRequestID(xRequestID string) *DeleteReplicationPolicyUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete replication policy unauthorized response +func (o *DeleteReplicationPolicyUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete replication policy unauthorized response +func (o *DeleteReplicationPolicyUnauthorized) WithPayload(payload *models.Errors) *DeleteReplicationPolicyUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete replication policy unauthorized response +func (o *DeleteReplicationPolicyUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteReplicationPolicyUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteReplicationPolicyForbiddenCode is the HTTP code returned for type DeleteReplicationPolicyForbidden +const DeleteReplicationPolicyForbiddenCode int = 403 + +/*DeleteReplicationPolicyForbidden Forbidden + +swagger:response deleteReplicationPolicyForbidden +*/ +type DeleteReplicationPolicyForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteReplicationPolicyForbidden creates DeleteReplicationPolicyForbidden with default headers values +func NewDeleteReplicationPolicyForbidden() *DeleteReplicationPolicyForbidden { + + return &DeleteReplicationPolicyForbidden{} +} + +// WithXRequestID adds the xRequestId to the delete replication policy forbidden response +func (o *DeleteReplicationPolicyForbidden) WithXRequestID(xRequestID string) *DeleteReplicationPolicyForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete replication policy forbidden response +func (o *DeleteReplicationPolicyForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete replication policy forbidden response +func (o *DeleteReplicationPolicyForbidden) WithPayload(payload *models.Errors) *DeleteReplicationPolicyForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete replication policy forbidden response +func (o *DeleteReplicationPolicyForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteReplicationPolicyForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteReplicationPolicyNotFoundCode is the HTTP code returned for type DeleteReplicationPolicyNotFound +const DeleteReplicationPolicyNotFoundCode int = 404 + +/*DeleteReplicationPolicyNotFound Not found + +swagger:response deleteReplicationPolicyNotFound +*/ +type DeleteReplicationPolicyNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteReplicationPolicyNotFound creates DeleteReplicationPolicyNotFound with default headers values +func NewDeleteReplicationPolicyNotFound() *DeleteReplicationPolicyNotFound { + + return &DeleteReplicationPolicyNotFound{} +} + +// WithXRequestID adds the xRequestId to the delete replication policy not found response +func (o *DeleteReplicationPolicyNotFound) WithXRequestID(xRequestID string) *DeleteReplicationPolicyNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete replication policy not found response +func (o *DeleteReplicationPolicyNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete replication policy not found response +func (o *DeleteReplicationPolicyNotFound) WithPayload(payload *models.Errors) *DeleteReplicationPolicyNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete replication policy not found response +func (o *DeleteReplicationPolicyNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteReplicationPolicyNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteReplicationPolicyPreconditionFailedCode is the HTTP code returned for type DeleteReplicationPolicyPreconditionFailed +const DeleteReplicationPolicyPreconditionFailedCode int = 412 + +/*DeleteReplicationPolicyPreconditionFailed Precondition failed + +swagger:response deleteReplicationPolicyPreconditionFailed +*/ +type DeleteReplicationPolicyPreconditionFailed struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteReplicationPolicyPreconditionFailed creates DeleteReplicationPolicyPreconditionFailed with default headers values +func NewDeleteReplicationPolicyPreconditionFailed() *DeleteReplicationPolicyPreconditionFailed { + + return &DeleteReplicationPolicyPreconditionFailed{} +} + +// WithXRequestID adds the xRequestId to the delete replication policy precondition failed response +func (o *DeleteReplicationPolicyPreconditionFailed) WithXRequestID(xRequestID string) *DeleteReplicationPolicyPreconditionFailed { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete replication policy precondition failed response +func (o *DeleteReplicationPolicyPreconditionFailed) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete replication policy precondition failed response +func (o *DeleteReplicationPolicyPreconditionFailed) WithPayload(payload *models.Errors) *DeleteReplicationPolicyPreconditionFailed { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete replication policy precondition failed response +func (o *DeleteReplicationPolicyPreconditionFailed) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteReplicationPolicyPreconditionFailed) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(412) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteReplicationPolicyInternalServerErrorCode is the HTTP code returned for type DeleteReplicationPolicyInternalServerError +const DeleteReplicationPolicyInternalServerErrorCode int = 500 + +/*DeleteReplicationPolicyInternalServerError Internal server error + +swagger:response deleteReplicationPolicyInternalServerError +*/ +type DeleteReplicationPolicyInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteReplicationPolicyInternalServerError creates DeleteReplicationPolicyInternalServerError with default headers values +func NewDeleteReplicationPolicyInternalServerError() *DeleteReplicationPolicyInternalServerError { + + return &DeleteReplicationPolicyInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the delete replication policy internal server error response +func (o *DeleteReplicationPolicyInternalServerError) WithXRequestID(xRequestID string) *DeleteReplicationPolicyInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete replication policy internal server error response +func (o *DeleteReplicationPolicyInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete replication policy internal server error response +func (o *DeleteReplicationPolicyInternalServerError) WithPayload(payload *models.Errors) *DeleteReplicationPolicyInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete replication policy internal server error response +func (o *DeleteReplicationPolicyInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteReplicationPolicyInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/replication/delete_replication_policy_urlbuilder.go b/src/server/v2.0/restapi/operations/replication/delete_replication_policy_urlbuilder.go new file mode 100644 index 000000000..99119d797 --- /dev/null +++ b/src/server/v2.0/restapi/operations/replication/delete_replication_policy_urlbuilder.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package replication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteReplicationPolicyURL generates an URL for the delete replication policy operation +type DeleteReplicationPolicyURL struct { + ID int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteReplicationPolicyURL) WithBasePath(bp string) *DeleteReplicationPolicyURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteReplicationPolicyURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteReplicationPolicyURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/replication/policies/{id}" + + id := swag.FormatInt64(o.ID) + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on DeleteReplicationPolicyURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteReplicationPolicyURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteReplicationPolicyURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteReplicationPolicyURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteReplicationPolicyURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteReplicationPolicyURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteReplicationPolicyURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/replication/get_replication_execution.go b/src/server/v2.0/restapi/operations/replication/get_replication_execution.go new file mode 100644 index 000000000..12c526dac --- /dev/null +++ b/src/server/v2.0/restapi/operations/replication/get_replication_execution.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package replication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetReplicationExecutionHandlerFunc turns a function with the right signature into a get replication execution handler +type GetReplicationExecutionHandlerFunc func(GetReplicationExecutionParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetReplicationExecutionHandlerFunc) Handle(params GetReplicationExecutionParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetReplicationExecutionHandler interface for that can handle valid get replication execution params +type GetReplicationExecutionHandler interface { + Handle(GetReplicationExecutionParams, interface{}) middleware.Responder +} + +// NewGetReplicationExecution creates a new http.Handler for the get replication execution operation +func NewGetReplicationExecution(ctx *middleware.Context, handler GetReplicationExecutionHandler) *GetReplicationExecution { + return &GetReplicationExecution{Context: ctx, Handler: handler} +} + +/*GetReplicationExecution swagger:route GET /replication/executions/{id} replication getReplicationExecution + +Get the specific replication execution + +Get the replication execution specified by ID + +*/ +type GetReplicationExecution struct { + Context *middleware.Context + Handler GetReplicationExecutionHandler +} + +func (o *GetReplicationExecution) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetReplicationExecutionParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/replication/get_replication_execution_parameters.go b/src/server/v2.0/restapi/operations/replication/get_replication_execution_parameters.go new file mode 100644 index 000000000..f9c2749b5 --- /dev/null +++ b/src/server/v2.0/restapi/operations/replication/get_replication_execution_parameters.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package replication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewGetReplicationExecutionParams creates a new GetReplicationExecutionParams object +// no default values defined in spec. +func NewGetReplicationExecutionParams() GetReplicationExecutionParams { + + return GetReplicationExecutionParams{} +} + +// GetReplicationExecutionParams contains all the bound params for the get replication execution operation +// typically these are obtained from a http.Request +// +// swagger:parameters getReplicationExecution +type GetReplicationExecutionParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The ID of the execution. + Required: true + In: path + */ + ID int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetReplicationExecutionParams() beforehand. +func (o *GetReplicationExecutionParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetReplicationExecutionParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetReplicationExecutionParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *GetReplicationExecutionParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("id", "path", "int64", raw) + } + o.ID = value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/replication/get_replication_execution_responses.go b/src/server/v2.0/restapi/operations/replication/get_replication_execution_responses.go new file mode 100644 index 000000000..ad1c59146 --- /dev/null +++ b/src/server/v2.0/restapi/operations/replication/get_replication_execution_responses.go @@ -0,0 +1,322 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package replication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetReplicationExecutionOKCode is the HTTP code returned for type GetReplicationExecutionOK +const GetReplicationExecutionOKCode int = 200 + +/*GetReplicationExecutionOK Success + +swagger:response getReplicationExecutionOK +*/ +type GetReplicationExecutionOK struct { + + /* + In: Body + */ + Payload *models.ReplicationExecution `json:"body,omitempty"` +} + +// NewGetReplicationExecutionOK creates GetReplicationExecutionOK with default headers values +func NewGetReplicationExecutionOK() *GetReplicationExecutionOK { + + return &GetReplicationExecutionOK{} +} + +// WithPayload adds the payload to the get replication execution o k response +func (o *GetReplicationExecutionOK) WithPayload(payload *models.ReplicationExecution) *GetReplicationExecutionOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get replication execution o k response +func (o *GetReplicationExecutionOK) SetPayload(payload *models.ReplicationExecution) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetReplicationExecutionOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetReplicationExecutionUnauthorizedCode is the HTTP code returned for type GetReplicationExecutionUnauthorized +const GetReplicationExecutionUnauthorizedCode int = 401 + +/*GetReplicationExecutionUnauthorized Unauthorized + +swagger:response getReplicationExecutionUnauthorized +*/ +type GetReplicationExecutionUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetReplicationExecutionUnauthorized creates GetReplicationExecutionUnauthorized with default headers values +func NewGetReplicationExecutionUnauthorized() *GetReplicationExecutionUnauthorized { + + return &GetReplicationExecutionUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the get replication execution unauthorized response +func (o *GetReplicationExecutionUnauthorized) WithXRequestID(xRequestID string) *GetReplicationExecutionUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get replication execution unauthorized response +func (o *GetReplicationExecutionUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get replication execution unauthorized response +func (o *GetReplicationExecutionUnauthorized) WithPayload(payload *models.Errors) *GetReplicationExecutionUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get replication execution unauthorized response +func (o *GetReplicationExecutionUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetReplicationExecutionUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetReplicationExecutionForbiddenCode is the HTTP code returned for type GetReplicationExecutionForbidden +const GetReplicationExecutionForbiddenCode int = 403 + +/*GetReplicationExecutionForbidden Forbidden + +swagger:response getReplicationExecutionForbidden +*/ +type GetReplicationExecutionForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetReplicationExecutionForbidden creates GetReplicationExecutionForbidden with default headers values +func NewGetReplicationExecutionForbidden() *GetReplicationExecutionForbidden { + + return &GetReplicationExecutionForbidden{} +} + +// WithXRequestID adds the xRequestId to the get replication execution forbidden response +func (o *GetReplicationExecutionForbidden) WithXRequestID(xRequestID string) *GetReplicationExecutionForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get replication execution forbidden response +func (o *GetReplicationExecutionForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get replication execution forbidden response +func (o *GetReplicationExecutionForbidden) WithPayload(payload *models.Errors) *GetReplicationExecutionForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get replication execution forbidden response +func (o *GetReplicationExecutionForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetReplicationExecutionForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetReplicationExecutionNotFoundCode is the HTTP code returned for type GetReplicationExecutionNotFound +const GetReplicationExecutionNotFoundCode int = 404 + +/*GetReplicationExecutionNotFound Not found + +swagger:response getReplicationExecutionNotFound +*/ +type GetReplicationExecutionNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetReplicationExecutionNotFound creates GetReplicationExecutionNotFound with default headers values +func NewGetReplicationExecutionNotFound() *GetReplicationExecutionNotFound { + + return &GetReplicationExecutionNotFound{} +} + +// WithXRequestID adds the xRequestId to the get replication execution not found response +func (o *GetReplicationExecutionNotFound) WithXRequestID(xRequestID string) *GetReplicationExecutionNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get replication execution not found response +func (o *GetReplicationExecutionNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get replication execution not found response +func (o *GetReplicationExecutionNotFound) WithPayload(payload *models.Errors) *GetReplicationExecutionNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get replication execution not found response +func (o *GetReplicationExecutionNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetReplicationExecutionNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetReplicationExecutionInternalServerErrorCode is the HTTP code returned for type GetReplicationExecutionInternalServerError +const GetReplicationExecutionInternalServerErrorCode int = 500 + +/*GetReplicationExecutionInternalServerError Internal server error + +swagger:response getReplicationExecutionInternalServerError +*/ +type GetReplicationExecutionInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetReplicationExecutionInternalServerError creates GetReplicationExecutionInternalServerError with default headers values +func NewGetReplicationExecutionInternalServerError() *GetReplicationExecutionInternalServerError { + + return &GetReplicationExecutionInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get replication execution internal server error response +func (o *GetReplicationExecutionInternalServerError) WithXRequestID(xRequestID string) *GetReplicationExecutionInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get replication execution internal server error response +func (o *GetReplicationExecutionInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get replication execution internal server error response +func (o *GetReplicationExecutionInternalServerError) WithPayload(payload *models.Errors) *GetReplicationExecutionInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get replication execution internal server error response +func (o *GetReplicationExecutionInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetReplicationExecutionInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/replication/get_replication_execution_urlbuilder.go b/src/server/v2.0/restapi/operations/replication/get_replication_execution_urlbuilder.go new file mode 100644 index 000000000..4121851b5 --- /dev/null +++ b/src/server/v2.0/restapi/operations/replication/get_replication_execution_urlbuilder.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package replication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetReplicationExecutionURL generates an URL for the get replication execution operation +type GetReplicationExecutionURL struct { + ID int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetReplicationExecutionURL) WithBasePath(bp string) *GetReplicationExecutionURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetReplicationExecutionURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetReplicationExecutionURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/replication/executions/{id}" + + id := swag.FormatInt64(o.ID) + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on GetReplicationExecutionURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetReplicationExecutionURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetReplicationExecutionURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetReplicationExecutionURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetReplicationExecutionURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetReplicationExecutionURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetReplicationExecutionURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/replication/get_replication_log.go b/src/server/v2.0/restapi/operations/replication/get_replication_log.go new file mode 100644 index 000000000..9b82b2c3f --- /dev/null +++ b/src/server/v2.0/restapi/operations/replication/get_replication_log.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package replication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetReplicationLogHandlerFunc turns a function with the right signature into a get replication log handler +type GetReplicationLogHandlerFunc func(GetReplicationLogParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetReplicationLogHandlerFunc) Handle(params GetReplicationLogParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetReplicationLogHandler interface for that can handle valid get replication log params +type GetReplicationLogHandler interface { + Handle(GetReplicationLogParams, interface{}) middleware.Responder +} + +// NewGetReplicationLog creates a new http.Handler for the get replication log operation +func NewGetReplicationLog(ctx *middleware.Context, handler GetReplicationLogHandler) *GetReplicationLog { + return &GetReplicationLog{Context: ctx, Handler: handler} +} + +/*GetReplicationLog swagger:route GET /replication/executions/{id}/tasks/{task_id}/log replication getReplicationLog + +Get the log of the specific replication task + +Get the log of the specific replication task + +*/ +type GetReplicationLog struct { + Context *middleware.Context + Handler GetReplicationLogHandler +} + +func (o *GetReplicationLog) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetReplicationLogParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/replication/get_replication_log_parameters.go b/src/server/v2.0/restapi/operations/replication/get_replication_log_parameters.go new file mode 100644 index 000000000..8c557ae77 --- /dev/null +++ b/src/server/v2.0/restapi/operations/replication/get_replication_log_parameters.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package replication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewGetReplicationLogParams creates a new GetReplicationLogParams object +// no default values defined in spec. +func NewGetReplicationLogParams() GetReplicationLogParams { + + return GetReplicationLogParams{} +} + +// GetReplicationLogParams contains all the bound params for the get replication log operation +// typically these are obtained from a http.Request +// +// swagger:parameters getReplicationLog +type GetReplicationLogParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The ID of the execution that the tasks belongs to. + Required: true + In: path + */ + ID int64 + /*The ID of the task. + Required: true + In: path + */ + TaskID int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetReplicationLogParams() beforehand. +func (o *GetReplicationLogParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + + rTaskID, rhkTaskID, _ := route.Params.GetOK("task_id") + if err := o.bindTaskID(rTaskID, rhkTaskID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetReplicationLogParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetReplicationLogParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *GetReplicationLogParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("id", "path", "int64", raw) + } + o.ID = value + + return nil +} + +// bindTaskID binds and validates parameter TaskID from path. +func (o *GetReplicationLogParams) bindTaskID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("task_id", "path", "int64", raw) + } + o.TaskID = value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/replication/get_replication_log_responses.go b/src/server/v2.0/restapi/operations/replication/get_replication_log_responses.go new file mode 100644 index 000000000..3d87a1b83 --- /dev/null +++ b/src/server/v2.0/restapi/operations/replication/get_replication_log_responses.go @@ -0,0 +1,342 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package replication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetReplicationLogOKCode is the HTTP code returned for type GetReplicationLogOK +const GetReplicationLogOKCode int = 200 + +/*GetReplicationLogOK Success + +swagger:response getReplicationLogOK +*/ +type GetReplicationLogOK struct { + /*The content type of response body + + */ + ContentType string `json:"Content-Type"` + + /* + In: Body + */ + Payload string `json:"body,omitempty"` +} + +// NewGetReplicationLogOK creates GetReplicationLogOK with default headers values +func NewGetReplicationLogOK() *GetReplicationLogOK { + + return &GetReplicationLogOK{} +} + +// WithContentType adds the contentType to the get replication log o k response +func (o *GetReplicationLogOK) WithContentType(contentType string) *GetReplicationLogOK { + o.ContentType = contentType + return o +} + +// SetContentType sets the contentType to the get replication log o k response +func (o *GetReplicationLogOK) SetContentType(contentType string) { + o.ContentType = contentType +} + +// WithPayload adds the payload to the get replication log o k response +func (o *GetReplicationLogOK) WithPayload(payload string) *GetReplicationLogOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get replication log o k response +func (o *GetReplicationLogOK) SetPayload(payload string) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetReplicationLogOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Content-Type + + contentType := o.ContentType + if contentType != "" { + rw.Header().Set("Content-Type", contentType) + } + + rw.WriteHeader(200) + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// GetReplicationLogUnauthorizedCode is the HTTP code returned for type GetReplicationLogUnauthorized +const GetReplicationLogUnauthorizedCode int = 401 + +/*GetReplicationLogUnauthorized Unauthorized + +swagger:response getReplicationLogUnauthorized +*/ +type GetReplicationLogUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetReplicationLogUnauthorized creates GetReplicationLogUnauthorized with default headers values +func NewGetReplicationLogUnauthorized() *GetReplicationLogUnauthorized { + + return &GetReplicationLogUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the get replication log unauthorized response +func (o *GetReplicationLogUnauthorized) WithXRequestID(xRequestID string) *GetReplicationLogUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get replication log unauthorized response +func (o *GetReplicationLogUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get replication log unauthorized response +func (o *GetReplicationLogUnauthorized) WithPayload(payload *models.Errors) *GetReplicationLogUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get replication log unauthorized response +func (o *GetReplicationLogUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetReplicationLogUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetReplicationLogForbiddenCode is the HTTP code returned for type GetReplicationLogForbidden +const GetReplicationLogForbiddenCode int = 403 + +/*GetReplicationLogForbidden Forbidden + +swagger:response getReplicationLogForbidden +*/ +type GetReplicationLogForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetReplicationLogForbidden creates GetReplicationLogForbidden with default headers values +func NewGetReplicationLogForbidden() *GetReplicationLogForbidden { + + return &GetReplicationLogForbidden{} +} + +// WithXRequestID adds the xRequestId to the get replication log forbidden response +func (o *GetReplicationLogForbidden) WithXRequestID(xRequestID string) *GetReplicationLogForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get replication log forbidden response +func (o *GetReplicationLogForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get replication log forbidden response +func (o *GetReplicationLogForbidden) WithPayload(payload *models.Errors) *GetReplicationLogForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get replication log forbidden response +func (o *GetReplicationLogForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetReplicationLogForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetReplicationLogNotFoundCode is the HTTP code returned for type GetReplicationLogNotFound +const GetReplicationLogNotFoundCode int = 404 + +/*GetReplicationLogNotFound Not found + +swagger:response getReplicationLogNotFound +*/ +type GetReplicationLogNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetReplicationLogNotFound creates GetReplicationLogNotFound with default headers values +func NewGetReplicationLogNotFound() *GetReplicationLogNotFound { + + return &GetReplicationLogNotFound{} +} + +// WithXRequestID adds the xRequestId to the get replication log not found response +func (o *GetReplicationLogNotFound) WithXRequestID(xRequestID string) *GetReplicationLogNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get replication log not found response +func (o *GetReplicationLogNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get replication log not found response +func (o *GetReplicationLogNotFound) WithPayload(payload *models.Errors) *GetReplicationLogNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get replication log not found response +func (o *GetReplicationLogNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetReplicationLogNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetReplicationLogInternalServerErrorCode is the HTTP code returned for type GetReplicationLogInternalServerError +const GetReplicationLogInternalServerErrorCode int = 500 + +/*GetReplicationLogInternalServerError Internal server error + +swagger:response getReplicationLogInternalServerError +*/ +type GetReplicationLogInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetReplicationLogInternalServerError creates GetReplicationLogInternalServerError with default headers values +func NewGetReplicationLogInternalServerError() *GetReplicationLogInternalServerError { + + return &GetReplicationLogInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get replication log internal server error response +func (o *GetReplicationLogInternalServerError) WithXRequestID(xRequestID string) *GetReplicationLogInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get replication log internal server error response +func (o *GetReplicationLogInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get replication log internal server error response +func (o *GetReplicationLogInternalServerError) WithPayload(payload *models.Errors) *GetReplicationLogInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get replication log internal server error response +func (o *GetReplicationLogInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetReplicationLogInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/replication/get_replication_log_urlbuilder.go b/src/server/v2.0/restapi/operations/replication/get_replication_log_urlbuilder.go new file mode 100644 index 000000000..92f9ad47a --- /dev/null +++ b/src/server/v2.0/restapi/operations/replication/get_replication_log_urlbuilder.go @@ -0,0 +1,109 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package replication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetReplicationLogURL generates an URL for the get replication log operation +type GetReplicationLogURL struct { + ID int64 + TaskID int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetReplicationLogURL) WithBasePath(bp string) *GetReplicationLogURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetReplicationLogURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetReplicationLogURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/replication/executions/{id}/tasks/{task_id}/log" + + id := swag.FormatInt64(o.ID) + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on GetReplicationLogURL") + } + + taskID := swag.FormatInt64(o.TaskID) + if taskID != "" { + _path = strings.Replace(_path, "{task_id}", taskID, -1) + } else { + return nil, errors.New("taskId is required on GetReplicationLogURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetReplicationLogURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetReplicationLogURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetReplicationLogURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetReplicationLogURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetReplicationLogURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetReplicationLogURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/replication/get_replication_policy.go b/src/server/v2.0/restapi/operations/replication/get_replication_policy.go new file mode 100644 index 000000000..20086b356 --- /dev/null +++ b/src/server/v2.0/restapi/operations/replication/get_replication_policy.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package replication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetReplicationPolicyHandlerFunc turns a function with the right signature into a get replication policy handler +type GetReplicationPolicyHandlerFunc func(GetReplicationPolicyParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetReplicationPolicyHandlerFunc) Handle(params GetReplicationPolicyParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetReplicationPolicyHandler interface for that can handle valid get replication policy params +type GetReplicationPolicyHandler interface { + Handle(GetReplicationPolicyParams, interface{}) middleware.Responder +} + +// NewGetReplicationPolicy creates a new http.Handler for the get replication policy operation +func NewGetReplicationPolicy(ctx *middleware.Context, handler GetReplicationPolicyHandler) *GetReplicationPolicy { + return &GetReplicationPolicy{Context: ctx, Handler: handler} +} + +/*GetReplicationPolicy swagger:route GET /replication/policies/{id} replication getReplicationPolicy + +Get the specific replication policy + +Get the specific replication policy + +*/ +type GetReplicationPolicy struct { + Context *middleware.Context + Handler GetReplicationPolicyHandler +} + +func (o *GetReplicationPolicy) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetReplicationPolicyParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/replication/get_replication_policy_parameters.go b/src/server/v2.0/restapi/operations/replication/get_replication_policy_parameters.go new file mode 100644 index 000000000..12e92823e --- /dev/null +++ b/src/server/v2.0/restapi/operations/replication/get_replication_policy_parameters.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package replication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewGetReplicationPolicyParams creates a new GetReplicationPolicyParams object +// no default values defined in spec. +func NewGetReplicationPolicyParams() GetReplicationPolicyParams { + + return GetReplicationPolicyParams{} +} + +// GetReplicationPolicyParams contains all the bound params for the get replication policy operation +// typically these are obtained from a http.Request +// +// swagger:parameters getReplicationPolicy +type GetReplicationPolicyParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*Policy ID + Required: true + In: path + */ + ID int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetReplicationPolicyParams() beforehand. +func (o *GetReplicationPolicyParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetReplicationPolicyParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetReplicationPolicyParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *GetReplicationPolicyParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("id", "path", "int64", raw) + } + o.ID = value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/replication/get_replication_policy_responses.go b/src/server/v2.0/restapi/operations/replication/get_replication_policy_responses.go new file mode 100644 index 000000000..721cf7ffd --- /dev/null +++ b/src/server/v2.0/restapi/operations/replication/get_replication_policy_responses.go @@ -0,0 +1,256 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package replication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetReplicationPolicyOKCode is the HTTP code returned for type GetReplicationPolicyOK +const GetReplicationPolicyOKCode int = 200 + +/*GetReplicationPolicyOK Success + +swagger:response getReplicationPolicyOK +*/ +type GetReplicationPolicyOK struct { + + /* + In: Body + */ + Payload *models.ReplicationPolicy `json:"body,omitempty"` +} + +// NewGetReplicationPolicyOK creates GetReplicationPolicyOK with default headers values +func NewGetReplicationPolicyOK() *GetReplicationPolicyOK { + + return &GetReplicationPolicyOK{} +} + +// WithPayload adds the payload to the get replication policy o k response +func (o *GetReplicationPolicyOK) WithPayload(payload *models.ReplicationPolicy) *GetReplicationPolicyOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get replication policy o k response +func (o *GetReplicationPolicyOK) SetPayload(payload *models.ReplicationPolicy) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetReplicationPolicyOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetReplicationPolicyUnauthorizedCode is the HTTP code returned for type GetReplicationPolicyUnauthorized +const GetReplicationPolicyUnauthorizedCode int = 401 + +/*GetReplicationPolicyUnauthorized Unauthorized + +swagger:response getReplicationPolicyUnauthorized +*/ +type GetReplicationPolicyUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetReplicationPolicyUnauthorized creates GetReplicationPolicyUnauthorized with default headers values +func NewGetReplicationPolicyUnauthorized() *GetReplicationPolicyUnauthorized { + + return &GetReplicationPolicyUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the get replication policy unauthorized response +func (o *GetReplicationPolicyUnauthorized) WithXRequestID(xRequestID string) *GetReplicationPolicyUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get replication policy unauthorized response +func (o *GetReplicationPolicyUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get replication policy unauthorized response +func (o *GetReplicationPolicyUnauthorized) WithPayload(payload *models.Errors) *GetReplicationPolicyUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get replication policy unauthorized response +func (o *GetReplicationPolicyUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetReplicationPolicyUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetReplicationPolicyForbiddenCode is the HTTP code returned for type GetReplicationPolicyForbidden +const GetReplicationPolicyForbiddenCode int = 403 + +/*GetReplicationPolicyForbidden Forbidden + +swagger:response getReplicationPolicyForbidden +*/ +type GetReplicationPolicyForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetReplicationPolicyForbidden creates GetReplicationPolicyForbidden with default headers values +func NewGetReplicationPolicyForbidden() *GetReplicationPolicyForbidden { + + return &GetReplicationPolicyForbidden{} +} + +// WithXRequestID adds the xRequestId to the get replication policy forbidden response +func (o *GetReplicationPolicyForbidden) WithXRequestID(xRequestID string) *GetReplicationPolicyForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get replication policy forbidden response +func (o *GetReplicationPolicyForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get replication policy forbidden response +func (o *GetReplicationPolicyForbidden) WithPayload(payload *models.Errors) *GetReplicationPolicyForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get replication policy forbidden response +func (o *GetReplicationPolicyForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetReplicationPolicyForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetReplicationPolicyInternalServerErrorCode is the HTTP code returned for type GetReplicationPolicyInternalServerError +const GetReplicationPolicyInternalServerErrorCode int = 500 + +/*GetReplicationPolicyInternalServerError Internal server error + +swagger:response getReplicationPolicyInternalServerError +*/ +type GetReplicationPolicyInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetReplicationPolicyInternalServerError creates GetReplicationPolicyInternalServerError with default headers values +func NewGetReplicationPolicyInternalServerError() *GetReplicationPolicyInternalServerError { + + return &GetReplicationPolicyInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get replication policy internal server error response +func (o *GetReplicationPolicyInternalServerError) WithXRequestID(xRequestID string) *GetReplicationPolicyInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get replication policy internal server error response +func (o *GetReplicationPolicyInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get replication policy internal server error response +func (o *GetReplicationPolicyInternalServerError) WithPayload(payload *models.Errors) *GetReplicationPolicyInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get replication policy internal server error response +func (o *GetReplicationPolicyInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetReplicationPolicyInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/replication/get_replication_policy_urlbuilder.go b/src/server/v2.0/restapi/operations/replication/get_replication_policy_urlbuilder.go new file mode 100644 index 000000000..0df4fdec5 --- /dev/null +++ b/src/server/v2.0/restapi/operations/replication/get_replication_policy_urlbuilder.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package replication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetReplicationPolicyURL generates an URL for the get replication policy operation +type GetReplicationPolicyURL struct { + ID int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetReplicationPolicyURL) WithBasePath(bp string) *GetReplicationPolicyURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetReplicationPolicyURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetReplicationPolicyURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/replication/policies/{id}" + + id := swag.FormatInt64(o.ID) + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on GetReplicationPolicyURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetReplicationPolicyURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetReplicationPolicyURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetReplicationPolicyURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetReplicationPolicyURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetReplicationPolicyURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetReplicationPolicyURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/replication/list_replication_executions.go b/src/server/v2.0/restapi/operations/replication/list_replication_executions.go new file mode 100644 index 000000000..b0060215b --- /dev/null +++ b/src/server/v2.0/restapi/operations/replication/list_replication_executions.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package replication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ListReplicationExecutionsHandlerFunc turns a function with the right signature into a list replication executions handler +type ListReplicationExecutionsHandlerFunc func(ListReplicationExecutionsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ListReplicationExecutionsHandlerFunc) Handle(params ListReplicationExecutionsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ListReplicationExecutionsHandler interface for that can handle valid list replication executions params +type ListReplicationExecutionsHandler interface { + Handle(ListReplicationExecutionsParams, interface{}) middleware.Responder +} + +// NewListReplicationExecutions creates a new http.Handler for the list replication executions operation +func NewListReplicationExecutions(ctx *middleware.Context, handler ListReplicationExecutionsHandler) *ListReplicationExecutions { + return &ListReplicationExecutions{Context: ctx, Handler: handler} +} + +/*ListReplicationExecutions swagger:route GET /replication/executions replication listReplicationExecutions + +List replication executions + +List replication executions + +*/ +type ListReplicationExecutions struct { + Context *middleware.Context + Handler ListReplicationExecutionsHandler +} + +func (o *ListReplicationExecutions) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewListReplicationExecutionsParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/replication/list_replication_executions_parameters.go b/src/server/v2.0/restapi/operations/replication/list_replication_executions_parameters.go new file mode 100644 index 000000000..9f57ce094 --- /dev/null +++ b/src/server/v2.0/restapi/operations/replication/list_replication_executions_parameters.go @@ -0,0 +1,297 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package replication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewListReplicationExecutionsParams creates a new ListReplicationExecutionsParams object +// with the default values initialized. +func NewListReplicationExecutionsParams() ListReplicationExecutionsParams { + + var ( + // initialize parameters with default values + + pageDefault = int64(1) + pageSizeDefault = int64(10) + ) + + return ListReplicationExecutionsParams{ + Page: &pageDefault, + + PageSize: &pageSizeDefault, + } +} + +// ListReplicationExecutionsParams contains all the bound params for the list replication executions operation +// typically these are obtained from a http.Request +// +// swagger:parameters listReplicationExecutions +type ListReplicationExecutionsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The page number + In: query + Default: 1 + */ + Page *int64 + /*The size of per page + Maximum: 100 + In: query + Default: 10 + */ + PageSize *int64 + /*The ID of the policy that the executions belong to. + In: query + */ + PolicyID *int64 + /*Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + In: query + */ + Sort *string + /*The execution status. + In: query + */ + Status *string + /*The trigger mode. + In: query + */ + Trigger *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewListReplicationExecutionsParams() beforehand. +func (o *ListReplicationExecutionsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + qPage, qhkPage, _ := qs.GetOK("page") + if err := o.bindPage(qPage, qhkPage, route.Formats); err != nil { + res = append(res, err) + } + + qPageSize, qhkPageSize, _ := qs.GetOK("page_size") + if err := o.bindPageSize(qPageSize, qhkPageSize, route.Formats); err != nil { + res = append(res, err) + } + + qPolicyID, qhkPolicyID, _ := qs.GetOK("policy_id") + if err := o.bindPolicyID(qPolicyID, qhkPolicyID, route.Formats); err != nil { + res = append(res, err) + } + + qSort, qhkSort, _ := qs.GetOK("sort") + if err := o.bindSort(qSort, qhkSort, route.Formats); err != nil { + res = append(res, err) + } + + qStatus, qhkStatus, _ := qs.GetOK("status") + if err := o.bindStatus(qStatus, qhkStatus, route.Formats); err != nil { + res = append(res, err) + } + + qTrigger, qhkTrigger, _ := qs.GetOK("trigger") + if err := o.bindTrigger(qTrigger, qhkTrigger, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *ListReplicationExecutionsParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *ListReplicationExecutionsParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindPage binds and validates parameter Page from query. +func (o *ListReplicationExecutionsParams) bindPage(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListReplicationExecutionsParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page", "query", "int64", raw) + } + o.Page = &value + + return nil +} + +// bindPageSize binds and validates parameter PageSize from query. +func (o *ListReplicationExecutionsParams) bindPageSize(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListReplicationExecutionsParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page_size", "query", "int64", raw) + } + o.PageSize = &value + + if err := o.validatePageSize(formats); err != nil { + return err + } + + return nil +} + +// validatePageSize carries on validations for parameter PageSize +func (o *ListReplicationExecutionsParams) validatePageSize(formats strfmt.Registry) error { + + if err := validate.MaximumInt("page_size", "query", int64(*o.PageSize), 100, false); err != nil { + return err + } + + return nil +} + +// bindPolicyID binds and validates parameter PolicyID from query. +func (o *ListReplicationExecutionsParams) bindPolicyID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("policy_id", "query", "int64", raw) + } + o.PolicyID = &value + + return nil +} + +// bindSort binds and validates parameter Sort from query. +func (o *ListReplicationExecutionsParams) bindSort(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Sort = &raw + + return nil +} + +// bindStatus binds and validates parameter Status from query. +func (o *ListReplicationExecutionsParams) bindStatus(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Status = &raw + + return nil +} + +// bindTrigger binds and validates parameter Trigger from query. +func (o *ListReplicationExecutionsParams) bindTrigger(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Trigger = &raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/replication/list_replication_executions_responses.go b/src/server/v2.0/restapi/operations/replication/list_replication_executions_responses.go new file mode 100644 index 000000000..2fa26f012 --- /dev/null +++ b/src/server/v2.0/restapi/operations/replication/list_replication_executions_responses.go @@ -0,0 +1,304 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package replication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/swag" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// ListReplicationExecutionsOKCode is the HTTP code returned for type ListReplicationExecutionsOK +const ListReplicationExecutionsOKCode int = 200 + +/*ListReplicationExecutionsOK Success + +swagger:response listReplicationExecutionsOK +*/ +type ListReplicationExecutionsOK struct { + /*Link refers to the previous page and next page + + */ + Link string `json:"Link"` + /*The total count of the resources + + */ + XTotalCount int64 `json:"X-Total-Count"` + + /* + In: Body + */ + Payload []*models.ReplicationExecution `json:"body,omitempty"` +} + +// NewListReplicationExecutionsOK creates ListReplicationExecutionsOK with default headers values +func NewListReplicationExecutionsOK() *ListReplicationExecutionsOK { + + return &ListReplicationExecutionsOK{} +} + +// WithLink adds the link to the list replication executions o k response +func (o *ListReplicationExecutionsOK) WithLink(link string) *ListReplicationExecutionsOK { + o.Link = link + return o +} + +// SetLink sets the link to the list replication executions o k response +func (o *ListReplicationExecutionsOK) SetLink(link string) { + o.Link = link +} + +// WithXTotalCount adds the xTotalCount to the list replication executions o k response +func (o *ListReplicationExecutionsOK) WithXTotalCount(xTotalCount int64) *ListReplicationExecutionsOK { + o.XTotalCount = xTotalCount + return o +} + +// SetXTotalCount sets the xTotalCount to the list replication executions o k response +func (o *ListReplicationExecutionsOK) SetXTotalCount(xTotalCount int64) { + o.XTotalCount = xTotalCount +} + +// WithPayload adds the payload to the list replication executions o k response +func (o *ListReplicationExecutionsOK) WithPayload(payload []*models.ReplicationExecution) *ListReplicationExecutionsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list replication executions o k response +func (o *ListReplicationExecutionsOK) SetPayload(payload []*models.ReplicationExecution) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListReplicationExecutionsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Link + + link := o.Link + if link != "" { + rw.Header().Set("Link", link) + } + + // response header X-Total-Count + + xTotalCount := swag.FormatInt64(o.XTotalCount) + if xTotalCount != "" { + rw.Header().Set("X-Total-Count", xTotalCount) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = make([]*models.ReplicationExecution, 0, 50) + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ListReplicationExecutionsUnauthorizedCode is the HTTP code returned for type ListReplicationExecutionsUnauthorized +const ListReplicationExecutionsUnauthorizedCode int = 401 + +/*ListReplicationExecutionsUnauthorized Unauthorized + +swagger:response listReplicationExecutionsUnauthorized +*/ +type ListReplicationExecutionsUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListReplicationExecutionsUnauthorized creates ListReplicationExecutionsUnauthorized with default headers values +func NewListReplicationExecutionsUnauthorized() *ListReplicationExecutionsUnauthorized { + + return &ListReplicationExecutionsUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the list replication executions unauthorized response +func (o *ListReplicationExecutionsUnauthorized) WithXRequestID(xRequestID string) *ListReplicationExecutionsUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list replication executions unauthorized response +func (o *ListReplicationExecutionsUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list replication executions unauthorized response +func (o *ListReplicationExecutionsUnauthorized) WithPayload(payload *models.Errors) *ListReplicationExecutionsUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list replication executions unauthorized response +func (o *ListReplicationExecutionsUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListReplicationExecutionsUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListReplicationExecutionsForbiddenCode is the HTTP code returned for type ListReplicationExecutionsForbidden +const ListReplicationExecutionsForbiddenCode int = 403 + +/*ListReplicationExecutionsForbidden Forbidden + +swagger:response listReplicationExecutionsForbidden +*/ +type ListReplicationExecutionsForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListReplicationExecutionsForbidden creates ListReplicationExecutionsForbidden with default headers values +func NewListReplicationExecutionsForbidden() *ListReplicationExecutionsForbidden { + + return &ListReplicationExecutionsForbidden{} +} + +// WithXRequestID adds the xRequestId to the list replication executions forbidden response +func (o *ListReplicationExecutionsForbidden) WithXRequestID(xRequestID string) *ListReplicationExecutionsForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list replication executions forbidden response +func (o *ListReplicationExecutionsForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list replication executions forbidden response +func (o *ListReplicationExecutionsForbidden) WithPayload(payload *models.Errors) *ListReplicationExecutionsForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list replication executions forbidden response +func (o *ListReplicationExecutionsForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListReplicationExecutionsForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListReplicationExecutionsInternalServerErrorCode is the HTTP code returned for type ListReplicationExecutionsInternalServerError +const ListReplicationExecutionsInternalServerErrorCode int = 500 + +/*ListReplicationExecutionsInternalServerError Internal server error + +swagger:response listReplicationExecutionsInternalServerError +*/ +type ListReplicationExecutionsInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListReplicationExecutionsInternalServerError creates ListReplicationExecutionsInternalServerError with default headers values +func NewListReplicationExecutionsInternalServerError() *ListReplicationExecutionsInternalServerError { + + return &ListReplicationExecutionsInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the list replication executions internal server error response +func (o *ListReplicationExecutionsInternalServerError) WithXRequestID(xRequestID string) *ListReplicationExecutionsInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list replication executions internal server error response +func (o *ListReplicationExecutionsInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list replication executions internal server error response +func (o *ListReplicationExecutionsInternalServerError) WithPayload(payload *models.Errors) *ListReplicationExecutionsInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list replication executions internal server error response +func (o *ListReplicationExecutionsInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListReplicationExecutionsInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/replication/list_replication_executions_urlbuilder.go b/src/server/v2.0/restapi/operations/replication/list_replication_executions_urlbuilder.go new file mode 100644 index 000000000..0fc292cc3 --- /dev/null +++ b/src/server/v2.0/restapi/operations/replication/list_replication_executions_urlbuilder.go @@ -0,0 +1,150 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package replication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// ListReplicationExecutionsURL generates an URL for the list replication executions operation +type ListReplicationExecutionsURL struct { + Page *int64 + PageSize *int64 + PolicyID *int64 + Sort *string + Status *string + Trigger *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListReplicationExecutionsURL) WithBasePath(bp string) *ListReplicationExecutionsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListReplicationExecutionsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ListReplicationExecutionsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/replication/executions" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var pageQ string + if o.Page != nil { + pageQ = swag.FormatInt64(*o.Page) + } + if pageQ != "" { + qs.Set("page", pageQ) + } + + var pageSizeQ string + if o.PageSize != nil { + pageSizeQ = swag.FormatInt64(*o.PageSize) + } + if pageSizeQ != "" { + qs.Set("page_size", pageSizeQ) + } + + var policyIDQ string + if o.PolicyID != nil { + policyIDQ = swag.FormatInt64(*o.PolicyID) + } + if policyIDQ != "" { + qs.Set("policy_id", policyIDQ) + } + + var sortQ string + if o.Sort != nil { + sortQ = *o.Sort + } + if sortQ != "" { + qs.Set("sort", sortQ) + } + + var statusQ string + if o.Status != nil { + statusQ = *o.Status + } + if statusQ != "" { + qs.Set("status", statusQ) + } + + var triggerQ string + if o.Trigger != nil { + triggerQ = *o.Trigger + } + if triggerQ != "" { + qs.Set("trigger", triggerQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ListReplicationExecutionsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ListReplicationExecutionsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ListReplicationExecutionsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ListReplicationExecutionsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ListReplicationExecutionsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ListReplicationExecutionsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/replication/list_replication_policies.go b/src/server/v2.0/restapi/operations/replication/list_replication_policies.go new file mode 100644 index 000000000..a318af5f0 --- /dev/null +++ b/src/server/v2.0/restapi/operations/replication/list_replication_policies.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package replication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ListReplicationPoliciesHandlerFunc turns a function with the right signature into a list replication policies handler +type ListReplicationPoliciesHandlerFunc func(ListReplicationPoliciesParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ListReplicationPoliciesHandlerFunc) Handle(params ListReplicationPoliciesParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ListReplicationPoliciesHandler interface for that can handle valid list replication policies params +type ListReplicationPoliciesHandler interface { + Handle(ListReplicationPoliciesParams, interface{}) middleware.Responder +} + +// NewListReplicationPolicies creates a new http.Handler for the list replication policies operation +func NewListReplicationPolicies(ctx *middleware.Context, handler ListReplicationPoliciesHandler) *ListReplicationPolicies { + return &ListReplicationPolicies{Context: ctx, Handler: handler} +} + +/*ListReplicationPolicies swagger:route GET /replication/policies replication listReplicationPolicies + +List replication policies + +List replication policies + +*/ +type ListReplicationPolicies struct { + Context *middleware.Context + Handler ListReplicationPoliciesHandler +} + +func (o *ListReplicationPolicies) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewListReplicationPoliciesParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/replication/list_replication_policies_parameters.go b/src/server/v2.0/restapi/operations/replication/list_replication_policies_parameters.go new file mode 100644 index 000000000..d6ebeab4a --- /dev/null +++ b/src/server/v2.0/restapi/operations/replication/list_replication_policies_parameters.go @@ -0,0 +1,266 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package replication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewListReplicationPoliciesParams creates a new ListReplicationPoliciesParams object +// with the default values initialized. +func NewListReplicationPoliciesParams() ListReplicationPoliciesParams { + + var ( + // initialize parameters with default values + + pageDefault = int64(1) + pageSizeDefault = int64(10) + ) + + return ListReplicationPoliciesParams{ + Page: &pageDefault, + + PageSize: &pageSizeDefault, + } +} + +// ListReplicationPoliciesParams contains all the bound params for the list replication policies operation +// typically these are obtained from a http.Request +// +// swagger:parameters listReplicationPolicies +type ListReplicationPoliciesParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*Deprecated, use "query" instead. The policy name. + In: query + */ + Name *string + /*The page number + In: query + Default: 1 + */ + Page *int64 + /*The size of per page + Maximum: 100 + In: query + Default: 10 + */ + PageSize *int64 + /*Query string to query resources. Supported query patterns are "exact match(k=v)", "fuzzy match(k=~v)", "range(k=[min~max])", "list with union releationship(k={v1 v2 v3})" and "list with intersetion relationship(k=(v1 v2 v3))". The value of range and list can be string(enclosed by " or '), integer or time(in format "2020-04-09 02:36:00"). All of these query patterns should be put in the query string "q=xxx" and splitted by ",". e.g. q=k1=v1,k2=~v2,k3=[min~max] + In: query + */ + Q *string + /*Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + In: query + */ + Sort *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewListReplicationPoliciesParams() beforehand. +func (o *ListReplicationPoliciesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + qName, qhkName, _ := qs.GetOK("name") + if err := o.bindName(qName, qhkName, route.Formats); err != nil { + res = append(res, err) + } + + qPage, qhkPage, _ := qs.GetOK("page") + if err := o.bindPage(qPage, qhkPage, route.Formats); err != nil { + res = append(res, err) + } + + qPageSize, qhkPageSize, _ := qs.GetOK("page_size") + if err := o.bindPageSize(qPageSize, qhkPageSize, route.Formats); err != nil { + res = append(res, err) + } + + qQ, qhkQ, _ := qs.GetOK("q") + if err := o.bindQ(qQ, qhkQ, route.Formats); err != nil { + res = append(res, err) + } + + qSort, qhkSort, _ := qs.GetOK("sort") + if err := o.bindSort(qSort, qhkSort, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *ListReplicationPoliciesParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *ListReplicationPoliciesParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindName binds and validates parameter Name from query. +func (o *ListReplicationPoliciesParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Name = &raw + + return nil +} + +// bindPage binds and validates parameter Page from query. +func (o *ListReplicationPoliciesParams) bindPage(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListReplicationPoliciesParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page", "query", "int64", raw) + } + o.Page = &value + + return nil +} + +// bindPageSize binds and validates parameter PageSize from query. +func (o *ListReplicationPoliciesParams) bindPageSize(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListReplicationPoliciesParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page_size", "query", "int64", raw) + } + o.PageSize = &value + + if err := o.validatePageSize(formats); err != nil { + return err + } + + return nil +} + +// validatePageSize carries on validations for parameter PageSize +func (o *ListReplicationPoliciesParams) validatePageSize(formats strfmt.Registry) error { + + if err := validate.MaximumInt("page_size", "query", int64(*o.PageSize), 100, false); err != nil { + return err + } + + return nil +} + +// bindQ binds and validates parameter Q from query. +func (o *ListReplicationPoliciesParams) bindQ(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Q = &raw + + return nil +} + +// bindSort binds and validates parameter Sort from query. +func (o *ListReplicationPoliciesParams) bindSort(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Sort = &raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/replication/list_replication_policies_responses.go b/src/server/v2.0/restapi/operations/replication/list_replication_policies_responses.go new file mode 100644 index 000000000..6f8a4fe3e --- /dev/null +++ b/src/server/v2.0/restapi/operations/replication/list_replication_policies_responses.go @@ -0,0 +1,304 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package replication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/swag" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// ListReplicationPoliciesOKCode is the HTTP code returned for type ListReplicationPoliciesOK +const ListReplicationPoliciesOKCode int = 200 + +/*ListReplicationPoliciesOK Success + +swagger:response listReplicationPoliciesOK +*/ +type ListReplicationPoliciesOK struct { + /*Link refers to the previous page and next page + + */ + Link string `json:"Link"` + /*The total count of the resources + + */ + XTotalCount int64 `json:"X-Total-Count"` + + /* + In: Body + */ + Payload []*models.ReplicationPolicy `json:"body,omitempty"` +} + +// NewListReplicationPoliciesOK creates ListReplicationPoliciesOK with default headers values +func NewListReplicationPoliciesOK() *ListReplicationPoliciesOK { + + return &ListReplicationPoliciesOK{} +} + +// WithLink adds the link to the list replication policies o k response +func (o *ListReplicationPoliciesOK) WithLink(link string) *ListReplicationPoliciesOK { + o.Link = link + return o +} + +// SetLink sets the link to the list replication policies o k response +func (o *ListReplicationPoliciesOK) SetLink(link string) { + o.Link = link +} + +// WithXTotalCount adds the xTotalCount to the list replication policies o k response +func (o *ListReplicationPoliciesOK) WithXTotalCount(xTotalCount int64) *ListReplicationPoliciesOK { + o.XTotalCount = xTotalCount + return o +} + +// SetXTotalCount sets the xTotalCount to the list replication policies o k response +func (o *ListReplicationPoliciesOK) SetXTotalCount(xTotalCount int64) { + o.XTotalCount = xTotalCount +} + +// WithPayload adds the payload to the list replication policies o k response +func (o *ListReplicationPoliciesOK) WithPayload(payload []*models.ReplicationPolicy) *ListReplicationPoliciesOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list replication policies o k response +func (o *ListReplicationPoliciesOK) SetPayload(payload []*models.ReplicationPolicy) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListReplicationPoliciesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Link + + link := o.Link + if link != "" { + rw.Header().Set("Link", link) + } + + // response header X-Total-Count + + xTotalCount := swag.FormatInt64(o.XTotalCount) + if xTotalCount != "" { + rw.Header().Set("X-Total-Count", xTotalCount) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = make([]*models.ReplicationPolicy, 0, 50) + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ListReplicationPoliciesUnauthorizedCode is the HTTP code returned for type ListReplicationPoliciesUnauthorized +const ListReplicationPoliciesUnauthorizedCode int = 401 + +/*ListReplicationPoliciesUnauthorized Unauthorized + +swagger:response listReplicationPoliciesUnauthorized +*/ +type ListReplicationPoliciesUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListReplicationPoliciesUnauthorized creates ListReplicationPoliciesUnauthorized with default headers values +func NewListReplicationPoliciesUnauthorized() *ListReplicationPoliciesUnauthorized { + + return &ListReplicationPoliciesUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the list replication policies unauthorized response +func (o *ListReplicationPoliciesUnauthorized) WithXRequestID(xRequestID string) *ListReplicationPoliciesUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list replication policies unauthorized response +func (o *ListReplicationPoliciesUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list replication policies unauthorized response +func (o *ListReplicationPoliciesUnauthorized) WithPayload(payload *models.Errors) *ListReplicationPoliciesUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list replication policies unauthorized response +func (o *ListReplicationPoliciesUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListReplicationPoliciesUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListReplicationPoliciesForbiddenCode is the HTTP code returned for type ListReplicationPoliciesForbidden +const ListReplicationPoliciesForbiddenCode int = 403 + +/*ListReplicationPoliciesForbidden Forbidden + +swagger:response listReplicationPoliciesForbidden +*/ +type ListReplicationPoliciesForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListReplicationPoliciesForbidden creates ListReplicationPoliciesForbidden with default headers values +func NewListReplicationPoliciesForbidden() *ListReplicationPoliciesForbidden { + + return &ListReplicationPoliciesForbidden{} +} + +// WithXRequestID adds the xRequestId to the list replication policies forbidden response +func (o *ListReplicationPoliciesForbidden) WithXRequestID(xRequestID string) *ListReplicationPoliciesForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list replication policies forbidden response +func (o *ListReplicationPoliciesForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list replication policies forbidden response +func (o *ListReplicationPoliciesForbidden) WithPayload(payload *models.Errors) *ListReplicationPoliciesForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list replication policies forbidden response +func (o *ListReplicationPoliciesForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListReplicationPoliciesForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListReplicationPoliciesInternalServerErrorCode is the HTTP code returned for type ListReplicationPoliciesInternalServerError +const ListReplicationPoliciesInternalServerErrorCode int = 500 + +/*ListReplicationPoliciesInternalServerError Internal server error + +swagger:response listReplicationPoliciesInternalServerError +*/ +type ListReplicationPoliciesInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListReplicationPoliciesInternalServerError creates ListReplicationPoliciesInternalServerError with default headers values +func NewListReplicationPoliciesInternalServerError() *ListReplicationPoliciesInternalServerError { + + return &ListReplicationPoliciesInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the list replication policies internal server error response +func (o *ListReplicationPoliciesInternalServerError) WithXRequestID(xRequestID string) *ListReplicationPoliciesInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list replication policies internal server error response +func (o *ListReplicationPoliciesInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list replication policies internal server error response +func (o *ListReplicationPoliciesInternalServerError) WithPayload(payload *models.Errors) *ListReplicationPoliciesInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list replication policies internal server error response +func (o *ListReplicationPoliciesInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListReplicationPoliciesInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/replication/list_replication_policies_urlbuilder.go b/src/server/v2.0/restapi/operations/replication/list_replication_policies_urlbuilder.go new file mode 100644 index 000000000..b48772256 --- /dev/null +++ b/src/server/v2.0/restapi/operations/replication/list_replication_policies_urlbuilder.go @@ -0,0 +1,141 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package replication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// ListReplicationPoliciesURL generates an URL for the list replication policies operation +type ListReplicationPoliciesURL struct { + Name *string + Page *int64 + PageSize *int64 + Q *string + Sort *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListReplicationPoliciesURL) WithBasePath(bp string) *ListReplicationPoliciesURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListReplicationPoliciesURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ListReplicationPoliciesURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/replication/policies" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var nameQ string + if o.Name != nil { + nameQ = *o.Name + } + if nameQ != "" { + qs.Set("name", nameQ) + } + + var pageQ string + if o.Page != nil { + pageQ = swag.FormatInt64(*o.Page) + } + if pageQ != "" { + qs.Set("page", pageQ) + } + + var pageSizeQ string + if o.PageSize != nil { + pageSizeQ = swag.FormatInt64(*o.PageSize) + } + if pageSizeQ != "" { + qs.Set("page_size", pageSizeQ) + } + + var qQ string + if o.Q != nil { + qQ = *o.Q + } + if qQ != "" { + qs.Set("q", qQ) + } + + var sortQ string + if o.Sort != nil { + sortQ = *o.Sort + } + if sortQ != "" { + qs.Set("sort", sortQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ListReplicationPoliciesURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ListReplicationPoliciesURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ListReplicationPoliciesURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ListReplicationPoliciesURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ListReplicationPoliciesURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ListReplicationPoliciesURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/replication/list_replication_tasks.go b/src/server/v2.0/restapi/operations/replication/list_replication_tasks.go new file mode 100644 index 000000000..90be22f94 --- /dev/null +++ b/src/server/v2.0/restapi/operations/replication/list_replication_tasks.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package replication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ListReplicationTasksHandlerFunc turns a function with the right signature into a list replication tasks handler +type ListReplicationTasksHandlerFunc func(ListReplicationTasksParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ListReplicationTasksHandlerFunc) Handle(params ListReplicationTasksParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ListReplicationTasksHandler interface for that can handle valid list replication tasks params +type ListReplicationTasksHandler interface { + Handle(ListReplicationTasksParams, interface{}) middleware.Responder +} + +// NewListReplicationTasks creates a new http.Handler for the list replication tasks operation +func NewListReplicationTasks(ctx *middleware.Context, handler ListReplicationTasksHandler) *ListReplicationTasks { + return &ListReplicationTasks{Context: ctx, Handler: handler} +} + +/*ListReplicationTasks swagger:route GET /replication/executions/{id}/tasks replication listReplicationTasks + +List replication tasks for a specific execution + +List replication tasks for a specific execution + +*/ +type ListReplicationTasks struct { + Context *middleware.Context + Handler ListReplicationTasksHandler +} + +func (o *ListReplicationTasks) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewListReplicationTasksParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/replication/list_replication_tasks_parameters.go b/src/server/v2.0/restapi/operations/replication/list_replication_tasks_parameters.go new file mode 100644 index 000000000..233f665c0 --- /dev/null +++ b/src/server/v2.0/restapi/operations/replication/list_replication_tasks_parameters.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package replication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewListReplicationTasksParams creates a new ListReplicationTasksParams object +// with the default values initialized. +func NewListReplicationTasksParams() ListReplicationTasksParams { + + var ( + // initialize parameters with default values + + pageDefault = int64(1) + pageSizeDefault = int64(10) + ) + + return ListReplicationTasksParams{ + Page: &pageDefault, + + PageSize: &pageSizeDefault, + } +} + +// ListReplicationTasksParams contains all the bound params for the list replication tasks operation +// typically these are obtained from a http.Request +// +// swagger:parameters listReplicationTasks +type ListReplicationTasksParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The ID of the execution that the tasks belongs to. + Required: true + In: path + */ + ID int64 + /*The page number + In: query + Default: 1 + */ + Page *int64 + /*The size of per page + Maximum: 100 + In: query + Default: 10 + */ + PageSize *int64 + /*The resource type. + In: query + */ + ResourceType *string + /*Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + In: query + */ + Sort *string + /*The task status. + In: query + */ + Status *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewListReplicationTasksParams() beforehand. +func (o *ListReplicationTasksParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + + qPage, qhkPage, _ := qs.GetOK("page") + if err := o.bindPage(qPage, qhkPage, route.Formats); err != nil { + res = append(res, err) + } + + qPageSize, qhkPageSize, _ := qs.GetOK("page_size") + if err := o.bindPageSize(qPageSize, qhkPageSize, route.Formats); err != nil { + res = append(res, err) + } + + qResourceType, qhkResourceType, _ := qs.GetOK("resource_type") + if err := o.bindResourceType(qResourceType, qhkResourceType, route.Formats); err != nil { + res = append(res, err) + } + + qSort, qhkSort, _ := qs.GetOK("sort") + if err := o.bindSort(qSort, qhkSort, route.Formats); err != nil { + res = append(res, err) + } + + qStatus, qhkStatus, _ := qs.GetOK("status") + if err := o.bindStatus(qStatus, qhkStatus, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *ListReplicationTasksParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *ListReplicationTasksParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *ListReplicationTasksParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("id", "path", "int64", raw) + } + o.ID = value + + return nil +} + +// bindPage binds and validates parameter Page from query. +func (o *ListReplicationTasksParams) bindPage(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListReplicationTasksParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page", "query", "int64", raw) + } + o.Page = &value + + return nil +} + +// bindPageSize binds and validates parameter PageSize from query. +func (o *ListReplicationTasksParams) bindPageSize(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListReplicationTasksParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page_size", "query", "int64", raw) + } + o.PageSize = &value + + if err := o.validatePageSize(formats); err != nil { + return err + } + + return nil +} + +// validatePageSize carries on validations for parameter PageSize +func (o *ListReplicationTasksParams) validatePageSize(formats strfmt.Registry) error { + + if err := validate.MaximumInt("page_size", "query", int64(*o.PageSize), 100, false); err != nil { + return err + } + + return nil +} + +// bindResourceType binds and validates parameter ResourceType from query. +func (o *ListReplicationTasksParams) bindResourceType(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.ResourceType = &raw + + return nil +} + +// bindSort binds and validates parameter Sort from query. +func (o *ListReplicationTasksParams) bindSort(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Sort = &raw + + return nil +} + +// bindStatus binds and validates parameter Status from query. +func (o *ListReplicationTasksParams) bindStatus(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Status = &raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/replication/list_replication_tasks_responses.go b/src/server/v2.0/restapi/operations/replication/list_replication_tasks_responses.go new file mode 100644 index 000000000..96ec4af48 --- /dev/null +++ b/src/server/v2.0/restapi/operations/replication/list_replication_tasks_responses.go @@ -0,0 +1,304 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package replication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/swag" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// ListReplicationTasksOKCode is the HTTP code returned for type ListReplicationTasksOK +const ListReplicationTasksOKCode int = 200 + +/*ListReplicationTasksOK Success + +swagger:response listReplicationTasksOK +*/ +type ListReplicationTasksOK struct { + /*Link refers to the previous page and next page + + */ + Link string `json:"Link"` + /*The total count of the resources + + */ + XTotalCount int64 `json:"X-Total-Count"` + + /* + In: Body + */ + Payload []*models.ReplicationTask `json:"body,omitempty"` +} + +// NewListReplicationTasksOK creates ListReplicationTasksOK with default headers values +func NewListReplicationTasksOK() *ListReplicationTasksOK { + + return &ListReplicationTasksOK{} +} + +// WithLink adds the link to the list replication tasks o k response +func (o *ListReplicationTasksOK) WithLink(link string) *ListReplicationTasksOK { + o.Link = link + return o +} + +// SetLink sets the link to the list replication tasks o k response +func (o *ListReplicationTasksOK) SetLink(link string) { + o.Link = link +} + +// WithXTotalCount adds the xTotalCount to the list replication tasks o k response +func (o *ListReplicationTasksOK) WithXTotalCount(xTotalCount int64) *ListReplicationTasksOK { + o.XTotalCount = xTotalCount + return o +} + +// SetXTotalCount sets the xTotalCount to the list replication tasks o k response +func (o *ListReplicationTasksOK) SetXTotalCount(xTotalCount int64) { + o.XTotalCount = xTotalCount +} + +// WithPayload adds the payload to the list replication tasks o k response +func (o *ListReplicationTasksOK) WithPayload(payload []*models.ReplicationTask) *ListReplicationTasksOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list replication tasks o k response +func (o *ListReplicationTasksOK) SetPayload(payload []*models.ReplicationTask) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListReplicationTasksOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Link + + link := o.Link + if link != "" { + rw.Header().Set("Link", link) + } + + // response header X-Total-Count + + xTotalCount := swag.FormatInt64(o.XTotalCount) + if xTotalCount != "" { + rw.Header().Set("X-Total-Count", xTotalCount) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = make([]*models.ReplicationTask, 0, 50) + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ListReplicationTasksUnauthorizedCode is the HTTP code returned for type ListReplicationTasksUnauthorized +const ListReplicationTasksUnauthorizedCode int = 401 + +/*ListReplicationTasksUnauthorized Unauthorized + +swagger:response listReplicationTasksUnauthorized +*/ +type ListReplicationTasksUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListReplicationTasksUnauthorized creates ListReplicationTasksUnauthorized with default headers values +func NewListReplicationTasksUnauthorized() *ListReplicationTasksUnauthorized { + + return &ListReplicationTasksUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the list replication tasks unauthorized response +func (o *ListReplicationTasksUnauthorized) WithXRequestID(xRequestID string) *ListReplicationTasksUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list replication tasks unauthorized response +func (o *ListReplicationTasksUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list replication tasks unauthorized response +func (o *ListReplicationTasksUnauthorized) WithPayload(payload *models.Errors) *ListReplicationTasksUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list replication tasks unauthorized response +func (o *ListReplicationTasksUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListReplicationTasksUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListReplicationTasksForbiddenCode is the HTTP code returned for type ListReplicationTasksForbidden +const ListReplicationTasksForbiddenCode int = 403 + +/*ListReplicationTasksForbidden Forbidden + +swagger:response listReplicationTasksForbidden +*/ +type ListReplicationTasksForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListReplicationTasksForbidden creates ListReplicationTasksForbidden with default headers values +func NewListReplicationTasksForbidden() *ListReplicationTasksForbidden { + + return &ListReplicationTasksForbidden{} +} + +// WithXRequestID adds the xRequestId to the list replication tasks forbidden response +func (o *ListReplicationTasksForbidden) WithXRequestID(xRequestID string) *ListReplicationTasksForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list replication tasks forbidden response +func (o *ListReplicationTasksForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list replication tasks forbidden response +func (o *ListReplicationTasksForbidden) WithPayload(payload *models.Errors) *ListReplicationTasksForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list replication tasks forbidden response +func (o *ListReplicationTasksForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListReplicationTasksForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListReplicationTasksInternalServerErrorCode is the HTTP code returned for type ListReplicationTasksInternalServerError +const ListReplicationTasksInternalServerErrorCode int = 500 + +/*ListReplicationTasksInternalServerError Internal server error + +swagger:response listReplicationTasksInternalServerError +*/ +type ListReplicationTasksInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListReplicationTasksInternalServerError creates ListReplicationTasksInternalServerError with default headers values +func NewListReplicationTasksInternalServerError() *ListReplicationTasksInternalServerError { + + return &ListReplicationTasksInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the list replication tasks internal server error response +func (o *ListReplicationTasksInternalServerError) WithXRequestID(xRequestID string) *ListReplicationTasksInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list replication tasks internal server error response +func (o *ListReplicationTasksInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list replication tasks internal server error response +func (o *ListReplicationTasksInternalServerError) WithPayload(payload *models.Errors) *ListReplicationTasksInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list replication tasks internal server error response +func (o *ListReplicationTasksInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListReplicationTasksInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/replication/list_replication_tasks_urlbuilder.go b/src/server/v2.0/restapi/operations/replication/list_replication_tasks_urlbuilder.go new file mode 100644 index 000000000..78e6f0138 --- /dev/null +++ b/src/server/v2.0/restapi/operations/replication/list_replication_tasks_urlbuilder.go @@ -0,0 +1,151 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package replication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ListReplicationTasksURL generates an URL for the list replication tasks operation +type ListReplicationTasksURL struct { + ID int64 + + Page *int64 + PageSize *int64 + ResourceType *string + Sort *string + Status *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListReplicationTasksURL) WithBasePath(bp string) *ListReplicationTasksURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListReplicationTasksURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ListReplicationTasksURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/replication/executions/{id}/tasks" + + id := swag.FormatInt64(o.ID) + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on ListReplicationTasksURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var pageQ string + if o.Page != nil { + pageQ = swag.FormatInt64(*o.Page) + } + if pageQ != "" { + qs.Set("page", pageQ) + } + + var pageSizeQ string + if o.PageSize != nil { + pageSizeQ = swag.FormatInt64(*o.PageSize) + } + if pageSizeQ != "" { + qs.Set("page_size", pageSizeQ) + } + + var resourceTypeQ string + if o.ResourceType != nil { + resourceTypeQ = *o.ResourceType + } + if resourceTypeQ != "" { + qs.Set("resource_type", resourceTypeQ) + } + + var sortQ string + if o.Sort != nil { + sortQ = *o.Sort + } + if sortQ != "" { + qs.Set("sort", sortQ) + } + + var statusQ string + if o.Status != nil { + statusQ = *o.Status + } + if statusQ != "" { + qs.Set("status", statusQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ListReplicationTasksURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ListReplicationTasksURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ListReplicationTasksURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ListReplicationTasksURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ListReplicationTasksURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ListReplicationTasksURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/replication/start_replication.go b/src/server/v2.0/restapi/operations/replication/start_replication.go new file mode 100644 index 000000000..d81dd3590 --- /dev/null +++ b/src/server/v2.0/restapi/operations/replication/start_replication.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package replication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// StartReplicationHandlerFunc turns a function with the right signature into a start replication handler +type StartReplicationHandlerFunc func(StartReplicationParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn StartReplicationHandlerFunc) Handle(params StartReplicationParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// StartReplicationHandler interface for that can handle valid start replication params +type StartReplicationHandler interface { + Handle(StartReplicationParams, interface{}) middleware.Responder +} + +// NewStartReplication creates a new http.Handler for the start replication operation +func NewStartReplication(ctx *middleware.Context, handler StartReplicationHandler) *StartReplication { + return &StartReplication{Context: ctx, Handler: handler} +} + +/*StartReplication swagger:route POST /replication/executions replication startReplication + +Start one replication execution + +Start one replication execution according to the policy + +*/ +type StartReplication struct { + Context *middleware.Context + Handler StartReplicationHandler +} + +func (o *StartReplication) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewStartReplicationParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/replication/start_replication_parameters.go b/src/server/v2.0/restapi/operations/replication/start_replication_parameters.go new file mode 100644 index 000000000..02db324b3 --- /dev/null +++ b/src/server/v2.0/restapi/operations/replication/start_replication_parameters.go @@ -0,0 +1,120 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package replication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewStartReplicationParams creates a new StartReplicationParams object +// no default values defined in spec. +func NewStartReplicationParams() StartReplicationParams { + + return StartReplicationParams{} +} + +// StartReplicationParams contains all the bound params for the start replication operation +// typically these are obtained from a http.Request +// +// swagger:parameters startReplication +type StartReplicationParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The ID of policy that the execution belongs to + Required: true + In: body + */ + Execution *models.StartReplicationExecution +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewStartReplicationParams() beforehand. +func (o *StartReplicationParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.StartReplicationExecution + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("execution", "body", "")) + } else { + res = append(res, errors.NewParseError("execution", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Execution = &body + } + } + } else { + res = append(res, errors.Required("execution", "body", "")) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *StartReplicationParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *StartReplicationParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} diff --git a/src/server/v2.0/restapi/operations/replication/start_replication_responses.go b/src/server/v2.0/restapi/operations/replication/start_replication_responses.go new file mode 100644 index 000000000..5a8e08fa7 --- /dev/null +++ b/src/server/v2.0/restapi/operations/replication/start_replication_responses.go @@ -0,0 +1,346 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package replication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// StartReplicationCreatedCode is the HTTP code returned for type StartReplicationCreated +const StartReplicationCreatedCode int = 201 + +/*StartReplicationCreated Created + +swagger:response startReplicationCreated +*/ +type StartReplicationCreated struct { + /*The location of the resource + + */ + Location string `json:"Location"` + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewStartReplicationCreated creates StartReplicationCreated with default headers values +func NewStartReplicationCreated() *StartReplicationCreated { + + return &StartReplicationCreated{} +} + +// WithLocation adds the location to the start replication created response +func (o *StartReplicationCreated) WithLocation(location string) *StartReplicationCreated { + o.Location = location + return o +} + +// SetLocation sets the location to the start replication created response +func (o *StartReplicationCreated) SetLocation(location string) { + o.Location = location +} + +// WithXRequestID adds the xRequestId to the start replication created response +func (o *StartReplicationCreated) WithXRequestID(xRequestID string) *StartReplicationCreated { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the start replication created response +func (o *StartReplicationCreated) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *StartReplicationCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Location + + location := o.Location + if location != "" { + rw.Header().Set("Location", location) + } + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(201) +} + +// StartReplicationBadRequestCode is the HTTP code returned for type StartReplicationBadRequest +const StartReplicationBadRequestCode int = 400 + +/*StartReplicationBadRequest Bad request + +swagger:response startReplicationBadRequest +*/ +type StartReplicationBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewStartReplicationBadRequest creates StartReplicationBadRequest with default headers values +func NewStartReplicationBadRequest() *StartReplicationBadRequest { + + return &StartReplicationBadRequest{} +} + +// WithXRequestID adds the xRequestId to the start replication bad request response +func (o *StartReplicationBadRequest) WithXRequestID(xRequestID string) *StartReplicationBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the start replication bad request response +func (o *StartReplicationBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the start replication bad request response +func (o *StartReplicationBadRequest) WithPayload(payload *models.Errors) *StartReplicationBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the start replication bad request response +func (o *StartReplicationBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *StartReplicationBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// StartReplicationUnauthorizedCode is the HTTP code returned for type StartReplicationUnauthorized +const StartReplicationUnauthorizedCode int = 401 + +/*StartReplicationUnauthorized Unauthorized + +swagger:response startReplicationUnauthorized +*/ +type StartReplicationUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewStartReplicationUnauthorized creates StartReplicationUnauthorized with default headers values +func NewStartReplicationUnauthorized() *StartReplicationUnauthorized { + + return &StartReplicationUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the start replication unauthorized response +func (o *StartReplicationUnauthorized) WithXRequestID(xRequestID string) *StartReplicationUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the start replication unauthorized response +func (o *StartReplicationUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the start replication unauthorized response +func (o *StartReplicationUnauthorized) WithPayload(payload *models.Errors) *StartReplicationUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the start replication unauthorized response +func (o *StartReplicationUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *StartReplicationUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// StartReplicationForbiddenCode is the HTTP code returned for type StartReplicationForbidden +const StartReplicationForbiddenCode int = 403 + +/*StartReplicationForbidden Forbidden + +swagger:response startReplicationForbidden +*/ +type StartReplicationForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewStartReplicationForbidden creates StartReplicationForbidden with default headers values +func NewStartReplicationForbidden() *StartReplicationForbidden { + + return &StartReplicationForbidden{} +} + +// WithXRequestID adds the xRequestId to the start replication forbidden response +func (o *StartReplicationForbidden) WithXRequestID(xRequestID string) *StartReplicationForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the start replication forbidden response +func (o *StartReplicationForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the start replication forbidden response +func (o *StartReplicationForbidden) WithPayload(payload *models.Errors) *StartReplicationForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the start replication forbidden response +func (o *StartReplicationForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *StartReplicationForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// StartReplicationInternalServerErrorCode is the HTTP code returned for type StartReplicationInternalServerError +const StartReplicationInternalServerErrorCode int = 500 + +/*StartReplicationInternalServerError Internal server error + +swagger:response startReplicationInternalServerError +*/ +type StartReplicationInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewStartReplicationInternalServerError creates StartReplicationInternalServerError with default headers values +func NewStartReplicationInternalServerError() *StartReplicationInternalServerError { + + return &StartReplicationInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the start replication internal server error response +func (o *StartReplicationInternalServerError) WithXRequestID(xRequestID string) *StartReplicationInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the start replication internal server error response +func (o *StartReplicationInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the start replication internal server error response +func (o *StartReplicationInternalServerError) WithPayload(payload *models.Errors) *StartReplicationInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the start replication internal server error response +func (o *StartReplicationInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *StartReplicationInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/replication/start_replication_urlbuilder.go b/src/server/v2.0/restapi/operations/replication/start_replication_urlbuilder.go new file mode 100644 index 000000000..4f451a86b --- /dev/null +++ b/src/server/v2.0/restapi/operations/replication/start_replication_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package replication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// StartReplicationURL generates an URL for the start replication operation +type StartReplicationURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *StartReplicationURL) WithBasePath(bp string) *StartReplicationURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *StartReplicationURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *StartReplicationURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/replication/executions" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *StartReplicationURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *StartReplicationURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *StartReplicationURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on StartReplicationURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on StartReplicationURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *StartReplicationURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/replication/stop_replication.go b/src/server/v2.0/restapi/operations/replication/stop_replication.go new file mode 100644 index 000000000..bfd86c19d --- /dev/null +++ b/src/server/v2.0/restapi/operations/replication/stop_replication.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package replication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// StopReplicationHandlerFunc turns a function with the right signature into a stop replication handler +type StopReplicationHandlerFunc func(StopReplicationParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn StopReplicationHandlerFunc) Handle(params StopReplicationParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// StopReplicationHandler interface for that can handle valid stop replication params +type StopReplicationHandler interface { + Handle(StopReplicationParams, interface{}) middleware.Responder +} + +// NewStopReplication creates a new http.Handler for the stop replication operation +func NewStopReplication(ctx *middleware.Context, handler StopReplicationHandler) *StopReplication { + return &StopReplication{Context: ctx, Handler: handler} +} + +/*StopReplication swagger:route PUT /replication/executions/{id} replication stopReplication + +Stop the specific replication execution + +Stop the replication execution specified by ID + +*/ +type StopReplication struct { + Context *middleware.Context + Handler StopReplicationHandler +} + +func (o *StopReplication) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewStopReplicationParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/replication/stop_replication_parameters.go b/src/server/v2.0/restapi/operations/replication/stop_replication_parameters.go new file mode 100644 index 000000000..675c15780 --- /dev/null +++ b/src/server/v2.0/restapi/operations/replication/stop_replication_parameters.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package replication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewStopReplicationParams creates a new StopReplicationParams object +// no default values defined in spec. +func NewStopReplicationParams() StopReplicationParams { + + return StopReplicationParams{} +} + +// StopReplicationParams contains all the bound params for the stop replication operation +// typically these are obtained from a http.Request +// +// swagger:parameters stopReplication +type StopReplicationParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The ID of the execution. + Required: true + In: path + */ + ID int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewStopReplicationParams() beforehand. +func (o *StopReplicationParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *StopReplicationParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *StopReplicationParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *StopReplicationParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("id", "path", "int64", raw) + } + o.ID = value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/replication/stop_replication_responses.go b/src/server/v2.0/restapi/operations/replication/stop_replication_responses.go new file mode 100644 index 000000000..887510d70 --- /dev/null +++ b/src/server/v2.0/restapi/operations/replication/stop_replication_responses.go @@ -0,0 +1,324 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package replication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// StopReplicationOKCode is the HTTP code returned for type StopReplicationOK +const StopReplicationOKCode int = 200 + +/*StopReplicationOK Success + +swagger:response stopReplicationOK +*/ +type StopReplicationOK struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewStopReplicationOK creates StopReplicationOK with default headers values +func NewStopReplicationOK() *StopReplicationOK { + + return &StopReplicationOK{} +} + +// WithXRequestID adds the xRequestId to the stop replication o k response +func (o *StopReplicationOK) WithXRequestID(xRequestID string) *StopReplicationOK { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the stop replication o k response +func (o *StopReplicationOK) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *StopReplicationOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// StopReplicationUnauthorizedCode is the HTTP code returned for type StopReplicationUnauthorized +const StopReplicationUnauthorizedCode int = 401 + +/*StopReplicationUnauthorized Unauthorized + +swagger:response stopReplicationUnauthorized +*/ +type StopReplicationUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewStopReplicationUnauthorized creates StopReplicationUnauthorized with default headers values +func NewStopReplicationUnauthorized() *StopReplicationUnauthorized { + + return &StopReplicationUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the stop replication unauthorized response +func (o *StopReplicationUnauthorized) WithXRequestID(xRequestID string) *StopReplicationUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the stop replication unauthorized response +func (o *StopReplicationUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the stop replication unauthorized response +func (o *StopReplicationUnauthorized) WithPayload(payload *models.Errors) *StopReplicationUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the stop replication unauthorized response +func (o *StopReplicationUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *StopReplicationUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// StopReplicationForbiddenCode is the HTTP code returned for type StopReplicationForbidden +const StopReplicationForbiddenCode int = 403 + +/*StopReplicationForbidden Forbidden + +swagger:response stopReplicationForbidden +*/ +type StopReplicationForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewStopReplicationForbidden creates StopReplicationForbidden with default headers values +func NewStopReplicationForbidden() *StopReplicationForbidden { + + return &StopReplicationForbidden{} +} + +// WithXRequestID adds the xRequestId to the stop replication forbidden response +func (o *StopReplicationForbidden) WithXRequestID(xRequestID string) *StopReplicationForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the stop replication forbidden response +func (o *StopReplicationForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the stop replication forbidden response +func (o *StopReplicationForbidden) WithPayload(payload *models.Errors) *StopReplicationForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the stop replication forbidden response +func (o *StopReplicationForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *StopReplicationForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// StopReplicationNotFoundCode is the HTTP code returned for type StopReplicationNotFound +const StopReplicationNotFoundCode int = 404 + +/*StopReplicationNotFound Not found + +swagger:response stopReplicationNotFound +*/ +type StopReplicationNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewStopReplicationNotFound creates StopReplicationNotFound with default headers values +func NewStopReplicationNotFound() *StopReplicationNotFound { + + return &StopReplicationNotFound{} +} + +// WithXRequestID adds the xRequestId to the stop replication not found response +func (o *StopReplicationNotFound) WithXRequestID(xRequestID string) *StopReplicationNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the stop replication not found response +func (o *StopReplicationNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the stop replication not found response +func (o *StopReplicationNotFound) WithPayload(payload *models.Errors) *StopReplicationNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the stop replication not found response +func (o *StopReplicationNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *StopReplicationNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// StopReplicationInternalServerErrorCode is the HTTP code returned for type StopReplicationInternalServerError +const StopReplicationInternalServerErrorCode int = 500 + +/*StopReplicationInternalServerError Internal server error + +swagger:response stopReplicationInternalServerError +*/ +type StopReplicationInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewStopReplicationInternalServerError creates StopReplicationInternalServerError with default headers values +func NewStopReplicationInternalServerError() *StopReplicationInternalServerError { + + return &StopReplicationInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the stop replication internal server error response +func (o *StopReplicationInternalServerError) WithXRequestID(xRequestID string) *StopReplicationInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the stop replication internal server error response +func (o *StopReplicationInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the stop replication internal server error response +func (o *StopReplicationInternalServerError) WithPayload(payload *models.Errors) *StopReplicationInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the stop replication internal server error response +func (o *StopReplicationInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *StopReplicationInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/replication/stop_replication_urlbuilder.go b/src/server/v2.0/restapi/operations/replication/stop_replication_urlbuilder.go new file mode 100644 index 000000000..54cde3901 --- /dev/null +++ b/src/server/v2.0/restapi/operations/replication/stop_replication_urlbuilder.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package replication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// StopReplicationURL generates an URL for the stop replication operation +type StopReplicationURL struct { + ID int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *StopReplicationURL) WithBasePath(bp string) *StopReplicationURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *StopReplicationURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *StopReplicationURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/replication/executions/{id}" + + id := swag.FormatInt64(o.ID) + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on StopReplicationURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *StopReplicationURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *StopReplicationURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *StopReplicationURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on StopReplicationURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on StopReplicationURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *StopReplicationURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/replication/update_replication_policy.go b/src/server/v2.0/restapi/operations/replication/update_replication_policy.go new file mode 100644 index 000000000..5d08fb470 --- /dev/null +++ b/src/server/v2.0/restapi/operations/replication/update_replication_policy.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package replication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// UpdateReplicationPolicyHandlerFunc turns a function with the right signature into a update replication policy handler +type UpdateReplicationPolicyHandlerFunc func(UpdateReplicationPolicyParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn UpdateReplicationPolicyHandlerFunc) Handle(params UpdateReplicationPolicyParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// UpdateReplicationPolicyHandler interface for that can handle valid update replication policy params +type UpdateReplicationPolicyHandler interface { + Handle(UpdateReplicationPolicyParams, interface{}) middleware.Responder +} + +// NewUpdateReplicationPolicy creates a new http.Handler for the update replication policy operation +func NewUpdateReplicationPolicy(ctx *middleware.Context, handler UpdateReplicationPolicyHandler) *UpdateReplicationPolicy { + return &UpdateReplicationPolicy{Context: ctx, Handler: handler} +} + +/*UpdateReplicationPolicy swagger:route PUT /replication/policies/{id} replication updateReplicationPolicy + +Update the replication policy + +Update the replication policy + +*/ +type UpdateReplicationPolicy struct { + Context *middleware.Context + Handler UpdateReplicationPolicyHandler +} + +func (o *UpdateReplicationPolicy) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewUpdateReplicationPolicyParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/replication/update_replication_policy_parameters.go b/src/server/v2.0/restapi/operations/replication/update_replication_policy_parameters.go new file mode 100644 index 000000000..b77372570 --- /dev/null +++ b/src/server/v2.0/restapi/operations/replication/update_replication_policy_parameters.go @@ -0,0 +1,150 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package replication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewUpdateReplicationPolicyParams creates a new UpdateReplicationPolicyParams object +// no default values defined in spec. +func NewUpdateReplicationPolicyParams() UpdateReplicationPolicyParams { + + return UpdateReplicationPolicyParams{} +} + +// UpdateReplicationPolicyParams contains all the bound params for the update replication policy operation +// typically these are obtained from a http.Request +// +// swagger:parameters updateReplicationPolicy +type UpdateReplicationPolicyParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The policy ID + Required: true + In: path + */ + ID int64 + /*The replication policy + Required: true + In: body + */ + Policy *models.ReplicationPolicy +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewUpdateReplicationPolicyParams() beforehand. +func (o *UpdateReplicationPolicyParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.ReplicationPolicy + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("policy", "body", "")) + } else { + res = append(res, errors.NewParseError("policy", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Policy = &body + } + } + } else { + res = append(res, errors.Required("policy", "body", "")) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *UpdateReplicationPolicyParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *UpdateReplicationPolicyParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *UpdateReplicationPolicyParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("id", "path", "int64", raw) + } + o.ID = value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/replication/update_replication_policy_responses.go b/src/server/v2.0/restapi/operations/replication/update_replication_policy_responses.go new file mode 100644 index 000000000..57505fa18 --- /dev/null +++ b/src/server/v2.0/restapi/operations/replication/update_replication_policy_responses.go @@ -0,0 +1,390 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package replication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// UpdateReplicationPolicyOKCode is the HTTP code returned for type UpdateReplicationPolicyOK +const UpdateReplicationPolicyOKCode int = 200 + +/*UpdateReplicationPolicyOK Success + +swagger:response updateReplicationPolicyOK +*/ +type UpdateReplicationPolicyOK struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewUpdateReplicationPolicyOK creates UpdateReplicationPolicyOK with default headers values +func NewUpdateReplicationPolicyOK() *UpdateReplicationPolicyOK { + + return &UpdateReplicationPolicyOK{} +} + +// WithXRequestID adds the xRequestId to the update replication policy o k response +func (o *UpdateReplicationPolicyOK) WithXRequestID(xRequestID string) *UpdateReplicationPolicyOK { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update replication policy o k response +func (o *UpdateReplicationPolicyOK) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *UpdateReplicationPolicyOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// UpdateReplicationPolicyUnauthorizedCode is the HTTP code returned for type UpdateReplicationPolicyUnauthorized +const UpdateReplicationPolicyUnauthorizedCode int = 401 + +/*UpdateReplicationPolicyUnauthorized Unauthorized + +swagger:response updateReplicationPolicyUnauthorized +*/ +type UpdateReplicationPolicyUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateReplicationPolicyUnauthorized creates UpdateReplicationPolicyUnauthorized with default headers values +func NewUpdateReplicationPolicyUnauthorized() *UpdateReplicationPolicyUnauthorized { + + return &UpdateReplicationPolicyUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the update replication policy unauthorized response +func (o *UpdateReplicationPolicyUnauthorized) WithXRequestID(xRequestID string) *UpdateReplicationPolicyUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update replication policy unauthorized response +func (o *UpdateReplicationPolicyUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update replication policy unauthorized response +func (o *UpdateReplicationPolicyUnauthorized) WithPayload(payload *models.Errors) *UpdateReplicationPolicyUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update replication policy unauthorized response +func (o *UpdateReplicationPolicyUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateReplicationPolicyUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateReplicationPolicyForbiddenCode is the HTTP code returned for type UpdateReplicationPolicyForbidden +const UpdateReplicationPolicyForbiddenCode int = 403 + +/*UpdateReplicationPolicyForbidden Forbidden + +swagger:response updateReplicationPolicyForbidden +*/ +type UpdateReplicationPolicyForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateReplicationPolicyForbidden creates UpdateReplicationPolicyForbidden with default headers values +func NewUpdateReplicationPolicyForbidden() *UpdateReplicationPolicyForbidden { + + return &UpdateReplicationPolicyForbidden{} +} + +// WithXRequestID adds the xRequestId to the update replication policy forbidden response +func (o *UpdateReplicationPolicyForbidden) WithXRequestID(xRequestID string) *UpdateReplicationPolicyForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update replication policy forbidden response +func (o *UpdateReplicationPolicyForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update replication policy forbidden response +func (o *UpdateReplicationPolicyForbidden) WithPayload(payload *models.Errors) *UpdateReplicationPolicyForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update replication policy forbidden response +func (o *UpdateReplicationPolicyForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateReplicationPolicyForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateReplicationPolicyNotFoundCode is the HTTP code returned for type UpdateReplicationPolicyNotFound +const UpdateReplicationPolicyNotFoundCode int = 404 + +/*UpdateReplicationPolicyNotFound Not found + +swagger:response updateReplicationPolicyNotFound +*/ +type UpdateReplicationPolicyNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateReplicationPolicyNotFound creates UpdateReplicationPolicyNotFound with default headers values +func NewUpdateReplicationPolicyNotFound() *UpdateReplicationPolicyNotFound { + + return &UpdateReplicationPolicyNotFound{} +} + +// WithXRequestID adds the xRequestId to the update replication policy not found response +func (o *UpdateReplicationPolicyNotFound) WithXRequestID(xRequestID string) *UpdateReplicationPolicyNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update replication policy not found response +func (o *UpdateReplicationPolicyNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update replication policy not found response +func (o *UpdateReplicationPolicyNotFound) WithPayload(payload *models.Errors) *UpdateReplicationPolicyNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update replication policy not found response +func (o *UpdateReplicationPolicyNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateReplicationPolicyNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateReplicationPolicyConflictCode is the HTTP code returned for type UpdateReplicationPolicyConflict +const UpdateReplicationPolicyConflictCode int = 409 + +/*UpdateReplicationPolicyConflict Conflict + +swagger:response updateReplicationPolicyConflict +*/ +type UpdateReplicationPolicyConflict struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateReplicationPolicyConflict creates UpdateReplicationPolicyConflict with default headers values +func NewUpdateReplicationPolicyConflict() *UpdateReplicationPolicyConflict { + + return &UpdateReplicationPolicyConflict{} +} + +// WithXRequestID adds the xRequestId to the update replication policy conflict response +func (o *UpdateReplicationPolicyConflict) WithXRequestID(xRequestID string) *UpdateReplicationPolicyConflict { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update replication policy conflict response +func (o *UpdateReplicationPolicyConflict) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update replication policy conflict response +func (o *UpdateReplicationPolicyConflict) WithPayload(payload *models.Errors) *UpdateReplicationPolicyConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update replication policy conflict response +func (o *UpdateReplicationPolicyConflict) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateReplicationPolicyConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateReplicationPolicyInternalServerErrorCode is the HTTP code returned for type UpdateReplicationPolicyInternalServerError +const UpdateReplicationPolicyInternalServerErrorCode int = 500 + +/*UpdateReplicationPolicyInternalServerError Internal server error + +swagger:response updateReplicationPolicyInternalServerError +*/ +type UpdateReplicationPolicyInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateReplicationPolicyInternalServerError creates UpdateReplicationPolicyInternalServerError with default headers values +func NewUpdateReplicationPolicyInternalServerError() *UpdateReplicationPolicyInternalServerError { + + return &UpdateReplicationPolicyInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the update replication policy internal server error response +func (o *UpdateReplicationPolicyInternalServerError) WithXRequestID(xRequestID string) *UpdateReplicationPolicyInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update replication policy internal server error response +func (o *UpdateReplicationPolicyInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update replication policy internal server error response +func (o *UpdateReplicationPolicyInternalServerError) WithPayload(payload *models.Errors) *UpdateReplicationPolicyInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update replication policy internal server error response +func (o *UpdateReplicationPolicyInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateReplicationPolicyInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/replication/update_replication_policy_urlbuilder.go b/src/server/v2.0/restapi/operations/replication/update_replication_policy_urlbuilder.go new file mode 100644 index 000000000..88d62f36e --- /dev/null +++ b/src/server/v2.0/restapi/operations/replication/update_replication_policy_urlbuilder.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package replication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// UpdateReplicationPolicyURL generates an URL for the update replication policy operation +type UpdateReplicationPolicyURL struct { + ID int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdateReplicationPolicyURL) WithBasePath(bp string) *UpdateReplicationPolicyURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdateReplicationPolicyURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *UpdateReplicationPolicyURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/replication/policies/{id}" + + id := swag.FormatInt64(o.ID) + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on UpdateReplicationPolicyURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *UpdateReplicationPolicyURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *UpdateReplicationPolicyURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *UpdateReplicationPolicyURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on UpdateReplicationPolicyURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on UpdateReplicationPolicyURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *UpdateReplicationPolicyURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/repository/delete_repository.go b/src/server/v2.0/restapi/operations/repository/delete_repository.go new file mode 100644 index 000000000..7dec2b29e --- /dev/null +++ b/src/server/v2.0/restapi/operations/repository/delete_repository.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package repository + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteRepositoryHandlerFunc turns a function with the right signature into a delete repository handler +type DeleteRepositoryHandlerFunc func(DeleteRepositoryParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteRepositoryHandlerFunc) Handle(params DeleteRepositoryParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteRepositoryHandler interface for that can handle valid delete repository params +type DeleteRepositoryHandler interface { + Handle(DeleteRepositoryParams, interface{}) middleware.Responder +} + +// NewDeleteRepository creates a new http.Handler for the delete repository operation +func NewDeleteRepository(ctx *middleware.Context, handler DeleteRepositoryHandler) *DeleteRepository { + return &DeleteRepository{Context: ctx, Handler: handler} +} + +/*DeleteRepository swagger:route DELETE /projects/{project_name}/repositories/{repository_name} repository deleteRepository + +Delete repository + +Delete the repository specified by name + +*/ +type DeleteRepository struct { + Context *middleware.Context + Handler DeleteRepositoryHandler +} + +func (o *DeleteRepository) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewDeleteRepositoryParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/repository/delete_repository_parameters.go b/src/server/v2.0/restapi/operations/repository/delete_repository_parameters.go new file mode 100644 index 000000000..c5f0ad134 --- /dev/null +++ b/src/server/v2.0/restapi/operations/repository/delete_repository_parameters.go @@ -0,0 +1,139 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package repository + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewDeleteRepositoryParams creates a new DeleteRepositoryParams object +// no default values defined in spec. +func NewDeleteRepositoryParams() DeleteRepositoryParams { + + return DeleteRepositoryParams{} +} + +// DeleteRepositoryParams contains all the bound params for the delete repository operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteRepository +type DeleteRepositoryParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The name of the project + Required: true + In: path + */ + ProjectName string + /*The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -> a%252Fb + Required: true + In: path + */ + RepositoryName string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteRepositoryParams() beforehand. +func (o *DeleteRepositoryParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rProjectName, rhkProjectName, _ := route.Params.GetOK("project_name") + if err := o.bindProjectName(rProjectName, rhkProjectName, route.Formats); err != nil { + res = append(res, err) + } + + rRepositoryName, rhkRepositoryName, _ := route.Params.GetOK("repository_name") + if err := o.bindRepositoryName(rRepositoryName, rhkRepositoryName, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *DeleteRepositoryParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *DeleteRepositoryParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindProjectName binds and validates parameter ProjectName from path. +func (o *DeleteRepositoryParams) bindProjectName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectName = raw + + return nil +} + +// bindRepositoryName binds and validates parameter RepositoryName from path. +func (o *DeleteRepositoryParams) bindRepositoryName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.RepositoryName = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/repository/delete_repository_responses.go b/src/server/v2.0/restapi/operations/repository/delete_repository_responses.go new file mode 100644 index 000000000..d48286cae --- /dev/null +++ b/src/server/v2.0/restapi/operations/repository/delete_repository_responses.go @@ -0,0 +1,390 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package repository + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// DeleteRepositoryOKCode is the HTTP code returned for type DeleteRepositoryOK +const DeleteRepositoryOKCode int = 200 + +/*DeleteRepositoryOK Success + +swagger:response deleteRepositoryOK +*/ +type DeleteRepositoryOK struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewDeleteRepositoryOK creates DeleteRepositoryOK with default headers values +func NewDeleteRepositoryOK() *DeleteRepositoryOK { + + return &DeleteRepositoryOK{} +} + +// WithXRequestID adds the xRequestId to the delete repository o k response +func (o *DeleteRepositoryOK) WithXRequestID(xRequestID string) *DeleteRepositoryOK { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete repository o k response +func (o *DeleteRepositoryOK) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *DeleteRepositoryOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// DeleteRepositoryBadRequestCode is the HTTP code returned for type DeleteRepositoryBadRequest +const DeleteRepositoryBadRequestCode int = 400 + +/*DeleteRepositoryBadRequest Bad request + +swagger:response deleteRepositoryBadRequest +*/ +type DeleteRepositoryBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteRepositoryBadRequest creates DeleteRepositoryBadRequest with default headers values +func NewDeleteRepositoryBadRequest() *DeleteRepositoryBadRequest { + + return &DeleteRepositoryBadRequest{} +} + +// WithXRequestID adds the xRequestId to the delete repository bad request response +func (o *DeleteRepositoryBadRequest) WithXRequestID(xRequestID string) *DeleteRepositoryBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete repository bad request response +func (o *DeleteRepositoryBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete repository bad request response +func (o *DeleteRepositoryBadRequest) WithPayload(payload *models.Errors) *DeleteRepositoryBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete repository bad request response +func (o *DeleteRepositoryBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteRepositoryBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteRepositoryUnauthorizedCode is the HTTP code returned for type DeleteRepositoryUnauthorized +const DeleteRepositoryUnauthorizedCode int = 401 + +/*DeleteRepositoryUnauthorized Unauthorized + +swagger:response deleteRepositoryUnauthorized +*/ +type DeleteRepositoryUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteRepositoryUnauthorized creates DeleteRepositoryUnauthorized with default headers values +func NewDeleteRepositoryUnauthorized() *DeleteRepositoryUnauthorized { + + return &DeleteRepositoryUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the delete repository unauthorized response +func (o *DeleteRepositoryUnauthorized) WithXRequestID(xRequestID string) *DeleteRepositoryUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete repository unauthorized response +func (o *DeleteRepositoryUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete repository unauthorized response +func (o *DeleteRepositoryUnauthorized) WithPayload(payload *models.Errors) *DeleteRepositoryUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete repository unauthorized response +func (o *DeleteRepositoryUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteRepositoryUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteRepositoryForbiddenCode is the HTTP code returned for type DeleteRepositoryForbidden +const DeleteRepositoryForbiddenCode int = 403 + +/*DeleteRepositoryForbidden Forbidden + +swagger:response deleteRepositoryForbidden +*/ +type DeleteRepositoryForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteRepositoryForbidden creates DeleteRepositoryForbidden with default headers values +func NewDeleteRepositoryForbidden() *DeleteRepositoryForbidden { + + return &DeleteRepositoryForbidden{} +} + +// WithXRequestID adds the xRequestId to the delete repository forbidden response +func (o *DeleteRepositoryForbidden) WithXRequestID(xRequestID string) *DeleteRepositoryForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete repository forbidden response +func (o *DeleteRepositoryForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete repository forbidden response +func (o *DeleteRepositoryForbidden) WithPayload(payload *models.Errors) *DeleteRepositoryForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete repository forbidden response +func (o *DeleteRepositoryForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteRepositoryForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteRepositoryNotFoundCode is the HTTP code returned for type DeleteRepositoryNotFound +const DeleteRepositoryNotFoundCode int = 404 + +/*DeleteRepositoryNotFound Not found + +swagger:response deleteRepositoryNotFound +*/ +type DeleteRepositoryNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteRepositoryNotFound creates DeleteRepositoryNotFound with default headers values +func NewDeleteRepositoryNotFound() *DeleteRepositoryNotFound { + + return &DeleteRepositoryNotFound{} +} + +// WithXRequestID adds the xRequestId to the delete repository not found response +func (o *DeleteRepositoryNotFound) WithXRequestID(xRequestID string) *DeleteRepositoryNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete repository not found response +func (o *DeleteRepositoryNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete repository not found response +func (o *DeleteRepositoryNotFound) WithPayload(payload *models.Errors) *DeleteRepositoryNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete repository not found response +func (o *DeleteRepositoryNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteRepositoryNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteRepositoryInternalServerErrorCode is the HTTP code returned for type DeleteRepositoryInternalServerError +const DeleteRepositoryInternalServerErrorCode int = 500 + +/*DeleteRepositoryInternalServerError Internal server error + +swagger:response deleteRepositoryInternalServerError +*/ +type DeleteRepositoryInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteRepositoryInternalServerError creates DeleteRepositoryInternalServerError with default headers values +func NewDeleteRepositoryInternalServerError() *DeleteRepositoryInternalServerError { + + return &DeleteRepositoryInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the delete repository internal server error response +func (o *DeleteRepositoryInternalServerError) WithXRequestID(xRequestID string) *DeleteRepositoryInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete repository internal server error response +func (o *DeleteRepositoryInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete repository internal server error response +func (o *DeleteRepositoryInternalServerError) WithPayload(payload *models.Errors) *DeleteRepositoryInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete repository internal server error response +func (o *DeleteRepositoryInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteRepositoryInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/repository/delete_repository_urlbuilder.go b/src/server/v2.0/restapi/operations/repository/delete_repository_urlbuilder.go new file mode 100644 index 000000000..eb19e1041 --- /dev/null +++ b/src/server/v2.0/restapi/operations/repository/delete_repository_urlbuilder.go @@ -0,0 +1,107 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package repository + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// DeleteRepositoryURL generates an URL for the delete repository operation +type DeleteRepositoryURL struct { + ProjectName string + RepositoryName string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteRepositoryURL) WithBasePath(bp string) *DeleteRepositoryURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteRepositoryURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteRepositoryURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name}/repositories/{repository_name}" + + projectName := o.ProjectName + if projectName != "" { + _path = strings.Replace(_path, "{project_name}", projectName, -1) + } else { + return nil, errors.New("projectName is required on DeleteRepositoryURL") + } + + repositoryName := o.RepositoryName + if repositoryName != "" { + _path = strings.Replace(_path, "{repository_name}", repositoryName, -1) + } else { + return nil, errors.New("repositoryName is required on DeleteRepositoryURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteRepositoryURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteRepositoryURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteRepositoryURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteRepositoryURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteRepositoryURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteRepositoryURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/repository/get_repository.go b/src/server/v2.0/restapi/operations/repository/get_repository.go new file mode 100644 index 000000000..2e5766285 --- /dev/null +++ b/src/server/v2.0/restapi/operations/repository/get_repository.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package repository + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetRepositoryHandlerFunc turns a function with the right signature into a get repository handler +type GetRepositoryHandlerFunc func(GetRepositoryParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetRepositoryHandlerFunc) Handle(params GetRepositoryParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetRepositoryHandler interface for that can handle valid get repository params +type GetRepositoryHandler interface { + Handle(GetRepositoryParams, interface{}) middleware.Responder +} + +// NewGetRepository creates a new http.Handler for the get repository operation +func NewGetRepository(ctx *middleware.Context, handler GetRepositoryHandler) *GetRepository { + return &GetRepository{Context: ctx, Handler: handler} +} + +/*GetRepository swagger:route GET /projects/{project_name}/repositories/{repository_name} repository getRepository + +Get repository + +Get the repository specified by name + +*/ +type GetRepository struct { + Context *middleware.Context + Handler GetRepositoryHandler +} + +func (o *GetRepository) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetRepositoryParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/repository/get_repository_parameters.go b/src/server/v2.0/restapi/operations/repository/get_repository_parameters.go new file mode 100644 index 000000000..86b635fdc --- /dev/null +++ b/src/server/v2.0/restapi/operations/repository/get_repository_parameters.go @@ -0,0 +1,139 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package repository + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewGetRepositoryParams creates a new GetRepositoryParams object +// no default values defined in spec. +func NewGetRepositoryParams() GetRepositoryParams { + + return GetRepositoryParams{} +} + +// GetRepositoryParams contains all the bound params for the get repository operation +// typically these are obtained from a http.Request +// +// swagger:parameters getRepository +type GetRepositoryParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The name of the project + Required: true + In: path + */ + ProjectName string + /*The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -> a%252Fb + Required: true + In: path + */ + RepositoryName string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetRepositoryParams() beforehand. +func (o *GetRepositoryParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rProjectName, rhkProjectName, _ := route.Params.GetOK("project_name") + if err := o.bindProjectName(rProjectName, rhkProjectName, route.Formats); err != nil { + res = append(res, err) + } + + rRepositoryName, rhkRepositoryName, _ := route.Params.GetOK("repository_name") + if err := o.bindRepositoryName(rRepositoryName, rhkRepositoryName, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetRepositoryParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetRepositoryParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindProjectName binds and validates parameter ProjectName from path. +func (o *GetRepositoryParams) bindProjectName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectName = raw + + return nil +} + +// bindRepositoryName binds and validates parameter RepositoryName from path. +func (o *GetRepositoryParams) bindRepositoryName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.RepositoryName = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/repository/get_repository_responses.go b/src/server/v2.0/restapi/operations/repository/get_repository_responses.go new file mode 100644 index 000000000..f64d458f9 --- /dev/null +++ b/src/server/v2.0/restapi/operations/repository/get_repository_responses.go @@ -0,0 +1,388 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package repository + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetRepositoryOKCode is the HTTP code returned for type GetRepositoryOK +const GetRepositoryOKCode int = 200 + +/*GetRepositoryOK Success + +swagger:response getRepositoryOK +*/ +type GetRepositoryOK struct { + + /* + In: Body + */ + Payload *models.Repository `json:"body,omitempty"` +} + +// NewGetRepositoryOK creates GetRepositoryOK with default headers values +func NewGetRepositoryOK() *GetRepositoryOK { + + return &GetRepositoryOK{} +} + +// WithPayload adds the payload to the get repository o k response +func (o *GetRepositoryOK) WithPayload(payload *models.Repository) *GetRepositoryOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get repository o k response +func (o *GetRepositoryOK) SetPayload(payload *models.Repository) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetRepositoryOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetRepositoryBadRequestCode is the HTTP code returned for type GetRepositoryBadRequest +const GetRepositoryBadRequestCode int = 400 + +/*GetRepositoryBadRequest Bad request + +swagger:response getRepositoryBadRequest +*/ +type GetRepositoryBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetRepositoryBadRequest creates GetRepositoryBadRequest with default headers values +func NewGetRepositoryBadRequest() *GetRepositoryBadRequest { + + return &GetRepositoryBadRequest{} +} + +// WithXRequestID adds the xRequestId to the get repository bad request response +func (o *GetRepositoryBadRequest) WithXRequestID(xRequestID string) *GetRepositoryBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get repository bad request response +func (o *GetRepositoryBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get repository bad request response +func (o *GetRepositoryBadRequest) WithPayload(payload *models.Errors) *GetRepositoryBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get repository bad request response +func (o *GetRepositoryBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetRepositoryBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetRepositoryUnauthorizedCode is the HTTP code returned for type GetRepositoryUnauthorized +const GetRepositoryUnauthorizedCode int = 401 + +/*GetRepositoryUnauthorized Unauthorized + +swagger:response getRepositoryUnauthorized +*/ +type GetRepositoryUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetRepositoryUnauthorized creates GetRepositoryUnauthorized with default headers values +func NewGetRepositoryUnauthorized() *GetRepositoryUnauthorized { + + return &GetRepositoryUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the get repository unauthorized response +func (o *GetRepositoryUnauthorized) WithXRequestID(xRequestID string) *GetRepositoryUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get repository unauthorized response +func (o *GetRepositoryUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get repository unauthorized response +func (o *GetRepositoryUnauthorized) WithPayload(payload *models.Errors) *GetRepositoryUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get repository unauthorized response +func (o *GetRepositoryUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetRepositoryUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetRepositoryForbiddenCode is the HTTP code returned for type GetRepositoryForbidden +const GetRepositoryForbiddenCode int = 403 + +/*GetRepositoryForbidden Forbidden + +swagger:response getRepositoryForbidden +*/ +type GetRepositoryForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetRepositoryForbidden creates GetRepositoryForbidden with default headers values +func NewGetRepositoryForbidden() *GetRepositoryForbidden { + + return &GetRepositoryForbidden{} +} + +// WithXRequestID adds the xRequestId to the get repository forbidden response +func (o *GetRepositoryForbidden) WithXRequestID(xRequestID string) *GetRepositoryForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get repository forbidden response +func (o *GetRepositoryForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get repository forbidden response +func (o *GetRepositoryForbidden) WithPayload(payload *models.Errors) *GetRepositoryForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get repository forbidden response +func (o *GetRepositoryForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetRepositoryForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetRepositoryNotFoundCode is the HTTP code returned for type GetRepositoryNotFound +const GetRepositoryNotFoundCode int = 404 + +/*GetRepositoryNotFound Not found + +swagger:response getRepositoryNotFound +*/ +type GetRepositoryNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetRepositoryNotFound creates GetRepositoryNotFound with default headers values +func NewGetRepositoryNotFound() *GetRepositoryNotFound { + + return &GetRepositoryNotFound{} +} + +// WithXRequestID adds the xRequestId to the get repository not found response +func (o *GetRepositoryNotFound) WithXRequestID(xRequestID string) *GetRepositoryNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get repository not found response +func (o *GetRepositoryNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get repository not found response +func (o *GetRepositoryNotFound) WithPayload(payload *models.Errors) *GetRepositoryNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get repository not found response +func (o *GetRepositoryNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetRepositoryNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetRepositoryInternalServerErrorCode is the HTTP code returned for type GetRepositoryInternalServerError +const GetRepositoryInternalServerErrorCode int = 500 + +/*GetRepositoryInternalServerError Internal server error + +swagger:response getRepositoryInternalServerError +*/ +type GetRepositoryInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetRepositoryInternalServerError creates GetRepositoryInternalServerError with default headers values +func NewGetRepositoryInternalServerError() *GetRepositoryInternalServerError { + + return &GetRepositoryInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get repository internal server error response +func (o *GetRepositoryInternalServerError) WithXRequestID(xRequestID string) *GetRepositoryInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get repository internal server error response +func (o *GetRepositoryInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get repository internal server error response +func (o *GetRepositoryInternalServerError) WithPayload(payload *models.Errors) *GetRepositoryInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get repository internal server error response +func (o *GetRepositoryInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetRepositoryInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/repository/get_repository_urlbuilder.go b/src/server/v2.0/restapi/operations/repository/get_repository_urlbuilder.go new file mode 100644 index 000000000..6dd5e0f56 --- /dev/null +++ b/src/server/v2.0/restapi/operations/repository/get_repository_urlbuilder.go @@ -0,0 +1,107 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package repository + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetRepositoryURL generates an URL for the get repository operation +type GetRepositoryURL struct { + ProjectName string + RepositoryName string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetRepositoryURL) WithBasePath(bp string) *GetRepositoryURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetRepositoryURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetRepositoryURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name}/repositories/{repository_name}" + + projectName := o.ProjectName + if projectName != "" { + _path = strings.Replace(_path, "{project_name}", projectName, -1) + } else { + return nil, errors.New("projectName is required on GetRepositoryURL") + } + + repositoryName := o.RepositoryName + if repositoryName != "" { + _path = strings.Replace(_path, "{repository_name}", repositoryName, -1) + } else { + return nil, errors.New("repositoryName is required on GetRepositoryURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetRepositoryURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetRepositoryURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetRepositoryURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetRepositoryURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetRepositoryURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetRepositoryURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/repository/list_all_repositories.go b/src/server/v2.0/restapi/operations/repository/list_all_repositories.go new file mode 100644 index 000000000..17576b622 --- /dev/null +++ b/src/server/v2.0/restapi/operations/repository/list_all_repositories.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package repository + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ListAllRepositoriesHandlerFunc turns a function with the right signature into a list all repositories handler +type ListAllRepositoriesHandlerFunc func(ListAllRepositoriesParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ListAllRepositoriesHandlerFunc) Handle(params ListAllRepositoriesParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ListAllRepositoriesHandler interface for that can handle valid list all repositories params +type ListAllRepositoriesHandler interface { + Handle(ListAllRepositoriesParams, interface{}) middleware.Responder +} + +// NewListAllRepositories creates a new http.Handler for the list all repositories operation +func NewListAllRepositories(ctx *middleware.Context, handler ListAllRepositoriesHandler) *ListAllRepositories { + return &ListAllRepositories{Context: ctx, Handler: handler} +} + +/*ListAllRepositories swagger:route GET /repositories repository listAllRepositories + +List all authorized repositories + +List all authorized repositories + +*/ +type ListAllRepositories struct { + Context *middleware.Context + Handler ListAllRepositoriesHandler +} + +func (o *ListAllRepositories) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewListAllRepositoriesParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/repository/list_all_repositories_parameters.go b/src/server/v2.0/restapi/operations/repository/list_all_repositories_parameters.go new file mode 100644 index 000000000..b6986b912 --- /dev/null +++ b/src/server/v2.0/restapi/operations/repository/list_all_repositories_parameters.go @@ -0,0 +1,239 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package repository + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewListAllRepositoriesParams creates a new ListAllRepositoriesParams object +// with the default values initialized. +func NewListAllRepositoriesParams() ListAllRepositoriesParams { + + var ( + // initialize parameters with default values + + pageDefault = int64(1) + pageSizeDefault = int64(10) + ) + + return ListAllRepositoriesParams{ + Page: &pageDefault, + + PageSize: &pageSizeDefault, + } +} + +// ListAllRepositoriesParams contains all the bound params for the list all repositories operation +// typically these are obtained from a http.Request +// +// swagger:parameters listAllRepositories +type ListAllRepositoriesParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The page number + In: query + Default: 1 + */ + Page *int64 + /*The size of per page + Maximum: 100 + In: query + Default: 10 + */ + PageSize *int64 + /*Query string to query resources. Supported query patterns are "exact match(k=v)", "fuzzy match(k=~v)", "range(k=[min~max])", "list with union releationship(k={v1 v2 v3})" and "list with intersetion relationship(k=(v1 v2 v3))". The value of range and list can be string(enclosed by " or '), integer or time(in format "2020-04-09 02:36:00"). All of these query patterns should be put in the query string "q=xxx" and splitted by ",". e.g. q=k1=v1,k2=~v2,k3=[min~max] + In: query + */ + Q *string + /*Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + In: query + */ + Sort *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewListAllRepositoriesParams() beforehand. +func (o *ListAllRepositoriesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + qPage, qhkPage, _ := qs.GetOK("page") + if err := o.bindPage(qPage, qhkPage, route.Formats); err != nil { + res = append(res, err) + } + + qPageSize, qhkPageSize, _ := qs.GetOK("page_size") + if err := o.bindPageSize(qPageSize, qhkPageSize, route.Formats); err != nil { + res = append(res, err) + } + + qQ, qhkQ, _ := qs.GetOK("q") + if err := o.bindQ(qQ, qhkQ, route.Formats); err != nil { + res = append(res, err) + } + + qSort, qhkSort, _ := qs.GetOK("sort") + if err := o.bindSort(qSort, qhkSort, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *ListAllRepositoriesParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *ListAllRepositoriesParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindPage binds and validates parameter Page from query. +func (o *ListAllRepositoriesParams) bindPage(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListAllRepositoriesParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page", "query", "int64", raw) + } + o.Page = &value + + return nil +} + +// bindPageSize binds and validates parameter PageSize from query. +func (o *ListAllRepositoriesParams) bindPageSize(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListAllRepositoriesParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page_size", "query", "int64", raw) + } + o.PageSize = &value + + if err := o.validatePageSize(formats); err != nil { + return err + } + + return nil +} + +// validatePageSize carries on validations for parameter PageSize +func (o *ListAllRepositoriesParams) validatePageSize(formats strfmt.Registry) error { + + if err := validate.MaximumInt("page_size", "query", int64(*o.PageSize), 100, false); err != nil { + return err + } + + return nil +} + +// bindQ binds and validates parameter Q from query. +func (o *ListAllRepositoriesParams) bindQ(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Q = &raw + + return nil +} + +// bindSort binds and validates parameter Sort from query. +func (o *ListAllRepositoriesParams) bindSort(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Sort = &raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/repository/list_all_repositories_responses.go b/src/server/v2.0/restapi/operations/repository/list_all_repositories_responses.go new file mode 100644 index 000000000..7960beb17 --- /dev/null +++ b/src/server/v2.0/restapi/operations/repository/list_all_repositories_responses.go @@ -0,0 +1,238 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package repository + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/swag" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// ListAllRepositoriesOKCode is the HTTP code returned for type ListAllRepositoriesOK +const ListAllRepositoriesOKCode int = 200 + +/*ListAllRepositoriesOK Success + +swagger:response listAllRepositoriesOK +*/ +type ListAllRepositoriesOK struct { + /*Link refers to the previous page and next page + + */ + Link string `json:"Link"` + /*The total count of repositories + + */ + XTotalCount int64 `json:"X-Total-Count"` + + /* + In: Body + */ + Payload []*models.Repository `json:"body,omitempty"` +} + +// NewListAllRepositoriesOK creates ListAllRepositoriesOK with default headers values +func NewListAllRepositoriesOK() *ListAllRepositoriesOK { + + return &ListAllRepositoriesOK{} +} + +// WithLink adds the link to the list all repositories o k response +func (o *ListAllRepositoriesOK) WithLink(link string) *ListAllRepositoriesOK { + o.Link = link + return o +} + +// SetLink sets the link to the list all repositories o k response +func (o *ListAllRepositoriesOK) SetLink(link string) { + o.Link = link +} + +// WithXTotalCount adds the xTotalCount to the list all repositories o k response +func (o *ListAllRepositoriesOK) WithXTotalCount(xTotalCount int64) *ListAllRepositoriesOK { + o.XTotalCount = xTotalCount + return o +} + +// SetXTotalCount sets the xTotalCount to the list all repositories o k response +func (o *ListAllRepositoriesOK) SetXTotalCount(xTotalCount int64) { + o.XTotalCount = xTotalCount +} + +// WithPayload adds the payload to the list all repositories o k response +func (o *ListAllRepositoriesOK) WithPayload(payload []*models.Repository) *ListAllRepositoriesOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list all repositories o k response +func (o *ListAllRepositoriesOK) SetPayload(payload []*models.Repository) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListAllRepositoriesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Link + + link := o.Link + if link != "" { + rw.Header().Set("Link", link) + } + + // response header X-Total-Count + + xTotalCount := swag.FormatInt64(o.XTotalCount) + if xTotalCount != "" { + rw.Header().Set("X-Total-Count", xTotalCount) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = make([]*models.Repository, 0, 50) + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ListAllRepositoriesBadRequestCode is the HTTP code returned for type ListAllRepositoriesBadRequest +const ListAllRepositoriesBadRequestCode int = 400 + +/*ListAllRepositoriesBadRequest Bad request + +swagger:response listAllRepositoriesBadRequest +*/ +type ListAllRepositoriesBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListAllRepositoriesBadRequest creates ListAllRepositoriesBadRequest with default headers values +func NewListAllRepositoriesBadRequest() *ListAllRepositoriesBadRequest { + + return &ListAllRepositoriesBadRequest{} +} + +// WithXRequestID adds the xRequestId to the list all repositories bad request response +func (o *ListAllRepositoriesBadRequest) WithXRequestID(xRequestID string) *ListAllRepositoriesBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list all repositories bad request response +func (o *ListAllRepositoriesBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list all repositories bad request response +func (o *ListAllRepositoriesBadRequest) WithPayload(payload *models.Errors) *ListAllRepositoriesBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list all repositories bad request response +func (o *ListAllRepositoriesBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListAllRepositoriesBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListAllRepositoriesInternalServerErrorCode is the HTTP code returned for type ListAllRepositoriesInternalServerError +const ListAllRepositoriesInternalServerErrorCode int = 500 + +/*ListAllRepositoriesInternalServerError Internal server error + +swagger:response listAllRepositoriesInternalServerError +*/ +type ListAllRepositoriesInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListAllRepositoriesInternalServerError creates ListAllRepositoriesInternalServerError with default headers values +func NewListAllRepositoriesInternalServerError() *ListAllRepositoriesInternalServerError { + + return &ListAllRepositoriesInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the list all repositories internal server error response +func (o *ListAllRepositoriesInternalServerError) WithXRequestID(xRequestID string) *ListAllRepositoriesInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list all repositories internal server error response +func (o *ListAllRepositoriesInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list all repositories internal server error response +func (o *ListAllRepositoriesInternalServerError) WithPayload(payload *models.Errors) *ListAllRepositoriesInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list all repositories internal server error response +func (o *ListAllRepositoriesInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListAllRepositoriesInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/repository/list_all_repositories_urlbuilder.go b/src/server/v2.0/restapi/operations/repository/list_all_repositories_urlbuilder.go new file mode 100644 index 000000000..be6d0dd5b --- /dev/null +++ b/src/server/v2.0/restapi/operations/repository/list_all_repositories_urlbuilder.go @@ -0,0 +1,132 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package repository + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// ListAllRepositoriesURL generates an URL for the list all repositories operation +type ListAllRepositoriesURL struct { + Page *int64 + PageSize *int64 + Q *string + Sort *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListAllRepositoriesURL) WithBasePath(bp string) *ListAllRepositoriesURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListAllRepositoriesURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ListAllRepositoriesURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/repositories" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var pageQ string + if o.Page != nil { + pageQ = swag.FormatInt64(*o.Page) + } + if pageQ != "" { + qs.Set("page", pageQ) + } + + var pageSizeQ string + if o.PageSize != nil { + pageSizeQ = swag.FormatInt64(*o.PageSize) + } + if pageSizeQ != "" { + qs.Set("page_size", pageSizeQ) + } + + var qQ string + if o.Q != nil { + qQ = *o.Q + } + if qQ != "" { + qs.Set("q", qQ) + } + + var sortQ string + if o.Sort != nil { + sortQ = *o.Sort + } + if sortQ != "" { + qs.Set("sort", sortQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ListAllRepositoriesURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ListAllRepositoriesURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ListAllRepositoriesURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ListAllRepositoriesURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ListAllRepositoriesURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ListAllRepositoriesURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/repository/list_repositories.go b/src/server/v2.0/restapi/operations/repository/list_repositories.go new file mode 100644 index 000000000..0c10f28ad --- /dev/null +++ b/src/server/v2.0/restapi/operations/repository/list_repositories.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package repository + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ListRepositoriesHandlerFunc turns a function with the right signature into a list repositories handler +type ListRepositoriesHandlerFunc func(ListRepositoriesParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ListRepositoriesHandlerFunc) Handle(params ListRepositoriesParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ListRepositoriesHandler interface for that can handle valid list repositories params +type ListRepositoriesHandler interface { + Handle(ListRepositoriesParams, interface{}) middleware.Responder +} + +// NewListRepositories creates a new http.Handler for the list repositories operation +func NewListRepositories(ctx *middleware.Context, handler ListRepositoriesHandler) *ListRepositories { + return &ListRepositories{Context: ctx, Handler: handler} +} + +/*ListRepositories swagger:route GET /projects/{project_name}/repositories repository listRepositories + +List repositories + +List repositories of the specified project + +*/ +type ListRepositories struct { + Context *middleware.Context + Handler ListRepositoriesHandler +} + +func (o *ListRepositories) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewListRepositoriesParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/repository/list_repositories_parameters.go b/src/server/v2.0/restapi/operations/repository/list_repositories_parameters.go new file mode 100644 index 000000000..ff9b825e1 --- /dev/null +++ b/src/server/v2.0/restapi/operations/repository/list_repositories_parameters.go @@ -0,0 +1,264 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package repository + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewListRepositoriesParams creates a new ListRepositoriesParams object +// with the default values initialized. +func NewListRepositoriesParams() ListRepositoriesParams { + + var ( + // initialize parameters with default values + + pageDefault = int64(1) + pageSizeDefault = int64(10) + ) + + return ListRepositoriesParams{ + Page: &pageDefault, + + PageSize: &pageSizeDefault, + } +} + +// ListRepositoriesParams contains all the bound params for the list repositories operation +// typically these are obtained from a http.Request +// +// swagger:parameters listRepositories +type ListRepositoriesParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The page number + In: query + Default: 1 + */ + Page *int64 + /*The size of per page + Maximum: 100 + In: query + Default: 10 + */ + PageSize *int64 + /*The name of the project + Required: true + In: path + */ + ProjectName string + /*Query string to query resources. Supported query patterns are "exact match(k=v)", "fuzzy match(k=~v)", "range(k=[min~max])", "list with union releationship(k={v1 v2 v3})" and "list with intersetion relationship(k=(v1 v2 v3))". The value of range and list can be string(enclosed by " or '), integer or time(in format "2020-04-09 02:36:00"). All of these query patterns should be put in the query string "q=xxx" and splitted by ",". e.g. q=k1=v1,k2=~v2,k3=[min~max] + In: query + */ + Q *string + /*Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + In: query + */ + Sort *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewListRepositoriesParams() beforehand. +func (o *ListRepositoriesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + qPage, qhkPage, _ := qs.GetOK("page") + if err := o.bindPage(qPage, qhkPage, route.Formats); err != nil { + res = append(res, err) + } + + qPageSize, qhkPageSize, _ := qs.GetOK("page_size") + if err := o.bindPageSize(qPageSize, qhkPageSize, route.Formats); err != nil { + res = append(res, err) + } + + rProjectName, rhkProjectName, _ := route.Params.GetOK("project_name") + if err := o.bindProjectName(rProjectName, rhkProjectName, route.Formats); err != nil { + res = append(res, err) + } + + qQ, qhkQ, _ := qs.GetOK("q") + if err := o.bindQ(qQ, qhkQ, route.Formats); err != nil { + res = append(res, err) + } + + qSort, qhkSort, _ := qs.GetOK("sort") + if err := o.bindSort(qSort, qhkSort, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *ListRepositoriesParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *ListRepositoriesParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindPage binds and validates parameter Page from query. +func (o *ListRepositoriesParams) bindPage(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListRepositoriesParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page", "query", "int64", raw) + } + o.Page = &value + + return nil +} + +// bindPageSize binds and validates parameter PageSize from query. +func (o *ListRepositoriesParams) bindPageSize(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListRepositoriesParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page_size", "query", "int64", raw) + } + o.PageSize = &value + + if err := o.validatePageSize(formats); err != nil { + return err + } + + return nil +} + +// validatePageSize carries on validations for parameter PageSize +func (o *ListRepositoriesParams) validatePageSize(formats strfmt.Registry) error { + + if err := validate.MaximumInt("page_size", "query", int64(*o.PageSize), 100, false); err != nil { + return err + } + + return nil +} + +// bindProjectName binds and validates parameter ProjectName from path. +func (o *ListRepositoriesParams) bindProjectName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectName = raw + + return nil +} + +// bindQ binds and validates parameter Q from query. +func (o *ListRepositoriesParams) bindQ(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Q = &raw + + return nil +} + +// bindSort binds and validates parameter Sort from query. +func (o *ListRepositoriesParams) bindSort(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Sort = &raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/repository/list_repositories_responses.go b/src/server/v2.0/restapi/operations/repository/list_repositories_responses.go new file mode 100644 index 000000000..627df5925 --- /dev/null +++ b/src/server/v2.0/restapi/operations/repository/list_repositories_responses.go @@ -0,0 +1,436 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package repository + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/swag" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// ListRepositoriesOKCode is the HTTP code returned for type ListRepositoriesOK +const ListRepositoriesOKCode int = 200 + +/*ListRepositoriesOK Success + +swagger:response listRepositoriesOK +*/ +type ListRepositoriesOK struct { + /*Link refers to the previous page and next page + + */ + Link string `json:"Link"` + /*The total count of repositories + + */ + XTotalCount int64 `json:"X-Total-Count"` + + /* + In: Body + */ + Payload []*models.Repository `json:"body,omitempty"` +} + +// NewListRepositoriesOK creates ListRepositoriesOK with default headers values +func NewListRepositoriesOK() *ListRepositoriesOK { + + return &ListRepositoriesOK{} +} + +// WithLink adds the link to the list repositories o k response +func (o *ListRepositoriesOK) WithLink(link string) *ListRepositoriesOK { + o.Link = link + return o +} + +// SetLink sets the link to the list repositories o k response +func (o *ListRepositoriesOK) SetLink(link string) { + o.Link = link +} + +// WithXTotalCount adds the xTotalCount to the list repositories o k response +func (o *ListRepositoriesOK) WithXTotalCount(xTotalCount int64) *ListRepositoriesOK { + o.XTotalCount = xTotalCount + return o +} + +// SetXTotalCount sets the xTotalCount to the list repositories o k response +func (o *ListRepositoriesOK) SetXTotalCount(xTotalCount int64) { + o.XTotalCount = xTotalCount +} + +// WithPayload adds the payload to the list repositories o k response +func (o *ListRepositoriesOK) WithPayload(payload []*models.Repository) *ListRepositoriesOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list repositories o k response +func (o *ListRepositoriesOK) SetPayload(payload []*models.Repository) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListRepositoriesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Link + + link := o.Link + if link != "" { + rw.Header().Set("Link", link) + } + + // response header X-Total-Count + + xTotalCount := swag.FormatInt64(o.XTotalCount) + if xTotalCount != "" { + rw.Header().Set("X-Total-Count", xTotalCount) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = make([]*models.Repository, 0, 50) + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ListRepositoriesBadRequestCode is the HTTP code returned for type ListRepositoriesBadRequest +const ListRepositoriesBadRequestCode int = 400 + +/*ListRepositoriesBadRequest Bad request + +swagger:response listRepositoriesBadRequest +*/ +type ListRepositoriesBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListRepositoriesBadRequest creates ListRepositoriesBadRequest with default headers values +func NewListRepositoriesBadRequest() *ListRepositoriesBadRequest { + + return &ListRepositoriesBadRequest{} +} + +// WithXRequestID adds the xRequestId to the list repositories bad request response +func (o *ListRepositoriesBadRequest) WithXRequestID(xRequestID string) *ListRepositoriesBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list repositories bad request response +func (o *ListRepositoriesBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list repositories bad request response +func (o *ListRepositoriesBadRequest) WithPayload(payload *models.Errors) *ListRepositoriesBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list repositories bad request response +func (o *ListRepositoriesBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListRepositoriesBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListRepositoriesUnauthorizedCode is the HTTP code returned for type ListRepositoriesUnauthorized +const ListRepositoriesUnauthorizedCode int = 401 + +/*ListRepositoriesUnauthorized Unauthorized + +swagger:response listRepositoriesUnauthorized +*/ +type ListRepositoriesUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListRepositoriesUnauthorized creates ListRepositoriesUnauthorized with default headers values +func NewListRepositoriesUnauthorized() *ListRepositoriesUnauthorized { + + return &ListRepositoriesUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the list repositories unauthorized response +func (o *ListRepositoriesUnauthorized) WithXRequestID(xRequestID string) *ListRepositoriesUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list repositories unauthorized response +func (o *ListRepositoriesUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list repositories unauthorized response +func (o *ListRepositoriesUnauthorized) WithPayload(payload *models.Errors) *ListRepositoriesUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list repositories unauthorized response +func (o *ListRepositoriesUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListRepositoriesUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListRepositoriesForbiddenCode is the HTTP code returned for type ListRepositoriesForbidden +const ListRepositoriesForbiddenCode int = 403 + +/*ListRepositoriesForbidden Forbidden + +swagger:response listRepositoriesForbidden +*/ +type ListRepositoriesForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListRepositoriesForbidden creates ListRepositoriesForbidden with default headers values +func NewListRepositoriesForbidden() *ListRepositoriesForbidden { + + return &ListRepositoriesForbidden{} +} + +// WithXRequestID adds the xRequestId to the list repositories forbidden response +func (o *ListRepositoriesForbidden) WithXRequestID(xRequestID string) *ListRepositoriesForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list repositories forbidden response +func (o *ListRepositoriesForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list repositories forbidden response +func (o *ListRepositoriesForbidden) WithPayload(payload *models.Errors) *ListRepositoriesForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list repositories forbidden response +func (o *ListRepositoriesForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListRepositoriesForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListRepositoriesNotFoundCode is the HTTP code returned for type ListRepositoriesNotFound +const ListRepositoriesNotFoundCode int = 404 + +/*ListRepositoriesNotFound Not found + +swagger:response listRepositoriesNotFound +*/ +type ListRepositoriesNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListRepositoriesNotFound creates ListRepositoriesNotFound with default headers values +func NewListRepositoriesNotFound() *ListRepositoriesNotFound { + + return &ListRepositoriesNotFound{} +} + +// WithXRequestID adds the xRequestId to the list repositories not found response +func (o *ListRepositoriesNotFound) WithXRequestID(xRequestID string) *ListRepositoriesNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list repositories not found response +func (o *ListRepositoriesNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list repositories not found response +func (o *ListRepositoriesNotFound) WithPayload(payload *models.Errors) *ListRepositoriesNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list repositories not found response +func (o *ListRepositoriesNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListRepositoriesNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListRepositoriesInternalServerErrorCode is the HTTP code returned for type ListRepositoriesInternalServerError +const ListRepositoriesInternalServerErrorCode int = 500 + +/*ListRepositoriesInternalServerError Internal server error + +swagger:response listRepositoriesInternalServerError +*/ +type ListRepositoriesInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListRepositoriesInternalServerError creates ListRepositoriesInternalServerError with default headers values +func NewListRepositoriesInternalServerError() *ListRepositoriesInternalServerError { + + return &ListRepositoriesInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the list repositories internal server error response +func (o *ListRepositoriesInternalServerError) WithXRequestID(xRequestID string) *ListRepositoriesInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list repositories internal server error response +func (o *ListRepositoriesInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list repositories internal server error response +func (o *ListRepositoriesInternalServerError) WithPayload(payload *models.Errors) *ListRepositoriesInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list repositories internal server error response +func (o *ListRepositoriesInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListRepositoriesInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/repository/list_repositories_urlbuilder.go b/src/server/v2.0/restapi/operations/repository/list_repositories_urlbuilder.go new file mode 100644 index 000000000..b3003fef9 --- /dev/null +++ b/src/server/v2.0/restapi/operations/repository/list_repositories_urlbuilder.go @@ -0,0 +1,142 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package repository + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ListRepositoriesURL generates an URL for the list repositories operation +type ListRepositoriesURL struct { + ProjectName string + + Page *int64 + PageSize *int64 + Q *string + Sort *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListRepositoriesURL) WithBasePath(bp string) *ListRepositoriesURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListRepositoriesURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ListRepositoriesURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name}/repositories" + + projectName := o.ProjectName + if projectName != "" { + _path = strings.Replace(_path, "{project_name}", projectName, -1) + } else { + return nil, errors.New("projectName is required on ListRepositoriesURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var pageQ string + if o.Page != nil { + pageQ = swag.FormatInt64(*o.Page) + } + if pageQ != "" { + qs.Set("page", pageQ) + } + + var pageSizeQ string + if o.PageSize != nil { + pageSizeQ = swag.FormatInt64(*o.PageSize) + } + if pageSizeQ != "" { + qs.Set("page_size", pageSizeQ) + } + + var qQ string + if o.Q != nil { + qQ = *o.Q + } + if qQ != "" { + qs.Set("q", qQ) + } + + var sortQ string + if o.Sort != nil { + sortQ = *o.Sort + } + if sortQ != "" { + qs.Set("sort", sortQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ListRepositoriesURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ListRepositoriesURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ListRepositoriesURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ListRepositoriesURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ListRepositoriesURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ListRepositoriesURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/repository/update_repository.go b/src/server/v2.0/restapi/operations/repository/update_repository.go new file mode 100644 index 000000000..19f377cac --- /dev/null +++ b/src/server/v2.0/restapi/operations/repository/update_repository.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package repository + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// UpdateRepositoryHandlerFunc turns a function with the right signature into a update repository handler +type UpdateRepositoryHandlerFunc func(UpdateRepositoryParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn UpdateRepositoryHandlerFunc) Handle(params UpdateRepositoryParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// UpdateRepositoryHandler interface for that can handle valid update repository params +type UpdateRepositoryHandler interface { + Handle(UpdateRepositoryParams, interface{}) middleware.Responder +} + +// NewUpdateRepository creates a new http.Handler for the update repository operation +func NewUpdateRepository(ctx *middleware.Context, handler UpdateRepositoryHandler) *UpdateRepository { + return &UpdateRepository{Context: ctx, Handler: handler} +} + +/*UpdateRepository swagger:route PUT /projects/{project_name}/repositories/{repository_name} repository updateRepository + +Update repository + +Update the repository specified by name + +*/ +type UpdateRepository struct { + Context *middleware.Context + Handler UpdateRepositoryHandler +} + +func (o *UpdateRepository) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewUpdateRepositoryParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/repository/update_repository_parameters.go b/src/server/v2.0/restapi/operations/repository/update_repository_parameters.go new file mode 100644 index 000000000..6e2acafba --- /dev/null +++ b/src/server/v2.0/restapi/operations/repository/update_repository_parameters.go @@ -0,0 +1,170 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package repository + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewUpdateRepositoryParams creates a new UpdateRepositoryParams object +// no default values defined in spec. +func NewUpdateRepositoryParams() UpdateRepositoryParams { + + return UpdateRepositoryParams{} +} + +// UpdateRepositoryParams contains all the bound params for the update repository operation +// typically these are obtained from a http.Request +// +// swagger:parameters updateRepository +type UpdateRepositoryParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The name of the project + Required: true + In: path + */ + ProjectName string + /*The JSON object of repository. + Required: true + In: body + */ + Repository *models.Repository + /*The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -> a%252Fb + Required: true + In: path + */ + RepositoryName string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewUpdateRepositoryParams() beforehand. +func (o *UpdateRepositoryParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rProjectName, rhkProjectName, _ := route.Params.GetOK("project_name") + if err := o.bindProjectName(rProjectName, rhkProjectName, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Repository + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("repository", "body", "")) + } else { + res = append(res, errors.NewParseError("repository", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Repository = &body + } + } + } else { + res = append(res, errors.Required("repository", "body", "")) + } + rRepositoryName, rhkRepositoryName, _ := route.Params.GetOK("repository_name") + if err := o.bindRepositoryName(rRepositoryName, rhkRepositoryName, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *UpdateRepositoryParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *UpdateRepositoryParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindProjectName binds and validates parameter ProjectName from path. +func (o *UpdateRepositoryParams) bindProjectName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectName = raw + + return nil +} + +// bindRepositoryName binds and validates parameter RepositoryName from path. +func (o *UpdateRepositoryParams) bindRepositoryName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.RepositoryName = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/repository/update_repository_responses.go b/src/server/v2.0/restapi/operations/repository/update_repository_responses.go new file mode 100644 index 000000000..d91ac3573 --- /dev/null +++ b/src/server/v2.0/restapi/operations/repository/update_repository_responses.go @@ -0,0 +1,390 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package repository + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// UpdateRepositoryOKCode is the HTTP code returned for type UpdateRepositoryOK +const UpdateRepositoryOKCode int = 200 + +/*UpdateRepositoryOK Success + +swagger:response updateRepositoryOK +*/ +type UpdateRepositoryOK struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewUpdateRepositoryOK creates UpdateRepositoryOK with default headers values +func NewUpdateRepositoryOK() *UpdateRepositoryOK { + + return &UpdateRepositoryOK{} +} + +// WithXRequestID adds the xRequestId to the update repository o k response +func (o *UpdateRepositoryOK) WithXRequestID(xRequestID string) *UpdateRepositoryOK { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update repository o k response +func (o *UpdateRepositoryOK) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *UpdateRepositoryOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// UpdateRepositoryBadRequestCode is the HTTP code returned for type UpdateRepositoryBadRequest +const UpdateRepositoryBadRequestCode int = 400 + +/*UpdateRepositoryBadRequest Bad request + +swagger:response updateRepositoryBadRequest +*/ +type UpdateRepositoryBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateRepositoryBadRequest creates UpdateRepositoryBadRequest with default headers values +func NewUpdateRepositoryBadRequest() *UpdateRepositoryBadRequest { + + return &UpdateRepositoryBadRequest{} +} + +// WithXRequestID adds the xRequestId to the update repository bad request response +func (o *UpdateRepositoryBadRequest) WithXRequestID(xRequestID string) *UpdateRepositoryBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update repository bad request response +func (o *UpdateRepositoryBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update repository bad request response +func (o *UpdateRepositoryBadRequest) WithPayload(payload *models.Errors) *UpdateRepositoryBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update repository bad request response +func (o *UpdateRepositoryBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateRepositoryBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateRepositoryUnauthorizedCode is the HTTP code returned for type UpdateRepositoryUnauthorized +const UpdateRepositoryUnauthorizedCode int = 401 + +/*UpdateRepositoryUnauthorized Unauthorized + +swagger:response updateRepositoryUnauthorized +*/ +type UpdateRepositoryUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateRepositoryUnauthorized creates UpdateRepositoryUnauthorized with default headers values +func NewUpdateRepositoryUnauthorized() *UpdateRepositoryUnauthorized { + + return &UpdateRepositoryUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the update repository unauthorized response +func (o *UpdateRepositoryUnauthorized) WithXRequestID(xRequestID string) *UpdateRepositoryUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update repository unauthorized response +func (o *UpdateRepositoryUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update repository unauthorized response +func (o *UpdateRepositoryUnauthorized) WithPayload(payload *models.Errors) *UpdateRepositoryUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update repository unauthorized response +func (o *UpdateRepositoryUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateRepositoryUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateRepositoryForbiddenCode is the HTTP code returned for type UpdateRepositoryForbidden +const UpdateRepositoryForbiddenCode int = 403 + +/*UpdateRepositoryForbidden Forbidden + +swagger:response updateRepositoryForbidden +*/ +type UpdateRepositoryForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateRepositoryForbidden creates UpdateRepositoryForbidden with default headers values +func NewUpdateRepositoryForbidden() *UpdateRepositoryForbidden { + + return &UpdateRepositoryForbidden{} +} + +// WithXRequestID adds the xRequestId to the update repository forbidden response +func (o *UpdateRepositoryForbidden) WithXRequestID(xRequestID string) *UpdateRepositoryForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update repository forbidden response +func (o *UpdateRepositoryForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update repository forbidden response +func (o *UpdateRepositoryForbidden) WithPayload(payload *models.Errors) *UpdateRepositoryForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update repository forbidden response +func (o *UpdateRepositoryForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateRepositoryForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateRepositoryNotFoundCode is the HTTP code returned for type UpdateRepositoryNotFound +const UpdateRepositoryNotFoundCode int = 404 + +/*UpdateRepositoryNotFound Not found + +swagger:response updateRepositoryNotFound +*/ +type UpdateRepositoryNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateRepositoryNotFound creates UpdateRepositoryNotFound with default headers values +func NewUpdateRepositoryNotFound() *UpdateRepositoryNotFound { + + return &UpdateRepositoryNotFound{} +} + +// WithXRequestID adds the xRequestId to the update repository not found response +func (o *UpdateRepositoryNotFound) WithXRequestID(xRequestID string) *UpdateRepositoryNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update repository not found response +func (o *UpdateRepositoryNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update repository not found response +func (o *UpdateRepositoryNotFound) WithPayload(payload *models.Errors) *UpdateRepositoryNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update repository not found response +func (o *UpdateRepositoryNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateRepositoryNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateRepositoryInternalServerErrorCode is the HTTP code returned for type UpdateRepositoryInternalServerError +const UpdateRepositoryInternalServerErrorCode int = 500 + +/*UpdateRepositoryInternalServerError Internal server error + +swagger:response updateRepositoryInternalServerError +*/ +type UpdateRepositoryInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateRepositoryInternalServerError creates UpdateRepositoryInternalServerError with default headers values +func NewUpdateRepositoryInternalServerError() *UpdateRepositoryInternalServerError { + + return &UpdateRepositoryInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the update repository internal server error response +func (o *UpdateRepositoryInternalServerError) WithXRequestID(xRequestID string) *UpdateRepositoryInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update repository internal server error response +func (o *UpdateRepositoryInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update repository internal server error response +func (o *UpdateRepositoryInternalServerError) WithPayload(payload *models.Errors) *UpdateRepositoryInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update repository internal server error response +func (o *UpdateRepositoryInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateRepositoryInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/repository/update_repository_urlbuilder.go b/src/server/v2.0/restapi/operations/repository/update_repository_urlbuilder.go new file mode 100644 index 000000000..5cbb2235e --- /dev/null +++ b/src/server/v2.0/restapi/operations/repository/update_repository_urlbuilder.go @@ -0,0 +1,107 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package repository + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// UpdateRepositoryURL generates an URL for the update repository operation +type UpdateRepositoryURL struct { + ProjectName string + RepositoryName string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdateRepositoryURL) WithBasePath(bp string) *UpdateRepositoryURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdateRepositoryURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *UpdateRepositoryURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name}/repositories/{repository_name}" + + projectName := o.ProjectName + if projectName != "" { + _path = strings.Replace(_path, "{project_name}", projectName, -1) + } else { + return nil, errors.New("projectName is required on UpdateRepositoryURL") + } + + repositoryName := o.RepositoryName + if repositoryName != "" { + _path = strings.Replace(_path, "{repository_name}", repositoryName, -1) + } else { + return nil, errors.New("repositoryName is required on UpdateRepositoryURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *UpdateRepositoryURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *UpdateRepositoryURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *UpdateRepositoryURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on UpdateRepositoryURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on UpdateRepositoryURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *UpdateRepositoryURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/retention/create_retention.go b/src/server/v2.0/restapi/operations/retention/create_retention.go new file mode 100644 index 000000000..c786010c0 --- /dev/null +++ b/src/server/v2.0/restapi/operations/retention/create_retention.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package retention + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateRetentionHandlerFunc turns a function with the right signature into a create retention handler +type CreateRetentionHandlerFunc func(CreateRetentionParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateRetentionHandlerFunc) Handle(params CreateRetentionParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateRetentionHandler interface for that can handle valid create retention params +type CreateRetentionHandler interface { + Handle(CreateRetentionParams, interface{}) middleware.Responder +} + +// NewCreateRetention creates a new http.Handler for the create retention operation +func NewCreateRetention(ctx *middleware.Context, handler CreateRetentionHandler) *CreateRetention { + return &CreateRetention{Context: ctx, Handler: handler} +} + +/*CreateRetention swagger:route POST /retentions Retention createRetention + +Create Retention Policy + +Create Retention Policy, you can reference metadatas API for the policy model. You can check project metadatas to find whether a retention policy is already binded. This method should only be called when no retention policy binded to project yet. + +*/ +type CreateRetention struct { + Context *middleware.Context + Handler CreateRetentionHandler +} + +func (o *CreateRetention) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewCreateRetentionParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/retention/create_retention_parameters.go b/src/server/v2.0/restapi/operations/retention/create_retention_parameters.go new file mode 100644 index 000000000..ee23d6d9f --- /dev/null +++ b/src/server/v2.0/restapi/operations/retention/create_retention_parameters.go @@ -0,0 +1,120 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package retention + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewCreateRetentionParams creates a new CreateRetentionParams object +// no default values defined in spec. +func NewCreateRetentionParams() CreateRetentionParams { + + return CreateRetentionParams{} +} + +// CreateRetentionParams contains all the bound params for the create retention operation +// typically these are obtained from a http.Request +// +// swagger:parameters createRetention +type CreateRetentionParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*Create Retention Policy successfully. + Required: true + In: body + */ + Policy *models.RetentionPolicy +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateRetentionParams() beforehand. +func (o *CreateRetentionParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.RetentionPolicy + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("policy", "body", "")) + } else { + res = append(res, errors.NewParseError("policy", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Policy = &body + } + } + } else { + res = append(res, errors.Required("policy", "body", "")) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *CreateRetentionParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *CreateRetentionParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} diff --git a/src/server/v2.0/restapi/operations/retention/create_retention_responses.go b/src/server/v2.0/restapi/operations/retention/create_retention_responses.go new file mode 100644 index 000000000..9c105edc4 --- /dev/null +++ b/src/server/v2.0/restapi/operations/retention/create_retention_responses.go @@ -0,0 +1,346 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package retention + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// CreateRetentionCreatedCode is the HTTP code returned for type CreateRetentionCreated +const CreateRetentionCreatedCode int = 201 + +/*CreateRetentionCreated Created + +swagger:response createRetentionCreated +*/ +type CreateRetentionCreated struct { + /*The location of the resource + + */ + Location string `json:"Location"` + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewCreateRetentionCreated creates CreateRetentionCreated with default headers values +func NewCreateRetentionCreated() *CreateRetentionCreated { + + return &CreateRetentionCreated{} +} + +// WithLocation adds the location to the create retention created response +func (o *CreateRetentionCreated) WithLocation(location string) *CreateRetentionCreated { + o.Location = location + return o +} + +// SetLocation sets the location to the create retention created response +func (o *CreateRetentionCreated) SetLocation(location string) { + o.Location = location +} + +// WithXRequestID adds the xRequestId to the create retention created response +func (o *CreateRetentionCreated) WithXRequestID(xRequestID string) *CreateRetentionCreated { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create retention created response +func (o *CreateRetentionCreated) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *CreateRetentionCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Location + + location := o.Location + if location != "" { + rw.Header().Set("Location", location) + } + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(201) +} + +// CreateRetentionBadRequestCode is the HTTP code returned for type CreateRetentionBadRequest +const CreateRetentionBadRequestCode int = 400 + +/*CreateRetentionBadRequest Bad request + +swagger:response createRetentionBadRequest +*/ +type CreateRetentionBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateRetentionBadRequest creates CreateRetentionBadRequest with default headers values +func NewCreateRetentionBadRequest() *CreateRetentionBadRequest { + + return &CreateRetentionBadRequest{} +} + +// WithXRequestID adds the xRequestId to the create retention bad request response +func (o *CreateRetentionBadRequest) WithXRequestID(xRequestID string) *CreateRetentionBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create retention bad request response +func (o *CreateRetentionBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create retention bad request response +func (o *CreateRetentionBadRequest) WithPayload(payload *models.Errors) *CreateRetentionBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create retention bad request response +func (o *CreateRetentionBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateRetentionBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateRetentionUnauthorizedCode is the HTTP code returned for type CreateRetentionUnauthorized +const CreateRetentionUnauthorizedCode int = 401 + +/*CreateRetentionUnauthorized Unauthorized + +swagger:response createRetentionUnauthorized +*/ +type CreateRetentionUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateRetentionUnauthorized creates CreateRetentionUnauthorized with default headers values +func NewCreateRetentionUnauthorized() *CreateRetentionUnauthorized { + + return &CreateRetentionUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the create retention unauthorized response +func (o *CreateRetentionUnauthorized) WithXRequestID(xRequestID string) *CreateRetentionUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create retention unauthorized response +func (o *CreateRetentionUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create retention unauthorized response +func (o *CreateRetentionUnauthorized) WithPayload(payload *models.Errors) *CreateRetentionUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create retention unauthorized response +func (o *CreateRetentionUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateRetentionUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateRetentionForbiddenCode is the HTTP code returned for type CreateRetentionForbidden +const CreateRetentionForbiddenCode int = 403 + +/*CreateRetentionForbidden Forbidden + +swagger:response createRetentionForbidden +*/ +type CreateRetentionForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateRetentionForbidden creates CreateRetentionForbidden with default headers values +func NewCreateRetentionForbidden() *CreateRetentionForbidden { + + return &CreateRetentionForbidden{} +} + +// WithXRequestID adds the xRequestId to the create retention forbidden response +func (o *CreateRetentionForbidden) WithXRequestID(xRequestID string) *CreateRetentionForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create retention forbidden response +func (o *CreateRetentionForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create retention forbidden response +func (o *CreateRetentionForbidden) WithPayload(payload *models.Errors) *CreateRetentionForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create retention forbidden response +func (o *CreateRetentionForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateRetentionForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateRetentionInternalServerErrorCode is the HTTP code returned for type CreateRetentionInternalServerError +const CreateRetentionInternalServerErrorCode int = 500 + +/*CreateRetentionInternalServerError Internal server error + +swagger:response createRetentionInternalServerError +*/ +type CreateRetentionInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateRetentionInternalServerError creates CreateRetentionInternalServerError with default headers values +func NewCreateRetentionInternalServerError() *CreateRetentionInternalServerError { + + return &CreateRetentionInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the create retention internal server error response +func (o *CreateRetentionInternalServerError) WithXRequestID(xRequestID string) *CreateRetentionInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create retention internal server error response +func (o *CreateRetentionInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create retention internal server error response +func (o *CreateRetentionInternalServerError) WithPayload(payload *models.Errors) *CreateRetentionInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create retention internal server error response +func (o *CreateRetentionInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateRetentionInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/retention/create_retention_urlbuilder.go b/src/server/v2.0/restapi/operations/retention/create_retention_urlbuilder.go new file mode 100644 index 000000000..abd3a02de --- /dev/null +++ b/src/server/v2.0/restapi/operations/retention/create_retention_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package retention + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// CreateRetentionURL generates an URL for the create retention operation +type CreateRetentionURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateRetentionURL) WithBasePath(bp string) *CreateRetentionURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateRetentionURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateRetentionURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/retentions" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateRetentionURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateRetentionURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateRetentionURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateRetentionURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateRetentionURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateRetentionURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/retention/delete_retention.go b/src/server/v2.0/restapi/operations/retention/delete_retention.go new file mode 100644 index 000000000..6452e5c07 --- /dev/null +++ b/src/server/v2.0/restapi/operations/retention/delete_retention.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package retention + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteRetentionHandlerFunc turns a function with the right signature into a delete retention handler +type DeleteRetentionHandlerFunc func(DeleteRetentionParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteRetentionHandlerFunc) Handle(params DeleteRetentionParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteRetentionHandler interface for that can handle valid delete retention params +type DeleteRetentionHandler interface { + Handle(DeleteRetentionParams, interface{}) middleware.Responder +} + +// NewDeleteRetention creates a new http.Handler for the delete retention operation +func NewDeleteRetention(ctx *middleware.Context, handler DeleteRetentionHandler) *DeleteRetention { + return &DeleteRetention{Context: ctx, Handler: handler} +} + +/*DeleteRetention swagger:route DELETE /retentions/{id} Retention deleteRetention + +Delete Retention Policy + +Delete Retention Policy, you can reference metadatas API for the policy model. You can check project metadatas to find whether a retention policy is already binded. This method should only be called when retention policy has already binded to project. + +*/ +type DeleteRetention struct { + Context *middleware.Context + Handler DeleteRetentionHandler +} + +func (o *DeleteRetention) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewDeleteRetentionParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/retention/delete_retention_parameters.go b/src/server/v2.0/restapi/operations/retention/delete_retention_parameters.go new file mode 100644 index 000000000..06b77cd33 --- /dev/null +++ b/src/server/v2.0/restapi/operations/retention/delete_retention_parameters.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package retention + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewDeleteRetentionParams creates a new DeleteRetentionParams object +// no default values defined in spec. +func NewDeleteRetentionParams() DeleteRetentionParams { + + return DeleteRetentionParams{} +} + +// DeleteRetentionParams contains all the bound params for the delete retention operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteRetention +type DeleteRetentionParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*Retention ID. + Required: true + In: path + */ + ID int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteRetentionParams() beforehand. +func (o *DeleteRetentionParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *DeleteRetentionParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *DeleteRetentionParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *DeleteRetentionParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("id", "path", "int64", raw) + } + o.ID = value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/retention/delete_retention_responses.go b/src/server/v2.0/restapi/operations/retention/delete_retention_responses.go new file mode 100644 index 000000000..9b356900c --- /dev/null +++ b/src/server/v2.0/restapi/operations/retention/delete_retention_responses.go @@ -0,0 +1,236 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package retention + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// DeleteRetentionOKCode is the HTTP code returned for type DeleteRetentionOK +const DeleteRetentionOKCode int = 200 + +/*DeleteRetentionOK Update Retention Policy successfully. + +swagger:response deleteRetentionOK +*/ +type DeleteRetentionOK struct { +} + +// NewDeleteRetentionOK creates DeleteRetentionOK with default headers values +func NewDeleteRetentionOK() *DeleteRetentionOK { + + return &DeleteRetentionOK{} +} + +// WriteResponse to the client +func (o *DeleteRetentionOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// DeleteRetentionUnauthorizedCode is the HTTP code returned for type DeleteRetentionUnauthorized +const DeleteRetentionUnauthorizedCode int = 401 + +/*DeleteRetentionUnauthorized Unauthorized + +swagger:response deleteRetentionUnauthorized +*/ +type DeleteRetentionUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteRetentionUnauthorized creates DeleteRetentionUnauthorized with default headers values +func NewDeleteRetentionUnauthorized() *DeleteRetentionUnauthorized { + + return &DeleteRetentionUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the delete retention unauthorized response +func (o *DeleteRetentionUnauthorized) WithXRequestID(xRequestID string) *DeleteRetentionUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete retention unauthorized response +func (o *DeleteRetentionUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete retention unauthorized response +func (o *DeleteRetentionUnauthorized) WithPayload(payload *models.Errors) *DeleteRetentionUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete retention unauthorized response +func (o *DeleteRetentionUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteRetentionUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteRetentionForbiddenCode is the HTTP code returned for type DeleteRetentionForbidden +const DeleteRetentionForbiddenCode int = 403 + +/*DeleteRetentionForbidden Forbidden + +swagger:response deleteRetentionForbidden +*/ +type DeleteRetentionForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteRetentionForbidden creates DeleteRetentionForbidden with default headers values +func NewDeleteRetentionForbidden() *DeleteRetentionForbidden { + + return &DeleteRetentionForbidden{} +} + +// WithXRequestID adds the xRequestId to the delete retention forbidden response +func (o *DeleteRetentionForbidden) WithXRequestID(xRequestID string) *DeleteRetentionForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete retention forbidden response +func (o *DeleteRetentionForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete retention forbidden response +func (o *DeleteRetentionForbidden) WithPayload(payload *models.Errors) *DeleteRetentionForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete retention forbidden response +func (o *DeleteRetentionForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteRetentionForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteRetentionInternalServerErrorCode is the HTTP code returned for type DeleteRetentionInternalServerError +const DeleteRetentionInternalServerErrorCode int = 500 + +/*DeleteRetentionInternalServerError Internal server error + +swagger:response deleteRetentionInternalServerError +*/ +type DeleteRetentionInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteRetentionInternalServerError creates DeleteRetentionInternalServerError with default headers values +func NewDeleteRetentionInternalServerError() *DeleteRetentionInternalServerError { + + return &DeleteRetentionInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the delete retention internal server error response +func (o *DeleteRetentionInternalServerError) WithXRequestID(xRequestID string) *DeleteRetentionInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete retention internal server error response +func (o *DeleteRetentionInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete retention internal server error response +func (o *DeleteRetentionInternalServerError) WithPayload(payload *models.Errors) *DeleteRetentionInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete retention internal server error response +func (o *DeleteRetentionInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteRetentionInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/retention/delete_retention_urlbuilder.go b/src/server/v2.0/restapi/operations/retention/delete_retention_urlbuilder.go new file mode 100644 index 000000000..85b5f04e8 --- /dev/null +++ b/src/server/v2.0/restapi/operations/retention/delete_retention_urlbuilder.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package retention + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteRetentionURL generates an URL for the delete retention operation +type DeleteRetentionURL struct { + ID int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteRetentionURL) WithBasePath(bp string) *DeleteRetentionURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteRetentionURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteRetentionURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/retentions/{id}" + + id := swag.FormatInt64(o.ID) + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on DeleteRetentionURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteRetentionURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteRetentionURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteRetentionURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteRetentionURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteRetentionURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteRetentionURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/retention/get_rentenition_metadata.go b/src/server/v2.0/restapi/operations/retention/get_rentenition_metadata.go new file mode 100644 index 000000000..129508c0f --- /dev/null +++ b/src/server/v2.0/restapi/operations/retention/get_rentenition_metadata.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package retention + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetRentenitionMetadataHandlerFunc turns a function with the right signature into a get rentenition metadata handler +type GetRentenitionMetadataHandlerFunc func(GetRentenitionMetadataParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetRentenitionMetadataHandlerFunc) Handle(params GetRentenitionMetadataParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetRentenitionMetadataHandler interface for that can handle valid get rentenition metadata params +type GetRentenitionMetadataHandler interface { + Handle(GetRentenitionMetadataParams, interface{}) middleware.Responder +} + +// NewGetRentenitionMetadata creates a new http.Handler for the get rentenition metadata operation +func NewGetRentenitionMetadata(ctx *middleware.Context, handler GetRentenitionMetadataHandler) *GetRentenitionMetadata { + return &GetRentenitionMetadata{Context: ctx, Handler: handler} +} + +/*GetRentenitionMetadata swagger:route GET /retentions/metadatas Retention getRentenitionMetadata + +Get Retention Metadatas + +Get Retention Metadatas. + +*/ +type GetRentenitionMetadata struct { + Context *middleware.Context + Handler GetRentenitionMetadataHandler +} + +func (o *GetRentenitionMetadata) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetRentenitionMetadataParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/retention/get_rentenition_metadata_parameters.go b/src/server/v2.0/restapi/operations/retention/get_rentenition_metadata_parameters.go new file mode 100644 index 000000000..5eff87720 --- /dev/null +++ b/src/server/v2.0/restapi/operations/retention/get_rentenition_metadata_parameters.go @@ -0,0 +1,89 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package retention + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewGetRentenitionMetadataParams creates a new GetRentenitionMetadataParams object +// no default values defined in spec. +func NewGetRentenitionMetadataParams() GetRentenitionMetadataParams { + + return GetRentenitionMetadataParams{} +} + +// GetRentenitionMetadataParams contains all the bound params for the get rentenition metadata operation +// typically these are obtained from a http.Request +// +// swagger:parameters getRentenitionMetadata +type GetRentenitionMetadataParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetRentenitionMetadataParams() beforehand. +func (o *GetRentenitionMetadataParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetRentenitionMetadataParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetRentenitionMetadataParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} diff --git a/src/server/v2.0/restapi/operations/retention/get_rentenition_metadata_responses.go b/src/server/v2.0/restapi/operations/retention/get_rentenition_metadata_responses.go new file mode 100644 index 000000000..e7b9fd94b --- /dev/null +++ b/src/server/v2.0/restapi/operations/retention/get_rentenition_metadata_responses.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package retention + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetRentenitionMetadataOKCode is the HTTP code returned for type GetRentenitionMetadataOK +const GetRentenitionMetadataOKCode int = 200 + +/*GetRentenitionMetadataOK Get Retention Metadatas successfully. + +swagger:response getRentenitionMetadataOK +*/ +type GetRentenitionMetadataOK struct { + + /* + In: Body + */ + Payload *models.RetentionMetadata `json:"body,omitempty"` +} + +// NewGetRentenitionMetadataOK creates GetRentenitionMetadataOK with default headers values +func NewGetRentenitionMetadataOK() *GetRentenitionMetadataOK { + + return &GetRentenitionMetadataOK{} +} + +// WithPayload adds the payload to the get rentenition metadata o k response +func (o *GetRentenitionMetadataOK) WithPayload(payload *models.RetentionMetadata) *GetRentenitionMetadataOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get rentenition metadata o k response +func (o *GetRentenitionMetadataOK) SetPayload(payload *models.RetentionMetadata) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetRentenitionMetadataOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/retention/get_rentenition_metadata_urlbuilder.go b/src/server/v2.0/restapi/operations/retention/get_rentenition_metadata_urlbuilder.go new file mode 100644 index 000000000..31887f9ae --- /dev/null +++ b/src/server/v2.0/restapi/operations/retention/get_rentenition_metadata_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package retention + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetRentenitionMetadataURL generates an URL for the get rentenition metadata operation +type GetRentenitionMetadataURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetRentenitionMetadataURL) WithBasePath(bp string) *GetRentenitionMetadataURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetRentenitionMetadataURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetRentenitionMetadataURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/retentions/metadatas" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetRentenitionMetadataURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetRentenitionMetadataURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetRentenitionMetadataURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetRentenitionMetadataURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetRentenitionMetadataURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetRentenitionMetadataURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/retention/get_retention.go b/src/server/v2.0/restapi/operations/retention/get_retention.go new file mode 100644 index 000000000..4364bd26f --- /dev/null +++ b/src/server/v2.0/restapi/operations/retention/get_retention.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package retention + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetRetentionHandlerFunc turns a function with the right signature into a get retention handler +type GetRetentionHandlerFunc func(GetRetentionParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetRetentionHandlerFunc) Handle(params GetRetentionParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetRetentionHandler interface for that can handle valid get retention params +type GetRetentionHandler interface { + Handle(GetRetentionParams, interface{}) middleware.Responder +} + +// NewGetRetention creates a new http.Handler for the get retention operation +func NewGetRetention(ctx *middleware.Context, handler GetRetentionHandler) *GetRetention { + return &GetRetention{Context: ctx, Handler: handler} +} + +/*GetRetention swagger:route GET /retentions/{id} Retention getRetention + +Get Retention Policy + +Get Retention Policy. + +*/ +type GetRetention struct { + Context *middleware.Context + Handler GetRetentionHandler +} + +func (o *GetRetention) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetRetentionParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/retention/get_retention_parameters.go b/src/server/v2.0/restapi/operations/retention/get_retention_parameters.go new file mode 100644 index 000000000..e5316e0e4 --- /dev/null +++ b/src/server/v2.0/restapi/operations/retention/get_retention_parameters.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package retention + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewGetRetentionParams creates a new GetRetentionParams object +// no default values defined in spec. +func NewGetRetentionParams() GetRetentionParams { + + return GetRetentionParams{} +} + +// GetRetentionParams contains all the bound params for the get retention operation +// typically these are obtained from a http.Request +// +// swagger:parameters getRetention +type GetRetentionParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*Retention ID. + Required: true + In: path + */ + ID int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetRetentionParams() beforehand. +func (o *GetRetentionParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetRetentionParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetRetentionParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *GetRetentionParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("id", "path", "int64", raw) + } + o.ID = value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/retention/get_retention_responses.go b/src/server/v2.0/restapi/operations/retention/get_retention_responses.go new file mode 100644 index 000000000..2b59c74d8 --- /dev/null +++ b/src/server/v2.0/restapi/operations/retention/get_retention_responses.go @@ -0,0 +1,256 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package retention + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetRetentionOKCode is the HTTP code returned for type GetRetentionOK +const GetRetentionOKCode int = 200 + +/*GetRetentionOK Get Retention Policy successfully. + +swagger:response getRetentionOK +*/ +type GetRetentionOK struct { + + /* + In: Body + */ + Payload *models.RetentionPolicy `json:"body,omitempty"` +} + +// NewGetRetentionOK creates GetRetentionOK with default headers values +func NewGetRetentionOK() *GetRetentionOK { + + return &GetRetentionOK{} +} + +// WithPayload adds the payload to the get retention o k response +func (o *GetRetentionOK) WithPayload(payload *models.RetentionPolicy) *GetRetentionOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get retention o k response +func (o *GetRetentionOK) SetPayload(payload *models.RetentionPolicy) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetRetentionOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetRetentionUnauthorizedCode is the HTTP code returned for type GetRetentionUnauthorized +const GetRetentionUnauthorizedCode int = 401 + +/*GetRetentionUnauthorized Unauthorized + +swagger:response getRetentionUnauthorized +*/ +type GetRetentionUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetRetentionUnauthorized creates GetRetentionUnauthorized with default headers values +func NewGetRetentionUnauthorized() *GetRetentionUnauthorized { + + return &GetRetentionUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the get retention unauthorized response +func (o *GetRetentionUnauthorized) WithXRequestID(xRequestID string) *GetRetentionUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get retention unauthorized response +func (o *GetRetentionUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get retention unauthorized response +func (o *GetRetentionUnauthorized) WithPayload(payload *models.Errors) *GetRetentionUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get retention unauthorized response +func (o *GetRetentionUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetRetentionUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetRetentionForbiddenCode is the HTTP code returned for type GetRetentionForbidden +const GetRetentionForbiddenCode int = 403 + +/*GetRetentionForbidden Forbidden + +swagger:response getRetentionForbidden +*/ +type GetRetentionForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetRetentionForbidden creates GetRetentionForbidden with default headers values +func NewGetRetentionForbidden() *GetRetentionForbidden { + + return &GetRetentionForbidden{} +} + +// WithXRequestID adds the xRequestId to the get retention forbidden response +func (o *GetRetentionForbidden) WithXRequestID(xRequestID string) *GetRetentionForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get retention forbidden response +func (o *GetRetentionForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get retention forbidden response +func (o *GetRetentionForbidden) WithPayload(payload *models.Errors) *GetRetentionForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get retention forbidden response +func (o *GetRetentionForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetRetentionForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetRetentionInternalServerErrorCode is the HTTP code returned for type GetRetentionInternalServerError +const GetRetentionInternalServerErrorCode int = 500 + +/*GetRetentionInternalServerError Internal server error + +swagger:response getRetentionInternalServerError +*/ +type GetRetentionInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetRetentionInternalServerError creates GetRetentionInternalServerError with default headers values +func NewGetRetentionInternalServerError() *GetRetentionInternalServerError { + + return &GetRetentionInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get retention internal server error response +func (o *GetRetentionInternalServerError) WithXRequestID(xRequestID string) *GetRetentionInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get retention internal server error response +func (o *GetRetentionInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get retention internal server error response +func (o *GetRetentionInternalServerError) WithPayload(payload *models.Errors) *GetRetentionInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get retention internal server error response +func (o *GetRetentionInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetRetentionInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/retention/get_retention_task_log.go b/src/server/v2.0/restapi/operations/retention/get_retention_task_log.go new file mode 100644 index 000000000..0ee86b19e --- /dev/null +++ b/src/server/v2.0/restapi/operations/retention/get_retention_task_log.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package retention + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetRetentionTaskLogHandlerFunc turns a function with the right signature into a get retention task log handler +type GetRetentionTaskLogHandlerFunc func(GetRetentionTaskLogParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetRetentionTaskLogHandlerFunc) Handle(params GetRetentionTaskLogParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetRetentionTaskLogHandler interface for that can handle valid get retention task log params +type GetRetentionTaskLogHandler interface { + Handle(GetRetentionTaskLogParams, interface{}) middleware.Responder +} + +// NewGetRetentionTaskLog creates a new http.Handler for the get retention task log operation +func NewGetRetentionTaskLog(ctx *middleware.Context, handler GetRetentionTaskLogHandler) *GetRetentionTaskLog { + return &GetRetentionTaskLog{Context: ctx, Handler: handler} +} + +/*GetRetentionTaskLog swagger:route GET /retentions/{id}/executions/{eid}/tasks/{tid} Retention getRetentionTaskLog + +Get Retention job task log + +Get Retention job task log, tags ratain or deletion detail will be shown in a table. + +*/ +type GetRetentionTaskLog struct { + Context *middleware.Context + Handler GetRetentionTaskLogHandler +} + +func (o *GetRetentionTaskLog) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetRetentionTaskLogParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/retention/get_retention_task_log_parameters.go b/src/server/v2.0/restapi/operations/retention/get_retention_task_log_parameters.go new file mode 100644 index 000000000..52708c1a9 --- /dev/null +++ b/src/server/v2.0/restapi/operations/retention/get_retention_task_log_parameters.go @@ -0,0 +1,177 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package retention + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewGetRetentionTaskLogParams creates a new GetRetentionTaskLogParams object +// no default values defined in spec. +func NewGetRetentionTaskLogParams() GetRetentionTaskLogParams { + + return GetRetentionTaskLogParams{} +} + +// GetRetentionTaskLogParams contains all the bound params for the get retention task log operation +// typically these are obtained from a http.Request +// +// swagger:parameters getRetentionTaskLog +type GetRetentionTaskLogParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*Retention execution ID. + Required: true + In: path + */ + Eid int64 + /*Retention ID. + Required: true + In: path + */ + ID int64 + /*Retention execution ID. + Required: true + In: path + */ + Tid int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetRetentionTaskLogParams() beforehand. +func (o *GetRetentionTaskLogParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rEid, rhkEid, _ := route.Params.GetOK("eid") + if err := o.bindEid(rEid, rhkEid, route.Formats); err != nil { + res = append(res, err) + } + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + + rTid, rhkTid, _ := route.Params.GetOK("tid") + if err := o.bindTid(rTid, rhkTid, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetRetentionTaskLogParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetRetentionTaskLogParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindEid binds and validates parameter Eid from path. +func (o *GetRetentionTaskLogParams) bindEid(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("eid", "path", "int64", raw) + } + o.Eid = value + + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *GetRetentionTaskLogParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("id", "path", "int64", raw) + } + o.ID = value + + return nil +} + +// bindTid binds and validates parameter Tid from path. +func (o *GetRetentionTaskLogParams) bindTid(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("tid", "path", "int64", raw) + } + o.Tid = value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/retention/get_retention_task_log_responses.go b/src/server/v2.0/restapi/operations/retention/get_retention_task_log_responses.go new file mode 100644 index 000000000..3696f0f93 --- /dev/null +++ b/src/server/v2.0/restapi/operations/retention/get_retention_task_log_responses.go @@ -0,0 +1,254 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package retention + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetRetentionTaskLogOKCode is the HTTP code returned for type GetRetentionTaskLogOK +const GetRetentionTaskLogOKCode int = 200 + +/*GetRetentionTaskLogOK Get Retention job task log successfully. + +swagger:response getRetentionTaskLogOK +*/ +type GetRetentionTaskLogOK struct { + + /* + In: Body + */ + Payload string `json:"body,omitempty"` +} + +// NewGetRetentionTaskLogOK creates GetRetentionTaskLogOK with default headers values +func NewGetRetentionTaskLogOK() *GetRetentionTaskLogOK { + + return &GetRetentionTaskLogOK{} +} + +// WithPayload adds the payload to the get retention task log o k response +func (o *GetRetentionTaskLogOK) WithPayload(payload string) *GetRetentionTaskLogOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get retention task log o k response +func (o *GetRetentionTaskLogOK) SetPayload(payload string) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetRetentionTaskLogOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// GetRetentionTaskLogUnauthorizedCode is the HTTP code returned for type GetRetentionTaskLogUnauthorized +const GetRetentionTaskLogUnauthorizedCode int = 401 + +/*GetRetentionTaskLogUnauthorized Unauthorized + +swagger:response getRetentionTaskLogUnauthorized +*/ +type GetRetentionTaskLogUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetRetentionTaskLogUnauthorized creates GetRetentionTaskLogUnauthorized with default headers values +func NewGetRetentionTaskLogUnauthorized() *GetRetentionTaskLogUnauthorized { + + return &GetRetentionTaskLogUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the get retention task log unauthorized response +func (o *GetRetentionTaskLogUnauthorized) WithXRequestID(xRequestID string) *GetRetentionTaskLogUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get retention task log unauthorized response +func (o *GetRetentionTaskLogUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get retention task log unauthorized response +func (o *GetRetentionTaskLogUnauthorized) WithPayload(payload *models.Errors) *GetRetentionTaskLogUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get retention task log unauthorized response +func (o *GetRetentionTaskLogUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetRetentionTaskLogUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetRetentionTaskLogForbiddenCode is the HTTP code returned for type GetRetentionTaskLogForbidden +const GetRetentionTaskLogForbiddenCode int = 403 + +/*GetRetentionTaskLogForbidden Forbidden + +swagger:response getRetentionTaskLogForbidden +*/ +type GetRetentionTaskLogForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetRetentionTaskLogForbidden creates GetRetentionTaskLogForbidden with default headers values +func NewGetRetentionTaskLogForbidden() *GetRetentionTaskLogForbidden { + + return &GetRetentionTaskLogForbidden{} +} + +// WithXRequestID adds the xRequestId to the get retention task log forbidden response +func (o *GetRetentionTaskLogForbidden) WithXRequestID(xRequestID string) *GetRetentionTaskLogForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get retention task log forbidden response +func (o *GetRetentionTaskLogForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get retention task log forbidden response +func (o *GetRetentionTaskLogForbidden) WithPayload(payload *models.Errors) *GetRetentionTaskLogForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get retention task log forbidden response +func (o *GetRetentionTaskLogForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetRetentionTaskLogForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetRetentionTaskLogInternalServerErrorCode is the HTTP code returned for type GetRetentionTaskLogInternalServerError +const GetRetentionTaskLogInternalServerErrorCode int = 500 + +/*GetRetentionTaskLogInternalServerError Internal server error + +swagger:response getRetentionTaskLogInternalServerError +*/ +type GetRetentionTaskLogInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetRetentionTaskLogInternalServerError creates GetRetentionTaskLogInternalServerError with default headers values +func NewGetRetentionTaskLogInternalServerError() *GetRetentionTaskLogInternalServerError { + + return &GetRetentionTaskLogInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get retention task log internal server error response +func (o *GetRetentionTaskLogInternalServerError) WithXRequestID(xRequestID string) *GetRetentionTaskLogInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get retention task log internal server error response +func (o *GetRetentionTaskLogInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get retention task log internal server error response +func (o *GetRetentionTaskLogInternalServerError) WithPayload(payload *models.Errors) *GetRetentionTaskLogInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get retention task log internal server error response +func (o *GetRetentionTaskLogInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetRetentionTaskLogInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/retention/get_retention_task_log_urlbuilder.go b/src/server/v2.0/restapi/operations/retention/get_retention_task_log_urlbuilder.go new file mode 100644 index 000000000..062a00051 --- /dev/null +++ b/src/server/v2.0/restapi/operations/retention/get_retention_task_log_urlbuilder.go @@ -0,0 +1,117 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package retention + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetRetentionTaskLogURL generates an URL for the get retention task log operation +type GetRetentionTaskLogURL struct { + Eid int64 + ID int64 + Tid int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetRetentionTaskLogURL) WithBasePath(bp string) *GetRetentionTaskLogURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetRetentionTaskLogURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetRetentionTaskLogURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/retentions/{id}/executions/{eid}/tasks/{tid}" + + eid := swag.FormatInt64(o.Eid) + if eid != "" { + _path = strings.Replace(_path, "{eid}", eid, -1) + } else { + return nil, errors.New("eid is required on GetRetentionTaskLogURL") + } + + id := swag.FormatInt64(o.ID) + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on GetRetentionTaskLogURL") + } + + tid := swag.FormatInt64(o.Tid) + if tid != "" { + _path = strings.Replace(_path, "{tid}", tid, -1) + } else { + return nil, errors.New("tid is required on GetRetentionTaskLogURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetRetentionTaskLogURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetRetentionTaskLogURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetRetentionTaskLogURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetRetentionTaskLogURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetRetentionTaskLogURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetRetentionTaskLogURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/retention/get_retention_urlbuilder.go b/src/server/v2.0/restapi/operations/retention/get_retention_urlbuilder.go new file mode 100644 index 000000000..567bfd737 --- /dev/null +++ b/src/server/v2.0/restapi/operations/retention/get_retention_urlbuilder.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package retention + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetRetentionURL generates an URL for the get retention operation +type GetRetentionURL struct { + ID int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetRetentionURL) WithBasePath(bp string) *GetRetentionURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetRetentionURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetRetentionURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/retentions/{id}" + + id := swag.FormatInt64(o.ID) + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on GetRetentionURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetRetentionURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetRetentionURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetRetentionURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetRetentionURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetRetentionURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetRetentionURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/retention/list_retention_executions.go b/src/server/v2.0/restapi/operations/retention/list_retention_executions.go new file mode 100644 index 000000000..06746a88e --- /dev/null +++ b/src/server/v2.0/restapi/operations/retention/list_retention_executions.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package retention + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ListRetentionExecutionsHandlerFunc turns a function with the right signature into a list retention executions handler +type ListRetentionExecutionsHandlerFunc func(ListRetentionExecutionsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ListRetentionExecutionsHandlerFunc) Handle(params ListRetentionExecutionsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ListRetentionExecutionsHandler interface for that can handle valid list retention executions params +type ListRetentionExecutionsHandler interface { + Handle(ListRetentionExecutionsParams, interface{}) middleware.Responder +} + +// NewListRetentionExecutions creates a new http.Handler for the list retention executions operation +func NewListRetentionExecutions(ctx *middleware.Context, handler ListRetentionExecutionsHandler) *ListRetentionExecutions { + return &ListRetentionExecutions{Context: ctx, Handler: handler} +} + +/*ListRetentionExecutions swagger:route GET /retentions/{id}/executions Retention listRetentionExecutions + +Get Retention executions + +Get Retention executions, execution status may be delayed before job service schedule it up. + +*/ +type ListRetentionExecutions struct { + Context *middleware.Context + Handler ListRetentionExecutionsHandler +} + +func (o *ListRetentionExecutions) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewListRetentionExecutionsParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/retention/list_retention_executions_parameters.go b/src/server/v2.0/restapi/operations/retention/list_retention_executions_parameters.go new file mode 100644 index 000000000..9e69ad4c6 --- /dev/null +++ b/src/server/v2.0/restapi/operations/retention/list_retention_executions_parameters.go @@ -0,0 +1,184 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package retention + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewListRetentionExecutionsParams creates a new ListRetentionExecutionsParams object +// no default values defined in spec. +func NewListRetentionExecutionsParams() ListRetentionExecutionsParams { + + return ListRetentionExecutionsParams{} +} + +// ListRetentionExecutionsParams contains all the bound params for the list retention executions operation +// typically these are obtained from a http.Request +// +// swagger:parameters listRetentionExecutions +type ListRetentionExecutionsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*Retention ID. + Required: true + In: path + */ + ID int64 + /*The page number. + In: query + */ + Page *int64 + /*The size of per page. + In: query + */ + PageSize *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewListRetentionExecutionsParams() beforehand. +func (o *ListRetentionExecutionsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + + qPage, qhkPage, _ := qs.GetOK("page") + if err := o.bindPage(qPage, qhkPage, route.Formats); err != nil { + res = append(res, err) + } + + qPageSize, qhkPageSize, _ := qs.GetOK("page_size") + if err := o.bindPageSize(qPageSize, qhkPageSize, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *ListRetentionExecutionsParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *ListRetentionExecutionsParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *ListRetentionExecutionsParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("id", "path", "int64", raw) + } + o.ID = value + + return nil +} + +// bindPage binds and validates parameter Page from query. +func (o *ListRetentionExecutionsParams) bindPage(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page", "query", "int64", raw) + } + o.Page = &value + + return nil +} + +// bindPageSize binds and validates parameter PageSize from query. +func (o *ListRetentionExecutionsParams) bindPageSize(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page_size", "query", "int64", raw) + } + o.PageSize = &value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/retention/list_retention_executions_responses.go b/src/server/v2.0/restapi/operations/retention/list_retention_executions_responses.go new file mode 100644 index 000000000..b0d7227c4 --- /dev/null +++ b/src/server/v2.0/restapi/operations/retention/list_retention_executions_responses.go @@ -0,0 +1,304 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package retention + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/swag" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// ListRetentionExecutionsOKCode is the HTTP code returned for type ListRetentionExecutionsOK +const ListRetentionExecutionsOKCode int = 200 + +/*ListRetentionExecutionsOK Get a Retention execution successfully. + +swagger:response listRetentionExecutionsOK +*/ +type ListRetentionExecutionsOK struct { + /*Link to previous page and next page + + */ + Link string `json:"Link"` + /*The total count of available items + + */ + XTotalCount int64 `json:"X-Total-Count"` + + /* + In: Body + */ + Payload []*models.RetentionExecution `json:"body,omitempty"` +} + +// NewListRetentionExecutionsOK creates ListRetentionExecutionsOK with default headers values +func NewListRetentionExecutionsOK() *ListRetentionExecutionsOK { + + return &ListRetentionExecutionsOK{} +} + +// WithLink adds the link to the list retention executions o k response +func (o *ListRetentionExecutionsOK) WithLink(link string) *ListRetentionExecutionsOK { + o.Link = link + return o +} + +// SetLink sets the link to the list retention executions o k response +func (o *ListRetentionExecutionsOK) SetLink(link string) { + o.Link = link +} + +// WithXTotalCount adds the xTotalCount to the list retention executions o k response +func (o *ListRetentionExecutionsOK) WithXTotalCount(xTotalCount int64) *ListRetentionExecutionsOK { + o.XTotalCount = xTotalCount + return o +} + +// SetXTotalCount sets the xTotalCount to the list retention executions o k response +func (o *ListRetentionExecutionsOK) SetXTotalCount(xTotalCount int64) { + o.XTotalCount = xTotalCount +} + +// WithPayload adds the payload to the list retention executions o k response +func (o *ListRetentionExecutionsOK) WithPayload(payload []*models.RetentionExecution) *ListRetentionExecutionsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list retention executions o k response +func (o *ListRetentionExecutionsOK) SetPayload(payload []*models.RetentionExecution) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListRetentionExecutionsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Link + + link := o.Link + if link != "" { + rw.Header().Set("Link", link) + } + + // response header X-Total-Count + + xTotalCount := swag.FormatInt64(o.XTotalCount) + if xTotalCount != "" { + rw.Header().Set("X-Total-Count", xTotalCount) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = make([]*models.RetentionExecution, 0, 50) + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ListRetentionExecutionsUnauthorizedCode is the HTTP code returned for type ListRetentionExecutionsUnauthorized +const ListRetentionExecutionsUnauthorizedCode int = 401 + +/*ListRetentionExecutionsUnauthorized Unauthorized + +swagger:response listRetentionExecutionsUnauthorized +*/ +type ListRetentionExecutionsUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListRetentionExecutionsUnauthorized creates ListRetentionExecutionsUnauthorized with default headers values +func NewListRetentionExecutionsUnauthorized() *ListRetentionExecutionsUnauthorized { + + return &ListRetentionExecutionsUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the list retention executions unauthorized response +func (o *ListRetentionExecutionsUnauthorized) WithXRequestID(xRequestID string) *ListRetentionExecutionsUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list retention executions unauthorized response +func (o *ListRetentionExecutionsUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list retention executions unauthorized response +func (o *ListRetentionExecutionsUnauthorized) WithPayload(payload *models.Errors) *ListRetentionExecutionsUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list retention executions unauthorized response +func (o *ListRetentionExecutionsUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListRetentionExecutionsUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListRetentionExecutionsForbiddenCode is the HTTP code returned for type ListRetentionExecutionsForbidden +const ListRetentionExecutionsForbiddenCode int = 403 + +/*ListRetentionExecutionsForbidden Forbidden + +swagger:response listRetentionExecutionsForbidden +*/ +type ListRetentionExecutionsForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListRetentionExecutionsForbidden creates ListRetentionExecutionsForbidden with default headers values +func NewListRetentionExecutionsForbidden() *ListRetentionExecutionsForbidden { + + return &ListRetentionExecutionsForbidden{} +} + +// WithXRequestID adds the xRequestId to the list retention executions forbidden response +func (o *ListRetentionExecutionsForbidden) WithXRequestID(xRequestID string) *ListRetentionExecutionsForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list retention executions forbidden response +func (o *ListRetentionExecutionsForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list retention executions forbidden response +func (o *ListRetentionExecutionsForbidden) WithPayload(payload *models.Errors) *ListRetentionExecutionsForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list retention executions forbidden response +func (o *ListRetentionExecutionsForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListRetentionExecutionsForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListRetentionExecutionsInternalServerErrorCode is the HTTP code returned for type ListRetentionExecutionsInternalServerError +const ListRetentionExecutionsInternalServerErrorCode int = 500 + +/*ListRetentionExecutionsInternalServerError Internal server error + +swagger:response listRetentionExecutionsInternalServerError +*/ +type ListRetentionExecutionsInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListRetentionExecutionsInternalServerError creates ListRetentionExecutionsInternalServerError with default headers values +func NewListRetentionExecutionsInternalServerError() *ListRetentionExecutionsInternalServerError { + + return &ListRetentionExecutionsInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the list retention executions internal server error response +func (o *ListRetentionExecutionsInternalServerError) WithXRequestID(xRequestID string) *ListRetentionExecutionsInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list retention executions internal server error response +func (o *ListRetentionExecutionsInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list retention executions internal server error response +func (o *ListRetentionExecutionsInternalServerError) WithPayload(payload *models.Errors) *ListRetentionExecutionsInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list retention executions internal server error response +func (o *ListRetentionExecutionsInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListRetentionExecutionsInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/retention/list_retention_executions_urlbuilder.go b/src/server/v2.0/restapi/operations/retention/list_retention_executions_urlbuilder.go new file mode 100644 index 000000000..f928b7058 --- /dev/null +++ b/src/server/v2.0/restapi/operations/retention/list_retention_executions_urlbuilder.go @@ -0,0 +1,124 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package retention + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ListRetentionExecutionsURL generates an URL for the list retention executions operation +type ListRetentionExecutionsURL struct { + ID int64 + + Page *int64 + PageSize *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListRetentionExecutionsURL) WithBasePath(bp string) *ListRetentionExecutionsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListRetentionExecutionsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ListRetentionExecutionsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/retentions/{id}/executions" + + id := swag.FormatInt64(o.ID) + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on ListRetentionExecutionsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var pageQ string + if o.Page != nil { + pageQ = swag.FormatInt64(*o.Page) + } + if pageQ != "" { + qs.Set("page", pageQ) + } + + var pageSizeQ string + if o.PageSize != nil { + pageSizeQ = swag.FormatInt64(*o.PageSize) + } + if pageSizeQ != "" { + qs.Set("page_size", pageSizeQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ListRetentionExecutionsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ListRetentionExecutionsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ListRetentionExecutionsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ListRetentionExecutionsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ListRetentionExecutionsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ListRetentionExecutionsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/retention/list_retention_tasks.go b/src/server/v2.0/restapi/operations/retention/list_retention_tasks.go new file mode 100644 index 000000000..76eff65ad --- /dev/null +++ b/src/server/v2.0/restapi/operations/retention/list_retention_tasks.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package retention + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ListRetentionTasksHandlerFunc turns a function with the right signature into a list retention tasks handler +type ListRetentionTasksHandlerFunc func(ListRetentionTasksParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ListRetentionTasksHandlerFunc) Handle(params ListRetentionTasksParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ListRetentionTasksHandler interface for that can handle valid list retention tasks params +type ListRetentionTasksHandler interface { + Handle(ListRetentionTasksParams, interface{}) middleware.Responder +} + +// NewListRetentionTasks creates a new http.Handler for the list retention tasks operation +func NewListRetentionTasks(ctx *middleware.Context, handler ListRetentionTasksHandler) *ListRetentionTasks { + return &ListRetentionTasks{Context: ctx, Handler: handler} +} + +/*ListRetentionTasks swagger:route GET /retentions/{id}/executions/{eid}/tasks Retention listRetentionTasks + +Get Retention tasks + +Get Retention tasks, each repository as a task. + +*/ +type ListRetentionTasks struct { + Context *middleware.Context + Handler ListRetentionTasksHandler +} + +func (o *ListRetentionTasks) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewListRetentionTasksParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/retention/list_retention_tasks_parameters.go b/src/server/v2.0/restapi/operations/retention/list_retention_tasks_parameters.go new file mode 100644 index 000000000..3b82f0a85 --- /dev/null +++ b/src/server/v2.0/restapi/operations/retention/list_retention_tasks_parameters.go @@ -0,0 +1,213 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package retention + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewListRetentionTasksParams creates a new ListRetentionTasksParams object +// no default values defined in spec. +func NewListRetentionTasksParams() ListRetentionTasksParams { + + return ListRetentionTasksParams{} +} + +// ListRetentionTasksParams contains all the bound params for the list retention tasks operation +// typically these are obtained from a http.Request +// +// swagger:parameters listRetentionTasks +type ListRetentionTasksParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*Retention execution ID. + Required: true + In: path + */ + Eid int64 + /*Retention ID. + Required: true + In: path + */ + ID int64 + /*The page number. + In: query + */ + Page *int64 + /*The size of per page. + In: query + */ + PageSize *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewListRetentionTasksParams() beforehand. +func (o *ListRetentionTasksParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rEid, rhkEid, _ := route.Params.GetOK("eid") + if err := o.bindEid(rEid, rhkEid, route.Formats); err != nil { + res = append(res, err) + } + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + + qPage, qhkPage, _ := qs.GetOK("page") + if err := o.bindPage(qPage, qhkPage, route.Formats); err != nil { + res = append(res, err) + } + + qPageSize, qhkPageSize, _ := qs.GetOK("page_size") + if err := o.bindPageSize(qPageSize, qhkPageSize, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *ListRetentionTasksParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *ListRetentionTasksParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindEid binds and validates parameter Eid from path. +func (o *ListRetentionTasksParams) bindEid(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("eid", "path", "int64", raw) + } + o.Eid = value + + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *ListRetentionTasksParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("id", "path", "int64", raw) + } + o.ID = value + + return nil +} + +// bindPage binds and validates parameter Page from query. +func (o *ListRetentionTasksParams) bindPage(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page", "query", "int64", raw) + } + o.Page = &value + + return nil +} + +// bindPageSize binds and validates parameter PageSize from query. +func (o *ListRetentionTasksParams) bindPageSize(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page_size", "query", "int64", raw) + } + o.PageSize = &value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/retention/list_retention_tasks_responses.go b/src/server/v2.0/restapi/operations/retention/list_retention_tasks_responses.go new file mode 100644 index 000000000..73875b211 --- /dev/null +++ b/src/server/v2.0/restapi/operations/retention/list_retention_tasks_responses.go @@ -0,0 +1,304 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package retention + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/swag" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// ListRetentionTasksOKCode is the HTTP code returned for type ListRetentionTasksOK +const ListRetentionTasksOKCode int = 200 + +/*ListRetentionTasksOK Get Retention job tasks successfully. + +swagger:response listRetentionTasksOK +*/ +type ListRetentionTasksOK struct { + /*Link to previous page and next page + + */ + Link string `json:"Link"` + /*The total count of available items + + */ + XTotalCount int64 `json:"X-Total-Count"` + + /* + In: Body + */ + Payload []*models.RetentionExecutionTask `json:"body,omitempty"` +} + +// NewListRetentionTasksOK creates ListRetentionTasksOK with default headers values +func NewListRetentionTasksOK() *ListRetentionTasksOK { + + return &ListRetentionTasksOK{} +} + +// WithLink adds the link to the list retention tasks o k response +func (o *ListRetentionTasksOK) WithLink(link string) *ListRetentionTasksOK { + o.Link = link + return o +} + +// SetLink sets the link to the list retention tasks o k response +func (o *ListRetentionTasksOK) SetLink(link string) { + o.Link = link +} + +// WithXTotalCount adds the xTotalCount to the list retention tasks o k response +func (o *ListRetentionTasksOK) WithXTotalCount(xTotalCount int64) *ListRetentionTasksOK { + o.XTotalCount = xTotalCount + return o +} + +// SetXTotalCount sets the xTotalCount to the list retention tasks o k response +func (o *ListRetentionTasksOK) SetXTotalCount(xTotalCount int64) { + o.XTotalCount = xTotalCount +} + +// WithPayload adds the payload to the list retention tasks o k response +func (o *ListRetentionTasksOK) WithPayload(payload []*models.RetentionExecutionTask) *ListRetentionTasksOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list retention tasks o k response +func (o *ListRetentionTasksOK) SetPayload(payload []*models.RetentionExecutionTask) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListRetentionTasksOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Link + + link := o.Link + if link != "" { + rw.Header().Set("Link", link) + } + + // response header X-Total-Count + + xTotalCount := swag.FormatInt64(o.XTotalCount) + if xTotalCount != "" { + rw.Header().Set("X-Total-Count", xTotalCount) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = make([]*models.RetentionExecutionTask, 0, 50) + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ListRetentionTasksUnauthorizedCode is the HTTP code returned for type ListRetentionTasksUnauthorized +const ListRetentionTasksUnauthorizedCode int = 401 + +/*ListRetentionTasksUnauthorized Unauthorized + +swagger:response listRetentionTasksUnauthorized +*/ +type ListRetentionTasksUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListRetentionTasksUnauthorized creates ListRetentionTasksUnauthorized with default headers values +func NewListRetentionTasksUnauthorized() *ListRetentionTasksUnauthorized { + + return &ListRetentionTasksUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the list retention tasks unauthorized response +func (o *ListRetentionTasksUnauthorized) WithXRequestID(xRequestID string) *ListRetentionTasksUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list retention tasks unauthorized response +func (o *ListRetentionTasksUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list retention tasks unauthorized response +func (o *ListRetentionTasksUnauthorized) WithPayload(payload *models.Errors) *ListRetentionTasksUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list retention tasks unauthorized response +func (o *ListRetentionTasksUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListRetentionTasksUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListRetentionTasksForbiddenCode is the HTTP code returned for type ListRetentionTasksForbidden +const ListRetentionTasksForbiddenCode int = 403 + +/*ListRetentionTasksForbidden Forbidden + +swagger:response listRetentionTasksForbidden +*/ +type ListRetentionTasksForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListRetentionTasksForbidden creates ListRetentionTasksForbidden with default headers values +func NewListRetentionTasksForbidden() *ListRetentionTasksForbidden { + + return &ListRetentionTasksForbidden{} +} + +// WithXRequestID adds the xRequestId to the list retention tasks forbidden response +func (o *ListRetentionTasksForbidden) WithXRequestID(xRequestID string) *ListRetentionTasksForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list retention tasks forbidden response +func (o *ListRetentionTasksForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list retention tasks forbidden response +func (o *ListRetentionTasksForbidden) WithPayload(payload *models.Errors) *ListRetentionTasksForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list retention tasks forbidden response +func (o *ListRetentionTasksForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListRetentionTasksForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListRetentionTasksInternalServerErrorCode is the HTTP code returned for type ListRetentionTasksInternalServerError +const ListRetentionTasksInternalServerErrorCode int = 500 + +/*ListRetentionTasksInternalServerError Internal server error + +swagger:response listRetentionTasksInternalServerError +*/ +type ListRetentionTasksInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListRetentionTasksInternalServerError creates ListRetentionTasksInternalServerError with default headers values +func NewListRetentionTasksInternalServerError() *ListRetentionTasksInternalServerError { + + return &ListRetentionTasksInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the list retention tasks internal server error response +func (o *ListRetentionTasksInternalServerError) WithXRequestID(xRequestID string) *ListRetentionTasksInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list retention tasks internal server error response +func (o *ListRetentionTasksInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list retention tasks internal server error response +func (o *ListRetentionTasksInternalServerError) WithPayload(payload *models.Errors) *ListRetentionTasksInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list retention tasks internal server error response +func (o *ListRetentionTasksInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListRetentionTasksInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/retention/list_retention_tasks_urlbuilder.go b/src/server/v2.0/restapi/operations/retention/list_retention_tasks_urlbuilder.go new file mode 100644 index 000000000..aa8c12a62 --- /dev/null +++ b/src/server/v2.0/restapi/operations/retention/list_retention_tasks_urlbuilder.go @@ -0,0 +1,132 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package retention + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ListRetentionTasksURL generates an URL for the list retention tasks operation +type ListRetentionTasksURL struct { + Eid int64 + ID int64 + + Page *int64 + PageSize *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListRetentionTasksURL) WithBasePath(bp string) *ListRetentionTasksURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListRetentionTasksURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ListRetentionTasksURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/retentions/{id}/executions/{eid}/tasks" + + eid := swag.FormatInt64(o.Eid) + if eid != "" { + _path = strings.Replace(_path, "{eid}", eid, -1) + } else { + return nil, errors.New("eid is required on ListRetentionTasksURL") + } + + id := swag.FormatInt64(o.ID) + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on ListRetentionTasksURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var pageQ string + if o.Page != nil { + pageQ = swag.FormatInt64(*o.Page) + } + if pageQ != "" { + qs.Set("page", pageQ) + } + + var pageSizeQ string + if o.PageSize != nil { + pageSizeQ = swag.FormatInt64(*o.PageSize) + } + if pageSizeQ != "" { + qs.Set("page_size", pageSizeQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ListRetentionTasksURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ListRetentionTasksURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ListRetentionTasksURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ListRetentionTasksURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ListRetentionTasksURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ListRetentionTasksURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/retention/operate_retention_execution.go b/src/server/v2.0/restapi/operations/retention/operate_retention_execution.go new file mode 100644 index 000000000..6cf655824 --- /dev/null +++ b/src/server/v2.0/restapi/operations/retention/operate_retention_execution.go @@ -0,0 +1,107 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package retention + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// OperateRetentionExecutionHandlerFunc turns a function with the right signature into a operate retention execution handler +type OperateRetentionExecutionHandlerFunc func(OperateRetentionExecutionParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn OperateRetentionExecutionHandlerFunc) Handle(params OperateRetentionExecutionParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// OperateRetentionExecutionHandler interface for that can handle valid operate retention execution params +type OperateRetentionExecutionHandler interface { + Handle(OperateRetentionExecutionParams, interface{}) middleware.Responder +} + +// NewOperateRetentionExecution creates a new http.Handler for the operate retention execution operation +func NewOperateRetentionExecution(ctx *middleware.Context, handler OperateRetentionExecutionHandler) *OperateRetentionExecution { + return &OperateRetentionExecution{Context: ctx, Handler: handler} +} + +/*OperateRetentionExecution swagger:route PATCH /retentions/{id}/executions/{eid} Retention operateRetentionExecution + +Stop a Retention execution + +Stop a Retention execution, only support "stop" action now. + +*/ +type OperateRetentionExecution struct { + Context *middleware.Context + Handler OperateRetentionExecutionHandler +} + +func (o *OperateRetentionExecution) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewOperateRetentionExecutionParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} + +// OperateRetentionExecutionBody operate retention execution body +// +// swagger:model OperateRetentionExecutionBody +type OperateRetentionExecutionBody struct { + + // action + Action string `json:"action,omitempty"` +} + +// Validate validates this operate retention execution body +func (o *OperateRetentionExecutionBody) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *OperateRetentionExecutionBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *OperateRetentionExecutionBody) UnmarshalBinary(b []byte) error { + var res OperateRetentionExecutionBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} diff --git a/src/server/v2.0/restapi/operations/retention/operate_retention_execution_parameters.go b/src/server/v2.0/restapi/operations/retention/operate_retention_execution_parameters.go new file mode 100644 index 000000000..a434b60e7 --- /dev/null +++ b/src/server/v2.0/restapi/operations/retention/operate_retention_execution_parameters.go @@ -0,0 +1,177 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package retention + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewOperateRetentionExecutionParams creates a new OperateRetentionExecutionParams object +// no default values defined in spec. +func NewOperateRetentionExecutionParams() OperateRetentionExecutionParams { + + return OperateRetentionExecutionParams{} +} + +// OperateRetentionExecutionParams contains all the bound params for the operate retention execution operation +// typically these are obtained from a http.Request +// +// swagger:parameters operateRetentionExecution +type OperateRetentionExecutionParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The action, only support "stop" now. + Required: true + In: body + */ + Body OperateRetentionExecutionBody + /*Retention execution ID. + Required: true + In: path + */ + Eid int64 + /*Retention ID. + Required: true + In: path + */ + ID int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewOperateRetentionExecutionParams() beforehand. +func (o *OperateRetentionExecutionParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body OperateRetentionExecutionBody + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("body", "body", "")) + } else { + res = append(res, errors.NewParseError("body", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Body = body + } + } + } else { + res = append(res, errors.Required("body", "body", "")) + } + rEid, rhkEid, _ := route.Params.GetOK("eid") + if err := o.bindEid(rEid, rhkEid, route.Formats); err != nil { + res = append(res, err) + } + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *OperateRetentionExecutionParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *OperateRetentionExecutionParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindEid binds and validates parameter Eid from path. +func (o *OperateRetentionExecutionParams) bindEid(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("eid", "path", "int64", raw) + } + o.Eid = value + + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *OperateRetentionExecutionParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("id", "path", "int64", raw) + } + o.ID = value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/retention/operate_retention_execution_responses.go b/src/server/v2.0/restapi/operations/retention/operate_retention_execution_responses.go new file mode 100644 index 000000000..305dd9bea --- /dev/null +++ b/src/server/v2.0/restapi/operations/retention/operate_retention_execution_responses.go @@ -0,0 +1,236 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package retention + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// OperateRetentionExecutionOKCode is the HTTP code returned for type OperateRetentionExecutionOK +const OperateRetentionExecutionOKCode int = 200 + +/*OperateRetentionExecutionOK Stop a Retention job successfully. + +swagger:response operateRetentionExecutionOK +*/ +type OperateRetentionExecutionOK struct { +} + +// NewOperateRetentionExecutionOK creates OperateRetentionExecutionOK with default headers values +func NewOperateRetentionExecutionOK() *OperateRetentionExecutionOK { + + return &OperateRetentionExecutionOK{} +} + +// WriteResponse to the client +func (o *OperateRetentionExecutionOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// OperateRetentionExecutionUnauthorizedCode is the HTTP code returned for type OperateRetentionExecutionUnauthorized +const OperateRetentionExecutionUnauthorizedCode int = 401 + +/*OperateRetentionExecutionUnauthorized Unauthorized + +swagger:response operateRetentionExecutionUnauthorized +*/ +type OperateRetentionExecutionUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewOperateRetentionExecutionUnauthorized creates OperateRetentionExecutionUnauthorized with default headers values +func NewOperateRetentionExecutionUnauthorized() *OperateRetentionExecutionUnauthorized { + + return &OperateRetentionExecutionUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the operate retention execution unauthorized response +func (o *OperateRetentionExecutionUnauthorized) WithXRequestID(xRequestID string) *OperateRetentionExecutionUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the operate retention execution unauthorized response +func (o *OperateRetentionExecutionUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the operate retention execution unauthorized response +func (o *OperateRetentionExecutionUnauthorized) WithPayload(payload *models.Errors) *OperateRetentionExecutionUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the operate retention execution unauthorized response +func (o *OperateRetentionExecutionUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *OperateRetentionExecutionUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// OperateRetentionExecutionForbiddenCode is the HTTP code returned for type OperateRetentionExecutionForbidden +const OperateRetentionExecutionForbiddenCode int = 403 + +/*OperateRetentionExecutionForbidden Forbidden + +swagger:response operateRetentionExecutionForbidden +*/ +type OperateRetentionExecutionForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewOperateRetentionExecutionForbidden creates OperateRetentionExecutionForbidden with default headers values +func NewOperateRetentionExecutionForbidden() *OperateRetentionExecutionForbidden { + + return &OperateRetentionExecutionForbidden{} +} + +// WithXRequestID adds the xRequestId to the operate retention execution forbidden response +func (o *OperateRetentionExecutionForbidden) WithXRequestID(xRequestID string) *OperateRetentionExecutionForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the operate retention execution forbidden response +func (o *OperateRetentionExecutionForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the operate retention execution forbidden response +func (o *OperateRetentionExecutionForbidden) WithPayload(payload *models.Errors) *OperateRetentionExecutionForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the operate retention execution forbidden response +func (o *OperateRetentionExecutionForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *OperateRetentionExecutionForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// OperateRetentionExecutionInternalServerErrorCode is the HTTP code returned for type OperateRetentionExecutionInternalServerError +const OperateRetentionExecutionInternalServerErrorCode int = 500 + +/*OperateRetentionExecutionInternalServerError Internal server error + +swagger:response operateRetentionExecutionInternalServerError +*/ +type OperateRetentionExecutionInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewOperateRetentionExecutionInternalServerError creates OperateRetentionExecutionInternalServerError with default headers values +func NewOperateRetentionExecutionInternalServerError() *OperateRetentionExecutionInternalServerError { + + return &OperateRetentionExecutionInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the operate retention execution internal server error response +func (o *OperateRetentionExecutionInternalServerError) WithXRequestID(xRequestID string) *OperateRetentionExecutionInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the operate retention execution internal server error response +func (o *OperateRetentionExecutionInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the operate retention execution internal server error response +func (o *OperateRetentionExecutionInternalServerError) WithPayload(payload *models.Errors) *OperateRetentionExecutionInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the operate retention execution internal server error response +func (o *OperateRetentionExecutionInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *OperateRetentionExecutionInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/retention/operate_retention_execution_urlbuilder.go b/src/server/v2.0/restapi/operations/retention/operate_retention_execution_urlbuilder.go new file mode 100644 index 000000000..29c2d3f6c --- /dev/null +++ b/src/server/v2.0/restapi/operations/retention/operate_retention_execution_urlbuilder.go @@ -0,0 +1,109 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package retention + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// OperateRetentionExecutionURL generates an URL for the operate retention execution operation +type OperateRetentionExecutionURL struct { + Eid int64 + ID int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *OperateRetentionExecutionURL) WithBasePath(bp string) *OperateRetentionExecutionURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *OperateRetentionExecutionURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *OperateRetentionExecutionURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/retentions/{id}/executions/{eid}" + + eid := swag.FormatInt64(o.Eid) + if eid != "" { + _path = strings.Replace(_path, "{eid}", eid, -1) + } else { + return nil, errors.New("eid is required on OperateRetentionExecutionURL") + } + + id := swag.FormatInt64(o.ID) + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on OperateRetentionExecutionURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *OperateRetentionExecutionURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *OperateRetentionExecutionURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *OperateRetentionExecutionURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on OperateRetentionExecutionURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on OperateRetentionExecutionURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *OperateRetentionExecutionURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/retention/trigger_retention_execution.go b/src/server/v2.0/restapi/operations/retention/trigger_retention_execution.go new file mode 100644 index 000000000..009f5dcca --- /dev/null +++ b/src/server/v2.0/restapi/operations/retention/trigger_retention_execution.go @@ -0,0 +1,107 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package retention + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// TriggerRetentionExecutionHandlerFunc turns a function with the right signature into a trigger retention execution handler +type TriggerRetentionExecutionHandlerFunc func(TriggerRetentionExecutionParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn TriggerRetentionExecutionHandlerFunc) Handle(params TriggerRetentionExecutionParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// TriggerRetentionExecutionHandler interface for that can handle valid trigger retention execution params +type TriggerRetentionExecutionHandler interface { + Handle(TriggerRetentionExecutionParams, interface{}) middleware.Responder +} + +// NewTriggerRetentionExecution creates a new http.Handler for the trigger retention execution operation +func NewTriggerRetentionExecution(ctx *middleware.Context, handler TriggerRetentionExecutionHandler) *TriggerRetentionExecution { + return &TriggerRetentionExecution{Context: ctx, Handler: handler} +} + +/*TriggerRetentionExecution swagger:route POST /retentions/{id}/executions Retention triggerRetentionExecution + +Trigger a Retention Execution + +Trigger a Retention Execution, if dry_run is True, nothing would be deleted actually. + +*/ +type TriggerRetentionExecution struct { + Context *middleware.Context + Handler TriggerRetentionExecutionHandler +} + +func (o *TriggerRetentionExecution) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewTriggerRetentionExecutionParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} + +// TriggerRetentionExecutionBody trigger retention execution body +// +// swagger:model TriggerRetentionExecutionBody +type TriggerRetentionExecutionBody struct { + + // dry run + DryRun bool `json:"dry_run,omitempty"` +} + +// Validate validates this trigger retention execution body +func (o *TriggerRetentionExecutionBody) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *TriggerRetentionExecutionBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *TriggerRetentionExecutionBody) UnmarshalBinary(b []byte) error { + var res TriggerRetentionExecutionBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} diff --git a/src/server/v2.0/restapi/operations/retention/trigger_retention_execution_parameters.go b/src/server/v2.0/restapi/operations/retention/trigger_retention_execution_parameters.go new file mode 100644 index 000000000..9296c6aa0 --- /dev/null +++ b/src/server/v2.0/restapi/operations/retention/trigger_retention_execution_parameters.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package retention + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewTriggerRetentionExecutionParams creates a new TriggerRetentionExecutionParams object +// no default values defined in spec. +func NewTriggerRetentionExecutionParams() TriggerRetentionExecutionParams { + + return TriggerRetentionExecutionParams{} +} + +// TriggerRetentionExecutionParams contains all the bound params for the trigger retention execution operation +// typically these are obtained from a http.Request +// +// swagger:parameters triggerRetentionExecution +type TriggerRetentionExecutionParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /* + Required: true + In: body + */ + Body TriggerRetentionExecutionBody + /*Retention ID. + Required: true + In: path + */ + ID int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewTriggerRetentionExecutionParams() beforehand. +func (o *TriggerRetentionExecutionParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body TriggerRetentionExecutionBody + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("body", "body", "")) + } else { + res = append(res, errors.NewParseError("body", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Body = body + } + } + } else { + res = append(res, errors.Required("body", "body", "")) + } + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *TriggerRetentionExecutionParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *TriggerRetentionExecutionParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *TriggerRetentionExecutionParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("id", "path", "int64", raw) + } + o.ID = value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/retention/trigger_retention_execution_responses.go b/src/server/v2.0/restapi/operations/retention/trigger_retention_execution_responses.go new file mode 100644 index 000000000..3c50ccf54 --- /dev/null +++ b/src/server/v2.0/restapi/operations/retention/trigger_retention_execution_responses.go @@ -0,0 +1,304 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package retention + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// TriggerRetentionExecutionOKCode is the HTTP code returned for type TriggerRetentionExecutionOK +const TriggerRetentionExecutionOKCode int = 200 + +/*TriggerRetentionExecutionOK Trigger a Retention job successfully. + +swagger:response triggerRetentionExecutionOK +*/ +type TriggerRetentionExecutionOK struct { +} + +// NewTriggerRetentionExecutionOK creates TriggerRetentionExecutionOK with default headers values +func NewTriggerRetentionExecutionOK() *TriggerRetentionExecutionOK { + + return &TriggerRetentionExecutionOK{} +} + +// WriteResponse to the client +func (o *TriggerRetentionExecutionOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// TriggerRetentionExecutionCreatedCode is the HTTP code returned for type TriggerRetentionExecutionCreated +const TriggerRetentionExecutionCreatedCode int = 201 + +/*TriggerRetentionExecutionCreated Created + +swagger:response triggerRetentionExecutionCreated +*/ +type TriggerRetentionExecutionCreated struct { + /*The location of the resource + + */ + Location string `json:"Location"` + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewTriggerRetentionExecutionCreated creates TriggerRetentionExecutionCreated with default headers values +func NewTriggerRetentionExecutionCreated() *TriggerRetentionExecutionCreated { + + return &TriggerRetentionExecutionCreated{} +} + +// WithLocation adds the location to the trigger retention execution created response +func (o *TriggerRetentionExecutionCreated) WithLocation(location string) *TriggerRetentionExecutionCreated { + o.Location = location + return o +} + +// SetLocation sets the location to the trigger retention execution created response +func (o *TriggerRetentionExecutionCreated) SetLocation(location string) { + o.Location = location +} + +// WithXRequestID adds the xRequestId to the trigger retention execution created response +func (o *TriggerRetentionExecutionCreated) WithXRequestID(xRequestID string) *TriggerRetentionExecutionCreated { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the trigger retention execution created response +func (o *TriggerRetentionExecutionCreated) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *TriggerRetentionExecutionCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Location + + location := o.Location + if location != "" { + rw.Header().Set("Location", location) + } + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(201) +} + +// TriggerRetentionExecutionUnauthorizedCode is the HTTP code returned for type TriggerRetentionExecutionUnauthorized +const TriggerRetentionExecutionUnauthorizedCode int = 401 + +/*TriggerRetentionExecutionUnauthorized Unauthorized + +swagger:response triggerRetentionExecutionUnauthorized +*/ +type TriggerRetentionExecutionUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewTriggerRetentionExecutionUnauthorized creates TriggerRetentionExecutionUnauthorized with default headers values +func NewTriggerRetentionExecutionUnauthorized() *TriggerRetentionExecutionUnauthorized { + + return &TriggerRetentionExecutionUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the trigger retention execution unauthorized response +func (o *TriggerRetentionExecutionUnauthorized) WithXRequestID(xRequestID string) *TriggerRetentionExecutionUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the trigger retention execution unauthorized response +func (o *TriggerRetentionExecutionUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the trigger retention execution unauthorized response +func (o *TriggerRetentionExecutionUnauthorized) WithPayload(payload *models.Errors) *TriggerRetentionExecutionUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the trigger retention execution unauthorized response +func (o *TriggerRetentionExecutionUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *TriggerRetentionExecutionUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// TriggerRetentionExecutionForbiddenCode is the HTTP code returned for type TriggerRetentionExecutionForbidden +const TriggerRetentionExecutionForbiddenCode int = 403 + +/*TriggerRetentionExecutionForbidden Forbidden + +swagger:response triggerRetentionExecutionForbidden +*/ +type TriggerRetentionExecutionForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewTriggerRetentionExecutionForbidden creates TriggerRetentionExecutionForbidden with default headers values +func NewTriggerRetentionExecutionForbidden() *TriggerRetentionExecutionForbidden { + + return &TriggerRetentionExecutionForbidden{} +} + +// WithXRequestID adds the xRequestId to the trigger retention execution forbidden response +func (o *TriggerRetentionExecutionForbidden) WithXRequestID(xRequestID string) *TriggerRetentionExecutionForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the trigger retention execution forbidden response +func (o *TriggerRetentionExecutionForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the trigger retention execution forbidden response +func (o *TriggerRetentionExecutionForbidden) WithPayload(payload *models.Errors) *TriggerRetentionExecutionForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the trigger retention execution forbidden response +func (o *TriggerRetentionExecutionForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *TriggerRetentionExecutionForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// TriggerRetentionExecutionInternalServerErrorCode is the HTTP code returned for type TriggerRetentionExecutionInternalServerError +const TriggerRetentionExecutionInternalServerErrorCode int = 500 + +/*TriggerRetentionExecutionInternalServerError Internal server error + +swagger:response triggerRetentionExecutionInternalServerError +*/ +type TriggerRetentionExecutionInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewTriggerRetentionExecutionInternalServerError creates TriggerRetentionExecutionInternalServerError with default headers values +func NewTriggerRetentionExecutionInternalServerError() *TriggerRetentionExecutionInternalServerError { + + return &TriggerRetentionExecutionInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the trigger retention execution internal server error response +func (o *TriggerRetentionExecutionInternalServerError) WithXRequestID(xRequestID string) *TriggerRetentionExecutionInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the trigger retention execution internal server error response +func (o *TriggerRetentionExecutionInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the trigger retention execution internal server error response +func (o *TriggerRetentionExecutionInternalServerError) WithPayload(payload *models.Errors) *TriggerRetentionExecutionInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the trigger retention execution internal server error response +func (o *TriggerRetentionExecutionInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *TriggerRetentionExecutionInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/retention/trigger_retention_execution_urlbuilder.go b/src/server/v2.0/restapi/operations/retention/trigger_retention_execution_urlbuilder.go new file mode 100644 index 000000000..d5a3cb77f --- /dev/null +++ b/src/server/v2.0/restapi/operations/retention/trigger_retention_execution_urlbuilder.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package retention + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// TriggerRetentionExecutionURL generates an URL for the trigger retention execution operation +type TriggerRetentionExecutionURL struct { + ID int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *TriggerRetentionExecutionURL) WithBasePath(bp string) *TriggerRetentionExecutionURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *TriggerRetentionExecutionURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *TriggerRetentionExecutionURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/retentions/{id}/executions" + + id := swag.FormatInt64(o.ID) + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on TriggerRetentionExecutionURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *TriggerRetentionExecutionURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *TriggerRetentionExecutionURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *TriggerRetentionExecutionURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on TriggerRetentionExecutionURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on TriggerRetentionExecutionURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *TriggerRetentionExecutionURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/retention/update_retention.go b/src/server/v2.0/restapi/operations/retention/update_retention.go new file mode 100644 index 000000000..8067f2ae3 --- /dev/null +++ b/src/server/v2.0/restapi/operations/retention/update_retention.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package retention + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// UpdateRetentionHandlerFunc turns a function with the right signature into a update retention handler +type UpdateRetentionHandlerFunc func(UpdateRetentionParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn UpdateRetentionHandlerFunc) Handle(params UpdateRetentionParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// UpdateRetentionHandler interface for that can handle valid update retention params +type UpdateRetentionHandler interface { + Handle(UpdateRetentionParams, interface{}) middleware.Responder +} + +// NewUpdateRetention creates a new http.Handler for the update retention operation +func NewUpdateRetention(ctx *middleware.Context, handler UpdateRetentionHandler) *UpdateRetention { + return &UpdateRetention{Context: ctx, Handler: handler} +} + +/*UpdateRetention swagger:route PUT /retentions/{id} Retention updateRetention + +Update Retention Policy + +Update Retention Policy, you can reference metadatas API for the policy model. You can check project metadatas to find whether a retention policy is already binded. This method should only be called when retention policy has already binded to project. + +*/ +type UpdateRetention struct { + Context *middleware.Context + Handler UpdateRetentionHandler +} + +func (o *UpdateRetention) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewUpdateRetentionParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/retention/update_retention_parameters.go b/src/server/v2.0/restapi/operations/retention/update_retention_parameters.go new file mode 100644 index 000000000..7baa66b0d --- /dev/null +++ b/src/server/v2.0/restapi/operations/retention/update_retention_parameters.go @@ -0,0 +1,150 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package retention + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewUpdateRetentionParams creates a new UpdateRetentionParams object +// no default values defined in spec. +func NewUpdateRetentionParams() UpdateRetentionParams { + + return UpdateRetentionParams{} +} + +// UpdateRetentionParams contains all the bound params for the update retention operation +// typically these are obtained from a http.Request +// +// swagger:parameters updateRetention +type UpdateRetentionParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*Retention ID. + Required: true + In: path + */ + ID int64 + /* + Required: true + In: body + */ + Policy *models.RetentionPolicy +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewUpdateRetentionParams() beforehand. +func (o *UpdateRetentionParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.RetentionPolicy + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("policy", "body", "")) + } else { + res = append(res, errors.NewParseError("policy", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Policy = &body + } + } + } else { + res = append(res, errors.Required("policy", "body", "")) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *UpdateRetentionParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *UpdateRetentionParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *UpdateRetentionParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("id", "path", "int64", raw) + } + o.ID = value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/retention/update_retention_responses.go b/src/server/v2.0/restapi/operations/retention/update_retention_responses.go new file mode 100644 index 000000000..e5e1ab1c7 --- /dev/null +++ b/src/server/v2.0/restapi/operations/retention/update_retention_responses.go @@ -0,0 +1,236 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package retention + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// UpdateRetentionOKCode is the HTTP code returned for type UpdateRetentionOK +const UpdateRetentionOKCode int = 200 + +/*UpdateRetentionOK Update Retention Policy successfully. + +swagger:response updateRetentionOK +*/ +type UpdateRetentionOK struct { +} + +// NewUpdateRetentionOK creates UpdateRetentionOK with default headers values +func NewUpdateRetentionOK() *UpdateRetentionOK { + + return &UpdateRetentionOK{} +} + +// WriteResponse to the client +func (o *UpdateRetentionOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// UpdateRetentionUnauthorizedCode is the HTTP code returned for type UpdateRetentionUnauthorized +const UpdateRetentionUnauthorizedCode int = 401 + +/*UpdateRetentionUnauthorized Unauthorized + +swagger:response updateRetentionUnauthorized +*/ +type UpdateRetentionUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateRetentionUnauthorized creates UpdateRetentionUnauthorized with default headers values +func NewUpdateRetentionUnauthorized() *UpdateRetentionUnauthorized { + + return &UpdateRetentionUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the update retention unauthorized response +func (o *UpdateRetentionUnauthorized) WithXRequestID(xRequestID string) *UpdateRetentionUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update retention unauthorized response +func (o *UpdateRetentionUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update retention unauthorized response +func (o *UpdateRetentionUnauthorized) WithPayload(payload *models.Errors) *UpdateRetentionUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update retention unauthorized response +func (o *UpdateRetentionUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateRetentionUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateRetentionForbiddenCode is the HTTP code returned for type UpdateRetentionForbidden +const UpdateRetentionForbiddenCode int = 403 + +/*UpdateRetentionForbidden Forbidden + +swagger:response updateRetentionForbidden +*/ +type UpdateRetentionForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateRetentionForbidden creates UpdateRetentionForbidden with default headers values +func NewUpdateRetentionForbidden() *UpdateRetentionForbidden { + + return &UpdateRetentionForbidden{} +} + +// WithXRequestID adds the xRequestId to the update retention forbidden response +func (o *UpdateRetentionForbidden) WithXRequestID(xRequestID string) *UpdateRetentionForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update retention forbidden response +func (o *UpdateRetentionForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update retention forbidden response +func (o *UpdateRetentionForbidden) WithPayload(payload *models.Errors) *UpdateRetentionForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update retention forbidden response +func (o *UpdateRetentionForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateRetentionForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateRetentionInternalServerErrorCode is the HTTP code returned for type UpdateRetentionInternalServerError +const UpdateRetentionInternalServerErrorCode int = 500 + +/*UpdateRetentionInternalServerError Internal server error + +swagger:response updateRetentionInternalServerError +*/ +type UpdateRetentionInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateRetentionInternalServerError creates UpdateRetentionInternalServerError with default headers values +func NewUpdateRetentionInternalServerError() *UpdateRetentionInternalServerError { + + return &UpdateRetentionInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the update retention internal server error response +func (o *UpdateRetentionInternalServerError) WithXRequestID(xRequestID string) *UpdateRetentionInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update retention internal server error response +func (o *UpdateRetentionInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update retention internal server error response +func (o *UpdateRetentionInternalServerError) WithPayload(payload *models.Errors) *UpdateRetentionInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update retention internal server error response +func (o *UpdateRetentionInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateRetentionInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/retention/update_retention_urlbuilder.go b/src/server/v2.0/restapi/operations/retention/update_retention_urlbuilder.go new file mode 100644 index 000000000..cc2181cb7 --- /dev/null +++ b/src/server/v2.0/restapi/operations/retention/update_retention_urlbuilder.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package retention + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// UpdateRetentionURL generates an URL for the update retention operation +type UpdateRetentionURL struct { + ID int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdateRetentionURL) WithBasePath(bp string) *UpdateRetentionURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdateRetentionURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *UpdateRetentionURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/retentions/{id}" + + id := swag.FormatInt64(o.ID) + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on UpdateRetentionURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *UpdateRetentionURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *UpdateRetentionURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *UpdateRetentionURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on UpdateRetentionURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on UpdateRetentionURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *UpdateRetentionURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/robot/create_robot.go b/src/server/v2.0/restapi/operations/robot/create_robot.go new file mode 100644 index 000000000..9961515c1 --- /dev/null +++ b/src/server/v2.0/restapi/operations/robot/create_robot.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package robot + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateRobotHandlerFunc turns a function with the right signature into a create robot handler +type CreateRobotHandlerFunc func(CreateRobotParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateRobotHandlerFunc) Handle(params CreateRobotParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateRobotHandler interface for that can handle valid create robot params +type CreateRobotHandler interface { + Handle(CreateRobotParams, interface{}) middleware.Responder +} + +// NewCreateRobot creates a new http.Handler for the create robot operation +func NewCreateRobot(ctx *middleware.Context, handler CreateRobotHandler) *CreateRobot { + return &CreateRobot{Context: ctx, Handler: handler} +} + +/*CreateRobot swagger:route POST /robots robot createRobot + +Create a robot account + +Create a robot account + +*/ +type CreateRobot struct { + Context *middleware.Context + Handler CreateRobotHandler +} + +func (o *CreateRobot) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewCreateRobotParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/robot/create_robot_parameters.go b/src/server/v2.0/restapi/operations/robot/create_robot_parameters.go new file mode 100644 index 000000000..a5cbba144 --- /dev/null +++ b/src/server/v2.0/restapi/operations/robot/create_robot_parameters.go @@ -0,0 +1,120 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package robot + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewCreateRobotParams creates a new CreateRobotParams object +// no default values defined in spec. +func NewCreateRobotParams() CreateRobotParams { + + return CreateRobotParams{} +} + +// CreateRobotParams contains all the bound params for the create robot operation +// typically these are obtained from a http.Request +// +// swagger:parameters CreateRobot +type CreateRobotParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The JSON object of a robot account. + Required: true + In: body + */ + Robot *models.RobotCreate +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateRobotParams() beforehand. +func (o *CreateRobotParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.RobotCreate + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("robot", "body", "")) + } else { + res = append(res, errors.NewParseError("robot", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Robot = &body + } + } + } else { + res = append(res, errors.Required("robot", "body", "")) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *CreateRobotParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *CreateRobotParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} diff --git a/src/server/v2.0/restapi/operations/robot/create_robot_responses.go b/src/server/v2.0/restapi/operations/robot/create_robot_responses.go new file mode 100644 index 000000000..9aff74f0b --- /dev/null +++ b/src/server/v2.0/restapi/operations/robot/create_robot_responses.go @@ -0,0 +1,432 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package robot + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// CreateRobotCreatedCode is the HTTP code returned for type CreateRobotCreated +const CreateRobotCreatedCode int = 201 + +/*CreateRobotCreated Created + +swagger:response createRobotCreated +*/ +type CreateRobotCreated struct { + /*The location of the resource + + */ + Location string `json:"Location"` + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.RobotCreated `json:"body,omitempty"` +} + +// NewCreateRobotCreated creates CreateRobotCreated with default headers values +func NewCreateRobotCreated() *CreateRobotCreated { + + return &CreateRobotCreated{} +} + +// WithLocation adds the location to the create robot created response +func (o *CreateRobotCreated) WithLocation(location string) *CreateRobotCreated { + o.Location = location + return o +} + +// SetLocation sets the location to the create robot created response +func (o *CreateRobotCreated) SetLocation(location string) { + o.Location = location +} + +// WithXRequestID adds the xRequestId to the create robot created response +func (o *CreateRobotCreated) WithXRequestID(xRequestID string) *CreateRobotCreated { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create robot created response +func (o *CreateRobotCreated) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create robot created response +func (o *CreateRobotCreated) WithPayload(payload *models.RobotCreated) *CreateRobotCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create robot created response +func (o *CreateRobotCreated) SetPayload(payload *models.RobotCreated) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateRobotCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Location + + location := o.Location + if location != "" { + rw.Header().Set("Location", location) + } + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateRobotBadRequestCode is the HTTP code returned for type CreateRobotBadRequest +const CreateRobotBadRequestCode int = 400 + +/*CreateRobotBadRequest Bad request + +swagger:response createRobotBadRequest +*/ +type CreateRobotBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateRobotBadRequest creates CreateRobotBadRequest with default headers values +func NewCreateRobotBadRequest() *CreateRobotBadRequest { + + return &CreateRobotBadRequest{} +} + +// WithXRequestID adds the xRequestId to the create robot bad request response +func (o *CreateRobotBadRequest) WithXRequestID(xRequestID string) *CreateRobotBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create robot bad request response +func (o *CreateRobotBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create robot bad request response +func (o *CreateRobotBadRequest) WithPayload(payload *models.Errors) *CreateRobotBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create robot bad request response +func (o *CreateRobotBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateRobotBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateRobotUnauthorizedCode is the HTTP code returned for type CreateRobotUnauthorized +const CreateRobotUnauthorizedCode int = 401 + +/*CreateRobotUnauthorized Unauthorized + +swagger:response createRobotUnauthorized +*/ +type CreateRobotUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateRobotUnauthorized creates CreateRobotUnauthorized with default headers values +func NewCreateRobotUnauthorized() *CreateRobotUnauthorized { + + return &CreateRobotUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the create robot unauthorized response +func (o *CreateRobotUnauthorized) WithXRequestID(xRequestID string) *CreateRobotUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create robot unauthorized response +func (o *CreateRobotUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create robot unauthorized response +func (o *CreateRobotUnauthorized) WithPayload(payload *models.Errors) *CreateRobotUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create robot unauthorized response +func (o *CreateRobotUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateRobotUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateRobotForbiddenCode is the HTTP code returned for type CreateRobotForbidden +const CreateRobotForbiddenCode int = 403 + +/*CreateRobotForbidden Forbidden + +swagger:response createRobotForbidden +*/ +type CreateRobotForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateRobotForbidden creates CreateRobotForbidden with default headers values +func NewCreateRobotForbidden() *CreateRobotForbidden { + + return &CreateRobotForbidden{} +} + +// WithXRequestID adds the xRequestId to the create robot forbidden response +func (o *CreateRobotForbidden) WithXRequestID(xRequestID string) *CreateRobotForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create robot forbidden response +func (o *CreateRobotForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create robot forbidden response +func (o *CreateRobotForbidden) WithPayload(payload *models.Errors) *CreateRobotForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create robot forbidden response +func (o *CreateRobotForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateRobotForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateRobotNotFoundCode is the HTTP code returned for type CreateRobotNotFound +const CreateRobotNotFoundCode int = 404 + +/*CreateRobotNotFound Not found + +swagger:response createRobotNotFound +*/ +type CreateRobotNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateRobotNotFound creates CreateRobotNotFound with default headers values +func NewCreateRobotNotFound() *CreateRobotNotFound { + + return &CreateRobotNotFound{} +} + +// WithXRequestID adds the xRequestId to the create robot not found response +func (o *CreateRobotNotFound) WithXRequestID(xRequestID string) *CreateRobotNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create robot not found response +func (o *CreateRobotNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create robot not found response +func (o *CreateRobotNotFound) WithPayload(payload *models.Errors) *CreateRobotNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create robot not found response +func (o *CreateRobotNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateRobotNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateRobotInternalServerErrorCode is the HTTP code returned for type CreateRobotInternalServerError +const CreateRobotInternalServerErrorCode int = 500 + +/*CreateRobotInternalServerError Internal server error + +swagger:response createRobotInternalServerError +*/ +type CreateRobotInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateRobotInternalServerError creates CreateRobotInternalServerError with default headers values +func NewCreateRobotInternalServerError() *CreateRobotInternalServerError { + + return &CreateRobotInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the create robot internal server error response +func (o *CreateRobotInternalServerError) WithXRequestID(xRequestID string) *CreateRobotInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create robot internal server error response +func (o *CreateRobotInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create robot internal server error response +func (o *CreateRobotInternalServerError) WithPayload(payload *models.Errors) *CreateRobotInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create robot internal server error response +func (o *CreateRobotInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateRobotInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/robot/create_robot_urlbuilder.go b/src/server/v2.0/restapi/operations/robot/create_robot_urlbuilder.go new file mode 100644 index 000000000..f742fbbad --- /dev/null +++ b/src/server/v2.0/restapi/operations/robot/create_robot_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package robot + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// CreateRobotURL generates an URL for the create robot operation +type CreateRobotURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateRobotURL) WithBasePath(bp string) *CreateRobotURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateRobotURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateRobotURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/robots" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateRobotURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateRobotURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateRobotURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateRobotURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateRobotURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateRobotURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/robot/delete_robot.go b/src/server/v2.0/restapi/operations/robot/delete_robot.go new file mode 100644 index 000000000..0da409df5 --- /dev/null +++ b/src/server/v2.0/restapi/operations/robot/delete_robot.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package robot + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteRobotHandlerFunc turns a function with the right signature into a delete robot handler +type DeleteRobotHandlerFunc func(DeleteRobotParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteRobotHandlerFunc) Handle(params DeleteRobotParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteRobotHandler interface for that can handle valid delete robot params +type DeleteRobotHandler interface { + Handle(DeleteRobotParams, interface{}) middleware.Responder +} + +// NewDeleteRobot creates a new http.Handler for the delete robot operation +func NewDeleteRobot(ctx *middleware.Context, handler DeleteRobotHandler) *DeleteRobot { + return &DeleteRobot{Context: ctx, Handler: handler} +} + +/*DeleteRobot swagger:route DELETE /robots/{robot_id} robot deleteRobot + +Delete a robot account + +This endpoint deletes specific robot account information by robot ID. + +*/ +type DeleteRobot struct { + Context *middleware.Context + Handler DeleteRobotHandler +} + +func (o *DeleteRobot) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewDeleteRobotParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/robot/delete_robot_parameters.go b/src/server/v2.0/restapi/operations/robot/delete_robot_parameters.go new file mode 100644 index 000000000..278260693 --- /dev/null +++ b/src/server/v2.0/restapi/operations/robot/delete_robot_parameters.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package robot + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewDeleteRobotParams creates a new DeleteRobotParams object +// no default values defined in spec. +func NewDeleteRobotParams() DeleteRobotParams { + + return DeleteRobotParams{} +} + +// DeleteRobotParams contains all the bound params for the delete robot operation +// typically these are obtained from a http.Request +// +// swagger:parameters DeleteRobot +type DeleteRobotParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*Robot ID + Required: true + In: path + */ + RobotID int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteRobotParams() beforehand. +func (o *DeleteRobotParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rRobotID, rhkRobotID, _ := route.Params.GetOK("robot_id") + if err := o.bindRobotID(rRobotID, rhkRobotID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *DeleteRobotParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *DeleteRobotParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindRobotID binds and validates parameter RobotID from path. +func (o *DeleteRobotParams) bindRobotID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("robot_id", "path", "int64", raw) + } + o.RobotID = value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/robot/delete_robot_responses.go b/src/server/v2.0/restapi/operations/robot/delete_robot_responses.go new file mode 100644 index 000000000..bb70fb398 --- /dev/null +++ b/src/server/v2.0/restapi/operations/robot/delete_robot_responses.go @@ -0,0 +1,390 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package robot + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// DeleteRobotOKCode is the HTTP code returned for type DeleteRobotOK +const DeleteRobotOKCode int = 200 + +/*DeleteRobotOK Success + +swagger:response deleteRobotOK +*/ +type DeleteRobotOK struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewDeleteRobotOK creates DeleteRobotOK with default headers values +func NewDeleteRobotOK() *DeleteRobotOK { + + return &DeleteRobotOK{} +} + +// WithXRequestID adds the xRequestId to the delete robot o k response +func (o *DeleteRobotOK) WithXRequestID(xRequestID string) *DeleteRobotOK { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete robot o k response +func (o *DeleteRobotOK) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *DeleteRobotOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// DeleteRobotBadRequestCode is the HTTP code returned for type DeleteRobotBadRequest +const DeleteRobotBadRequestCode int = 400 + +/*DeleteRobotBadRequest Bad request + +swagger:response deleteRobotBadRequest +*/ +type DeleteRobotBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteRobotBadRequest creates DeleteRobotBadRequest with default headers values +func NewDeleteRobotBadRequest() *DeleteRobotBadRequest { + + return &DeleteRobotBadRequest{} +} + +// WithXRequestID adds the xRequestId to the delete robot bad request response +func (o *DeleteRobotBadRequest) WithXRequestID(xRequestID string) *DeleteRobotBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete robot bad request response +func (o *DeleteRobotBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete robot bad request response +func (o *DeleteRobotBadRequest) WithPayload(payload *models.Errors) *DeleteRobotBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete robot bad request response +func (o *DeleteRobotBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteRobotBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteRobotUnauthorizedCode is the HTTP code returned for type DeleteRobotUnauthorized +const DeleteRobotUnauthorizedCode int = 401 + +/*DeleteRobotUnauthorized Unauthorized + +swagger:response deleteRobotUnauthorized +*/ +type DeleteRobotUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteRobotUnauthorized creates DeleteRobotUnauthorized with default headers values +func NewDeleteRobotUnauthorized() *DeleteRobotUnauthorized { + + return &DeleteRobotUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the delete robot unauthorized response +func (o *DeleteRobotUnauthorized) WithXRequestID(xRequestID string) *DeleteRobotUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete robot unauthorized response +func (o *DeleteRobotUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete robot unauthorized response +func (o *DeleteRobotUnauthorized) WithPayload(payload *models.Errors) *DeleteRobotUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete robot unauthorized response +func (o *DeleteRobotUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteRobotUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteRobotForbiddenCode is the HTTP code returned for type DeleteRobotForbidden +const DeleteRobotForbiddenCode int = 403 + +/*DeleteRobotForbidden Forbidden + +swagger:response deleteRobotForbidden +*/ +type DeleteRobotForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteRobotForbidden creates DeleteRobotForbidden with default headers values +func NewDeleteRobotForbidden() *DeleteRobotForbidden { + + return &DeleteRobotForbidden{} +} + +// WithXRequestID adds the xRequestId to the delete robot forbidden response +func (o *DeleteRobotForbidden) WithXRequestID(xRequestID string) *DeleteRobotForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete robot forbidden response +func (o *DeleteRobotForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete robot forbidden response +func (o *DeleteRobotForbidden) WithPayload(payload *models.Errors) *DeleteRobotForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete robot forbidden response +func (o *DeleteRobotForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteRobotForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteRobotNotFoundCode is the HTTP code returned for type DeleteRobotNotFound +const DeleteRobotNotFoundCode int = 404 + +/*DeleteRobotNotFound Not found + +swagger:response deleteRobotNotFound +*/ +type DeleteRobotNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteRobotNotFound creates DeleteRobotNotFound with default headers values +func NewDeleteRobotNotFound() *DeleteRobotNotFound { + + return &DeleteRobotNotFound{} +} + +// WithXRequestID adds the xRequestId to the delete robot not found response +func (o *DeleteRobotNotFound) WithXRequestID(xRequestID string) *DeleteRobotNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete robot not found response +func (o *DeleteRobotNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete robot not found response +func (o *DeleteRobotNotFound) WithPayload(payload *models.Errors) *DeleteRobotNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete robot not found response +func (o *DeleteRobotNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteRobotNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteRobotInternalServerErrorCode is the HTTP code returned for type DeleteRobotInternalServerError +const DeleteRobotInternalServerErrorCode int = 500 + +/*DeleteRobotInternalServerError Internal server error + +swagger:response deleteRobotInternalServerError +*/ +type DeleteRobotInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteRobotInternalServerError creates DeleteRobotInternalServerError with default headers values +func NewDeleteRobotInternalServerError() *DeleteRobotInternalServerError { + + return &DeleteRobotInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the delete robot internal server error response +func (o *DeleteRobotInternalServerError) WithXRequestID(xRequestID string) *DeleteRobotInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete robot internal server error response +func (o *DeleteRobotInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete robot internal server error response +func (o *DeleteRobotInternalServerError) WithPayload(payload *models.Errors) *DeleteRobotInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete robot internal server error response +func (o *DeleteRobotInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteRobotInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/robot/delete_robot_urlbuilder.go b/src/server/v2.0/restapi/operations/robot/delete_robot_urlbuilder.go new file mode 100644 index 000000000..311c54a7d --- /dev/null +++ b/src/server/v2.0/restapi/operations/robot/delete_robot_urlbuilder.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package robot + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteRobotURL generates an URL for the delete robot operation +type DeleteRobotURL struct { + RobotID int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteRobotURL) WithBasePath(bp string) *DeleteRobotURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteRobotURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteRobotURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/robots/{robot_id}" + + robotID := swag.FormatInt64(o.RobotID) + if robotID != "" { + _path = strings.Replace(_path, "{robot_id}", robotID, -1) + } else { + return nil, errors.New("robotId is required on DeleteRobotURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteRobotURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteRobotURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteRobotURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteRobotURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteRobotURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteRobotURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/robot/get_robot_by_id.go b/src/server/v2.0/restapi/operations/robot/get_robot_by_id.go new file mode 100644 index 000000000..525fc6e7d --- /dev/null +++ b/src/server/v2.0/restapi/operations/robot/get_robot_by_id.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package robot + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetRobotByIDHandlerFunc turns a function with the right signature into a get robot by ID handler +type GetRobotByIDHandlerFunc func(GetRobotByIDParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetRobotByIDHandlerFunc) Handle(params GetRobotByIDParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetRobotByIDHandler interface for that can handle valid get robot by ID params +type GetRobotByIDHandler interface { + Handle(GetRobotByIDParams, interface{}) middleware.Responder +} + +// NewGetRobotByID creates a new http.Handler for the get robot by ID operation +func NewGetRobotByID(ctx *middleware.Context, handler GetRobotByIDHandler) *GetRobotByID { + return &GetRobotByID{Context: ctx, Handler: handler} +} + +/*GetRobotByID swagger:route GET /robots/{robot_id} robot getRobotById + +Get a robot account + +This endpoint returns specific robot account information by robot ID. + +*/ +type GetRobotByID struct { + Context *middleware.Context + Handler GetRobotByIDHandler +} + +func (o *GetRobotByID) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetRobotByIDParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/robot/get_robot_by_id_parameters.go b/src/server/v2.0/restapi/operations/robot/get_robot_by_id_parameters.go new file mode 100644 index 000000000..d6426b61b --- /dev/null +++ b/src/server/v2.0/restapi/operations/robot/get_robot_by_id_parameters.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package robot + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewGetRobotByIDParams creates a new GetRobotByIDParams object +// no default values defined in spec. +func NewGetRobotByIDParams() GetRobotByIDParams { + + return GetRobotByIDParams{} +} + +// GetRobotByIDParams contains all the bound params for the get robot by ID operation +// typically these are obtained from a http.Request +// +// swagger:parameters GetRobotByID +type GetRobotByIDParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*Robot ID + Required: true + In: path + */ + RobotID int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetRobotByIDParams() beforehand. +func (o *GetRobotByIDParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rRobotID, rhkRobotID, _ := route.Params.GetOK("robot_id") + if err := o.bindRobotID(rRobotID, rhkRobotID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetRobotByIDParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetRobotByIDParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindRobotID binds and validates parameter RobotID from path. +func (o *GetRobotByIDParams) bindRobotID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("robot_id", "path", "int64", raw) + } + o.RobotID = value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/robot/get_robot_by_id_responses.go b/src/server/v2.0/restapi/operations/robot/get_robot_by_id_responses.go new file mode 100644 index 000000000..656220d41 --- /dev/null +++ b/src/server/v2.0/restapi/operations/robot/get_robot_by_id_responses.go @@ -0,0 +1,322 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package robot + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetRobotByIDOKCode is the HTTP code returned for type GetRobotByIDOK +const GetRobotByIDOKCode int = 200 + +/*GetRobotByIDOK Return matched robot information. + +swagger:response getRobotByIdOK +*/ +type GetRobotByIDOK struct { + + /* + In: Body + */ + Payload *models.Robot `json:"body,omitempty"` +} + +// NewGetRobotByIDOK creates GetRobotByIDOK with default headers values +func NewGetRobotByIDOK() *GetRobotByIDOK { + + return &GetRobotByIDOK{} +} + +// WithPayload adds the payload to the get robot by Id o k response +func (o *GetRobotByIDOK) WithPayload(payload *models.Robot) *GetRobotByIDOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get robot by Id o k response +func (o *GetRobotByIDOK) SetPayload(payload *models.Robot) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetRobotByIDOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetRobotByIDUnauthorizedCode is the HTTP code returned for type GetRobotByIDUnauthorized +const GetRobotByIDUnauthorizedCode int = 401 + +/*GetRobotByIDUnauthorized Unauthorized + +swagger:response getRobotByIdUnauthorized +*/ +type GetRobotByIDUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetRobotByIDUnauthorized creates GetRobotByIDUnauthorized with default headers values +func NewGetRobotByIDUnauthorized() *GetRobotByIDUnauthorized { + + return &GetRobotByIDUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the get robot by Id unauthorized response +func (o *GetRobotByIDUnauthorized) WithXRequestID(xRequestID string) *GetRobotByIDUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get robot by Id unauthorized response +func (o *GetRobotByIDUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get robot by Id unauthorized response +func (o *GetRobotByIDUnauthorized) WithPayload(payload *models.Errors) *GetRobotByIDUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get robot by Id unauthorized response +func (o *GetRobotByIDUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetRobotByIDUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetRobotByIDForbiddenCode is the HTTP code returned for type GetRobotByIDForbidden +const GetRobotByIDForbiddenCode int = 403 + +/*GetRobotByIDForbidden Forbidden + +swagger:response getRobotByIdForbidden +*/ +type GetRobotByIDForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetRobotByIDForbidden creates GetRobotByIDForbidden with default headers values +func NewGetRobotByIDForbidden() *GetRobotByIDForbidden { + + return &GetRobotByIDForbidden{} +} + +// WithXRequestID adds the xRequestId to the get robot by Id forbidden response +func (o *GetRobotByIDForbidden) WithXRequestID(xRequestID string) *GetRobotByIDForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get robot by Id forbidden response +func (o *GetRobotByIDForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get robot by Id forbidden response +func (o *GetRobotByIDForbidden) WithPayload(payload *models.Errors) *GetRobotByIDForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get robot by Id forbidden response +func (o *GetRobotByIDForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetRobotByIDForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetRobotByIDNotFoundCode is the HTTP code returned for type GetRobotByIDNotFound +const GetRobotByIDNotFoundCode int = 404 + +/*GetRobotByIDNotFound Not found + +swagger:response getRobotByIdNotFound +*/ +type GetRobotByIDNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetRobotByIDNotFound creates GetRobotByIDNotFound with default headers values +func NewGetRobotByIDNotFound() *GetRobotByIDNotFound { + + return &GetRobotByIDNotFound{} +} + +// WithXRequestID adds the xRequestId to the get robot by Id not found response +func (o *GetRobotByIDNotFound) WithXRequestID(xRequestID string) *GetRobotByIDNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get robot by Id not found response +func (o *GetRobotByIDNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get robot by Id not found response +func (o *GetRobotByIDNotFound) WithPayload(payload *models.Errors) *GetRobotByIDNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get robot by Id not found response +func (o *GetRobotByIDNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetRobotByIDNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetRobotByIDInternalServerErrorCode is the HTTP code returned for type GetRobotByIDInternalServerError +const GetRobotByIDInternalServerErrorCode int = 500 + +/*GetRobotByIDInternalServerError Internal server error + +swagger:response getRobotByIdInternalServerError +*/ +type GetRobotByIDInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetRobotByIDInternalServerError creates GetRobotByIDInternalServerError with default headers values +func NewGetRobotByIDInternalServerError() *GetRobotByIDInternalServerError { + + return &GetRobotByIDInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get robot by Id internal server error response +func (o *GetRobotByIDInternalServerError) WithXRequestID(xRequestID string) *GetRobotByIDInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get robot by Id internal server error response +func (o *GetRobotByIDInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get robot by Id internal server error response +func (o *GetRobotByIDInternalServerError) WithPayload(payload *models.Errors) *GetRobotByIDInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get robot by Id internal server error response +func (o *GetRobotByIDInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetRobotByIDInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/robot/get_robot_by_id_urlbuilder.go b/src/server/v2.0/restapi/operations/robot/get_robot_by_id_urlbuilder.go new file mode 100644 index 000000000..b67bf828f --- /dev/null +++ b/src/server/v2.0/restapi/operations/robot/get_robot_by_id_urlbuilder.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package robot + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetRobotByIDURL generates an URL for the get robot by ID operation +type GetRobotByIDURL struct { + RobotID int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetRobotByIDURL) WithBasePath(bp string) *GetRobotByIDURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetRobotByIDURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetRobotByIDURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/robots/{robot_id}" + + robotID := swag.FormatInt64(o.RobotID) + if robotID != "" { + _path = strings.Replace(_path, "{robot_id}", robotID, -1) + } else { + return nil, errors.New("robotId is required on GetRobotByIDURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetRobotByIDURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetRobotByIDURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetRobotByIDURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetRobotByIDURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetRobotByIDURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetRobotByIDURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/robot/list_robot.go b/src/server/v2.0/restapi/operations/robot/list_robot.go new file mode 100644 index 000000000..ee0c2b2c5 --- /dev/null +++ b/src/server/v2.0/restapi/operations/robot/list_robot.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package robot + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ListRobotHandlerFunc turns a function with the right signature into a list robot handler +type ListRobotHandlerFunc func(ListRobotParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ListRobotHandlerFunc) Handle(params ListRobotParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ListRobotHandler interface for that can handle valid list robot params +type ListRobotHandler interface { + Handle(ListRobotParams, interface{}) middleware.Responder +} + +// NewListRobot creates a new http.Handler for the list robot operation +func NewListRobot(ctx *middleware.Context, handler ListRobotHandler) *ListRobot { + return &ListRobot{Context: ctx, Handler: handler} +} + +/*ListRobot swagger:route GET /robots robot listRobot + +Get robot account + +List the robot accounts with the specified level and project. + +*/ +type ListRobot struct { + Context *middleware.Context + Handler ListRobotHandler +} + +func (o *ListRobot) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewListRobotParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/robot/list_robot_parameters.go b/src/server/v2.0/restapi/operations/robot/list_robot_parameters.go new file mode 100644 index 000000000..3b0ad9705 --- /dev/null +++ b/src/server/v2.0/restapi/operations/robot/list_robot_parameters.go @@ -0,0 +1,239 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package robot + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewListRobotParams creates a new ListRobotParams object +// with the default values initialized. +func NewListRobotParams() ListRobotParams { + + var ( + // initialize parameters with default values + + pageDefault = int64(1) + pageSizeDefault = int64(10) + ) + + return ListRobotParams{ + Page: &pageDefault, + + PageSize: &pageSizeDefault, + } +} + +// ListRobotParams contains all the bound params for the list robot operation +// typically these are obtained from a http.Request +// +// swagger:parameters ListRobot +type ListRobotParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The page number + In: query + Default: 1 + */ + Page *int64 + /*The size of per page + Maximum: 100 + In: query + Default: 10 + */ + PageSize *int64 + /*Query string to query resources. Supported query patterns are "exact match(k=v)", "fuzzy match(k=~v)", "range(k=[min~max])", "list with union releationship(k={v1 v2 v3})" and "list with intersetion relationship(k=(v1 v2 v3))". The value of range and list can be string(enclosed by " or '), integer or time(in format "2020-04-09 02:36:00"). All of these query patterns should be put in the query string "q=xxx" and splitted by ",". e.g. q=k1=v1,k2=~v2,k3=[min~max] + In: query + */ + Q *string + /*Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + In: query + */ + Sort *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewListRobotParams() beforehand. +func (o *ListRobotParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + qPage, qhkPage, _ := qs.GetOK("page") + if err := o.bindPage(qPage, qhkPage, route.Formats); err != nil { + res = append(res, err) + } + + qPageSize, qhkPageSize, _ := qs.GetOK("page_size") + if err := o.bindPageSize(qPageSize, qhkPageSize, route.Formats); err != nil { + res = append(res, err) + } + + qQ, qhkQ, _ := qs.GetOK("q") + if err := o.bindQ(qQ, qhkQ, route.Formats); err != nil { + res = append(res, err) + } + + qSort, qhkSort, _ := qs.GetOK("sort") + if err := o.bindSort(qSort, qhkSort, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *ListRobotParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *ListRobotParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindPage binds and validates parameter Page from query. +func (o *ListRobotParams) bindPage(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListRobotParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page", "query", "int64", raw) + } + o.Page = &value + + return nil +} + +// bindPageSize binds and validates parameter PageSize from query. +func (o *ListRobotParams) bindPageSize(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListRobotParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page_size", "query", "int64", raw) + } + o.PageSize = &value + + if err := o.validatePageSize(formats); err != nil { + return err + } + + return nil +} + +// validatePageSize carries on validations for parameter PageSize +func (o *ListRobotParams) validatePageSize(formats strfmt.Registry) error { + + if err := validate.MaximumInt("page_size", "query", int64(*o.PageSize), 100, false); err != nil { + return err + } + + return nil +} + +// bindQ binds and validates parameter Q from query. +func (o *ListRobotParams) bindQ(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Q = &raw + + return nil +} + +// bindSort binds and validates parameter Sort from query. +func (o *ListRobotParams) bindSort(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Sort = &raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/robot/list_robot_responses.go b/src/server/v2.0/restapi/operations/robot/list_robot_responses.go new file mode 100644 index 000000000..541efd362 --- /dev/null +++ b/src/server/v2.0/restapi/operations/robot/list_robot_responses.go @@ -0,0 +1,304 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package robot + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/swag" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// ListRobotOKCode is the HTTP code returned for type ListRobotOK +const ListRobotOKCode int = 200 + +/*ListRobotOK Success + +swagger:response listRobotOK +*/ +type ListRobotOK struct { + /*Link refers to the previous page and next page + + */ + Link string `json:"Link"` + /*The total count of robot accounts + + */ + XTotalCount int64 `json:"X-Total-Count"` + + /* + In: Body + */ + Payload []*models.Robot `json:"body,omitempty"` +} + +// NewListRobotOK creates ListRobotOK with default headers values +func NewListRobotOK() *ListRobotOK { + + return &ListRobotOK{} +} + +// WithLink adds the link to the list robot o k response +func (o *ListRobotOK) WithLink(link string) *ListRobotOK { + o.Link = link + return o +} + +// SetLink sets the link to the list robot o k response +func (o *ListRobotOK) SetLink(link string) { + o.Link = link +} + +// WithXTotalCount adds the xTotalCount to the list robot o k response +func (o *ListRobotOK) WithXTotalCount(xTotalCount int64) *ListRobotOK { + o.XTotalCount = xTotalCount + return o +} + +// SetXTotalCount sets the xTotalCount to the list robot o k response +func (o *ListRobotOK) SetXTotalCount(xTotalCount int64) { + o.XTotalCount = xTotalCount +} + +// WithPayload adds the payload to the list robot o k response +func (o *ListRobotOK) WithPayload(payload []*models.Robot) *ListRobotOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list robot o k response +func (o *ListRobotOK) SetPayload(payload []*models.Robot) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListRobotOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Link + + link := o.Link + if link != "" { + rw.Header().Set("Link", link) + } + + // response header X-Total-Count + + xTotalCount := swag.FormatInt64(o.XTotalCount) + if xTotalCount != "" { + rw.Header().Set("X-Total-Count", xTotalCount) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = make([]*models.Robot, 0, 50) + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ListRobotBadRequestCode is the HTTP code returned for type ListRobotBadRequest +const ListRobotBadRequestCode int = 400 + +/*ListRobotBadRequest Bad request + +swagger:response listRobotBadRequest +*/ +type ListRobotBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListRobotBadRequest creates ListRobotBadRequest with default headers values +func NewListRobotBadRequest() *ListRobotBadRequest { + + return &ListRobotBadRequest{} +} + +// WithXRequestID adds the xRequestId to the list robot bad request response +func (o *ListRobotBadRequest) WithXRequestID(xRequestID string) *ListRobotBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list robot bad request response +func (o *ListRobotBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list robot bad request response +func (o *ListRobotBadRequest) WithPayload(payload *models.Errors) *ListRobotBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list robot bad request response +func (o *ListRobotBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListRobotBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListRobotNotFoundCode is the HTTP code returned for type ListRobotNotFound +const ListRobotNotFoundCode int = 404 + +/*ListRobotNotFound Not found + +swagger:response listRobotNotFound +*/ +type ListRobotNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListRobotNotFound creates ListRobotNotFound with default headers values +func NewListRobotNotFound() *ListRobotNotFound { + + return &ListRobotNotFound{} +} + +// WithXRequestID adds the xRequestId to the list robot not found response +func (o *ListRobotNotFound) WithXRequestID(xRequestID string) *ListRobotNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list robot not found response +func (o *ListRobotNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list robot not found response +func (o *ListRobotNotFound) WithPayload(payload *models.Errors) *ListRobotNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list robot not found response +func (o *ListRobotNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListRobotNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListRobotInternalServerErrorCode is the HTTP code returned for type ListRobotInternalServerError +const ListRobotInternalServerErrorCode int = 500 + +/*ListRobotInternalServerError Internal server error + +swagger:response listRobotInternalServerError +*/ +type ListRobotInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListRobotInternalServerError creates ListRobotInternalServerError with default headers values +func NewListRobotInternalServerError() *ListRobotInternalServerError { + + return &ListRobotInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the list robot internal server error response +func (o *ListRobotInternalServerError) WithXRequestID(xRequestID string) *ListRobotInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list robot internal server error response +func (o *ListRobotInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list robot internal server error response +func (o *ListRobotInternalServerError) WithPayload(payload *models.Errors) *ListRobotInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list robot internal server error response +func (o *ListRobotInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListRobotInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/robot/list_robot_urlbuilder.go b/src/server/v2.0/restapi/operations/robot/list_robot_urlbuilder.go new file mode 100644 index 000000000..6b3086f3a --- /dev/null +++ b/src/server/v2.0/restapi/operations/robot/list_robot_urlbuilder.go @@ -0,0 +1,132 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package robot + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// ListRobotURL generates an URL for the list robot operation +type ListRobotURL struct { + Page *int64 + PageSize *int64 + Q *string + Sort *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListRobotURL) WithBasePath(bp string) *ListRobotURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListRobotURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ListRobotURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/robots" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var pageQ string + if o.Page != nil { + pageQ = swag.FormatInt64(*o.Page) + } + if pageQ != "" { + qs.Set("page", pageQ) + } + + var pageSizeQ string + if o.PageSize != nil { + pageSizeQ = swag.FormatInt64(*o.PageSize) + } + if pageSizeQ != "" { + qs.Set("page_size", pageSizeQ) + } + + var qQ string + if o.Q != nil { + qQ = *o.Q + } + if qQ != "" { + qs.Set("q", qQ) + } + + var sortQ string + if o.Sort != nil { + sortQ = *o.Sort + } + if sortQ != "" { + qs.Set("sort", sortQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ListRobotURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ListRobotURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ListRobotURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ListRobotURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ListRobotURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ListRobotURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/robot/refresh_sec.go b/src/server/v2.0/restapi/operations/robot/refresh_sec.go new file mode 100644 index 000000000..08613168f --- /dev/null +++ b/src/server/v2.0/restapi/operations/robot/refresh_sec.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package robot + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// RefreshSecHandlerFunc turns a function with the right signature into a refresh sec handler +type RefreshSecHandlerFunc func(RefreshSecParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn RefreshSecHandlerFunc) Handle(params RefreshSecParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// RefreshSecHandler interface for that can handle valid refresh sec params +type RefreshSecHandler interface { + Handle(RefreshSecParams, interface{}) middleware.Responder +} + +// NewRefreshSec creates a new http.Handler for the refresh sec operation +func NewRefreshSec(ctx *middleware.Context, handler RefreshSecHandler) *RefreshSec { + return &RefreshSec{Context: ctx, Handler: handler} +} + +/*RefreshSec swagger:route PATCH /robots/{robot_id} robot refreshSec + +Refresh the robot secret + +Refresh the robot secret + +*/ +type RefreshSec struct { + Context *middleware.Context + Handler RefreshSecHandler +} + +func (o *RefreshSec) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewRefreshSecParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/robot/refresh_sec_parameters.go b/src/server/v2.0/restapi/operations/robot/refresh_sec_parameters.go new file mode 100644 index 000000000..cbbcf1b1c --- /dev/null +++ b/src/server/v2.0/restapi/operations/robot/refresh_sec_parameters.go @@ -0,0 +1,150 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package robot + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewRefreshSecParams creates a new RefreshSecParams object +// no default values defined in spec. +func NewRefreshSecParams() RefreshSecParams { + + return RefreshSecParams{} +} + +// RefreshSecParams contains all the bound params for the refresh sec operation +// typically these are obtained from a http.Request +// +// swagger:parameters RefreshSec +type RefreshSecParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The JSON object of a robot account. + Required: true + In: body + */ + RobotSec *models.RobotSec + /*Robot ID + Required: true + In: path + */ + RobotID int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewRefreshSecParams() beforehand. +func (o *RefreshSecParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.RobotSec + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("robotSec", "body", "")) + } else { + res = append(res, errors.NewParseError("robotSec", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.RobotSec = &body + } + } + } else { + res = append(res, errors.Required("robotSec", "body", "")) + } + rRobotID, rhkRobotID, _ := route.Params.GetOK("robot_id") + if err := o.bindRobotID(rRobotID, rhkRobotID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *RefreshSecParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *RefreshSecParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindRobotID binds and validates parameter RobotID from path. +func (o *RefreshSecParams) bindRobotID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("robot_id", "path", "int64", raw) + } + o.RobotID = value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/robot/refresh_sec_responses.go b/src/server/v2.0/restapi/operations/robot/refresh_sec_responses.go new file mode 100644 index 000000000..b145d8b4b --- /dev/null +++ b/src/server/v2.0/restapi/operations/robot/refresh_sec_responses.go @@ -0,0 +1,388 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package robot + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// RefreshSecOKCode is the HTTP code returned for type RefreshSecOK +const RefreshSecOKCode int = 200 + +/*RefreshSecOK Return refreshed robot sec. + +swagger:response refreshSecOK +*/ +type RefreshSecOK struct { + + /* + In: Body + */ + Payload *models.RobotSec `json:"body,omitempty"` +} + +// NewRefreshSecOK creates RefreshSecOK with default headers values +func NewRefreshSecOK() *RefreshSecOK { + + return &RefreshSecOK{} +} + +// WithPayload adds the payload to the refresh sec o k response +func (o *RefreshSecOK) WithPayload(payload *models.RobotSec) *RefreshSecOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the refresh sec o k response +func (o *RefreshSecOK) SetPayload(payload *models.RobotSec) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *RefreshSecOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// RefreshSecBadRequestCode is the HTTP code returned for type RefreshSecBadRequest +const RefreshSecBadRequestCode int = 400 + +/*RefreshSecBadRequest Bad request + +swagger:response refreshSecBadRequest +*/ +type RefreshSecBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewRefreshSecBadRequest creates RefreshSecBadRequest with default headers values +func NewRefreshSecBadRequest() *RefreshSecBadRequest { + + return &RefreshSecBadRequest{} +} + +// WithXRequestID adds the xRequestId to the refresh sec bad request response +func (o *RefreshSecBadRequest) WithXRequestID(xRequestID string) *RefreshSecBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the refresh sec bad request response +func (o *RefreshSecBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the refresh sec bad request response +func (o *RefreshSecBadRequest) WithPayload(payload *models.Errors) *RefreshSecBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the refresh sec bad request response +func (o *RefreshSecBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *RefreshSecBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// RefreshSecUnauthorizedCode is the HTTP code returned for type RefreshSecUnauthorized +const RefreshSecUnauthorizedCode int = 401 + +/*RefreshSecUnauthorized Unauthorized + +swagger:response refreshSecUnauthorized +*/ +type RefreshSecUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewRefreshSecUnauthorized creates RefreshSecUnauthorized with default headers values +func NewRefreshSecUnauthorized() *RefreshSecUnauthorized { + + return &RefreshSecUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the refresh sec unauthorized response +func (o *RefreshSecUnauthorized) WithXRequestID(xRequestID string) *RefreshSecUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the refresh sec unauthorized response +func (o *RefreshSecUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the refresh sec unauthorized response +func (o *RefreshSecUnauthorized) WithPayload(payload *models.Errors) *RefreshSecUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the refresh sec unauthorized response +func (o *RefreshSecUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *RefreshSecUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// RefreshSecForbiddenCode is the HTTP code returned for type RefreshSecForbidden +const RefreshSecForbiddenCode int = 403 + +/*RefreshSecForbidden Forbidden + +swagger:response refreshSecForbidden +*/ +type RefreshSecForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewRefreshSecForbidden creates RefreshSecForbidden with default headers values +func NewRefreshSecForbidden() *RefreshSecForbidden { + + return &RefreshSecForbidden{} +} + +// WithXRequestID adds the xRequestId to the refresh sec forbidden response +func (o *RefreshSecForbidden) WithXRequestID(xRequestID string) *RefreshSecForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the refresh sec forbidden response +func (o *RefreshSecForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the refresh sec forbidden response +func (o *RefreshSecForbidden) WithPayload(payload *models.Errors) *RefreshSecForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the refresh sec forbidden response +func (o *RefreshSecForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *RefreshSecForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// RefreshSecNotFoundCode is the HTTP code returned for type RefreshSecNotFound +const RefreshSecNotFoundCode int = 404 + +/*RefreshSecNotFound Not found + +swagger:response refreshSecNotFound +*/ +type RefreshSecNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewRefreshSecNotFound creates RefreshSecNotFound with default headers values +func NewRefreshSecNotFound() *RefreshSecNotFound { + + return &RefreshSecNotFound{} +} + +// WithXRequestID adds the xRequestId to the refresh sec not found response +func (o *RefreshSecNotFound) WithXRequestID(xRequestID string) *RefreshSecNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the refresh sec not found response +func (o *RefreshSecNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the refresh sec not found response +func (o *RefreshSecNotFound) WithPayload(payload *models.Errors) *RefreshSecNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the refresh sec not found response +func (o *RefreshSecNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *RefreshSecNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// RefreshSecInternalServerErrorCode is the HTTP code returned for type RefreshSecInternalServerError +const RefreshSecInternalServerErrorCode int = 500 + +/*RefreshSecInternalServerError Internal server error + +swagger:response refreshSecInternalServerError +*/ +type RefreshSecInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewRefreshSecInternalServerError creates RefreshSecInternalServerError with default headers values +func NewRefreshSecInternalServerError() *RefreshSecInternalServerError { + + return &RefreshSecInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the refresh sec internal server error response +func (o *RefreshSecInternalServerError) WithXRequestID(xRequestID string) *RefreshSecInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the refresh sec internal server error response +func (o *RefreshSecInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the refresh sec internal server error response +func (o *RefreshSecInternalServerError) WithPayload(payload *models.Errors) *RefreshSecInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the refresh sec internal server error response +func (o *RefreshSecInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *RefreshSecInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/robot/refresh_sec_urlbuilder.go b/src/server/v2.0/restapi/operations/robot/refresh_sec_urlbuilder.go new file mode 100644 index 000000000..6d7c27c9e --- /dev/null +++ b/src/server/v2.0/restapi/operations/robot/refresh_sec_urlbuilder.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package robot + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// RefreshSecURL generates an URL for the refresh sec operation +type RefreshSecURL struct { + RobotID int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *RefreshSecURL) WithBasePath(bp string) *RefreshSecURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *RefreshSecURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *RefreshSecURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/robots/{robot_id}" + + robotID := swag.FormatInt64(o.RobotID) + if robotID != "" { + _path = strings.Replace(_path, "{robot_id}", robotID, -1) + } else { + return nil, errors.New("robotId is required on RefreshSecURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *RefreshSecURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *RefreshSecURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *RefreshSecURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on RefreshSecURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on RefreshSecURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *RefreshSecURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/robot/update_robot.go b/src/server/v2.0/restapi/operations/robot/update_robot.go new file mode 100644 index 000000000..281ea29fe --- /dev/null +++ b/src/server/v2.0/restapi/operations/robot/update_robot.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package robot + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// UpdateRobotHandlerFunc turns a function with the right signature into a update robot handler +type UpdateRobotHandlerFunc func(UpdateRobotParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn UpdateRobotHandlerFunc) Handle(params UpdateRobotParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// UpdateRobotHandler interface for that can handle valid update robot params +type UpdateRobotHandler interface { + Handle(UpdateRobotParams, interface{}) middleware.Responder +} + +// NewUpdateRobot creates a new http.Handler for the update robot operation +func NewUpdateRobot(ctx *middleware.Context, handler UpdateRobotHandler) *UpdateRobot { + return &UpdateRobot{Context: ctx, Handler: handler} +} + +/*UpdateRobot swagger:route PUT /robots/{robot_id} robot updateRobot + +Update a robot account + +This endpoint updates specific robot account information by robot ID. + +*/ +type UpdateRobot struct { + Context *middleware.Context + Handler UpdateRobotHandler +} + +func (o *UpdateRobot) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewUpdateRobotParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/robot/update_robot_parameters.go b/src/server/v2.0/restapi/operations/robot/update_robot_parameters.go new file mode 100644 index 000000000..70d49283e --- /dev/null +++ b/src/server/v2.0/restapi/operations/robot/update_robot_parameters.go @@ -0,0 +1,150 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package robot + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewUpdateRobotParams creates a new UpdateRobotParams object +// no default values defined in spec. +func NewUpdateRobotParams() UpdateRobotParams { + + return UpdateRobotParams{} +} + +// UpdateRobotParams contains all the bound params for the update robot operation +// typically these are obtained from a http.Request +// +// swagger:parameters UpdateRobot +type UpdateRobotParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The JSON object of a robot account. + Required: true + In: body + */ + Robot *models.Robot + /*Robot ID + Required: true + In: path + */ + RobotID int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewUpdateRobotParams() beforehand. +func (o *UpdateRobotParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Robot + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("robot", "body", "")) + } else { + res = append(res, errors.NewParseError("robot", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Robot = &body + } + } + } else { + res = append(res, errors.Required("robot", "body", "")) + } + rRobotID, rhkRobotID, _ := route.Params.GetOK("robot_id") + if err := o.bindRobotID(rRobotID, rhkRobotID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *UpdateRobotParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *UpdateRobotParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindRobotID binds and validates parameter RobotID from path. +func (o *UpdateRobotParams) bindRobotID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("robot_id", "path", "int64", raw) + } + o.RobotID = value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/robot/update_robot_responses.go b/src/server/v2.0/restapi/operations/robot/update_robot_responses.go new file mode 100644 index 000000000..5f99434b4 --- /dev/null +++ b/src/server/v2.0/restapi/operations/robot/update_robot_responses.go @@ -0,0 +1,456 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package robot + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// UpdateRobotOKCode is the HTTP code returned for type UpdateRobotOK +const UpdateRobotOKCode int = 200 + +/*UpdateRobotOK Success + +swagger:response updateRobotOK +*/ +type UpdateRobotOK struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewUpdateRobotOK creates UpdateRobotOK with default headers values +func NewUpdateRobotOK() *UpdateRobotOK { + + return &UpdateRobotOK{} +} + +// WithXRequestID adds the xRequestId to the update robot o k response +func (o *UpdateRobotOK) WithXRequestID(xRequestID string) *UpdateRobotOK { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update robot o k response +func (o *UpdateRobotOK) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *UpdateRobotOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// UpdateRobotBadRequestCode is the HTTP code returned for type UpdateRobotBadRequest +const UpdateRobotBadRequestCode int = 400 + +/*UpdateRobotBadRequest Bad request + +swagger:response updateRobotBadRequest +*/ +type UpdateRobotBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateRobotBadRequest creates UpdateRobotBadRequest with default headers values +func NewUpdateRobotBadRequest() *UpdateRobotBadRequest { + + return &UpdateRobotBadRequest{} +} + +// WithXRequestID adds the xRequestId to the update robot bad request response +func (o *UpdateRobotBadRequest) WithXRequestID(xRequestID string) *UpdateRobotBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update robot bad request response +func (o *UpdateRobotBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update robot bad request response +func (o *UpdateRobotBadRequest) WithPayload(payload *models.Errors) *UpdateRobotBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update robot bad request response +func (o *UpdateRobotBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateRobotBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateRobotUnauthorizedCode is the HTTP code returned for type UpdateRobotUnauthorized +const UpdateRobotUnauthorizedCode int = 401 + +/*UpdateRobotUnauthorized Unauthorized + +swagger:response updateRobotUnauthorized +*/ +type UpdateRobotUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateRobotUnauthorized creates UpdateRobotUnauthorized with default headers values +func NewUpdateRobotUnauthorized() *UpdateRobotUnauthorized { + + return &UpdateRobotUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the update robot unauthorized response +func (o *UpdateRobotUnauthorized) WithXRequestID(xRequestID string) *UpdateRobotUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update robot unauthorized response +func (o *UpdateRobotUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update robot unauthorized response +func (o *UpdateRobotUnauthorized) WithPayload(payload *models.Errors) *UpdateRobotUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update robot unauthorized response +func (o *UpdateRobotUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateRobotUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateRobotForbiddenCode is the HTTP code returned for type UpdateRobotForbidden +const UpdateRobotForbiddenCode int = 403 + +/*UpdateRobotForbidden Forbidden + +swagger:response updateRobotForbidden +*/ +type UpdateRobotForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateRobotForbidden creates UpdateRobotForbidden with default headers values +func NewUpdateRobotForbidden() *UpdateRobotForbidden { + + return &UpdateRobotForbidden{} +} + +// WithXRequestID adds the xRequestId to the update robot forbidden response +func (o *UpdateRobotForbidden) WithXRequestID(xRequestID string) *UpdateRobotForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update robot forbidden response +func (o *UpdateRobotForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update robot forbidden response +func (o *UpdateRobotForbidden) WithPayload(payload *models.Errors) *UpdateRobotForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update robot forbidden response +func (o *UpdateRobotForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateRobotForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateRobotNotFoundCode is the HTTP code returned for type UpdateRobotNotFound +const UpdateRobotNotFoundCode int = 404 + +/*UpdateRobotNotFound Not found + +swagger:response updateRobotNotFound +*/ +type UpdateRobotNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateRobotNotFound creates UpdateRobotNotFound with default headers values +func NewUpdateRobotNotFound() *UpdateRobotNotFound { + + return &UpdateRobotNotFound{} +} + +// WithXRequestID adds the xRequestId to the update robot not found response +func (o *UpdateRobotNotFound) WithXRequestID(xRequestID string) *UpdateRobotNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update robot not found response +func (o *UpdateRobotNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update robot not found response +func (o *UpdateRobotNotFound) WithPayload(payload *models.Errors) *UpdateRobotNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update robot not found response +func (o *UpdateRobotNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateRobotNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateRobotConflictCode is the HTTP code returned for type UpdateRobotConflict +const UpdateRobotConflictCode int = 409 + +/*UpdateRobotConflict Conflict + +swagger:response updateRobotConflict +*/ +type UpdateRobotConflict struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateRobotConflict creates UpdateRobotConflict with default headers values +func NewUpdateRobotConflict() *UpdateRobotConflict { + + return &UpdateRobotConflict{} +} + +// WithXRequestID adds the xRequestId to the update robot conflict response +func (o *UpdateRobotConflict) WithXRequestID(xRequestID string) *UpdateRobotConflict { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update robot conflict response +func (o *UpdateRobotConflict) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update robot conflict response +func (o *UpdateRobotConflict) WithPayload(payload *models.Errors) *UpdateRobotConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update robot conflict response +func (o *UpdateRobotConflict) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateRobotConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateRobotInternalServerErrorCode is the HTTP code returned for type UpdateRobotInternalServerError +const UpdateRobotInternalServerErrorCode int = 500 + +/*UpdateRobotInternalServerError Internal server error + +swagger:response updateRobotInternalServerError +*/ +type UpdateRobotInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateRobotInternalServerError creates UpdateRobotInternalServerError with default headers values +func NewUpdateRobotInternalServerError() *UpdateRobotInternalServerError { + + return &UpdateRobotInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the update robot internal server error response +func (o *UpdateRobotInternalServerError) WithXRequestID(xRequestID string) *UpdateRobotInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update robot internal server error response +func (o *UpdateRobotInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update robot internal server error response +func (o *UpdateRobotInternalServerError) WithPayload(payload *models.Errors) *UpdateRobotInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update robot internal server error response +func (o *UpdateRobotInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateRobotInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/robot/update_robot_urlbuilder.go b/src/server/v2.0/restapi/operations/robot/update_robot_urlbuilder.go new file mode 100644 index 000000000..655147c93 --- /dev/null +++ b/src/server/v2.0/restapi/operations/robot/update_robot_urlbuilder.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package robot + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// UpdateRobotURL generates an URL for the update robot operation +type UpdateRobotURL struct { + RobotID int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdateRobotURL) WithBasePath(bp string) *UpdateRobotURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdateRobotURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *UpdateRobotURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/robots/{robot_id}" + + robotID := swag.FormatInt64(o.RobotID) + if robotID != "" { + _path = strings.Replace(_path, "{robot_id}", robotID, -1) + } else { + return nil, errors.New("robotId is required on UpdateRobotURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *UpdateRobotURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *UpdateRobotURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *UpdateRobotURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on UpdateRobotURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on UpdateRobotURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *UpdateRobotURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/robotv1/create_robot_v1.go b/src/server/v2.0/restapi/operations/robotv1/create_robot_v1.go new file mode 100644 index 000000000..9a9cba14c --- /dev/null +++ b/src/server/v2.0/restapi/operations/robotv1/create_robot_v1.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package robotv1 + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateRobotV1HandlerFunc turns a function with the right signature into a create robot v1 handler +type CreateRobotV1HandlerFunc func(CreateRobotV1Params, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateRobotV1HandlerFunc) Handle(params CreateRobotV1Params, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateRobotV1Handler interface for that can handle valid create robot v1 params +type CreateRobotV1Handler interface { + Handle(CreateRobotV1Params, interface{}) middleware.Responder +} + +// NewCreateRobotV1 creates a new http.Handler for the create robot v1 operation +func NewCreateRobotV1(ctx *middleware.Context, handler CreateRobotV1Handler) *CreateRobotV1 { + return &CreateRobotV1{Context: ctx, Handler: handler} +} + +/*CreateRobotV1 swagger:route POST /projects/{project_name_or_id}/robots robotv1 createRobotV1 + +Create a robot account + +Create a robot account + +*/ +type CreateRobotV1 struct { + Context *middleware.Context + Handler CreateRobotV1Handler +} + +func (o *CreateRobotV1) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewCreateRobotV1Params() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/robotv1/create_robot_v1_parameters.go b/src/server/v2.0/restapi/operations/robotv1/create_robot_v1_parameters.go new file mode 100644 index 000000000..0798b5588 --- /dev/null +++ b/src/server/v2.0/restapi/operations/robotv1/create_robot_v1_parameters.go @@ -0,0 +1,186 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package robotv1 + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewCreateRobotV1Params creates a new CreateRobotV1Params object +// with the default values initialized. +func NewCreateRobotV1Params() CreateRobotV1Params { + + var ( + // initialize parameters with default values + + xIsResourceNameDefault = bool(false) + ) + + return CreateRobotV1Params{ + XIsResourceName: &xIsResourceNameDefault, + } +} + +// CreateRobotV1Params contains all the bound params for the create robot v1 operation +// typically these are obtained from a http.Request +// +// swagger:parameters CreateRobotV1 +type CreateRobotV1Params struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name. + In: header + Default: false + */ + XIsResourceName *bool + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The name or id of the project + Required: true + In: path + */ + ProjectNameOrID string + /*The JSON object of a robot account. + Required: true + In: body + */ + Robot *models.RobotCreateV1 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateRobotV1Params() beforehand. +func (o *CreateRobotV1Params) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXIsResourceName(r.Header[http.CanonicalHeaderKey("X-Is-Resource-Name")], true, route.Formats); err != nil { + res = append(res, err) + } + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rProjectNameOrID, rhkProjectNameOrID, _ := route.Params.GetOK("project_name_or_id") + if err := o.bindProjectNameOrID(rProjectNameOrID, rhkProjectNameOrID, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.RobotCreateV1 + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("robot", "body", "")) + } else { + res = append(res, errors.NewParseError("robot", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Robot = &body + } + } + } else { + res = append(res, errors.Required("robot", "body", "")) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXIsResourceName binds and validates parameter XIsResourceName from header. +func (o *CreateRobotV1Params) bindXIsResourceName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateRobotV1Params() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("X-Is-Resource-Name", "header", "bool", raw) + } + o.XIsResourceName = &value + + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *CreateRobotV1Params) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *CreateRobotV1Params) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindProjectNameOrID binds and validates parameter ProjectNameOrID from path. +func (o *CreateRobotV1Params) bindProjectNameOrID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectNameOrID = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/robotv1/create_robot_v1_responses.go b/src/server/v2.0/restapi/operations/robotv1/create_robot_v1_responses.go new file mode 100644 index 000000000..0f719b91e --- /dev/null +++ b/src/server/v2.0/restapi/operations/robotv1/create_robot_v1_responses.go @@ -0,0 +1,432 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package robotv1 + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// CreateRobotV1CreatedCode is the HTTP code returned for type CreateRobotV1Created +const CreateRobotV1CreatedCode int = 201 + +/*CreateRobotV1Created Created + +swagger:response createRobotV1Created +*/ +type CreateRobotV1Created struct { + /*The location of the resource + + */ + Location string `json:"Location"` + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.RobotCreated `json:"body,omitempty"` +} + +// NewCreateRobotV1Created creates CreateRobotV1Created with default headers values +func NewCreateRobotV1Created() *CreateRobotV1Created { + + return &CreateRobotV1Created{} +} + +// WithLocation adds the location to the create robot v1 created response +func (o *CreateRobotV1Created) WithLocation(location string) *CreateRobotV1Created { + o.Location = location + return o +} + +// SetLocation sets the location to the create robot v1 created response +func (o *CreateRobotV1Created) SetLocation(location string) { + o.Location = location +} + +// WithXRequestID adds the xRequestId to the create robot v1 created response +func (o *CreateRobotV1Created) WithXRequestID(xRequestID string) *CreateRobotV1Created { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create robot v1 created response +func (o *CreateRobotV1Created) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create robot v1 created response +func (o *CreateRobotV1Created) WithPayload(payload *models.RobotCreated) *CreateRobotV1Created { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create robot v1 created response +func (o *CreateRobotV1Created) SetPayload(payload *models.RobotCreated) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateRobotV1Created) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Location + + location := o.Location + if location != "" { + rw.Header().Set("Location", location) + } + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateRobotV1BadRequestCode is the HTTP code returned for type CreateRobotV1BadRequest +const CreateRobotV1BadRequestCode int = 400 + +/*CreateRobotV1BadRequest Bad request + +swagger:response createRobotV1BadRequest +*/ +type CreateRobotV1BadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateRobotV1BadRequest creates CreateRobotV1BadRequest with default headers values +func NewCreateRobotV1BadRequest() *CreateRobotV1BadRequest { + + return &CreateRobotV1BadRequest{} +} + +// WithXRequestID adds the xRequestId to the create robot v1 bad request response +func (o *CreateRobotV1BadRequest) WithXRequestID(xRequestID string) *CreateRobotV1BadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create robot v1 bad request response +func (o *CreateRobotV1BadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create robot v1 bad request response +func (o *CreateRobotV1BadRequest) WithPayload(payload *models.Errors) *CreateRobotV1BadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create robot v1 bad request response +func (o *CreateRobotV1BadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateRobotV1BadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateRobotV1UnauthorizedCode is the HTTP code returned for type CreateRobotV1Unauthorized +const CreateRobotV1UnauthorizedCode int = 401 + +/*CreateRobotV1Unauthorized Unauthorized + +swagger:response createRobotV1Unauthorized +*/ +type CreateRobotV1Unauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateRobotV1Unauthorized creates CreateRobotV1Unauthorized with default headers values +func NewCreateRobotV1Unauthorized() *CreateRobotV1Unauthorized { + + return &CreateRobotV1Unauthorized{} +} + +// WithXRequestID adds the xRequestId to the create robot v1 unauthorized response +func (o *CreateRobotV1Unauthorized) WithXRequestID(xRequestID string) *CreateRobotV1Unauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create robot v1 unauthorized response +func (o *CreateRobotV1Unauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create robot v1 unauthorized response +func (o *CreateRobotV1Unauthorized) WithPayload(payload *models.Errors) *CreateRobotV1Unauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create robot v1 unauthorized response +func (o *CreateRobotV1Unauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateRobotV1Unauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateRobotV1ForbiddenCode is the HTTP code returned for type CreateRobotV1Forbidden +const CreateRobotV1ForbiddenCode int = 403 + +/*CreateRobotV1Forbidden Forbidden + +swagger:response createRobotV1Forbidden +*/ +type CreateRobotV1Forbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateRobotV1Forbidden creates CreateRobotV1Forbidden with default headers values +func NewCreateRobotV1Forbidden() *CreateRobotV1Forbidden { + + return &CreateRobotV1Forbidden{} +} + +// WithXRequestID adds the xRequestId to the create robot v1 forbidden response +func (o *CreateRobotV1Forbidden) WithXRequestID(xRequestID string) *CreateRobotV1Forbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create robot v1 forbidden response +func (o *CreateRobotV1Forbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create robot v1 forbidden response +func (o *CreateRobotV1Forbidden) WithPayload(payload *models.Errors) *CreateRobotV1Forbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create robot v1 forbidden response +func (o *CreateRobotV1Forbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateRobotV1Forbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateRobotV1NotFoundCode is the HTTP code returned for type CreateRobotV1NotFound +const CreateRobotV1NotFoundCode int = 404 + +/*CreateRobotV1NotFound Not found + +swagger:response createRobotV1NotFound +*/ +type CreateRobotV1NotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateRobotV1NotFound creates CreateRobotV1NotFound with default headers values +func NewCreateRobotV1NotFound() *CreateRobotV1NotFound { + + return &CreateRobotV1NotFound{} +} + +// WithXRequestID adds the xRequestId to the create robot v1 not found response +func (o *CreateRobotV1NotFound) WithXRequestID(xRequestID string) *CreateRobotV1NotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create robot v1 not found response +func (o *CreateRobotV1NotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create robot v1 not found response +func (o *CreateRobotV1NotFound) WithPayload(payload *models.Errors) *CreateRobotV1NotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create robot v1 not found response +func (o *CreateRobotV1NotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateRobotV1NotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateRobotV1InternalServerErrorCode is the HTTP code returned for type CreateRobotV1InternalServerError +const CreateRobotV1InternalServerErrorCode int = 500 + +/*CreateRobotV1InternalServerError Internal server error + +swagger:response createRobotV1InternalServerError +*/ +type CreateRobotV1InternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateRobotV1InternalServerError creates CreateRobotV1InternalServerError with default headers values +func NewCreateRobotV1InternalServerError() *CreateRobotV1InternalServerError { + + return &CreateRobotV1InternalServerError{} +} + +// WithXRequestID adds the xRequestId to the create robot v1 internal server error response +func (o *CreateRobotV1InternalServerError) WithXRequestID(xRequestID string) *CreateRobotV1InternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create robot v1 internal server error response +func (o *CreateRobotV1InternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create robot v1 internal server error response +func (o *CreateRobotV1InternalServerError) WithPayload(payload *models.Errors) *CreateRobotV1InternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create robot v1 internal server error response +func (o *CreateRobotV1InternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateRobotV1InternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/robotv1/create_robot_v1_urlbuilder.go b/src/server/v2.0/restapi/operations/robotv1/create_robot_v1_urlbuilder.go new file mode 100644 index 000000000..29914c4ea --- /dev/null +++ b/src/server/v2.0/restapi/operations/robotv1/create_robot_v1_urlbuilder.go @@ -0,0 +1,99 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package robotv1 + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// CreateRobotV1URL generates an URL for the create robot v1 operation +type CreateRobotV1URL struct { + ProjectNameOrID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateRobotV1URL) WithBasePath(bp string) *CreateRobotV1URL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateRobotV1URL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateRobotV1URL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name_or_id}/robots" + + projectNameOrID := o.ProjectNameOrID + if projectNameOrID != "" { + _path = strings.Replace(_path, "{project_name_or_id}", projectNameOrID, -1) + } else { + return nil, errors.New("projectNameOrId is required on CreateRobotV1URL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateRobotV1URL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateRobotV1URL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateRobotV1URL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateRobotV1URL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateRobotV1URL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateRobotV1URL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/robotv1/delete_robot_v1.go b/src/server/v2.0/restapi/operations/robotv1/delete_robot_v1.go new file mode 100644 index 000000000..72cdb6ae1 --- /dev/null +++ b/src/server/v2.0/restapi/operations/robotv1/delete_robot_v1.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package robotv1 + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteRobotV1HandlerFunc turns a function with the right signature into a delete robot v1 handler +type DeleteRobotV1HandlerFunc func(DeleteRobotV1Params, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteRobotV1HandlerFunc) Handle(params DeleteRobotV1Params, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteRobotV1Handler interface for that can handle valid delete robot v1 params +type DeleteRobotV1Handler interface { + Handle(DeleteRobotV1Params, interface{}) middleware.Responder +} + +// NewDeleteRobotV1 creates a new http.Handler for the delete robot v1 operation +func NewDeleteRobotV1(ctx *middleware.Context, handler DeleteRobotV1Handler) *DeleteRobotV1 { + return &DeleteRobotV1{Context: ctx, Handler: handler} +} + +/*DeleteRobotV1 swagger:route DELETE /projects/{project_name_or_id}/robots/{robot_id} robotv1 deleteRobotV1 + +Delete a robot account + +This endpoint deletes specific robot account information by robot ID. + +*/ +type DeleteRobotV1 struct { + Context *middleware.Context + Handler DeleteRobotV1Handler +} + +func (o *DeleteRobotV1) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewDeleteRobotV1Params() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/robotv1/delete_robot_v1_parameters.go b/src/server/v2.0/restapi/operations/robotv1/delete_robot_v1_parameters.go new file mode 100644 index 000000000..278353577 --- /dev/null +++ b/src/server/v2.0/restapi/operations/robotv1/delete_robot_v1_parameters.go @@ -0,0 +1,184 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package robotv1 + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewDeleteRobotV1Params creates a new DeleteRobotV1Params object +// with the default values initialized. +func NewDeleteRobotV1Params() DeleteRobotV1Params { + + var ( + // initialize parameters with default values + + xIsResourceNameDefault = bool(false) + ) + + return DeleteRobotV1Params{ + XIsResourceName: &xIsResourceNameDefault, + } +} + +// DeleteRobotV1Params contains all the bound params for the delete robot v1 operation +// typically these are obtained from a http.Request +// +// swagger:parameters DeleteRobotV1 +type DeleteRobotV1Params struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name. + In: header + Default: false + */ + XIsResourceName *bool + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The name or id of the project + Required: true + In: path + */ + ProjectNameOrID string + /*Robot ID + Required: true + In: path + */ + RobotID int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteRobotV1Params() beforehand. +func (o *DeleteRobotV1Params) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXIsResourceName(r.Header[http.CanonicalHeaderKey("X-Is-Resource-Name")], true, route.Formats); err != nil { + res = append(res, err) + } + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rProjectNameOrID, rhkProjectNameOrID, _ := route.Params.GetOK("project_name_or_id") + if err := o.bindProjectNameOrID(rProjectNameOrID, rhkProjectNameOrID, route.Formats); err != nil { + res = append(res, err) + } + + rRobotID, rhkRobotID, _ := route.Params.GetOK("robot_id") + if err := o.bindRobotID(rRobotID, rhkRobotID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXIsResourceName binds and validates parameter XIsResourceName from header. +func (o *DeleteRobotV1Params) bindXIsResourceName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteRobotV1Params() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("X-Is-Resource-Name", "header", "bool", raw) + } + o.XIsResourceName = &value + + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *DeleteRobotV1Params) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *DeleteRobotV1Params) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindProjectNameOrID binds and validates parameter ProjectNameOrID from path. +func (o *DeleteRobotV1Params) bindProjectNameOrID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectNameOrID = raw + + return nil +} + +// bindRobotID binds and validates parameter RobotID from path. +func (o *DeleteRobotV1Params) bindRobotID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("robot_id", "path", "int64", raw) + } + o.RobotID = value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/robotv1/delete_robot_v1_responses.go b/src/server/v2.0/restapi/operations/robotv1/delete_robot_v1_responses.go new file mode 100644 index 000000000..ce12d38d7 --- /dev/null +++ b/src/server/v2.0/restapi/operations/robotv1/delete_robot_v1_responses.go @@ -0,0 +1,390 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package robotv1 + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// DeleteRobotV1OKCode is the HTTP code returned for type DeleteRobotV1OK +const DeleteRobotV1OKCode int = 200 + +/*DeleteRobotV1OK Success + +swagger:response deleteRobotV1OK +*/ +type DeleteRobotV1OK struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewDeleteRobotV1OK creates DeleteRobotV1OK with default headers values +func NewDeleteRobotV1OK() *DeleteRobotV1OK { + + return &DeleteRobotV1OK{} +} + +// WithXRequestID adds the xRequestId to the delete robot v1 o k response +func (o *DeleteRobotV1OK) WithXRequestID(xRequestID string) *DeleteRobotV1OK { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete robot v1 o k response +func (o *DeleteRobotV1OK) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *DeleteRobotV1OK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// DeleteRobotV1BadRequestCode is the HTTP code returned for type DeleteRobotV1BadRequest +const DeleteRobotV1BadRequestCode int = 400 + +/*DeleteRobotV1BadRequest Bad request + +swagger:response deleteRobotV1BadRequest +*/ +type DeleteRobotV1BadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteRobotV1BadRequest creates DeleteRobotV1BadRequest with default headers values +func NewDeleteRobotV1BadRequest() *DeleteRobotV1BadRequest { + + return &DeleteRobotV1BadRequest{} +} + +// WithXRequestID adds the xRequestId to the delete robot v1 bad request response +func (o *DeleteRobotV1BadRequest) WithXRequestID(xRequestID string) *DeleteRobotV1BadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete robot v1 bad request response +func (o *DeleteRobotV1BadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete robot v1 bad request response +func (o *DeleteRobotV1BadRequest) WithPayload(payload *models.Errors) *DeleteRobotV1BadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete robot v1 bad request response +func (o *DeleteRobotV1BadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteRobotV1BadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteRobotV1UnauthorizedCode is the HTTP code returned for type DeleteRobotV1Unauthorized +const DeleteRobotV1UnauthorizedCode int = 401 + +/*DeleteRobotV1Unauthorized Unauthorized + +swagger:response deleteRobotV1Unauthorized +*/ +type DeleteRobotV1Unauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteRobotV1Unauthorized creates DeleteRobotV1Unauthorized with default headers values +func NewDeleteRobotV1Unauthorized() *DeleteRobotV1Unauthorized { + + return &DeleteRobotV1Unauthorized{} +} + +// WithXRequestID adds the xRequestId to the delete robot v1 unauthorized response +func (o *DeleteRobotV1Unauthorized) WithXRequestID(xRequestID string) *DeleteRobotV1Unauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete robot v1 unauthorized response +func (o *DeleteRobotV1Unauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete robot v1 unauthorized response +func (o *DeleteRobotV1Unauthorized) WithPayload(payload *models.Errors) *DeleteRobotV1Unauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete robot v1 unauthorized response +func (o *DeleteRobotV1Unauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteRobotV1Unauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteRobotV1ForbiddenCode is the HTTP code returned for type DeleteRobotV1Forbidden +const DeleteRobotV1ForbiddenCode int = 403 + +/*DeleteRobotV1Forbidden Forbidden + +swagger:response deleteRobotV1Forbidden +*/ +type DeleteRobotV1Forbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteRobotV1Forbidden creates DeleteRobotV1Forbidden with default headers values +func NewDeleteRobotV1Forbidden() *DeleteRobotV1Forbidden { + + return &DeleteRobotV1Forbidden{} +} + +// WithXRequestID adds the xRequestId to the delete robot v1 forbidden response +func (o *DeleteRobotV1Forbidden) WithXRequestID(xRequestID string) *DeleteRobotV1Forbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete robot v1 forbidden response +func (o *DeleteRobotV1Forbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete robot v1 forbidden response +func (o *DeleteRobotV1Forbidden) WithPayload(payload *models.Errors) *DeleteRobotV1Forbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete robot v1 forbidden response +func (o *DeleteRobotV1Forbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteRobotV1Forbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteRobotV1NotFoundCode is the HTTP code returned for type DeleteRobotV1NotFound +const DeleteRobotV1NotFoundCode int = 404 + +/*DeleteRobotV1NotFound Not found + +swagger:response deleteRobotV1NotFound +*/ +type DeleteRobotV1NotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteRobotV1NotFound creates DeleteRobotV1NotFound with default headers values +func NewDeleteRobotV1NotFound() *DeleteRobotV1NotFound { + + return &DeleteRobotV1NotFound{} +} + +// WithXRequestID adds the xRequestId to the delete robot v1 not found response +func (o *DeleteRobotV1NotFound) WithXRequestID(xRequestID string) *DeleteRobotV1NotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete robot v1 not found response +func (o *DeleteRobotV1NotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete robot v1 not found response +func (o *DeleteRobotV1NotFound) WithPayload(payload *models.Errors) *DeleteRobotV1NotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete robot v1 not found response +func (o *DeleteRobotV1NotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteRobotV1NotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteRobotV1InternalServerErrorCode is the HTTP code returned for type DeleteRobotV1InternalServerError +const DeleteRobotV1InternalServerErrorCode int = 500 + +/*DeleteRobotV1InternalServerError Internal server error + +swagger:response deleteRobotV1InternalServerError +*/ +type DeleteRobotV1InternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteRobotV1InternalServerError creates DeleteRobotV1InternalServerError with default headers values +func NewDeleteRobotV1InternalServerError() *DeleteRobotV1InternalServerError { + + return &DeleteRobotV1InternalServerError{} +} + +// WithXRequestID adds the xRequestId to the delete robot v1 internal server error response +func (o *DeleteRobotV1InternalServerError) WithXRequestID(xRequestID string) *DeleteRobotV1InternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete robot v1 internal server error response +func (o *DeleteRobotV1InternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete robot v1 internal server error response +func (o *DeleteRobotV1InternalServerError) WithPayload(payload *models.Errors) *DeleteRobotV1InternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete robot v1 internal server error response +func (o *DeleteRobotV1InternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteRobotV1InternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/robotv1/delete_robot_v1_urlbuilder.go b/src/server/v2.0/restapi/operations/robotv1/delete_robot_v1_urlbuilder.go new file mode 100644 index 000000000..5a9c92f37 --- /dev/null +++ b/src/server/v2.0/restapi/operations/robotv1/delete_robot_v1_urlbuilder.go @@ -0,0 +1,109 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package robotv1 + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteRobotV1URL generates an URL for the delete robot v1 operation +type DeleteRobotV1URL struct { + ProjectNameOrID string + RobotID int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteRobotV1URL) WithBasePath(bp string) *DeleteRobotV1URL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteRobotV1URL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteRobotV1URL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name_or_id}/robots/{robot_id}" + + projectNameOrID := o.ProjectNameOrID + if projectNameOrID != "" { + _path = strings.Replace(_path, "{project_name_or_id}", projectNameOrID, -1) + } else { + return nil, errors.New("projectNameOrId is required on DeleteRobotV1URL") + } + + robotID := swag.FormatInt64(o.RobotID) + if robotID != "" { + _path = strings.Replace(_path, "{robot_id}", robotID, -1) + } else { + return nil, errors.New("robotId is required on DeleteRobotV1URL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteRobotV1URL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteRobotV1URL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteRobotV1URL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteRobotV1URL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteRobotV1URL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteRobotV1URL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/robotv1/get_robot_by_id_v1.go b/src/server/v2.0/restapi/operations/robotv1/get_robot_by_id_v1.go new file mode 100644 index 000000000..67b6fa619 --- /dev/null +++ b/src/server/v2.0/restapi/operations/robotv1/get_robot_by_id_v1.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package robotv1 + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetRobotByIDV1HandlerFunc turns a function with the right signature into a get robot by ID v1 handler +type GetRobotByIDV1HandlerFunc func(GetRobotByIDV1Params, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetRobotByIDV1HandlerFunc) Handle(params GetRobotByIDV1Params, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetRobotByIDV1Handler interface for that can handle valid get robot by ID v1 params +type GetRobotByIDV1Handler interface { + Handle(GetRobotByIDV1Params, interface{}) middleware.Responder +} + +// NewGetRobotByIDV1 creates a new http.Handler for the get robot by ID v1 operation +func NewGetRobotByIDV1(ctx *middleware.Context, handler GetRobotByIDV1Handler) *GetRobotByIDV1 { + return &GetRobotByIDV1{Context: ctx, Handler: handler} +} + +/*GetRobotByIDV1 swagger:route GET /projects/{project_name_or_id}/robots/{robot_id} robotv1 getRobotByIdV1 + +Get a robot account + +This endpoint returns specific robot account information by robot ID. + +*/ +type GetRobotByIDV1 struct { + Context *middleware.Context + Handler GetRobotByIDV1Handler +} + +func (o *GetRobotByIDV1) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetRobotByIDV1Params() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/robotv1/get_robot_by_id_v1_parameters.go b/src/server/v2.0/restapi/operations/robotv1/get_robot_by_id_v1_parameters.go new file mode 100644 index 000000000..848bd041a --- /dev/null +++ b/src/server/v2.0/restapi/operations/robotv1/get_robot_by_id_v1_parameters.go @@ -0,0 +1,184 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package robotv1 + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewGetRobotByIDV1Params creates a new GetRobotByIDV1Params object +// with the default values initialized. +func NewGetRobotByIDV1Params() GetRobotByIDV1Params { + + var ( + // initialize parameters with default values + + xIsResourceNameDefault = bool(false) + ) + + return GetRobotByIDV1Params{ + XIsResourceName: &xIsResourceNameDefault, + } +} + +// GetRobotByIDV1Params contains all the bound params for the get robot by ID v1 operation +// typically these are obtained from a http.Request +// +// swagger:parameters GetRobotByIDV1 +type GetRobotByIDV1Params struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name. + In: header + Default: false + */ + XIsResourceName *bool + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The name or id of the project + Required: true + In: path + */ + ProjectNameOrID string + /*Robot ID + Required: true + In: path + */ + RobotID int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetRobotByIDV1Params() beforehand. +func (o *GetRobotByIDV1Params) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXIsResourceName(r.Header[http.CanonicalHeaderKey("X-Is-Resource-Name")], true, route.Formats); err != nil { + res = append(res, err) + } + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rProjectNameOrID, rhkProjectNameOrID, _ := route.Params.GetOK("project_name_or_id") + if err := o.bindProjectNameOrID(rProjectNameOrID, rhkProjectNameOrID, route.Formats); err != nil { + res = append(res, err) + } + + rRobotID, rhkRobotID, _ := route.Params.GetOK("robot_id") + if err := o.bindRobotID(rRobotID, rhkRobotID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXIsResourceName binds and validates parameter XIsResourceName from header. +func (o *GetRobotByIDV1Params) bindXIsResourceName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewGetRobotByIDV1Params() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("X-Is-Resource-Name", "header", "bool", raw) + } + o.XIsResourceName = &value + + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetRobotByIDV1Params) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetRobotByIDV1Params) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindProjectNameOrID binds and validates parameter ProjectNameOrID from path. +func (o *GetRobotByIDV1Params) bindProjectNameOrID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectNameOrID = raw + + return nil +} + +// bindRobotID binds and validates parameter RobotID from path. +func (o *GetRobotByIDV1Params) bindRobotID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("robot_id", "path", "int64", raw) + } + o.RobotID = value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/robotv1/get_robot_by_id_v1_responses.go b/src/server/v2.0/restapi/operations/robotv1/get_robot_by_id_v1_responses.go new file mode 100644 index 000000000..f0bd69317 --- /dev/null +++ b/src/server/v2.0/restapi/operations/robotv1/get_robot_by_id_v1_responses.go @@ -0,0 +1,322 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package robotv1 + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetRobotByIDV1OKCode is the HTTP code returned for type GetRobotByIDV1OK +const GetRobotByIDV1OKCode int = 200 + +/*GetRobotByIDV1OK Return matched robot information. + +swagger:response getRobotByIdV1OK +*/ +type GetRobotByIDV1OK struct { + + /* + In: Body + */ + Payload *models.Robot `json:"body,omitempty"` +} + +// NewGetRobotByIDV1OK creates GetRobotByIDV1OK with default headers values +func NewGetRobotByIDV1OK() *GetRobotByIDV1OK { + + return &GetRobotByIDV1OK{} +} + +// WithPayload adds the payload to the get robot by Id v1 o k response +func (o *GetRobotByIDV1OK) WithPayload(payload *models.Robot) *GetRobotByIDV1OK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get robot by Id v1 o k response +func (o *GetRobotByIDV1OK) SetPayload(payload *models.Robot) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetRobotByIDV1OK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetRobotByIDV1UnauthorizedCode is the HTTP code returned for type GetRobotByIDV1Unauthorized +const GetRobotByIDV1UnauthorizedCode int = 401 + +/*GetRobotByIDV1Unauthorized Unauthorized + +swagger:response getRobotByIdV1Unauthorized +*/ +type GetRobotByIDV1Unauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetRobotByIDV1Unauthorized creates GetRobotByIDV1Unauthorized with default headers values +func NewGetRobotByIDV1Unauthorized() *GetRobotByIDV1Unauthorized { + + return &GetRobotByIDV1Unauthorized{} +} + +// WithXRequestID adds the xRequestId to the get robot by Id v1 unauthorized response +func (o *GetRobotByIDV1Unauthorized) WithXRequestID(xRequestID string) *GetRobotByIDV1Unauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get robot by Id v1 unauthorized response +func (o *GetRobotByIDV1Unauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get robot by Id v1 unauthorized response +func (o *GetRobotByIDV1Unauthorized) WithPayload(payload *models.Errors) *GetRobotByIDV1Unauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get robot by Id v1 unauthorized response +func (o *GetRobotByIDV1Unauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetRobotByIDV1Unauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetRobotByIDV1ForbiddenCode is the HTTP code returned for type GetRobotByIDV1Forbidden +const GetRobotByIDV1ForbiddenCode int = 403 + +/*GetRobotByIDV1Forbidden Forbidden + +swagger:response getRobotByIdV1Forbidden +*/ +type GetRobotByIDV1Forbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetRobotByIDV1Forbidden creates GetRobotByIDV1Forbidden with default headers values +func NewGetRobotByIDV1Forbidden() *GetRobotByIDV1Forbidden { + + return &GetRobotByIDV1Forbidden{} +} + +// WithXRequestID adds the xRequestId to the get robot by Id v1 forbidden response +func (o *GetRobotByIDV1Forbidden) WithXRequestID(xRequestID string) *GetRobotByIDV1Forbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get robot by Id v1 forbidden response +func (o *GetRobotByIDV1Forbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get robot by Id v1 forbidden response +func (o *GetRobotByIDV1Forbidden) WithPayload(payload *models.Errors) *GetRobotByIDV1Forbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get robot by Id v1 forbidden response +func (o *GetRobotByIDV1Forbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetRobotByIDV1Forbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetRobotByIDV1NotFoundCode is the HTTP code returned for type GetRobotByIDV1NotFound +const GetRobotByIDV1NotFoundCode int = 404 + +/*GetRobotByIDV1NotFound Not found + +swagger:response getRobotByIdV1NotFound +*/ +type GetRobotByIDV1NotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetRobotByIDV1NotFound creates GetRobotByIDV1NotFound with default headers values +func NewGetRobotByIDV1NotFound() *GetRobotByIDV1NotFound { + + return &GetRobotByIDV1NotFound{} +} + +// WithXRequestID adds the xRequestId to the get robot by Id v1 not found response +func (o *GetRobotByIDV1NotFound) WithXRequestID(xRequestID string) *GetRobotByIDV1NotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get robot by Id v1 not found response +func (o *GetRobotByIDV1NotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get robot by Id v1 not found response +func (o *GetRobotByIDV1NotFound) WithPayload(payload *models.Errors) *GetRobotByIDV1NotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get robot by Id v1 not found response +func (o *GetRobotByIDV1NotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetRobotByIDV1NotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetRobotByIDV1InternalServerErrorCode is the HTTP code returned for type GetRobotByIDV1InternalServerError +const GetRobotByIDV1InternalServerErrorCode int = 500 + +/*GetRobotByIDV1InternalServerError Internal server error + +swagger:response getRobotByIdV1InternalServerError +*/ +type GetRobotByIDV1InternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetRobotByIDV1InternalServerError creates GetRobotByIDV1InternalServerError with default headers values +func NewGetRobotByIDV1InternalServerError() *GetRobotByIDV1InternalServerError { + + return &GetRobotByIDV1InternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get robot by Id v1 internal server error response +func (o *GetRobotByIDV1InternalServerError) WithXRequestID(xRequestID string) *GetRobotByIDV1InternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get robot by Id v1 internal server error response +func (o *GetRobotByIDV1InternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get robot by Id v1 internal server error response +func (o *GetRobotByIDV1InternalServerError) WithPayload(payload *models.Errors) *GetRobotByIDV1InternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get robot by Id v1 internal server error response +func (o *GetRobotByIDV1InternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetRobotByIDV1InternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/robotv1/get_robot_by_id_v1_urlbuilder.go b/src/server/v2.0/restapi/operations/robotv1/get_robot_by_id_v1_urlbuilder.go new file mode 100644 index 000000000..3eac9dccf --- /dev/null +++ b/src/server/v2.0/restapi/operations/robotv1/get_robot_by_id_v1_urlbuilder.go @@ -0,0 +1,109 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package robotv1 + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetRobotByIDV1URL generates an URL for the get robot by ID v1 operation +type GetRobotByIDV1URL struct { + ProjectNameOrID string + RobotID int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetRobotByIDV1URL) WithBasePath(bp string) *GetRobotByIDV1URL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetRobotByIDV1URL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetRobotByIDV1URL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name_or_id}/robots/{robot_id}" + + projectNameOrID := o.ProjectNameOrID + if projectNameOrID != "" { + _path = strings.Replace(_path, "{project_name_or_id}", projectNameOrID, -1) + } else { + return nil, errors.New("projectNameOrId is required on GetRobotByIDV1URL") + } + + robotID := swag.FormatInt64(o.RobotID) + if robotID != "" { + _path = strings.Replace(_path, "{robot_id}", robotID, -1) + } else { + return nil, errors.New("robotId is required on GetRobotByIDV1URL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetRobotByIDV1URL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetRobotByIDV1URL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetRobotByIDV1URL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetRobotByIDV1URL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetRobotByIDV1URL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetRobotByIDV1URL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/robotv1/list_robot_v1.go b/src/server/v2.0/restapi/operations/robotv1/list_robot_v1.go new file mode 100644 index 000000000..d5f23368a --- /dev/null +++ b/src/server/v2.0/restapi/operations/robotv1/list_robot_v1.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package robotv1 + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ListRobotV1HandlerFunc turns a function with the right signature into a list robot v1 handler +type ListRobotV1HandlerFunc func(ListRobotV1Params, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ListRobotV1HandlerFunc) Handle(params ListRobotV1Params, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ListRobotV1Handler interface for that can handle valid list robot v1 params +type ListRobotV1Handler interface { + Handle(ListRobotV1Params, interface{}) middleware.Responder +} + +// NewListRobotV1 creates a new http.Handler for the list robot v1 operation +func NewListRobotV1(ctx *middleware.Context, handler ListRobotV1Handler) *ListRobotV1 { + return &ListRobotV1{Context: ctx, Handler: handler} +} + +/*ListRobotV1 swagger:route GET /projects/{project_name_or_id}/robots robotv1 listRobotV1 + +Get all robot accounts of specified project + +Get all robot accounts of specified project + +*/ +type ListRobotV1 struct { + Context *middleware.Context + Handler ListRobotV1Handler +} + +func (o *ListRobotV1) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewListRobotV1Params() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/robotv1/list_robot_v1_parameters.go b/src/server/v2.0/restapi/operations/robotv1/list_robot_v1_parameters.go new file mode 100644 index 000000000..e0b5bef75 --- /dev/null +++ b/src/server/v2.0/restapi/operations/robotv1/list_robot_v1_parameters.go @@ -0,0 +1,300 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package robotv1 + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewListRobotV1Params creates a new ListRobotV1Params object +// with the default values initialized. +func NewListRobotV1Params() ListRobotV1Params { + + var ( + // initialize parameters with default values + + xIsResourceNameDefault = bool(false) + + pageDefault = int64(1) + pageSizeDefault = int64(10) + ) + + return ListRobotV1Params{ + XIsResourceName: &xIsResourceNameDefault, + + Page: &pageDefault, + + PageSize: &pageSizeDefault, + } +} + +// ListRobotV1Params contains all the bound params for the list robot v1 operation +// typically these are obtained from a http.Request +// +// swagger:parameters ListRobotV1 +type ListRobotV1Params struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name. + In: header + Default: false + */ + XIsResourceName *bool + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The page number + In: query + Default: 1 + */ + Page *int64 + /*The size of per page + Maximum: 100 + In: query + Default: 10 + */ + PageSize *int64 + /*The name or id of the project + Required: true + In: path + */ + ProjectNameOrID string + /*Query string to query resources. Supported query patterns are "exact match(k=v)", "fuzzy match(k=~v)", "range(k=[min~max])", "list with union releationship(k={v1 v2 v3})" and "list with intersetion relationship(k=(v1 v2 v3))". The value of range and list can be string(enclosed by " or '), integer or time(in format "2020-04-09 02:36:00"). All of these query patterns should be put in the query string "q=xxx" and splitted by ",". e.g. q=k1=v1,k2=~v2,k3=[min~max] + In: query + */ + Q *string + /*Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + In: query + */ + Sort *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewListRobotV1Params() beforehand. +func (o *ListRobotV1Params) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if err := o.bindXIsResourceName(r.Header[http.CanonicalHeaderKey("X-Is-Resource-Name")], true, route.Formats); err != nil { + res = append(res, err) + } + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + qPage, qhkPage, _ := qs.GetOK("page") + if err := o.bindPage(qPage, qhkPage, route.Formats); err != nil { + res = append(res, err) + } + + qPageSize, qhkPageSize, _ := qs.GetOK("page_size") + if err := o.bindPageSize(qPageSize, qhkPageSize, route.Formats); err != nil { + res = append(res, err) + } + + rProjectNameOrID, rhkProjectNameOrID, _ := route.Params.GetOK("project_name_or_id") + if err := o.bindProjectNameOrID(rProjectNameOrID, rhkProjectNameOrID, route.Formats); err != nil { + res = append(res, err) + } + + qQ, qhkQ, _ := qs.GetOK("q") + if err := o.bindQ(qQ, qhkQ, route.Formats); err != nil { + res = append(res, err) + } + + qSort, qhkSort, _ := qs.GetOK("sort") + if err := o.bindSort(qSort, qhkSort, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXIsResourceName binds and validates parameter XIsResourceName from header. +func (o *ListRobotV1Params) bindXIsResourceName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListRobotV1Params() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("X-Is-Resource-Name", "header", "bool", raw) + } + o.XIsResourceName = &value + + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *ListRobotV1Params) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *ListRobotV1Params) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindPage binds and validates parameter Page from query. +func (o *ListRobotV1Params) bindPage(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListRobotV1Params() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page", "query", "int64", raw) + } + o.Page = &value + + return nil +} + +// bindPageSize binds and validates parameter PageSize from query. +func (o *ListRobotV1Params) bindPageSize(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListRobotV1Params() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page_size", "query", "int64", raw) + } + o.PageSize = &value + + if err := o.validatePageSize(formats); err != nil { + return err + } + + return nil +} + +// validatePageSize carries on validations for parameter PageSize +func (o *ListRobotV1Params) validatePageSize(formats strfmt.Registry) error { + + if err := validate.MaximumInt("page_size", "query", int64(*o.PageSize), 100, false); err != nil { + return err + } + + return nil +} + +// bindProjectNameOrID binds and validates parameter ProjectNameOrID from path. +func (o *ListRobotV1Params) bindProjectNameOrID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectNameOrID = raw + + return nil +} + +// bindQ binds and validates parameter Q from query. +func (o *ListRobotV1Params) bindQ(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Q = &raw + + return nil +} + +// bindSort binds and validates parameter Sort from query. +func (o *ListRobotV1Params) bindSort(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Sort = &raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/robotv1/list_robot_v1_responses.go b/src/server/v2.0/restapi/operations/robotv1/list_robot_v1_responses.go new file mode 100644 index 000000000..3760c64ec --- /dev/null +++ b/src/server/v2.0/restapi/operations/robotv1/list_robot_v1_responses.go @@ -0,0 +1,304 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package robotv1 + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/swag" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// ListRobotV1OKCode is the HTTP code returned for type ListRobotV1OK +const ListRobotV1OKCode int = 200 + +/*ListRobotV1OK Success + +swagger:response listRobotV1OK +*/ +type ListRobotV1OK struct { + /*Link refers to the previous page and next page + + */ + Link string `json:"Link"` + /*The total count of robot accounts + + */ + XTotalCount int64 `json:"X-Total-Count"` + + /* + In: Body + */ + Payload []*models.Robot `json:"body,omitempty"` +} + +// NewListRobotV1OK creates ListRobotV1OK with default headers values +func NewListRobotV1OK() *ListRobotV1OK { + + return &ListRobotV1OK{} +} + +// WithLink adds the link to the list robot v1 o k response +func (o *ListRobotV1OK) WithLink(link string) *ListRobotV1OK { + o.Link = link + return o +} + +// SetLink sets the link to the list robot v1 o k response +func (o *ListRobotV1OK) SetLink(link string) { + o.Link = link +} + +// WithXTotalCount adds the xTotalCount to the list robot v1 o k response +func (o *ListRobotV1OK) WithXTotalCount(xTotalCount int64) *ListRobotV1OK { + o.XTotalCount = xTotalCount + return o +} + +// SetXTotalCount sets the xTotalCount to the list robot v1 o k response +func (o *ListRobotV1OK) SetXTotalCount(xTotalCount int64) { + o.XTotalCount = xTotalCount +} + +// WithPayload adds the payload to the list robot v1 o k response +func (o *ListRobotV1OK) WithPayload(payload []*models.Robot) *ListRobotV1OK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list robot v1 o k response +func (o *ListRobotV1OK) SetPayload(payload []*models.Robot) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListRobotV1OK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Link + + link := o.Link + if link != "" { + rw.Header().Set("Link", link) + } + + // response header X-Total-Count + + xTotalCount := swag.FormatInt64(o.XTotalCount) + if xTotalCount != "" { + rw.Header().Set("X-Total-Count", xTotalCount) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = make([]*models.Robot, 0, 50) + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ListRobotV1BadRequestCode is the HTTP code returned for type ListRobotV1BadRequest +const ListRobotV1BadRequestCode int = 400 + +/*ListRobotV1BadRequest Bad request + +swagger:response listRobotV1BadRequest +*/ +type ListRobotV1BadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListRobotV1BadRequest creates ListRobotV1BadRequest with default headers values +func NewListRobotV1BadRequest() *ListRobotV1BadRequest { + + return &ListRobotV1BadRequest{} +} + +// WithXRequestID adds the xRequestId to the list robot v1 bad request response +func (o *ListRobotV1BadRequest) WithXRequestID(xRequestID string) *ListRobotV1BadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list robot v1 bad request response +func (o *ListRobotV1BadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list robot v1 bad request response +func (o *ListRobotV1BadRequest) WithPayload(payload *models.Errors) *ListRobotV1BadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list robot v1 bad request response +func (o *ListRobotV1BadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListRobotV1BadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListRobotV1NotFoundCode is the HTTP code returned for type ListRobotV1NotFound +const ListRobotV1NotFoundCode int = 404 + +/*ListRobotV1NotFound Not found + +swagger:response listRobotV1NotFound +*/ +type ListRobotV1NotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListRobotV1NotFound creates ListRobotV1NotFound with default headers values +func NewListRobotV1NotFound() *ListRobotV1NotFound { + + return &ListRobotV1NotFound{} +} + +// WithXRequestID adds the xRequestId to the list robot v1 not found response +func (o *ListRobotV1NotFound) WithXRequestID(xRequestID string) *ListRobotV1NotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list robot v1 not found response +func (o *ListRobotV1NotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list robot v1 not found response +func (o *ListRobotV1NotFound) WithPayload(payload *models.Errors) *ListRobotV1NotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list robot v1 not found response +func (o *ListRobotV1NotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListRobotV1NotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListRobotV1InternalServerErrorCode is the HTTP code returned for type ListRobotV1InternalServerError +const ListRobotV1InternalServerErrorCode int = 500 + +/*ListRobotV1InternalServerError Internal server error + +swagger:response listRobotV1InternalServerError +*/ +type ListRobotV1InternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListRobotV1InternalServerError creates ListRobotV1InternalServerError with default headers values +func NewListRobotV1InternalServerError() *ListRobotV1InternalServerError { + + return &ListRobotV1InternalServerError{} +} + +// WithXRequestID adds the xRequestId to the list robot v1 internal server error response +func (o *ListRobotV1InternalServerError) WithXRequestID(xRequestID string) *ListRobotV1InternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list robot v1 internal server error response +func (o *ListRobotV1InternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list robot v1 internal server error response +func (o *ListRobotV1InternalServerError) WithPayload(payload *models.Errors) *ListRobotV1InternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list robot v1 internal server error response +func (o *ListRobotV1InternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListRobotV1InternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/robotv1/list_robot_v1_urlbuilder.go b/src/server/v2.0/restapi/operations/robotv1/list_robot_v1_urlbuilder.go new file mode 100644 index 000000000..60d44d73b --- /dev/null +++ b/src/server/v2.0/restapi/operations/robotv1/list_robot_v1_urlbuilder.go @@ -0,0 +1,142 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package robotv1 + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ListRobotV1URL generates an URL for the list robot v1 operation +type ListRobotV1URL struct { + ProjectNameOrID string + + Page *int64 + PageSize *int64 + Q *string + Sort *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListRobotV1URL) WithBasePath(bp string) *ListRobotV1URL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListRobotV1URL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ListRobotV1URL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name_or_id}/robots" + + projectNameOrID := o.ProjectNameOrID + if projectNameOrID != "" { + _path = strings.Replace(_path, "{project_name_or_id}", projectNameOrID, -1) + } else { + return nil, errors.New("projectNameOrId is required on ListRobotV1URL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var pageQ string + if o.Page != nil { + pageQ = swag.FormatInt64(*o.Page) + } + if pageQ != "" { + qs.Set("page", pageQ) + } + + var pageSizeQ string + if o.PageSize != nil { + pageSizeQ = swag.FormatInt64(*o.PageSize) + } + if pageSizeQ != "" { + qs.Set("page_size", pageSizeQ) + } + + var qQ string + if o.Q != nil { + qQ = *o.Q + } + if qQ != "" { + qs.Set("q", qQ) + } + + var sortQ string + if o.Sort != nil { + sortQ = *o.Sort + } + if sortQ != "" { + qs.Set("sort", sortQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ListRobotV1URL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ListRobotV1URL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ListRobotV1URL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ListRobotV1URL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ListRobotV1URL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ListRobotV1URL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/robotv1/update_robot_v1.go b/src/server/v2.0/restapi/operations/robotv1/update_robot_v1.go new file mode 100644 index 000000000..07ee39495 --- /dev/null +++ b/src/server/v2.0/restapi/operations/robotv1/update_robot_v1.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package robotv1 + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// UpdateRobotV1HandlerFunc turns a function with the right signature into a update robot v1 handler +type UpdateRobotV1HandlerFunc func(UpdateRobotV1Params, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn UpdateRobotV1HandlerFunc) Handle(params UpdateRobotV1Params, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// UpdateRobotV1Handler interface for that can handle valid update robot v1 params +type UpdateRobotV1Handler interface { + Handle(UpdateRobotV1Params, interface{}) middleware.Responder +} + +// NewUpdateRobotV1 creates a new http.Handler for the update robot v1 operation +func NewUpdateRobotV1(ctx *middleware.Context, handler UpdateRobotV1Handler) *UpdateRobotV1 { + return &UpdateRobotV1{Context: ctx, Handler: handler} +} + +/*UpdateRobotV1 swagger:route PUT /projects/{project_name_or_id}/robots/{robot_id} robotv1 updateRobotV1 + +Update status of robot account. + +Used to disable/enable a specified robot account. + +*/ +type UpdateRobotV1 struct { + Context *middleware.Context + Handler UpdateRobotV1Handler +} + +func (o *UpdateRobotV1) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewUpdateRobotV1Params() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/robotv1/update_robot_v1_parameters.go b/src/server/v2.0/restapi/operations/robotv1/update_robot_v1_parameters.go new file mode 100644 index 000000000..bb2e8a24f --- /dev/null +++ b/src/server/v2.0/restapi/operations/robotv1/update_robot_v1_parameters.go @@ -0,0 +1,215 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package robotv1 + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewUpdateRobotV1Params creates a new UpdateRobotV1Params object +// with the default values initialized. +func NewUpdateRobotV1Params() UpdateRobotV1Params { + + var ( + // initialize parameters with default values + + xIsResourceNameDefault = bool(false) + ) + + return UpdateRobotV1Params{ + XIsResourceName: &xIsResourceNameDefault, + } +} + +// UpdateRobotV1Params contains all the bound params for the update robot v1 operation +// typically these are obtained from a http.Request +// +// swagger:parameters UpdateRobotV1 +type UpdateRobotV1Params struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name. + In: header + Default: false + */ + XIsResourceName *bool + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The name or id of the project + Required: true + In: path + */ + ProjectNameOrID string + /*The JSON object of a robot account. + Required: true + In: body + */ + Robot *models.Robot + /*Robot ID + Required: true + In: path + */ + RobotID int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewUpdateRobotV1Params() beforehand. +func (o *UpdateRobotV1Params) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXIsResourceName(r.Header[http.CanonicalHeaderKey("X-Is-Resource-Name")], true, route.Formats); err != nil { + res = append(res, err) + } + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rProjectNameOrID, rhkProjectNameOrID, _ := route.Params.GetOK("project_name_or_id") + if err := o.bindProjectNameOrID(rProjectNameOrID, rhkProjectNameOrID, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Robot + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("robot", "body", "")) + } else { + res = append(res, errors.NewParseError("robot", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Robot = &body + } + } + } else { + res = append(res, errors.Required("robot", "body", "")) + } + rRobotID, rhkRobotID, _ := route.Params.GetOK("robot_id") + if err := o.bindRobotID(rRobotID, rhkRobotID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXIsResourceName binds and validates parameter XIsResourceName from header. +func (o *UpdateRobotV1Params) bindXIsResourceName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewUpdateRobotV1Params() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("X-Is-Resource-Name", "header", "bool", raw) + } + o.XIsResourceName = &value + + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *UpdateRobotV1Params) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *UpdateRobotV1Params) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindProjectNameOrID binds and validates parameter ProjectNameOrID from path. +func (o *UpdateRobotV1Params) bindProjectNameOrID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectNameOrID = raw + + return nil +} + +// bindRobotID binds and validates parameter RobotID from path. +func (o *UpdateRobotV1Params) bindRobotID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("robot_id", "path", "int64", raw) + } + o.RobotID = value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/robotv1/update_robot_v1_responses.go b/src/server/v2.0/restapi/operations/robotv1/update_robot_v1_responses.go new file mode 100644 index 000000000..da68ddb1d --- /dev/null +++ b/src/server/v2.0/restapi/operations/robotv1/update_robot_v1_responses.go @@ -0,0 +1,456 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package robotv1 + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// UpdateRobotV1OKCode is the HTTP code returned for type UpdateRobotV1OK +const UpdateRobotV1OKCode int = 200 + +/*UpdateRobotV1OK Success + +swagger:response updateRobotV1OK +*/ +type UpdateRobotV1OK struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewUpdateRobotV1OK creates UpdateRobotV1OK with default headers values +func NewUpdateRobotV1OK() *UpdateRobotV1OK { + + return &UpdateRobotV1OK{} +} + +// WithXRequestID adds the xRequestId to the update robot v1 o k response +func (o *UpdateRobotV1OK) WithXRequestID(xRequestID string) *UpdateRobotV1OK { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update robot v1 o k response +func (o *UpdateRobotV1OK) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *UpdateRobotV1OK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// UpdateRobotV1BadRequestCode is the HTTP code returned for type UpdateRobotV1BadRequest +const UpdateRobotV1BadRequestCode int = 400 + +/*UpdateRobotV1BadRequest Bad request + +swagger:response updateRobotV1BadRequest +*/ +type UpdateRobotV1BadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateRobotV1BadRequest creates UpdateRobotV1BadRequest with default headers values +func NewUpdateRobotV1BadRequest() *UpdateRobotV1BadRequest { + + return &UpdateRobotV1BadRequest{} +} + +// WithXRequestID adds the xRequestId to the update robot v1 bad request response +func (o *UpdateRobotV1BadRequest) WithXRequestID(xRequestID string) *UpdateRobotV1BadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update robot v1 bad request response +func (o *UpdateRobotV1BadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update robot v1 bad request response +func (o *UpdateRobotV1BadRequest) WithPayload(payload *models.Errors) *UpdateRobotV1BadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update robot v1 bad request response +func (o *UpdateRobotV1BadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateRobotV1BadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateRobotV1UnauthorizedCode is the HTTP code returned for type UpdateRobotV1Unauthorized +const UpdateRobotV1UnauthorizedCode int = 401 + +/*UpdateRobotV1Unauthorized Unauthorized + +swagger:response updateRobotV1Unauthorized +*/ +type UpdateRobotV1Unauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateRobotV1Unauthorized creates UpdateRobotV1Unauthorized with default headers values +func NewUpdateRobotV1Unauthorized() *UpdateRobotV1Unauthorized { + + return &UpdateRobotV1Unauthorized{} +} + +// WithXRequestID adds the xRequestId to the update robot v1 unauthorized response +func (o *UpdateRobotV1Unauthorized) WithXRequestID(xRequestID string) *UpdateRobotV1Unauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update robot v1 unauthorized response +func (o *UpdateRobotV1Unauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update robot v1 unauthorized response +func (o *UpdateRobotV1Unauthorized) WithPayload(payload *models.Errors) *UpdateRobotV1Unauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update robot v1 unauthorized response +func (o *UpdateRobotV1Unauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateRobotV1Unauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateRobotV1ForbiddenCode is the HTTP code returned for type UpdateRobotV1Forbidden +const UpdateRobotV1ForbiddenCode int = 403 + +/*UpdateRobotV1Forbidden Forbidden + +swagger:response updateRobotV1Forbidden +*/ +type UpdateRobotV1Forbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateRobotV1Forbidden creates UpdateRobotV1Forbidden with default headers values +func NewUpdateRobotV1Forbidden() *UpdateRobotV1Forbidden { + + return &UpdateRobotV1Forbidden{} +} + +// WithXRequestID adds the xRequestId to the update robot v1 forbidden response +func (o *UpdateRobotV1Forbidden) WithXRequestID(xRequestID string) *UpdateRobotV1Forbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update robot v1 forbidden response +func (o *UpdateRobotV1Forbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update robot v1 forbidden response +func (o *UpdateRobotV1Forbidden) WithPayload(payload *models.Errors) *UpdateRobotV1Forbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update robot v1 forbidden response +func (o *UpdateRobotV1Forbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateRobotV1Forbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateRobotV1NotFoundCode is the HTTP code returned for type UpdateRobotV1NotFound +const UpdateRobotV1NotFoundCode int = 404 + +/*UpdateRobotV1NotFound Not found + +swagger:response updateRobotV1NotFound +*/ +type UpdateRobotV1NotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateRobotV1NotFound creates UpdateRobotV1NotFound with default headers values +func NewUpdateRobotV1NotFound() *UpdateRobotV1NotFound { + + return &UpdateRobotV1NotFound{} +} + +// WithXRequestID adds the xRequestId to the update robot v1 not found response +func (o *UpdateRobotV1NotFound) WithXRequestID(xRequestID string) *UpdateRobotV1NotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update robot v1 not found response +func (o *UpdateRobotV1NotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update robot v1 not found response +func (o *UpdateRobotV1NotFound) WithPayload(payload *models.Errors) *UpdateRobotV1NotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update robot v1 not found response +func (o *UpdateRobotV1NotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateRobotV1NotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateRobotV1ConflictCode is the HTTP code returned for type UpdateRobotV1Conflict +const UpdateRobotV1ConflictCode int = 409 + +/*UpdateRobotV1Conflict Conflict + +swagger:response updateRobotV1Conflict +*/ +type UpdateRobotV1Conflict struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateRobotV1Conflict creates UpdateRobotV1Conflict with default headers values +func NewUpdateRobotV1Conflict() *UpdateRobotV1Conflict { + + return &UpdateRobotV1Conflict{} +} + +// WithXRequestID adds the xRequestId to the update robot v1 conflict response +func (o *UpdateRobotV1Conflict) WithXRequestID(xRequestID string) *UpdateRobotV1Conflict { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update robot v1 conflict response +func (o *UpdateRobotV1Conflict) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update robot v1 conflict response +func (o *UpdateRobotV1Conflict) WithPayload(payload *models.Errors) *UpdateRobotV1Conflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update robot v1 conflict response +func (o *UpdateRobotV1Conflict) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateRobotV1Conflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateRobotV1InternalServerErrorCode is the HTTP code returned for type UpdateRobotV1InternalServerError +const UpdateRobotV1InternalServerErrorCode int = 500 + +/*UpdateRobotV1InternalServerError Internal server error + +swagger:response updateRobotV1InternalServerError +*/ +type UpdateRobotV1InternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateRobotV1InternalServerError creates UpdateRobotV1InternalServerError with default headers values +func NewUpdateRobotV1InternalServerError() *UpdateRobotV1InternalServerError { + + return &UpdateRobotV1InternalServerError{} +} + +// WithXRequestID adds the xRequestId to the update robot v1 internal server error response +func (o *UpdateRobotV1InternalServerError) WithXRequestID(xRequestID string) *UpdateRobotV1InternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update robot v1 internal server error response +func (o *UpdateRobotV1InternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update robot v1 internal server error response +func (o *UpdateRobotV1InternalServerError) WithPayload(payload *models.Errors) *UpdateRobotV1InternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update robot v1 internal server error response +func (o *UpdateRobotV1InternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateRobotV1InternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/robotv1/update_robot_v1_urlbuilder.go b/src/server/v2.0/restapi/operations/robotv1/update_robot_v1_urlbuilder.go new file mode 100644 index 000000000..8f3e97a84 --- /dev/null +++ b/src/server/v2.0/restapi/operations/robotv1/update_robot_v1_urlbuilder.go @@ -0,0 +1,109 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package robotv1 + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// UpdateRobotV1URL generates an URL for the update robot v1 operation +type UpdateRobotV1URL struct { + ProjectNameOrID string + RobotID int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdateRobotV1URL) WithBasePath(bp string) *UpdateRobotV1URL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdateRobotV1URL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *UpdateRobotV1URL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name_or_id}/robots/{robot_id}" + + projectNameOrID := o.ProjectNameOrID + if projectNameOrID != "" { + _path = strings.Replace(_path, "{project_name_or_id}", projectNameOrID, -1) + } else { + return nil, errors.New("projectNameOrId is required on UpdateRobotV1URL") + } + + robotID := swag.FormatInt64(o.RobotID) + if robotID != "" { + _path = strings.Replace(_path, "{robot_id}", robotID, -1) + } else { + return nil, errors.New("robotId is required on UpdateRobotV1URL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *UpdateRobotV1URL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *UpdateRobotV1URL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *UpdateRobotV1URL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on UpdateRobotV1URL") + } + if host == "" { + return nil, errors.New("host is required for a full url on UpdateRobotV1URL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *UpdateRobotV1URL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/scan/get_report_log.go b/src/server/v2.0/restapi/operations/scan/get_report_log.go new file mode 100644 index 000000000..bfad0a44b --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan/get_report_log.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetReportLogHandlerFunc turns a function with the right signature into a get report log handler +type GetReportLogHandlerFunc func(GetReportLogParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetReportLogHandlerFunc) Handle(params GetReportLogParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetReportLogHandler interface for that can handle valid get report log params +type GetReportLogHandler interface { + Handle(GetReportLogParams, interface{}) middleware.Responder +} + +// NewGetReportLog creates a new http.Handler for the get report log operation +func NewGetReportLog(ctx *middleware.Context, handler GetReportLogHandler) *GetReportLog { + return &GetReportLog{Context: ctx, Handler: handler} +} + +/*GetReportLog swagger:route GET /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/scan/{report_id}/log scan getReportLog + +Get the log of the scan report + +Get the log of the scan report + +*/ +type GetReportLog struct { + Context *middleware.Context + Handler GetReportLogHandler +} + +func (o *GetReportLog) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetReportLogParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/scan/get_report_log_parameters.go b/src/server/v2.0/restapi/operations/scan/get_report_log_parameters.go new file mode 100644 index 000000000..d33bd5d28 --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan/get_report_log_parameters.go @@ -0,0 +1,189 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewGetReportLogParams creates a new GetReportLogParams object +// no default values defined in spec. +func NewGetReportLogParams() GetReportLogParams { + + return GetReportLogParams{} +} + +// GetReportLogParams contains all the bound params for the get report log operation +// typically these are obtained from a http.Request +// +// swagger:parameters getReportLog +type GetReportLogParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The name of the project + Required: true + In: path + */ + ProjectName string + /*The reference of the artifact, can be digest or tag + Required: true + In: path + */ + Reference string + /*The report id to get the log + Required: true + In: path + */ + ReportID string + /*The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -> a%252Fb + Required: true + In: path + */ + RepositoryName string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetReportLogParams() beforehand. +func (o *GetReportLogParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rProjectName, rhkProjectName, _ := route.Params.GetOK("project_name") + if err := o.bindProjectName(rProjectName, rhkProjectName, route.Formats); err != nil { + res = append(res, err) + } + + rReference, rhkReference, _ := route.Params.GetOK("reference") + if err := o.bindReference(rReference, rhkReference, route.Formats); err != nil { + res = append(res, err) + } + + rReportID, rhkReportID, _ := route.Params.GetOK("report_id") + if err := o.bindReportID(rReportID, rhkReportID, route.Formats); err != nil { + res = append(res, err) + } + + rRepositoryName, rhkRepositoryName, _ := route.Params.GetOK("repository_name") + if err := o.bindRepositoryName(rRepositoryName, rhkRepositoryName, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetReportLogParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetReportLogParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindProjectName binds and validates parameter ProjectName from path. +func (o *GetReportLogParams) bindProjectName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectName = raw + + return nil +} + +// bindReference binds and validates parameter Reference from path. +func (o *GetReportLogParams) bindReference(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.Reference = raw + + return nil +} + +// bindReportID binds and validates parameter ReportID from path. +func (o *GetReportLogParams) bindReportID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ReportID = raw + + return nil +} + +// bindRepositoryName binds and validates parameter RepositoryName from path. +func (o *GetReportLogParams) bindRepositoryName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.RepositoryName = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/scan/get_report_log_responses.go b/src/server/v2.0/restapi/operations/scan/get_report_log_responses.go new file mode 100644 index 000000000..a59ddac17 --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan/get_report_log_responses.go @@ -0,0 +1,320 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetReportLogOKCode is the HTTP code returned for type GetReportLogOK +const GetReportLogOKCode int = 200 + +/*GetReportLogOK Successfully get scan log file + +swagger:response getReportLogOK +*/ +type GetReportLogOK struct { + + /* + In: Body + */ + Payload string `json:"body,omitempty"` +} + +// NewGetReportLogOK creates GetReportLogOK with default headers values +func NewGetReportLogOK() *GetReportLogOK { + + return &GetReportLogOK{} +} + +// WithPayload adds the payload to the get report log o k response +func (o *GetReportLogOK) WithPayload(payload string) *GetReportLogOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get report log o k response +func (o *GetReportLogOK) SetPayload(payload string) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetReportLogOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// GetReportLogUnauthorizedCode is the HTTP code returned for type GetReportLogUnauthorized +const GetReportLogUnauthorizedCode int = 401 + +/*GetReportLogUnauthorized Unauthorized + +swagger:response getReportLogUnauthorized +*/ +type GetReportLogUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetReportLogUnauthorized creates GetReportLogUnauthorized with default headers values +func NewGetReportLogUnauthorized() *GetReportLogUnauthorized { + + return &GetReportLogUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the get report log unauthorized response +func (o *GetReportLogUnauthorized) WithXRequestID(xRequestID string) *GetReportLogUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get report log unauthorized response +func (o *GetReportLogUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get report log unauthorized response +func (o *GetReportLogUnauthorized) WithPayload(payload *models.Errors) *GetReportLogUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get report log unauthorized response +func (o *GetReportLogUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetReportLogUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetReportLogForbiddenCode is the HTTP code returned for type GetReportLogForbidden +const GetReportLogForbiddenCode int = 403 + +/*GetReportLogForbidden Forbidden + +swagger:response getReportLogForbidden +*/ +type GetReportLogForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetReportLogForbidden creates GetReportLogForbidden with default headers values +func NewGetReportLogForbidden() *GetReportLogForbidden { + + return &GetReportLogForbidden{} +} + +// WithXRequestID adds the xRequestId to the get report log forbidden response +func (o *GetReportLogForbidden) WithXRequestID(xRequestID string) *GetReportLogForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get report log forbidden response +func (o *GetReportLogForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get report log forbidden response +func (o *GetReportLogForbidden) WithPayload(payload *models.Errors) *GetReportLogForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get report log forbidden response +func (o *GetReportLogForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetReportLogForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetReportLogNotFoundCode is the HTTP code returned for type GetReportLogNotFound +const GetReportLogNotFoundCode int = 404 + +/*GetReportLogNotFound Not found + +swagger:response getReportLogNotFound +*/ +type GetReportLogNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetReportLogNotFound creates GetReportLogNotFound with default headers values +func NewGetReportLogNotFound() *GetReportLogNotFound { + + return &GetReportLogNotFound{} +} + +// WithXRequestID adds the xRequestId to the get report log not found response +func (o *GetReportLogNotFound) WithXRequestID(xRequestID string) *GetReportLogNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get report log not found response +func (o *GetReportLogNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get report log not found response +func (o *GetReportLogNotFound) WithPayload(payload *models.Errors) *GetReportLogNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get report log not found response +func (o *GetReportLogNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetReportLogNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetReportLogInternalServerErrorCode is the HTTP code returned for type GetReportLogInternalServerError +const GetReportLogInternalServerErrorCode int = 500 + +/*GetReportLogInternalServerError Internal server error + +swagger:response getReportLogInternalServerError +*/ +type GetReportLogInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetReportLogInternalServerError creates GetReportLogInternalServerError with default headers values +func NewGetReportLogInternalServerError() *GetReportLogInternalServerError { + + return &GetReportLogInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get report log internal server error response +func (o *GetReportLogInternalServerError) WithXRequestID(xRequestID string) *GetReportLogInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get report log internal server error response +func (o *GetReportLogInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get report log internal server error response +func (o *GetReportLogInternalServerError) WithPayload(payload *models.Errors) *GetReportLogInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get report log internal server error response +func (o *GetReportLogInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetReportLogInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/scan/get_report_log_urlbuilder.go b/src/server/v2.0/restapi/operations/scan/get_report_log_urlbuilder.go new file mode 100644 index 000000000..d778d36ce --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan/get_report_log_urlbuilder.go @@ -0,0 +1,123 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetReportLogURL generates an URL for the get report log operation +type GetReportLogURL struct { + ProjectName string + Reference string + ReportID string + RepositoryName string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetReportLogURL) WithBasePath(bp string) *GetReportLogURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetReportLogURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetReportLogURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/scan/{report_id}/log" + + projectName := o.ProjectName + if projectName != "" { + _path = strings.Replace(_path, "{project_name}", projectName, -1) + } else { + return nil, errors.New("projectName is required on GetReportLogURL") + } + + reference := o.Reference + if reference != "" { + _path = strings.Replace(_path, "{reference}", reference, -1) + } else { + return nil, errors.New("reference is required on GetReportLogURL") + } + + reportID := o.ReportID + if reportID != "" { + _path = strings.Replace(_path, "{report_id}", reportID, -1) + } else { + return nil, errors.New("reportId is required on GetReportLogURL") + } + + repositoryName := o.RepositoryName + if repositoryName != "" { + _path = strings.Replace(_path, "{repository_name}", repositoryName, -1) + } else { + return nil, errors.New("repositoryName is required on GetReportLogURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetReportLogURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetReportLogURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetReportLogURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetReportLogURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetReportLogURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetReportLogURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/scan/scan_artifact.go b/src/server/v2.0/restapi/operations/scan/scan_artifact.go new file mode 100644 index 000000000..d864efc2c --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan/scan_artifact.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ScanArtifactHandlerFunc turns a function with the right signature into a scan artifact handler +type ScanArtifactHandlerFunc func(ScanArtifactParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ScanArtifactHandlerFunc) Handle(params ScanArtifactParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ScanArtifactHandler interface for that can handle valid scan artifact params +type ScanArtifactHandler interface { + Handle(ScanArtifactParams, interface{}) middleware.Responder +} + +// NewScanArtifact creates a new http.Handler for the scan artifact operation +func NewScanArtifact(ctx *middleware.Context, handler ScanArtifactHandler) *ScanArtifact { + return &ScanArtifact{Context: ctx, Handler: handler} +} + +/*ScanArtifact swagger:route POST /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/scan scan scanArtifact + +Scan the artifact + +Scan the specified artifact + +*/ +type ScanArtifact struct { + Context *middleware.Context + Handler ScanArtifactHandler +} + +func (o *ScanArtifact) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewScanArtifactParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/scan/scan_artifact_parameters.go b/src/server/v2.0/restapi/operations/scan/scan_artifact_parameters.go new file mode 100644 index 000000000..42598fc49 --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan/scan_artifact_parameters.go @@ -0,0 +1,164 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewScanArtifactParams creates a new ScanArtifactParams object +// no default values defined in spec. +func NewScanArtifactParams() ScanArtifactParams { + + return ScanArtifactParams{} +} + +// ScanArtifactParams contains all the bound params for the scan artifact operation +// typically these are obtained from a http.Request +// +// swagger:parameters scanArtifact +type ScanArtifactParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The name of the project + Required: true + In: path + */ + ProjectName string + /*The reference of the artifact, can be digest or tag + Required: true + In: path + */ + Reference string + /*The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -> a%252Fb + Required: true + In: path + */ + RepositoryName string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewScanArtifactParams() beforehand. +func (o *ScanArtifactParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rProjectName, rhkProjectName, _ := route.Params.GetOK("project_name") + if err := o.bindProjectName(rProjectName, rhkProjectName, route.Formats); err != nil { + res = append(res, err) + } + + rReference, rhkReference, _ := route.Params.GetOK("reference") + if err := o.bindReference(rReference, rhkReference, route.Formats); err != nil { + res = append(res, err) + } + + rRepositoryName, rhkRepositoryName, _ := route.Params.GetOK("repository_name") + if err := o.bindRepositoryName(rRepositoryName, rhkRepositoryName, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *ScanArtifactParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *ScanArtifactParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindProjectName binds and validates parameter ProjectName from path. +func (o *ScanArtifactParams) bindProjectName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectName = raw + + return nil +} + +// bindReference binds and validates parameter Reference from path. +func (o *ScanArtifactParams) bindReference(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.Reference = raw + + return nil +} + +// bindRepositoryName binds and validates parameter RepositoryName from path. +func (o *ScanArtifactParams) bindRepositoryName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.RepositoryName = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/scan/scan_artifact_responses.go b/src/server/v2.0/restapi/operations/scan/scan_artifact_responses.go new file mode 100644 index 000000000..b90ac4449 --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan/scan_artifact_responses.go @@ -0,0 +1,390 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// ScanArtifactAcceptedCode is the HTTP code returned for type ScanArtifactAccepted +const ScanArtifactAcceptedCode int = 202 + +/*ScanArtifactAccepted Accepted + +swagger:response scanArtifactAccepted +*/ +type ScanArtifactAccepted struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewScanArtifactAccepted creates ScanArtifactAccepted with default headers values +func NewScanArtifactAccepted() *ScanArtifactAccepted { + + return &ScanArtifactAccepted{} +} + +// WithXRequestID adds the xRequestId to the scan artifact accepted response +func (o *ScanArtifactAccepted) WithXRequestID(xRequestID string) *ScanArtifactAccepted { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the scan artifact accepted response +func (o *ScanArtifactAccepted) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *ScanArtifactAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// ScanArtifactBadRequestCode is the HTTP code returned for type ScanArtifactBadRequest +const ScanArtifactBadRequestCode int = 400 + +/*ScanArtifactBadRequest Bad request + +swagger:response scanArtifactBadRequest +*/ +type ScanArtifactBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewScanArtifactBadRequest creates ScanArtifactBadRequest with default headers values +func NewScanArtifactBadRequest() *ScanArtifactBadRequest { + + return &ScanArtifactBadRequest{} +} + +// WithXRequestID adds the xRequestId to the scan artifact bad request response +func (o *ScanArtifactBadRequest) WithXRequestID(xRequestID string) *ScanArtifactBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the scan artifact bad request response +func (o *ScanArtifactBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the scan artifact bad request response +func (o *ScanArtifactBadRequest) WithPayload(payload *models.Errors) *ScanArtifactBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the scan artifact bad request response +func (o *ScanArtifactBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ScanArtifactBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ScanArtifactUnauthorizedCode is the HTTP code returned for type ScanArtifactUnauthorized +const ScanArtifactUnauthorizedCode int = 401 + +/*ScanArtifactUnauthorized Unauthorized + +swagger:response scanArtifactUnauthorized +*/ +type ScanArtifactUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewScanArtifactUnauthorized creates ScanArtifactUnauthorized with default headers values +func NewScanArtifactUnauthorized() *ScanArtifactUnauthorized { + + return &ScanArtifactUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the scan artifact unauthorized response +func (o *ScanArtifactUnauthorized) WithXRequestID(xRequestID string) *ScanArtifactUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the scan artifact unauthorized response +func (o *ScanArtifactUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the scan artifact unauthorized response +func (o *ScanArtifactUnauthorized) WithPayload(payload *models.Errors) *ScanArtifactUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the scan artifact unauthorized response +func (o *ScanArtifactUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ScanArtifactUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ScanArtifactForbiddenCode is the HTTP code returned for type ScanArtifactForbidden +const ScanArtifactForbiddenCode int = 403 + +/*ScanArtifactForbidden Forbidden + +swagger:response scanArtifactForbidden +*/ +type ScanArtifactForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewScanArtifactForbidden creates ScanArtifactForbidden with default headers values +func NewScanArtifactForbidden() *ScanArtifactForbidden { + + return &ScanArtifactForbidden{} +} + +// WithXRequestID adds the xRequestId to the scan artifact forbidden response +func (o *ScanArtifactForbidden) WithXRequestID(xRequestID string) *ScanArtifactForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the scan artifact forbidden response +func (o *ScanArtifactForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the scan artifact forbidden response +func (o *ScanArtifactForbidden) WithPayload(payload *models.Errors) *ScanArtifactForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the scan artifact forbidden response +func (o *ScanArtifactForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ScanArtifactForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ScanArtifactNotFoundCode is the HTTP code returned for type ScanArtifactNotFound +const ScanArtifactNotFoundCode int = 404 + +/*ScanArtifactNotFound Not found + +swagger:response scanArtifactNotFound +*/ +type ScanArtifactNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewScanArtifactNotFound creates ScanArtifactNotFound with default headers values +func NewScanArtifactNotFound() *ScanArtifactNotFound { + + return &ScanArtifactNotFound{} +} + +// WithXRequestID adds the xRequestId to the scan artifact not found response +func (o *ScanArtifactNotFound) WithXRequestID(xRequestID string) *ScanArtifactNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the scan artifact not found response +func (o *ScanArtifactNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the scan artifact not found response +func (o *ScanArtifactNotFound) WithPayload(payload *models.Errors) *ScanArtifactNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the scan artifact not found response +func (o *ScanArtifactNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ScanArtifactNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ScanArtifactInternalServerErrorCode is the HTTP code returned for type ScanArtifactInternalServerError +const ScanArtifactInternalServerErrorCode int = 500 + +/*ScanArtifactInternalServerError Internal server error + +swagger:response scanArtifactInternalServerError +*/ +type ScanArtifactInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewScanArtifactInternalServerError creates ScanArtifactInternalServerError with default headers values +func NewScanArtifactInternalServerError() *ScanArtifactInternalServerError { + + return &ScanArtifactInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the scan artifact internal server error response +func (o *ScanArtifactInternalServerError) WithXRequestID(xRequestID string) *ScanArtifactInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the scan artifact internal server error response +func (o *ScanArtifactInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the scan artifact internal server error response +func (o *ScanArtifactInternalServerError) WithPayload(payload *models.Errors) *ScanArtifactInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the scan artifact internal server error response +func (o *ScanArtifactInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ScanArtifactInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/scan/scan_artifact_urlbuilder.go b/src/server/v2.0/restapi/operations/scan/scan_artifact_urlbuilder.go new file mode 100644 index 000000000..e87e4f2b3 --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan/scan_artifact_urlbuilder.go @@ -0,0 +1,115 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// ScanArtifactURL generates an URL for the scan artifact operation +type ScanArtifactURL struct { + ProjectName string + Reference string + RepositoryName string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ScanArtifactURL) WithBasePath(bp string) *ScanArtifactURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ScanArtifactURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ScanArtifactURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/scan" + + projectName := o.ProjectName + if projectName != "" { + _path = strings.Replace(_path, "{project_name}", projectName, -1) + } else { + return nil, errors.New("projectName is required on ScanArtifactURL") + } + + reference := o.Reference + if reference != "" { + _path = strings.Replace(_path, "{reference}", reference, -1) + } else { + return nil, errors.New("reference is required on ScanArtifactURL") + } + + repositoryName := o.RepositoryName + if repositoryName != "" { + _path = strings.Replace(_path, "{repository_name}", repositoryName, -1) + } else { + return nil, errors.New("repositoryName is required on ScanArtifactURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ScanArtifactURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ScanArtifactURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ScanArtifactURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ScanArtifactURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ScanArtifactURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ScanArtifactURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/scan/stop_scan_artifact.go b/src/server/v2.0/restapi/operations/scan/stop_scan_artifact.go new file mode 100644 index 000000000..226f1855a --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan/stop_scan_artifact.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// StopScanArtifactHandlerFunc turns a function with the right signature into a stop scan artifact handler +type StopScanArtifactHandlerFunc func(StopScanArtifactParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn StopScanArtifactHandlerFunc) Handle(params StopScanArtifactParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// StopScanArtifactHandler interface for that can handle valid stop scan artifact params +type StopScanArtifactHandler interface { + Handle(StopScanArtifactParams, interface{}) middleware.Responder +} + +// NewStopScanArtifact creates a new http.Handler for the stop scan artifact operation +func NewStopScanArtifact(ctx *middleware.Context, handler StopScanArtifactHandler) *StopScanArtifact { + return &StopScanArtifact{Context: ctx, Handler: handler} +} + +/*StopScanArtifact swagger:route POST /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/scan/stop scan stopScanArtifact + +Cancelling a scan job for a particular artifact + +Cancelling a scan job for a particular artifact + +*/ +type StopScanArtifact struct { + Context *middleware.Context + Handler StopScanArtifactHandler +} + +func (o *StopScanArtifact) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewStopScanArtifactParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/scan/stop_scan_artifact_parameters.go b/src/server/v2.0/restapi/operations/scan/stop_scan_artifact_parameters.go new file mode 100644 index 000000000..8ced453dd --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan/stop_scan_artifact_parameters.go @@ -0,0 +1,164 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewStopScanArtifactParams creates a new StopScanArtifactParams object +// no default values defined in spec. +func NewStopScanArtifactParams() StopScanArtifactParams { + + return StopScanArtifactParams{} +} + +// StopScanArtifactParams contains all the bound params for the stop scan artifact operation +// typically these are obtained from a http.Request +// +// swagger:parameters stopScanArtifact +type StopScanArtifactParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The name of the project + Required: true + In: path + */ + ProjectName string + /*The reference of the artifact, can be digest or tag + Required: true + In: path + */ + Reference string + /*The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -> a%252Fb + Required: true + In: path + */ + RepositoryName string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewStopScanArtifactParams() beforehand. +func (o *StopScanArtifactParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rProjectName, rhkProjectName, _ := route.Params.GetOK("project_name") + if err := o.bindProjectName(rProjectName, rhkProjectName, route.Formats); err != nil { + res = append(res, err) + } + + rReference, rhkReference, _ := route.Params.GetOK("reference") + if err := o.bindReference(rReference, rhkReference, route.Formats); err != nil { + res = append(res, err) + } + + rRepositoryName, rhkRepositoryName, _ := route.Params.GetOK("repository_name") + if err := o.bindRepositoryName(rRepositoryName, rhkRepositoryName, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *StopScanArtifactParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *StopScanArtifactParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindProjectName binds and validates parameter ProjectName from path. +func (o *StopScanArtifactParams) bindProjectName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectName = raw + + return nil +} + +// bindReference binds and validates parameter Reference from path. +func (o *StopScanArtifactParams) bindReference(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.Reference = raw + + return nil +} + +// bindRepositoryName binds and validates parameter RepositoryName from path. +func (o *StopScanArtifactParams) bindRepositoryName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.RepositoryName = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/scan/stop_scan_artifact_responses.go b/src/server/v2.0/restapi/operations/scan/stop_scan_artifact_responses.go new file mode 100644 index 000000000..7f9715dd8 --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan/stop_scan_artifact_responses.go @@ -0,0 +1,390 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// StopScanArtifactAcceptedCode is the HTTP code returned for type StopScanArtifactAccepted +const StopScanArtifactAcceptedCode int = 202 + +/*StopScanArtifactAccepted Accepted + +swagger:response stopScanArtifactAccepted +*/ +type StopScanArtifactAccepted struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewStopScanArtifactAccepted creates StopScanArtifactAccepted with default headers values +func NewStopScanArtifactAccepted() *StopScanArtifactAccepted { + + return &StopScanArtifactAccepted{} +} + +// WithXRequestID adds the xRequestId to the stop scan artifact accepted response +func (o *StopScanArtifactAccepted) WithXRequestID(xRequestID string) *StopScanArtifactAccepted { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the stop scan artifact accepted response +func (o *StopScanArtifactAccepted) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *StopScanArtifactAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// StopScanArtifactBadRequestCode is the HTTP code returned for type StopScanArtifactBadRequest +const StopScanArtifactBadRequestCode int = 400 + +/*StopScanArtifactBadRequest Bad request + +swagger:response stopScanArtifactBadRequest +*/ +type StopScanArtifactBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewStopScanArtifactBadRequest creates StopScanArtifactBadRequest with default headers values +func NewStopScanArtifactBadRequest() *StopScanArtifactBadRequest { + + return &StopScanArtifactBadRequest{} +} + +// WithXRequestID adds the xRequestId to the stop scan artifact bad request response +func (o *StopScanArtifactBadRequest) WithXRequestID(xRequestID string) *StopScanArtifactBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the stop scan artifact bad request response +func (o *StopScanArtifactBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the stop scan artifact bad request response +func (o *StopScanArtifactBadRequest) WithPayload(payload *models.Errors) *StopScanArtifactBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the stop scan artifact bad request response +func (o *StopScanArtifactBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *StopScanArtifactBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// StopScanArtifactUnauthorizedCode is the HTTP code returned for type StopScanArtifactUnauthorized +const StopScanArtifactUnauthorizedCode int = 401 + +/*StopScanArtifactUnauthorized Unauthorized + +swagger:response stopScanArtifactUnauthorized +*/ +type StopScanArtifactUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewStopScanArtifactUnauthorized creates StopScanArtifactUnauthorized with default headers values +func NewStopScanArtifactUnauthorized() *StopScanArtifactUnauthorized { + + return &StopScanArtifactUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the stop scan artifact unauthorized response +func (o *StopScanArtifactUnauthorized) WithXRequestID(xRequestID string) *StopScanArtifactUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the stop scan artifact unauthorized response +func (o *StopScanArtifactUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the stop scan artifact unauthorized response +func (o *StopScanArtifactUnauthorized) WithPayload(payload *models.Errors) *StopScanArtifactUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the stop scan artifact unauthorized response +func (o *StopScanArtifactUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *StopScanArtifactUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// StopScanArtifactForbiddenCode is the HTTP code returned for type StopScanArtifactForbidden +const StopScanArtifactForbiddenCode int = 403 + +/*StopScanArtifactForbidden Forbidden + +swagger:response stopScanArtifactForbidden +*/ +type StopScanArtifactForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewStopScanArtifactForbidden creates StopScanArtifactForbidden with default headers values +func NewStopScanArtifactForbidden() *StopScanArtifactForbidden { + + return &StopScanArtifactForbidden{} +} + +// WithXRequestID adds the xRequestId to the stop scan artifact forbidden response +func (o *StopScanArtifactForbidden) WithXRequestID(xRequestID string) *StopScanArtifactForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the stop scan artifact forbidden response +func (o *StopScanArtifactForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the stop scan artifact forbidden response +func (o *StopScanArtifactForbidden) WithPayload(payload *models.Errors) *StopScanArtifactForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the stop scan artifact forbidden response +func (o *StopScanArtifactForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *StopScanArtifactForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// StopScanArtifactNotFoundCode is the HTTP code returned for type StopScanArtifactNotFound +const StopScanArtifactNotFoundCode int = 404 + +/*StopScanArtifactNotFound Not found + +swagger:response stopScanArtifactNotFound +*/ +type StopScanArtifactNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewStopScanArtifactNotFound creates StopScanArtifactNotFound with default headers values +func NewStopScanArtifactNotFound() *StopScanArtifactNotFound { + + return &StopScanArtifactNotFound{} +} + +// WithXRequestID adds the xRequestId to the stop scan artifact not found response +func (o *StopScanArtifactNotFound) WithXRequestID(xRequestID string) *StopScanArtifactNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the stop scan artifact not found response +func (o *StopScanArtifactNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the stop scan artifact not found response +func (o *StopScanArtifactNotFound) WithPayload(payload *models.Errors) *StopScanArtifactNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the stop scan artifact not found response +func (o *StopScanArtifactNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *StopScanArtifactNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// StopScanArtifactInternalServerErrorCode is the HTTP code returned for type StopScanArtifactInternalServerError +const StopScanArtifactInternalServerErrorCode int = 500 + +/*StopScanArtifactInternalServerError Internal server error + +swagger:response stopScanArtifactInternalServerError +*/ +type StopScanArtifactInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewStopScanArtifactInternalServerError creates StopScanArtifactInternalServerError with default headers values +func NewStopScanArtifactInternalServerError() *StopScanArtifactInternalServerError { + + return &StopScanArtifactInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the stop scan artifact internal server error response +func (o *StopScanArtifactInternalServerError) WithXRequestID(xRequestID string) *StopScanArtifactInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the stop scan artifact internal server error response +func (o *StopScanArtifactInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the stop scan artifact internal server error response +func (o *StopScanArtifactInternalServerError) WithPayload(payload *models.Errors) *StopScanArtifactInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the stop scan artifact internal server error response +func (o *StopScanArtifactInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *StopScanArtifactInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/scan/stop_scan_artifact_urlbuilder.go b/src/server/v2.0/restapi/operations/scan/stop_scan_artifact_urlbuilder.go new file mode 100644 index 000000000..ff2fe5490 --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan/stop_scan_artifact_urlbuilder.go @@ -0,0 +1,115 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// StopScanArtifactURL generates an URL for the stop scan artifact operation +type StopScanArtifactURL struct { + ProjectName string + Reference string + RepositoryName string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *StopScanArtifactURL) WithBasePath(bp string) *StopScanArtifactURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *StopScanArtifactURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *StopScanArtifactURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/scan/stop" + + projectName := o.ProjectName + if projectName != "" { + _path = strings.Replace(_path, "{project_name}", projectName, -1) + } else { + return nil, errors.New("projectName is required on StopScanArtifactURL") + } + + reference := o.Reference + if reference != "" { + _path = strings.Replace(_path, "{reference}", reference, -1) + } else { + return nil, errors.New("reference is required on StopScanArtifactURL") + } + + repositoryName := o.RepositoryName + if repositoryName != "" { + _path = strings.Replace(_path, "{repository_name}", repositoryName, -1) + } else { + return nil, errors.New("repositoryName is required on StopScanArtifactURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *StopScanArtifactURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *StopScanArtifactURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *StopScanArtifactURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on StopScanArtifactURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on StopScanArtifactURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *StopScanArtifactURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/scan_all/create_scan_all_schedule.go b/src/server/v2.0/restapi/operations/scan_all/create_scan_all_schedule.go new file mode 100644 index 000000000..2a85207bc --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan_all/create_scan_all_schedule.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan_all + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateScanAllScheduleHandlerFunc turns a function with the right signature into a create scan all schedule handler +type CreateScanAllScheduleHandlerFunc func(CreateScanAllScheduleParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateScanAllScheduleHandlerFunc) Handle(params CreateScanAllScheduleParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateScanAllScheduleHandler interface for that can handle valid create scan all schedule params +type CreateScanAllScheduleHandler interface { + Handle(CreateScanAllScheduleParams, interface{}) middleware.Responder +} + +// NewCreateScanAllSchedule creates a new http.Handler for the create scan all schedule operation +func NewCreateScanAllSchedule(ctx *middleware.Context, handler CreateScanAllScheduleHandler) *CreateScanAllSchedule { + return &CreateScanAllSchedule{Context: ctx, Handler: handler} +} + +/*CreateScanAllSchedule swagger:route POST /system/scanAll/schedule scanAll createScanAllSchedule + +Create a schedule or a manual trigger for the scan all job. + +This endpoint is for creating a schedule or a manual trigger for the scan all job, which scans all of images in Harbor. + +*/ +type CreateScanAllSchedule struct { + Context *middleware.Context + Handler CreateScanAllScheduleHandler +} + +func (o *CreateScanAllSchedule) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewCreateScanAllScheduleParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/scan_all/create_scan_all_schedule_parameters.go b/src/server/v2.0/restapi/operations/scan_all/create_scan_all_schedule_parameters.go new file mode 100644 index 000000000..a2ccd5953 --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan_all/create_scan_all_schedule_parameters.go @@ -0,0 +1,120 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan_all + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewCreateScanAllScheduleParams creates a new CreateScanAllScheduleParams object +// no default values defined in spec. +func NewCreateScanAllScheduleParams() CreateScanAllScheduleParams { + + return CreateScanAllScheduleParams{} +} + +// CreateScanAllScheduleParams contains all the bound params for the create scan all schedule operation +// typically these are obtained from a http.Request +// +// swagger:parameters createScanAllSchedule +type CreateScanAllScheduleParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*Create a schedule or a manual trigger for the scan all job. + Required: true + In: body + */ + Schedule *models.Schedule +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateScanAllScheduleParams() beforehand. +func (o *CreateScanAllScheduleParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Schedule + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("schedule", "body", "")) + } else { + res = append(res, errors.NewParseError("schedule", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Schedule = &body + } + } + } else { + res = append(res, errors.Required("schedule", "body", "")) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *CreateScanAllScheduleParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *CreateScanAllScheduleParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} diff --git a/src/server/v2.0/restapi/operations/scan_all/create_scan_all_schedule_responses.go b/src/server/v2.0/restapi/operations/scan_all/create_scan_all_schedule_responses.go new file mode 100644 index 000000000..f48bb9b12 --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan_all/create_scan_all_schedule_responses.go @@ -0,0 +1,478 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan_all + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// CreateScanAllScheduleCreatedCode is the HTTP code returned for type CreateScanAllScheduleCreated +const CreateScanAllScheduleCreatedCode int = 201 + +/*CreateScanAllScheduleCreated Created + +swagger:response createScanAllScheduleCreated +*/ +type CreateScanAllScheduleCreated struct { + /*The location of the resource + + */ + Location string `json:"Location"` + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewCreateScanAllScheduleCreated creates CreateScanAllScheduleCreated with default headers values +func NewCreateScanAllScheduleCreated() *CreateScanAllScheduleCreated { + + return &CreateScanAllScheduleCreated{} +} + +// WithLocation adds the location to the create scan all schedule created response +func (o *CreateScanAllScheduleCreated) WithLocation(location string) *CreateScanAllScheduleCreated { + o.Location = location + return o +} + +// SetLocation sets the location to the create scan all schedule created response +func (o *CreateScanAllScheduleCreated) SetLocation(location string) { + o.Location = location +} + +// WithXRequestID adds the xRequestId to the create scan all schedule created response +func (o *CreateScanAllScheduleCreated) WithXRequestID(xRequestID string) *CreateScanAllScheduleCreated { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create scan all schedule created response +func (o *CreateScanAllScheduleCreated) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *CreateScanAllScheduleCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Location + + location := o.Location + if location != "" { + rw.Header().Set("Location", location) + } + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(201) +} + +// CreateScanAllScheduleBadRequestCode is the HTTP code returned for type CreateScanAllScheduleBadRequest +const CreateScanAllScheduleBadRequestCode int = 400 + +/*CreateScanAllScheduleBadRequest Bad request + +swagger:response createScanAllScheduleBadRequest +*/ +type CreateScanAllScheduleBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateScanAllScheduleBadRequest creates CreateScanAllScheduleBadRequest with default headers values +func NewCreateScanAllScheduleBadRequest() *CreateScanAllScheduleBadRequest { + + return &CreateScanAllScheduleBadRequest{} +} + +// WithXRequestID adds the xRequestId to the create scan all schedule bad request response +func (o *CreateScanAllScheduleBadRequest) WithXRequestID(xRequestID string) *CreateScanAllScheduleBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create scan all schedule bad request response +func (o *CreateScanAllScheduleBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create scan all schedule bad request response +func (o *CreateScanAllScheduleBadRequest) WithPayload(payload *models.Errors) *CreateScanAllScheduleBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create scan all schedule bad request response +func (o *CreateScanAllScheduleBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateScanAllScheduleBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateScanAllScheduleUnauthorizedCode is the HTTP code returned for type CreateScanAllScheduleUnauthorized +const CreateScanAllScheduleUnauthorizedCode int = 401 + +/*CreateScanAllScheduleUnauthorized Unauthorized + +swagger:response createScanAllScheduleUnauthorized +*/ +type CreateScanAllScheduleUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateScanAllScheduleUnauthorized creates CreateScanAllScheduleUnauthorized with default headers values +func NewCreateScanAllScheduleUnauthorized() *CreateScanAllScheduleUnauthorized { + + return &CreateScanAllScheduleUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the create scan all schedule unauthorized response +func (o *CreateScanAllScheduleUnauthorized) WithXRequestID(xRequestID string) *CreateScanAllScheduleUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create scan all schedule unauthorized response +func (o *CreateScanAllScheduleUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create scan all schedule unauthorized response +func (o *CreateScanAllScheduleUnauthorized) WithPayload(payload *models.Errors) *CreateScanAllScheduleUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create scan all schedule unauthorized response +func (o *CreateScanAllScheduleUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateScanAllScheduleUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateScanAllScheduleForbiddenCode is the HTTP code returned for type CreateScanAllScheduleForbidden +const CreateScanAllScheduleForbiddenCode int = 403 + +/*CreateScanAllScheduleForbidden Forbidden + +swagger:response createScanAllScheduleForbidden +*/ +type CreateScanAllScheduleForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateScanAllScheduleForbidden creates CreateScanAllScheduleForbidden with default headers values +func NewCreateScanAllScheduleForbidden() *CreateScanAllScheduleForbidden { + + return &CreateScanAllScheduleForbidden{} +} + +// WithXRequestID adds the xRequestId to the create scan all schedule forbidden response +func (o *CreateScanAllScheduleForbidden) WithXRequestID(xRequestID string) *CreateScanAllScheduleForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create scan all schedule forbidden response +func (o *CreateScanAllScheduleForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create scan all schedule forbidden response +func (o *CreateScanAllScheduleForbidden) WithPayload(payload *models.Errors) *CreateScanAllScheduleForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create scan all schedule forbidden response +func (o *CreateScanAllScheduleForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateScanAllScheduleForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateScanAllScheduleConflictCode is the HTTP code returned for type CreateScanAllScheduleConflict +const CreateScanAllScheduleConflictCode int = 409 + +/*CreateScanAllScheduleConflict Conflict + +swagger:response createScanAllScheduleConflict +*/ +type CreateScanAllScheduleConflict struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateScanAllScheduleConflict creates CreateScanAllScheduleConflict with default headers values +func NewCreateScanAllScheduleConflict() *CreateScanAllScheduleConflict { + + return &CreateScanAllScheduleConflict{} +} + +// WithXRequestID adds the xRequestId to the create scan all schedule conflict response +func (o *CreateScanAllScheduleConflict) WithXRequestID(xRequestID string) *CreateScanAllScheduleConflict { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create scan all schedule conflict response +func (o *CreateScanAllScheduleConflict) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create scan all schedule conflict response +func (o *CreateScanAllScheduleConflict) WithPayload(payload *models.Errors) *CreateScanAllScheduleConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create scan all schedule conflict response +func (o *CreateScanAllScheduleConflict) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateScanAllScheduleConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateScanAllSchedulePreconditionFailedCode is the HTTP code returned for type CreateScanAllSchedulePreconditionFailed +const CreateScanAllSchedulePreconditionFailedCode int = 412 + +/*CreateScanAllSchedulePreconditionFailed Precondition failed + +swagger:response createScanAllSchedulePreconditionFailed +*/ +type CreateScanAllSchedulePreconditionFailed struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateScanAllSchedulePreconditionFailed creates CreateScanAllSchedulePreconditionFailed with default headers values +func NewCreateScanAllSchedulePreconditionFailed() *CreateScanAllSchedulePreconditionFailed { + + return &CreateScanAllSchedulePreconditionFailed{} +} + +// WithXRequestID adds the xRequestId to the create scan all schedule precondition failed response +func (o *CreateScanAllSchedulePreconditionFailed) WithXRequestID(xRequestID string) *CreateScanAllSchedulePreconditionFailed { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create scan all schedule precondition failed response +func (o *CreateScanAllSchedulePreconditionFailed) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create scan all schedule precondition failed response +func (o *CreateScanAllSchedulePreconditionFailed) WithPayload(payload *models.Errors) *CreateScanAllSchedulePreconditionFailed { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create scan all schedule precondition failed response +func (o *CreateScanAllSchedulePreconditionFailed) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateScanAllSchedulePreconditionFailed) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(412) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateScanAllScheduleInternalServerErrorCode is the HTTP code returned for type CreateScanAllScheduleInternalServerError +const CreateScanAllScheduleInternalServerErrorCode int = 500 + +/*CreateScanAllScheduleInternalServerError Internal server error + +swagger:response createScanAllScheduleInternalServerError +*/ +type CreateScanAllScheduleInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateScanAllScheduleInternalServerError creates CreateScanAllScheduleInternalServerError with default headers values +func NewCreateScanAllScheduleInternalServerError() *CreateScanAllScheduleInternalServerError { + + return &CreateScanAllScheduleInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the create scan all schedule internal server error response +func (o *CreateScanAllScheduleInternalServerError) WithXRequestID(xRequestID string) *CreateScanAllScheduleInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create scan all schedule internal server error response +func (o *CreateScanAllScheduleInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create scan all schedule internal server error response +func (o *CreateScanAllScheduleInternalServerError) WithPayload(payload *models.Errors) *CreateScanAllScheduleInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create scan all schedule internal server error response +func (o *CreateScanAllScheduleInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateScanAllScheduleInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/scan_all/create_scan_all_schedule_urlbuilder.go b/src/server/v2.0/restapi/operations/scan_all/create_scan_all_schedule_urlbuilder.go new file mode 100644 index 000000000..3afeba263 --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan_all/create_scan_all_schedule_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan_all + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// CreateScanAllScheduleURL generates an URL for the create scan all schedule operation +type CreateScanAllScheduleURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateScanAllScheduleURL) WithBasePath(bp string) *CreateScanAllScheduleURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateScanAllScheduleURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateScanAllScheduleURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/system/scanAll/schedule" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateScanAllScheduleURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateScanAllScheduleURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateScanAllScheduleURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateScanAllScheduleURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateScanAllScheduleURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateScanAllScheduleURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/scan_all/get_latest_scan_all_metrics.go b/src/server/v2.0/restapi/operations/scan_all/get_latest_scan_all_metrics.go new file mode 100644 index 000000000..e07ceec79 --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan_all/get_latest_scan_all_metrics.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan_all + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetLatestScanAllMetricsHandlerFunc turns a function with the right signature into a get latest scan all metrics handler +type GetLatestScanAllMetricsHandlerFunc func(GetLatestScanAllMetricsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetLatestScanAllMetricsHandlerFunc) Handle(params GetLatestScanAllMetricsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetLatestScanAllMetricsHandler interface for that can handle valid get latest scan all metrics params +type GetLatestScanAllMetricsHandler interface { + Handle(GetLatestScanAllMetricsParams, interface{}) middleware.Responder +} + +// NewGetLatestScanAllMetrics creates a new http.Handler for the get latest scan all metrics operation +func NewGetLatestScanAllMetrics(ctx *middleware.Context, handler GetLatestScanAllMetricsHandler) *GetLatestScanAllMetrics { + return &GetLatestScanAllMetrics{Context: ctx, Handler: handler} +} + +/*GetLatestScanAllMetrics swagger:route GET /scans/all/metrics scanAll getLatestScanAllMetrics + +Get the metrics of the latest scan all process + +Get the metrics of the latest scan all process + +*/ +type GetLatestScanAllMetrics struct { + Context *middleware.Context + Handler GetLatestScanAllMetricsHandler +} + +func (o *GetLatestScanAllMetrics) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetLatestScanAllMetricsParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/scan_all/get_latest_scan_all_metrics_parameters.go b/src/server/v2.0/restapi/operations/scan_all/get_latest_scan_all_metrics_parameters.go new file mode 100644 index 000000000..512b4d6d5 --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan_all/get_latest_scan_all_metrics_parameters.go @@ -0,0 +1,89 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan_all + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewGetLatestScanAllMetricsParams creates a new GetLatestScanAllMetricsParams object +// no default values defined in spec. +func NewGetLatestScanAllMetricsParams() GetLatestScanAllMetricsParams { + + return GetLatestScanAllMetricsParams{} +} + +// GetLatestScanAllMetricsParams contains all the bound params for the get latest scan all metrics operation +// typically these are obtained from a http.Request +// +// swagger:parameters getLatestScanAllMetrics +type GetLatestScanAllMetricsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetLatestScanAllMetricsParams() beforehand. +func (o *GetLatestScanAllMetricsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetLatestScanAllMetricsParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetLatestScanAllMetricsParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} diff --git a/src/server/v2.0/restapi/operations/scan_all/get_latest_scan_all_metrics_responses.go b/src/server/v2.0/restapi/operations/scan_all/get_latest_scan_all_metrics_responses.go new file mode 100644 index 000000000..563349edc --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan_all/get_latest_scan_all_metrics_responses.go @@ -0,0 +1,322 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan_all + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetLatestScanAllMetricsOKCode is the HTTP code returned for type GetLatestScanAllMetricsOK +const GetLatestScanAllMetricsOKCode int = 200 + +/*GetLatestScanAllMetricsOK OK + +swagger:response getLatestScanAllMetricsOK +*/ +type GetLatestScanAllMetricsOK struct { + + /* + In: Body + */ + Payload *models.Stats `json:"body,omitempty"` +} + +// NewGetLatestScanAllMetricsOK creates GetLatestScanAllMetricsOK with default headers values +func NewGetLatestScanAllMetricsOK() *GetLatestScanAllMetricsOK { + + return &GetLatestScanAllMetricsOK{} +} + +// WithPayload adds the payload to the get latest scan all metrics o k response +func (o *GetLatestScanAllMetricsOK) WithPayload(payload *models.Stats) *GetLatestScanAllMetricsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get latest scan all metrics o k response +func (o *GetLatestScanAllMetricsOK) SetPayload(payload *models.Stats) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLatestScanAllMetricsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetLatestScanAllMetricsUnauthorizedCode is the HTTP code returned for type GetLatestScanAllMetricsUnauthorized +const GetLatestScanAllMetricsUnauthorizedCode int = 401 + +/*GetLatestScanAllMetricsUnauthorized Unauthorized + +swagger:response getLatestScanAllMetricsUnauthorized +*/ +type GetLatestScanAllMetricsUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetLatestScanAllMetricsUnauthorized creates GetLatestScanAllMetricsUnauthorized with default headers values +func NewGetLatestScanAllMetricsUnauthorized() *GetLatestScanAllMetricsUnauthorized { + + return &GetLatestScanAllMetricsUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the get latest scan all metrics unauthorized response +func (o *GetLatestScanAllMetricsUnauthorized) WithXRequestID(xRequestID string) *GetLatestScanAllMetricsUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get latest scan all metrics unauthorized response +func (o *GetLatestScanAllMetricsUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get latest scan all metrics unauthorized response +func (o *GetLatestScanAllMetricsUnauthorized) WithPayload(payload *models.Errors) *GetLatestScanAllMetricsUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get latest scan all metrics unauthorized response +func (o *GetLatestScanAllMetricsUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLatestScanAllMetricsUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetLatestScanAllMetricsForbiddenCode is the HTTP code returned for type GetLatestScanAllMetricsForbidden +const GetLatestScanAllMetricsForbiddenCode int = 403 + +/*GetLatestScanAllMetricsForbidden Forbidden + +swagger:response getLatestScanAllMetricsForbidden +*/ +type GetLatestScanAllMetricsForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetLatestScanAllMetricsForbidden creates GetLatestScanAllMetricsForbidden with default headers values +func NewGetLatestScanAllMetricsForbidden() *GetLatestScanAllMetricsForbidden { + + return &GetLatestScanAllMetricsForbidden{} +} + +// WithXRequestID adds the xRequestId to the get latest scan all metrics forbidden response +func (o *GetLatestScanAllMetricsForbidden) WithXRequestID(xRequestID string) *GetLatestScanAllMetricsForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get latest scan all metrics forbidden response +func (o *GetLatestScanAllMetricsForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get latest scan all metrics forbidden response +func (o *GetLatestScanAllMetricsForbidden) WithPayload(payload *models.Errors) *GetLatestScanAllMetricsForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get latest scan all metrics forbidden response +func (o *GetLatestScanAllMetricsForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLatestScanAllMetricsForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetLatestScanAllMetricsPreconditionFailedCode is the HTTP code returned for type GetLatestScanAllMetricsPreconditionFailed +const GetLatestScanAllMetricsPreconditionFailedCode int = 412 + +/*GetLatestScanAllMetricsPreconditionFailed Precondition failed + +swagger:response getLatestScanAllMetricsPreconditionFailed +*/ +type GetLatestScanAllMetricsPreconditionFailed struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetLatestScanAllMetricsPreconditionFailed creates GetLatestScanAllMetricsPreconditionFailed with default headers values +func NewGetLatestScanAllMetricsPreconditionFailed() *GetLatestScanAllMetricsPreconditionFailed { + + return &GetLatestScanAllMetricsPreconditionFailed{} +} + +// WithXRequestID adds the xRequestId to the get latest scan all metrics precondition failed response +func (o *GetLatestScanAllMetricsPreconditionFailed) WithXRequestID(xRequestID string) *GetLatestScanAllMetricsPreconditionFailed { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get latest scan all metrics precondition failed response +func (o *GetLatestScanAllMetricsPreconditionFailed) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get latest scan all metrics precondition failed response +func (o *GetLatestScanAllMetricsPreconditionFailed) WithPayload(payload *models.Errors) *GetLatestScanAllMetricsPreconditionFailed { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get latest scan all metrics precondition failed response +func (o *GetLatestScanAllMetricsPreconditionFailed) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLatestScanAllMetricsPreconditionFailed) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(412) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetLatestScanAllMetricsInternalServerErrorCode is the HTTP code returned for type GetLatestScanAllMetricsInternalServerError +const GetLatestScanAllMetricsInternalServerErrorCode int = 500 + +/*GetLatestScanAllMetricsInternalServerError Internal server error + +swagger:response getLatestScanAllMetricsInternalServerError +*/ +type GetLatestScanAllMetricsInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetLatestScanAllMetricsInternalServerError creates GetLatestScanAllMetricsInternalServerError with default headers values +func NewGetLatestScanAllMetricsInternalServerError() *GetLatestScanAllMetricsInternalServerError { + + return &GetLatestScanAllMetricsInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get latest scan all metrics internal server error response +func (o *GetLatestScanAllMetricsInternalServerError) WithXRequestID(xRequestID string) *GetLatestScanAllMetricsInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get latest scan all metrics internal server error response +func (o *GetLatestScanAllMetricsInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get latest scan all metrics internal server error response +func (o *GetLatestScanAllMetricsInternalServerError) WithPayload(payload *models.Errors) *GetLatestScanAllMetricsInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get latest scan all metrics internal server error response +func (o *GetLatestScanAllMetricsInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLatestScanAllMetricsInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/scan_all/get_latest_scan_all_metrics_urlbuilder.go b/src/server/v2.0/restapi/operations/scan_all/get_latest_scan_all_metrics_urlbuilder.go new file mode 100644 index 000000000..fabe6a134 --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan_all/get_latest_scan_all_metrics_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan_all + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetLatestScanAllMetricsURL generates an URL for the get latest scan all metrics operation +type GetLatestScanAllMetricsURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetLatestScanAllMetricsURL) WithBasePath(bp string) *GetLatestScanAllMetricsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetLatestScanAllMetricsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetLatestScanAllMetricsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/scans/all/metrics" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetLatestScanAllMetricsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetLatestScanAllMetricsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetLatestScanAllMetricsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetLatestScanAllMetricsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetLatestScanAllMetricsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetLatestScanAllMetricsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/scan_all/get_latest_scheduled_scan_all_metrics.go b/src/server/v2.0/restapi/operations/scan_all/get_latest_scheduled_scan_all_metrics.go new file mode 100644 index 000000000..7dfe3b8bb --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan_all/get_latest_scheduled_scan_all_metrics.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan_all + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetLatestScheduledScanAllMetricsHandlerFunc turns a function with the right signature into a get latest scheduled scan all metrics handler +type GetLatestScheduledScanAllMetricsHandlerFunc func(GetLatestScheduledScanAllMetricsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetLatestScheduledScanAllMetricsHandlerFunc) Handle(params GetLatestScheduledScanAllMetricsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetLatestScheduledScanAllMetricsHandler interface for that can handle valid get latest scheduled scan all metrics params +type GetLatestScheduledScanAllMetricsHandler interface { + Handle(GetLatestScheduledScanAllMetricsParams, interface{}) middleware.Responder +} + +// NewGetLatestScheduledScanAllMetrics creates a new http.Handler for the get latest scheduled scan all metrics operation +func NewGetLatestScheduledScanAllMetrics(ctx *middleware.Context, handler GetLatestScheduledScanAllMetricsHandler) *GetLatestScheduledScanAllMetrics { + return &GetLatestScheduledScanAllMetrics{Context: ctx, Handler: handler} +} + +/*GetLatestScheduledScanAllMetrics swagger:route GET /scans/schedule/metrics scanAll getLatestScheduledScanAllMetrics + +Get the metrics of the latest scheduled scan all process + +Get the metrics of the latest scheduled scan all process + +*/ +type GetLatestScheduledScanAllMetrics struct { + Context *middleware.Context + Handler GetLatestScheduledScanAllMetricsHandler +} + +func (o *GetLatestScheduledScanAllMetrics) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetLatestScheduledScanAllMetricsParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/scan_all/get_latest_scheduled_scan_all_metrics_parameters.go b/src/server/v2.0/restapi/operations/scan_all/get_latest_scheduled_scan_all_metrics_parameters.go new file mode 100644 index 000000000..73ad16151 --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan_all/get_latest_scheduled_scan_all_metrics_parameters.go @@ -0,0 +1,89 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan_all + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewGetLatestScheduledScanAllMetricsParams creates a new GetLatestScheduledScanAllMetricsParams object +// no default values defined in spec. +func NewGetLatestScheduledScanAllMetricsParams() GetLatestScheduledScanAllMetricsParams { + + return GetLatestScheduledScanAllMetricsParams{} +} + +// GetLatestScheduledScanAllMetricsParams contains all the bound params for the get latest scheduled scan all metrics operation +// typically these are obtained from a http.Request +// +// swagger:parameters getLatestScheduledScanAllMetrics +type GetLatestScheduledScanAllMetricsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetLatestScheduledScanAllMetricsParams() beforehand. +func (o *GetLatestScheduledScanAllMetricsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetLatestScheduledScanAllMetricsParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetLatestScheduledScanAllMetricsParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} diff --git a/src/server/v2.0/restapi/operations/scan_all/get_latest_scheduled_scan_all_metrics_responses.go b/src/server/v2.0/restapi/operations/scan_all/get_latest_scheduled_scan_all_metrics_responses.go new file mode 100644 index 000000000..2b1d798c0 --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan_all/get_latest_scheduled_scan_all_metrics_responses.go @@ -0,0 +1,322 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan_all + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetLatestScheduledScanAllMetricsOKCode is the HTTP code returned for type GetLatestScheduledScanAllMetricsOK +const GetLatestScheduledScanAllMetricsOKCode int = 200 + +/*GetLatestScheduledScanAllMetricsOK OK + +swagger:response getLatestScheduledScanAllMetricsOK +*/ +type GetLatestScheduledScanAllMetricsOK struct { + + /* + In: Body + */ + Payload *models.Stats `json:"body,omitempty"` +} + +// NewGetLatestScheduledScanAllMetricsOK creates GetLatestScheduledScanAllMetricsOK with default headers values +func NewGetLatestScheduledScanAllMetricsOK() *GetLatestScheduledScanAllMetricsOK { + + return &GetLatestScheduledScanAllMetricsOK{} +} + +// WithPayload adds the payload to the get latest scheduled scan all metrics o k response +func (o *GetLatestScheduledScanAllMetricsOK) WithPayload(payload *models.Stats) *GetLatestScheduledScanAllMetricsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get latest scheduled scan all metrics o k response +func (o *GetLatestScheduledScanAllMetricsOK) SetPayload(payload *models.Stats) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLatestScheduledScanAllMetricsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetLatestScheduledScanAllMetricsUnauthorizedCode is the HTTP code returned for type GetLatestScheduledScanAllMetricsUnauthorized +const GetLatestScheduledScanAllMetricsUnauthorizedCode int = 401 + +/*GetLatestScheduledScanAllMetricsUnauthorized Unauthorized + +swagger:response getLatestScheduledScanAllMetricsUnauthorized +*/ +type GetLatestScheduledScanAllMetricsUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetLatestScheduledScanAllMetricsUnauthorized creates GetLatestScheduledScanAllMetricsUnauthorized with default headers values +func NewGetLatestScheduledScanAllMetricsUnauthorized() *GetLatestScheduledScanAllMetricsUnauthorized { + + return &GetLatestScheduledScanAllMetricsUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the get latest scheduled scan all metrics unauthorized response +func (o *GetLatestScheduledScanAllMetricsUnauthorized) WithXRequestID(xRequestID string) *GetLatestScheduledScanAllMetricsUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get latest scheduled scan all metrics unauthorized response +func (o *GetLatestScheduledScanAllMetricsUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get latest scheduled scan all metrics unauthorized response +func (o *GetLatestScheduledScanAllMetricsUnauthorized) WithPayload(payload *models.Errors) *GetLatestScheduledScanAllMetricsUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get latest scheduled scan all metrics unauthorized response +func (o *GetLatestScheduledScanAllMetricsUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLatestScheduledScanAllMetricsUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetLatestScheduledScanAllMetricsForbiddenCode is the HTTP code returned for type GetLatestScheduledScanAllMetricsForbidden +const GetLatestScheduledScanAllMetricsForbiddenCode int = 403 + +/*GetLatestScheduledScanAllMetricsForbidden Forbidden + +swagger:response getLatestScheduledScanAllMetricsForbidden +*/ +type GetLatestScheduledScanAllMetricsForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetLatestScheduledScanAllMetricsForbidden creates GetLatestScheduledScanAllMetricsForbidden with default headers values +func NewGetLatestScheduledScanAllMetricsForbidden() *GetLatestScheduledScanAllMetricsForbidden { + + return &GetLatestScheduledScanAllMetricsForbidden{} +} + +// WithXRequestID adds the xRequestId to the get latest scheduled scan all metrics forbidden response +func (o *GetLatestScheduledScanAllMetricsForbidden) WithXRequestID(xRequestID string) *GetLatestScheduledScanAllMetricsForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get latest scheduled scan all metrics forbidden response +func (o *GetLatestScheduledScanAllMetricsForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get latest scheduled scan all metrics forbidden response +func (o *GetLatestScheduledScanAllMetricsForbidden) WithPayload(payload *models.Errors) *GetLatestScheduledScanAllMetricsForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get latest scheduled scan all metrics forbidden response +func (o *GetLatestScheduledScanAllMetricsForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLatestScheduledScanAllMetricsForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetLatestScheduledScanAllMetricsPreconditionFailedCode is the HTTP code returned for type GetLatestScheduledScanAllMetricsPreconditionFailed +const GetLatestScheduledScanAllMetricsPreconditionFailedCode int = 412 + +/*GetLatestScheduledScanAllMetricsPreconditionFailed Precondition failed + +swagger:response getLatestScheduledScanAllMetricsPreconditionFailed +*/ +type GetLatestScheduledScanAllMetricsPreconditionFailed struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetLatestScheduledScanAllMetricsPreconditionFailed creates GetLatestScheduledScanAllMetricsPreconditionFailed with default headers values +func NewGetLatestScheduledScanAllMetricsPreconditionFailed() *GetLatestScheduledScanAllMetricsPreconditionFailed { + + return &GetLatestScheduledScanAllMetricsPreconditionFailed{} +} + +// WithXRequestID adds the xRequestId to the get latest scheduled scan all metrics precondition failed response +func (o *GetLatestScheduledScanAllMetricsPreconditionFailed) WithXRequestID(xRequestID string) *GetLatestScheduledScanAllMetricsPreconditionFailed { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get latest scheduled scan all metrics precondition failed response +func (o *GetLatestScheduledScanAllMetricsPreconditionFailed) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get latest scheduled scan all metrics precondition failed response +func (o *GetLatestScheduledScanAllMetricsPreconditionFailed) WithPayload(payload *models.Errors) *GetLatestScheduledScanAllMetricsPreconditionFailed { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get latest scheduled scan all metrics precondition failed response +func (o *GetLatestScheduledScanAllMetricsPreconditionFailed) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLatestScheduledScanAllMetricsPreconditionFailed) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(412) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetLatestScheduledScanAllMetricsInternalServerErrorCode is the HTTP code returned for type GetLatestScheduledScanAllMetricsInternalServerError +const GetLatestScheduledScanAllMetricsInternalServerErrorCode int = 500 + +/*GetLatestScheduledScanAllMetricsInternalServerError Internal server error + +swagger:response getLatestScheduledScanAllMetricsInternalServerError +*/ +type GetLatestScheduledScanAllMetricsInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetLatestScheduledScanAllMetricsInternalServerError creates GetLatestScheduledScanAllMetricsInternalServerError with default headers values +func NewGetLatestScheduledScanAllMetricsInternalServerError() *GetLatestScheduledScanAllMetricsInternalServerError { + + return &GetLatestScheduledScanAllMetricsInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get latest scheduled scan all metrics internal server error response +func (o *GetLatestScheduledScanAllMetricsInternalServerError) WithXRequestID(xRequestID string) *GetLatestScheduledScanAllMetricsInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get latest scheduled scan all metrics internal server error response +func (o *GetLatestScheduledScanAllMetricsInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get latest scheduled scan all metrics internal server error response +func (o *GetLatestScheduledScanAllMetricsInternalServerError) WithPayload(payload *models.Errors) *GetLatestScheduledScanAllMetricsInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get latest scheduled scan all metrics internal server error response +func (o *GetLatestScheduledScanAllMetricsInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLatestScheduledScanAllMetricsInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/scan_all/get_latest_scheduled_scan_all_metrics_urlbuilder.go b/src/server/v2.0/restapi/operations/scan_all/get_latest_scheduled_scan_all_metrics_urlbuilder.go new file mode 100644 index 000000000..9db5bad64 --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan_all/get_latest_scheduled_scan_all_metrics_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan_all + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetLatestScheduledScanAllMetricsURL generates an URL for the get latest scheduled scan all metrics operation +type GetLatestScheduledScanAllMetricsURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetLatestScheduledScanAllMetricsURL) WithBasePath(bp string) *GetLatestScheduledScanAllMetricsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetLatestScheduledScanAllMetricsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetLatestScheduledScanAllMetricsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/scans/schedule/metrics" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetLatestScheduledScanAllMetricsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetLatestScheduledScanAllMetricsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetLatestScheduledScanAllMetricsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetLatestScheduledScanAllMetricsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetLatestScheduledScanAllMetricsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetLatestScheduledScanAllMetricsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/scan_all/get_scan_all_schedule.go b/src/server/v2.0/restapi/operations/scan_all/get_scan_all_schedule.go new file mode 100644 index 000000000..58432427e --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan_all/get_scan_all_schedule.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan_all + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetScanAllScheduleHandlerFunc turns a function with the right signature into a get scan all schedule handler +type GetScanAllScheduleHandlerFunc func(GetScanAllScheduleParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetScanAllScheduleHandlerFunc) Handle(params GetScanAllScheduleParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetScanAllScheduleHandler interface for that can handle valid get scan all schedule params +type GetScanAllScheduleHandler interface { + Handle(GetScanAllScheduleParams, interface{}) middleware.Responder +} + +// NewGetScanAllSchedule creates a new http.Handler for the get scan all schedule operation +func NewGetScanAllSchedule(ctx *middleware.Context, handler GetScanAllScheduleHandler) *GetScanAllSchedule { + return &GetScanAllSchedule{Context: ctx, Handler: handler} +} + +/*GetScanAllSchedule swagger:route GET /system/scanAll/schedule scanAll getScanAllSchedule + +Get scan all's schedule. + +This endpoint is for getting a schedule for the scan all job, which scans all of images in Harbor. + +*/ +type GetScanAllSchedule struct { + Context *middleware.Context + Handler GetScanAllScheduleHandler +} + +func (o *GetScanAllSchedule) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetScanAllScheduleParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/scan_all/get_scan_all_schedule_parameters.go b/src/server/v2.0/restapi/operations/scan_all/get_scan_all_schedule_parameters.go new file mode 100644 index 000000000..bf6f18d75 --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan_all/get_scan_all_schedule_parameters.go @@ -0,0 +1,89 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan_all + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewGetScanAllScheduleParams creates a new GetScanAllScheduleParams object +// no default values defined in spec. +func NewGetScanAllScheduleParams() GetScanAllScheduleParams { + + return GetScanAllScheduleParams{} +} + +// GetScanAllScheduleParams contains all the bound params for the get scan all schedule operation +// typically these are obtained from a http.Request +// +// swagger:parameters getScanAllSchedule +type GetScanAllScheduleParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetScanAllScheduleParams() beforehand. +func (o *GetScanAllScheduleParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetScanAllScheduleParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetScanAllScheduleParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} diff --git a/src/server/v2.0/restapi/operations/scan_all/get_scan_all_schedule_responses.go b/src/server/v2.0/restapi/operations/scan_all/get_scan_all_schedule_responses.go new file mode 100644 index 000000000..5ef6289a5 --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan_all/get_scan_all_schedule_responses.go @@ -0,0 +1,322 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan_all + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetScanAllScheduleOKCode is the HTTP code returned for type GetScanAllScheduleOK +const GetScanAllScheduleOKCode int = 200 + +/*GetScanAllScheduleOK Get a schedule for the scan all job, which scans all of images in Harbor. + +swagger:response getScanAllScheduleOK +*/ +type GetScanAllScheduleOK struct { + + /* + In: Body + */ + Payload *models.Schedule `json:"body,omitempty"` +} + +// NewGetScanAllScheduleOK creates GetScanAllScheduleOK with default headers values +func NewGetScanAllScheduleOK() *GetScanAllScheduleOK { + + return &GetScanAllScheduleOK{} +} + +// WithPayload adds the payload to the get scan all schedule o k response +func (o *GetScanAllScheduleOK) WithPayload(payload *models.Schedule) *GetScanAllScheduleOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get scan all schedule o k response +func (o *GetScanAllScheduleOK) SetPayload(payload *models.Schedule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetScanAllScheduleOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetScanAllScheduleUnauthorizedCode is the HTTP code returned for type GetScanAllScheduleUnauthorized +const GetScanAllScheduleUnauthorizedCode int = 401 + +/*GetScanAllScheduleUnauthorized Unauthorized + +swagger:response getScanAllScheduleUnauthorized +*/ +type GetScanAllScheduleUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetScanAllScheduleUnauthorized creates GetScanAllScheduleUnauthorized with default headers values +func NewGetScanAllScheduleUnauthorized() *GetScanAllScheduleUnauthorized { + + return &GetScanAllScheduleUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the get scan all schedule unauthorized response +func (o *GetScanAllScheduleUnauthorized) WithXRequestID(xRequestID string) *GetScanAllScheduleUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get scan all schedule unauthorized response +func (o *GetScanAllScheduleUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get scan all schedule unauthorized response +func (o *GetScanAllScheduleUnauthorized) WithPayload(payload *models.Errors) *GetScanAllScheduleUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get scan all schedule unauthorized response +func (o *GetScanAllScheduleUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetScanAllScheduleUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetScanAllScheduleForbiddenCode is the HTTP code returned for type GetScanAllScheduleForbidden +const GetScanAllScheduleForbiddenCode int = 403 + +/*GetScanAllScheduleForbidden Forbidden + +swagger:response getScanAllScheduleForbidden +*/ +type GetScanAllScheduleForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetScanAllScheduleForbidden creates GetScanAllScheduleForbidden with default headers values +func NewGetScanAllScheduleForbidden() *GetScanAllScheduleForbidden { + + return &GetScanAllScheduleForbidden{} +} + +// WithXRequestID adds the xRequestId to the get scan all schedule forbidden response +func (o *GetScanAllScheduleForbidden) WithXRequestID(xRequestID string) *GetScanAllScheduleForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get scan all schedule forbidden response +func (o *GetScanAllScheduleForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get scan all schedule forbidden response +func (o *GetScanAllScheduleForbidden) WithPayload(payload *models.Errors) *GetScanAllScheduleForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get scan all schedule forbidden response +func (o *GetScanAllScheduleForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetScanAllScheduleForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetScanAllSchedulePreconditionFailedCode is the HTTP code returned for type GetScanAllSchedulePreconditionFailed +const GetScanAllSchedulePreconditionFailedCode int = 412 + +/*GetScanAllSchedulePreconditionFailed Precondition failed + +swagger:response getScanAllSchedulePreconditionFailed +*/ +type GetScanAllSchedulePreconditionFailed struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetScanAllSchedulePreconditionFailed creates GetScanAllSchedulePreconditionFailed with default headers values +func NewGetScanAllSchedulePreconditionFailed() *GetScanAllSchedulePreconditionFailed { + + return &GetScanAllSchedulePreconditionFailed{} +} + +// WithXRequestID adds the xRequestId to the get scan all schedule precondition failed response +func (o *GetScanAllSchedulePreconditionFailed) WithXRequestID(xRequestID string) *GetScanAllSchedulePreconditionFailed { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get scan all schedule precondition failed response +func (o *GetScanAllSchedulePreconditionFailed) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get scan all schedule precondition failed response +func (o *GetScanAllSchedulePreconditionFailed) WithPayload(payload *models.Errors) *GetScanAllSchedulePreconditionFailed { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get scan all schedule precondition failed response +func (o *GetScanAllSchedulePreconditionFailed) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetScanAllSchedulePreconditionFailed) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(412) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetScanAllScheduleInternalServerErrorCode is the HTTP code returned for type GetScanAllScheduleInternalServerError +const GetScanAllScheduleInternalServerErrorCode int = 500 + +/*GetScanAllScheduleInternalServerError Internal server error + +swagger:response getScanAllScheduleInternalServerError +*/ +type GetScanAllScheduleInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetScanAllScheduleInternalServerError creates GetScanAllScheduleInternalServerError with default headers values +func NewGetScanAllScheduleInternalServerError() *GetScanAllScheduleInternalServerError { + + return &GetScanAllScheduleInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get scan all schedule internal server error response +func (o *GetScanAllScheduleInternalServerError) WithXRequestID(xRequestID string) *GetScanAllScheduleInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get scan all schedule internal server error response +func (o *GetScanAllScheduleInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get scan all schedule internal server error response +func (o *GetScanAllScheduleInternalServerError) WithPayload(payload *models.Errors) *GetScanAllScheduleInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get scan all schedule internal server error response +func (o *GetScanAllScheduleInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetScanAllScheduleInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/scan_all/get_scan_all_schedule_urlbuilder.go b/src/server/v2.0/restapi/operations/scan_all/get_scan_all_schedule_urlbuilder.go new file mode 100644 index 000000000..d71c330eb --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan_all/get_scan_all_schedule_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan_all + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetScanAllScheduleURL generates an URL for the get scan all schedule operation +type GetScanAllScheduleURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetScanAllScheduleURL) WithBasePath(bp string) *GetScanAllScheduleURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetScanAllScheduleURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetScanAllScheduleURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/system/scanAll/schedule" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetScanAllScheduleURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetScanAllScheduleURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetScanAllScheduleURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetScanAllScheduleURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetScanAllScheduleURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetScanAllScheduleURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/scan_all/stop_scan_all.go b/src/server/v2.0/restapi/operations/scan_all/stop_scan_all.go new file mode 100644 index 000000000..77ca38c67 --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan_all/stop_scan_all.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan_all + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// StopScanAllHandlerFunc turns a function with the right signature into a stop scan all handler +type StopScanAllHandlerFunc func(StopScanAllParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn StopScanAllHandlerFunc) Handle(params StopScanAllParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// StopScanAllHandler interface for that can handle valid stop scan all params +type StopScanAllHandler interface { + Handle(StopScanAllParams, interface{}) middleware.Responder +} + +// NewStopScanAll creates a new http.Handler for the stop scan all operation +func NewStopScanAll(ctx *middleware.Context, handler StopScanAllHandler) *StopScanAll { + return &StopScanAll{Context: ctx, Handler: handler} +} + +/*StopScanAll swagger:route POST /system/scanAll/stop scanAll stopScanAll + +Stop scanAll job execution + +Stop scanAll job execution + +*/ +type StopScanAll struct { + Context *middleware.Context + Handler StopScanAllHandler +} + +func (o *StopScanAll) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewStopScanAllParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/scan_all/stop_scan_all_parameters.go b/src/server/v2.0/restapi/operations/scan_all/stop_scan_all_parameters.go new file mode 100644 index 000000000..a366f67ab --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan_all/stop_scan_all_parameters.go @@ -0,0 +1,89 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan_all + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewStopScanAllParams creates a new StopScanAllParams object +// no default values defined in spec. +func NewStopScanAllParams() StopScanAllParams { + + return StopScanAllParams{} +} + +// StopScanAllParams contains all the bound params for the stop scan all operation +// typically these are obtained from a http.Request +// +// swagger:parameters stopScanAll +type StopScanAllParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewStopScanAllParams() beforehand. +func (o *StopScanAllParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *StopScanAllParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *StopScanAllParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} diff --git a/src/server/v2.0/restapi/operations/scan_all/stop_scan_all_responses.go b/src/server/v2.0/restapi/operations/scan_all/stop_scan_all_responses.go new file mode 100644 index 000000000..2821be023 --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan_all/stop_scan_all_responses.go @@ -0,0 +1,324 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan_all + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// StopScanAllAcceptedCode is the HTTP code returned for type StopScanAllAccepted +const StopScanAllAcceptedCode int = 202 + +/*StopScanAllAccepted Accepted + +swagger:response stopScanAllAccepted +*/ +type StopScanAllAccepted struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewStopScanAllAccepted creates StopScanAllAccepted with default headers values +func NewStopScanAllAccepted() *StopScanAllAccepted { + + return &StopScanAllAccepted{} +} + +// WithXRequestID adds the xRequestId to the stop scan all accepted response +func (o *StopScanAllAccepted) WithXRequestID(xRequestID string) *StopScanAllAccepted { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the stop scan all accepted response +func (o *StopScanAllAccepted) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *StopScanAllAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// StopScanAllBadRequestCode is the HTTP code returned for type StopScanAllBadRequest +const StopScanAllBadRequestCode int = 400 + +/*StopScanAllBadRequest Bad request + +swagger:response stopScanAllBadRequest +*/ +type StopScanAllBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewStopScanAllBadRequest creates StopScanAllBadRequest with default headers values +func NewStopScanAllBadRequest() *StopScanAllBadRequest { + + return &StopScanAllBadRequest{} +} + +// WithXRequestID adds the xRequestId to the stop scan all bad request response +func (o *StopScanAllBadRequest) WithXRequestID(xRequestID string) *StopScanAllBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the stop scan all bad request response +func (o *StopScanAllBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the stop scan all bad request response +func (o *StopScanAllBadRequest) WithPayload(payload *models.Errors) *StopScanAllBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the stop scan all bad request response +func (o *StopScanAllBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *StopScanAllBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// StopScanAllUnauthorizedCode is the HTTP code returned for type StopScanAllUnauthorized +const StopScanAllUnauthorizedCode int = 401 + +/*StopScanAllUnauthorized Unauthorized + +swagger:response stopScanAllUnauthorized +*/ +type StopScanAllUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewStopScanAllUnauthorized creates StopScanAllUnauthorized with default headers values +func NewStopScanAllUnauthorized() *StopScanAllUnauthorized { + + return &StopScanAllUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the stop scan all unauthorized response +func (o *StopScanAllUnauthorized) WithXRequestID(xRequestID string) *StopScanAllUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the stop scan all unauthorized response +func (o *StopScanAllUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the stop scan all unauthorized response +func (o *StopScanAllUnauthorized) WithPayload(payload *models.Errors) *StopScanAllUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the stop scan all unauthorized response +func (o *StopScanAllUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *StopScanAllUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// StopScanAllForbiddenCode is the HTTP code returned for type StopScanAllForbidden +const StopScanAllForbiddenCode int = 403 + +/*StopScanAllForbidden Forbidden + +swagger:response stopScanAllForbidden +*/ +type StopScanAllForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewStopScanAllForbidden creates StopScanAllForbidden with default headers values +func NewStopScanAllForbidden() *StopScanAllForbidden { + + return &StopScanAllForbidden{} +} + +// WithXRequestID adds the xRequestId to the stop scan all forbidden response +func (o *StopScanAllForbidden) WithXRequestID(xRequestID string) *StopScanAllForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the stop scan all forbidden response +func (o *StopScanAllForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the stop scan all forbidden response +func (o *StopScanAllForbidden) WithPayload(payload *models.Errors) *StopScanAllForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the stop scan all forbidden response +func (o *StopScanAllForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *StopScanAllForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// StopScanAllInternalServerErrorCode is the HTTP code returned for type StopScanAllInternalServerError +const StopScanAllInternalServerErrorCode int = 500 + +/*StopScanAllInternalServerError Internal server error + +swagger:response stopScanAllInternalServerError +*/ +type StopScanAllInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewStopScanAllInternalServerError creates StopScanAllInternalServerError with default headers values +func NewStopScanAllInternalServerError() *StopScanAllInternalServerError { + + return &StopScanAllInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the stop scan all internal server error response +func (o *StopScanAllInternalServerError) WithXRequestID(xRequestID string) *StopScanAllInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the stop scan all internal server error response +func (o *StopScanAllInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the stop scan all internal server error response +func (o *StopScanAllInternalServerError) WithPayload(payload *models.Errors) *StopScanAllInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the stop scan all internal server error response +func (o *StopScanAllInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *StopScanAllInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/scan_all/stop_scan_all_urlbuilder.go b/src/server/v2.0/restapi/operations/scan_all/stop_scan_all_urlbuilder.go new file mode 100644 index 000000000..225bf4019 --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan_all/stop_scan_all_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan_all + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// StopScanAllURL generates an URL for the stop scan all operation +type StopScanAllURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *StopScanAllURL) WithBasePath(bp string) *StopScanAllURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *StopScanAllURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *StopScanAllURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/system/scanAll/stop" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *StopScanAllURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *StopScanAllURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *StopScanAllURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on StopScanAllURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on StopScanAllURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *StopScanAllURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/scan_all/update_scan_all_schedule.go b/src/server/v2.0/restapi/operations/scan_all/update_scan_all_schedule.go new file mode 100644 index 000000000..dcc33e9a6 --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan_all/update_scan_all_schedule.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan_all + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// UpdateScanAllScheduleHandlerFunc turns a function with the right signature into a update scan all schedule handler +type UpdateScanAllScheduleHandlerFunc func(UpdateScanAllScheduleParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn UpdateScanAllScheduleHandlerFunc) Handle(params UpdateScanAllScheduleParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// UpdateScanAllScheduleHandler interface for that can handle valid update scan all schedule params +type UpdateScanAllScheduleHandler interface { + Handle(UpdateScanAllScheduleParams, interface{}) middleware.Responder +} + +// NewUpdateScanAllSchedule creates a new http.Handler for the update scan all schedule operation +func NewUpdateScanAllSchedule(ctx *middleware.Context, handler UpdateScanAllScheduleHandler) *UpdateScanAllSchedule { + return &UpdateScanAllSchedule{Context: ctx, Handler: handler} +} + +/*UpdateScanAllSchedule swagger:route PUT /system/scanAll/schedule scanAll updateScanAllSchedule + +Update scan all's schedule. + +This endpoint is for updating the schedule of scan all job, which scans all of images in Harbor. + +*/ +type UpdateScanAllSchedule struct { + Context *middleware.Context + Handler UpdateScanAllScheduleHandler +} + +func (o *UpdateScanAllSchedule) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewUpdateScanAllScheduleParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/scan_all/update_scan_all_schedule_parameters.go b/src/server/v2.0/restapi/operations/scan_all/update_scan_all_schedule_parameters.go new file mode 100644 index 000000000..77085550d --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan_all/update_scan_all_schedule_parameters.go @@ -0,0 +1,120 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan_all + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewUpdateScanAllScheduleParams creates a new UpdateScanAllScheduleParams object +// no default values defined in spec. +func NewUpdateScanAllScheduleParams() UpdateScanAllScheduleParams { + + return UpdateScanAllScheduleParams{} +} + +// UpdateScanAllScheduleParams contains all the bound params for the update scan all schedule operation +// typically these are obtained from a http.Request +// +// swagger:parameters updateScanAllSchedule +type UpdateScanAllScheduleParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*Updates the schedule of scan all job, which scans all of images in Harbor. + Required: true + In: body + */ + Schedule *models.Schedule +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewUpdateScanAllScheduleParams() beforehand. +func (o *UpdateScanAllScheduleParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Schedule + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("schedule", "body", "")) + } else { + res = append(res, errors.NewParseError("schedule", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Schedule = &body + } + } + } else { + res = append(res, errors.Required("schedule", "body", "")) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *UpdateScanAllScheduleParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *UpdateScanAllScheduleParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} diff --git a/src/server/v2.0/restapi/operations/scan_all/update_scan_all_schedule_responses.go b/src/server/v2.0/restapi/operations/scan_all/update_scan_all_schedule_responses.go new file mode 100644 index 000000000..17c7532dc --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan_all/update_scan_all_schedule_responses.go @@ -0,0 +1,390 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan_all + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// UpdateScanAllScheduleOKCode is the HTTP code returned for type UpdateScanAllScheduleOK +const UpdateScanAllScheduleOKCode int = 200 + +/*UpdateScanAllScheduleOK Success + +swagger:response updateScanAllScheduleOK +*/ +type UpdateScanAllScheduleOK struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewUpdateScanAllScheduleOK creates UpdateScanAllScheduleOK with default headers values +func NewUpdateScanAllScheduleOK() *UpdateScanAllScheduleOK { + + return &UpdateScanAllScheduleOK{} +} + +// WithXRequestID adds the xRequestId to the update scan all schedule o k response +func (o *UpdateScanAllScheduleOK) WithXRequestID(xRequestID string) *UpdateScanAllScheduleOK { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update scan all schedule o k response +func (o *UpdateScanAllScheduleOK) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *UpdateScanAllScheduleOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// UpdateScanAllScheduleBadRequestCode is the HTTP code returned for type UpdateScanAllScheduleBadRequest +const UpdateScanAllScheduleBadRequestCode int = 400 + +/*UpdateScanAllScheduleBadRequest Bad request + +swagger:response updateScanAllScheduleBadRequest +*/ +type UpdateScanAllScheduleBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateScanAllScheduleBadRequest creates UpdateScanAllScheduleBadRequest with default headers values +func NewUpdateScanAllScheduleBadRequest() *UpdateScanAllScheduleBadRequest { + + return &UpdateScanAllScheduleBadRequest{} +} + +// WithXRequestID adds the xRequestId to the update scan all schedule bad request response +func (o *UpdateScanAllScheduleBadRequest) WithXRequestID(xRequestID string) *UpdateScanAllScheduleBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update scan all schedule bad request response +func (o *UpdateScanAllScheduleBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update scan all schedule bad request response +func (o *UpdateScanAllScheduleBadRequest) WithPayload(payload *models.Errors) *UpdateScanAllScheduleBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update scan all schedule bad request response +func (o *UpdateScanAllScheduleBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateScanAllScheduleBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateScanAllScheduleUnauthorizedCode is the HTTP code returned for type UpdateScanAllScheduleUnauthorized +const UpdateScanAllScheduleUnauthorizedCode int = 401 + +/*UpdateScanAllScheduleUnauthorized Unauthorized + +swagger:response updateScanAllScheduleUnauthorized +*/ +type UpdateScanAllScheduleUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateScanAllScheduleUnauthorized creates UpdateScanAllScheduleUnauthorized with default headers values +func NewUpdateScanAllScheduleUnauthorized() *UpdateScanAllScheduleUnauthorized { + + return &UpdateScanAllScheduleUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the update scan all schedule unauthorized response +func (o *UpdateScanAllScheduleUnauthorized) WithXRequestID(xRequestID string) *UpdateScanAllScheduleUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update scan all schedule unauthorized response +func (o *UpdateScanAllScheduleUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update scan all schedule unauthorized response +func (o *UpdateScanAllScheduleUnauthorized) WithPayload(payload *models.Errors) *UpdateScanAllScheduleUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update scan all schedule unauthorized response +func (o *UpdateScanAllScheduleUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateScanAllScheduleUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateScanAllScheduleForbiddenCode is the HTTP code returned for type UpdateScanAllScheduleForbidden +const UpdateScanAllScheduleForbiddenCode int = 403 + +/*UpdateScanAllScheduleForbidden Forbidden + +swagger:response updateScanAllScheduleForbidden +*/ +type UpdateScanAllScheduleForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateScanAllScheduleForbidden creates UpdateScanAllScheduleForbidden with default headers values +func NewUpdateScanAllScheduleForbidden() *UpdateScanAllScheduleForbidden { + + return &UpdateScanAllScheduleForbidden{} +} + +// WithXRequestID adds the xRequestId to the update scan all schedule forbidden response +func (o *UpdateScanAllScheduleForbidden) WithXRequestID(xRequestID string) *UpdateScanAllScheduleForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update scan all schedule forbidden response +func (o *UpdateScanAllScheduleForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update scan all schedule forbidden response +func (o *UpdateScanAllScheduleForbidden) WithPayload(payload *models.Errors) *UpdateScanAllScheduleForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update scan all schedule forbidden response +func (o *UpdateScanAllScheduleForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateScanAllScheduleForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateScanAllSchedulePreconditionFailedCode is the HTTP code returned for type UpdateScanAllSchedulePreconditionFailed +const UpdateScanAllSchedulePreconditionFailedCode int = 412 + +/*UpdateScanAllSchedulePreconditionFailed Precondition failed + +swagger:response updateScanAllSchedulePreconditionFailed +*/ +type UpdateScanAllSchedulePreconditionFailed struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateScanAllSchedulePreconditionFailed creates UpdateScanAllSchedulePreconditionFailed with default headers values +func NewUpdateScanAllSchedulePreconditionFailed() *UpdateScanAllSchedulePreconditionFailed { + + return &UpdateScanAllSchedulePreconditionFailed{} +} + +// WithXRequestID adds the xRequestId to the update scan all schedule precondition failed response +func (o *UpdateScanAllSchedulePreconditionFailed) WithXRequestID(xRequestID string) *UpdateScanAllSchedulePreconditionFailed { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update scan all schedule precondition failed response +func (o *UpdateScanAllSchedulePreconditionFailed) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update scan all schedule precondition failed response +func (o *UpdateScanAllSchedulePreconditionFailed) WithPayload(payload *models.Errors) *UpdateScanAllSchedulePreconditionFailed { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update scan all schedule precondition failed response +func (o *UpdateScanAllSchedulePreconditionFailed) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateScanAllSchedulePreconditionFailed) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(412) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateScanAllScheduleInternalServerErrorCode is the HTTP code returned for type UpdateScanAllScheduleInternalServerError +const UpdateScanAllScheduleInternalServerErrorCode int = 500 + +/*UpdateScanAllScheduleInternalServerError Internal server error + +swagger:response updateScanAllScheduleInternalServerError +*/ +type UpdateScanAllScheduleInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateScanAllScheduleInternalServerError creates UpdateScanAllScheduleInternalServerError with default headers values +func NewUpdateScanAllScheduleInternalServerError() *UpdateScanAllScheduleInternalServerError { + + return &UpdateScanAllScheduleInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the update scan all schedule internal server error response +func (o *UpdateScanAllScheduleInternalServerError) WithXRequestID(xRequestID string) *UpdateScanAllScheduleInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update scan all schedule internal server error response +func (o *UpdateScanAllScheduleInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update scan all schedule internal server error response +func (o *UpdateScanAllScheduleInternalServerError) WithPayload(payload *models.Errors) *UpdateScanAllScheduleInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update scan all schedule internal server error response +func (o *UpdateScanAllScheduleInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateScanAllScheduleInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/scan_all/update_scan_all_schedule_urlbuilder.go b/src/server/v2.0/restapi/operations/scan_all/update_scan_all_schedule_urlbuilder.go new file mode 100644 index 000000000..ea8095132 --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan_all/update_scan_all_schedule_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan_all + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// UpdateScanAllScheduleURL generates an URL for the update scan all schedule operation +type UpdateScanAllScheduleURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdateScanAllScheduleURL) WithBasePath(bp string) *UpdateScanAllScheduleURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdateScanAllScheduleURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *UpdateScanAllScheduleURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/system/scanAll/schedule" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *UpdateScanAllScheduleURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *UpdateScanAllScheduleURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *UpdateScanAllScheduleURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on UpdateScanAllScheduleURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on UpdateScanAllScheduleURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *UpdateScanAllScheduleURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/scan_data_export/download_scan_data.go b/src/server/v2.0/restapi/operations/scan_data_export/download_scan_data.go new file mode 100644 index 000000000..767870398 --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan_data_export/download_scan_data.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan_data_export + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DownloadScanDataHandlerFunc turns a function with the right signature into a download scan data handler +type DownloadScanDataHandlerFunc func(DownloadScanDataParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DownloadScanDataHandlerFunc) Handle(params DownloadScanDataParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DownloadScanDataHandler interface for that can handle valid download scan data params +type DownloadScanDataHandler interface { + Handle(DownloadScanDataParams, interface{}) middleware.Responder +} + +// NewDownloadScanData creates a new http.Handler for the download scan data operation +func NewDownloadScanData(ctx *middleware.Context, handler DownloadScanDataHandler) *DownloadScanData { + return &DownloadScanData{Context: ctx, Handler: handler} +} + +/*DownloadScanData swagger:route GET /export/cve/download/{execution_id} scan data export downloadScanData + +Download the scan data export file + +Download the scan data report. Default format is CSV + +*/ +type DownloadScanData struct { + Context *middleware.Context + Handler DownloadScanDataHandler +} + +func (o *DownloadScanData) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewDownloadScanDataParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/scan_data_export/download_scan_data_parameters.go b/src/server/v2.0/restapi/operations/scan_data_export/download_scan_data_parameters.go new file mode 100644 index 000000000..40579f911 --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan_data_export/download_scan_data_parameters.go @@ -0,0 +1,149 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan_data_export + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewDownloadScanDataParams creates a new DownloadScanDataParams object +// no default values defined in spec. +func NewDownloadScanDataParams() DownloadScanDataParams { + + return DownloadScanDataParams{} +} + +// DownloadScanDataParams contains all the bound params for the download scan data operation +// typically these are obtained from a http.Request +// +// swagger:parameters downloadScanData +type DownloadScanDataParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*Execution ID + Required: true + In: path + */ + ExecutionID int64 + /*The format of the data to be exported. e.g. CSV or PDF + In: query + */ + Format *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDownloadScanDataParams() beforehand. +func (o *DownloadScanDataParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rExecutionID, rhkExecutionID, _ := route.Params.GetOK("execution_id") + if err := o.bindExecutionID(rExecutionID, rhkExecutionID, route.Formats); err != nil { + res = append(res, err) + } + + qFormat, qhkFormat, _ := qs.GetOK("format") + if err := o.bindFormat(qFormat, qhkFormat, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *DownloadScanDataParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *DownloadScanDataParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindExecutionID binds and validates parameter ExecutionID from path. +func (o *DownloadScanDataParams) bindExecutionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("execution_id", "path", "int64", raw) + } + o.ExecutionID = value + + return nil +} + +// bindFormat binds and validates parameter Format from query. +func (o *DownloadScanDataParams) bindFormat(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Format = &raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/scan_data_export/download_scan_data_responses.go b/src/server/v2.0/restapi/operations/scan_data_export/download_scan_data_responses.go new file mode 100644 index 000000000..0cae07296 --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan_data_export/download_scan_data_responses.go @@ -0,0 +1,343 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan_data_export + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// DownloadScanDataOKCode is the HTTP code returned for type DownloadScanDataOK +const DownloadScanDataOKCode int = 200 + +/*DownloadScanDataOK Data file containing the export data + +swagger:response downloadScanDataOK +*/ +type DownloadScanDataOK struct { + /*Value is a CSV formatted file; filename=export.csv + + */ + ContentDisposition string `json:"Content-Disposition"` + + /* + In: Body + */ + Payload io.ReadCloser `json:"body,omitempty"` +} + +// NewDownloadScanDataOK creates DownloadScanDataOK with default headers values +func NewDownloadScanDataOK() *DownloadScanDataOK { + + return &DownloadScanDataOK{} +} + +// WithContentDisposition adds the contentDisposition to the download scan data o k response +func (o *DownloadScanDataOK) WithContentDisposition(contentDisposition string) *DownloadScanDataOK { + o.ContentDisposition = contentDisposition + return o +} + +// SetContentDisposition sets the contentDisposition to the download scan data o k response +func (o *DownloadScanDataOK) SetContentDisposition(contentDisposition string) { + o.ContentDisposition = contentDisposition +} + +// WithPayload adds the payload to the download scan data o k response +func (o *DownloadScanDataOK) WithPayload(payload io.ReadCloser) *DownloadScanDataOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the download scan data o k response +func (o *DownloadScanDataOK) SetPayload(payload io.ReadCloser) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DownloadScanDataOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Content-Disposition + + contentDisposition := o.ContentDisposition + if contentDisposition != "" { + rw.Header().Set("Content-Disposition", contentDisposition) + } + + rw.WriteHeader(200) + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// DownloadScanDataUnauthorizedCode is the HTTP code returned for type DownloadScanDataUnauthorized +const DownloadScanDataUnauthorizedCode int = 401 + +/*DownloadScanDataUnauthorized Unauthorized + +swagger:response downloadScanDataUnauthorized +*/ +type DownloadScanDataUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDownloadScanDataUnauthorized creates DownloadScanDataUnauthorized with default headers values +func NewDownloadScanDataUnauthorized() *DownloadScanDataUnauthorized { + + return &DownloadScanDataUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the download scan data unauthorized response +func (o *DownloadScanDataUnauthorized) WithXRequestID(xRequestID string) *DownloadScanDataUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the download scan data unauthorized response +func (o *DownloadScanDataUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the download scan data unauthorized response +func (o *DownloadScanDataUnauthorized) WithPayload(payload *models.Errors) *DownloadScanDataUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the download scan data unauthorized response +func (o *DownloadScanDataUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DownloadScanDataUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DownloadScanDataForbiddenCode is the HTTP code returned for type DownloadScanDataForbidden +const DownloadScanDataForbiddenCode int = 403 + +/*DownloadScanDataForbidden Forbidden + +swagger:response downloadScanDataForbidden +*/ +type DownloadScanDataForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDownloadScanDataForbidden creates DownloadScanDataForbidden with default headers values +func NewDownloadScanDataForbidden() *DownloadScanDataForbidden { + + return &DownloadScanDataForbidden{} +} + +// WithXRequestID adds the xRequestId to the download scan data forbidden response +func (o *DownloadScanDataForbidden) WithXRequestID(xRequestID string) *DownloadScanDataForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the download scan data forbidden response +func (o *DownloadScanDataForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the download scan data forbidden response +func (o *DownloadScanDataForbidden) WithPayload(payload *models.Errors) *DownloadScanDataForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the download scan data forbidden response +func (o *DownloadScanDataForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DownloadScanDataForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DownloadScanDataNotFoundCode is the HTTP code returned for type DownloadScanDataNotFound +const DownloadScanDataNotFoundCode int = 404 + +/*DownloadScanDataNotFound Not found + +swagger:response downloadScanDataNotFound +*/ +type DownloadScanDataNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDownloadScanDataNotFound creates DownloadScanDataNotFound with default headers values +func NewDownloadScanDataNotFound() *DownloadScanDataNotFound { + + return &DownloadScanDataNotFound{} +} + +// WithXRequestID adds the xRequestId to the download scan data not found response +func (o *DownloadScanDataNotFound) WithXRequestID(xRequestID string) *DownloadScanDataNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the download scan data not found response +func (o *DownloadScanDataNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the download scan data not found response +func (o *DownloadScanDataNotFound) WithPayload(payload *models.Errors) *DownloadScanDataNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the download scan data not found response +func (o *DownloadScanDataNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DownloadScanDataNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DownloadScanDataInternalServerErrorCode is the HTTP code returned for type DownloadScanDataInternalServerError +const DownloadScanDataInternalServerErrorCode int = 500 + +/*DownloadScanDataInternalServerError Internal server error + +swagger:response downloadScanDataInternalServerError +*/ +type DownloadScanDataInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDownloadScanDataInternalServerError creates DownloadScanDataInternalServerError with default headers values +func NewDownloadScanDataInternalServerError() *DownloadScanDataInternalServerError { + + return &DownloadScanDataInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the download scan data internal server error response +func (o *DownloadScanDataInternalServerError) WithXRequestID(xRequestID string) *DownloadScanDataInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the download scan data internal server error response +func (o *DownloadScanDataInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the download scan data internal server error response +func (o *DownloadScanDataInternalServerError) WithPayload(payload *models.Errors) *DownloadScanDataInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the download scan data internal server error response +func (o *DownloadScanDataInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DownloadScanDataInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/scan_data_export/download_scan_data_urlbuilder.go b/src/server/v2.0/restapi/operations/scan_data_export/download_scan_data_urlbuilder.go new file mode 100644 index 000000000..e2dbe9df6 --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan_data_export/download_scan_data_urlbuilder.go @@ -0,0 +1,115 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan_data_export + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DownloadScanDataURL generates an URL for the download scan data operation +type DownloadScanDataURL struct { + ExecutionID int64 + + Format *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DownloadScanDataURL) WithBasePath(bp string) *DownloadScanDataURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DownloadScanDataURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DownloadScanDataURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/export/cve/download/{execution_id}" + + executionID := swag.FormatInt64(o.ExecutionID) + if executionID != "" { + _path = strings.Replace(_path, "{execution_id}", executionID, -1) + } else { + return nil, errors.New("executionId is required on DownloadScanDataURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var formatQ string + if o.Format != nil { + formatQ = *o.Format + } + if formatQ != "" { + qs.Set("format", formatQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DownloadScanDataURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DownloadScanDataURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DownloadScanDataURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DownloadScanDataURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DownloadScanDataURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DownloadScanDataURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/scan_data_export/export_scan_data.go b/src/server/v2.0/restapi/operations/scan_data_export/export_scan_data.go new file mode 100644 index 000000000..da7b20bb1 --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan_data_export/export_scan_data.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan_data_export + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ExportScanDataHandlerFunc turns a function with the right signature into a export scan data handler +type ExportScanDataHandlerFunc func(ExportScanDataParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ExportScanDataHandlerFunc) Handle(params ExportScanDataParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ExportScanDataHandler interface for that can handle valid export scan data params +type ExportScanDataHandler interface { + Handle(ExportScanDataParams, interface{}) middleware.Responder +} + +// NewExportScanData creates a new http.Handler for the export scan data operation +func NewExportScanData(ctx *middleware.Context, handler ExportScanDataHandler) *ExportScanData { + return &ExportScanData{Context: ctx, Handler: handler} +} + +/*ExportScanData swagger:route POST /export/cve scan data export exportScanData + +Export scan data for selected projects + +Export scan data for selected projects + +*/ +type ExportScanData struct { + Context *middleware.Context + Handler ExportScanDataHandler +} + +func (o *ExportScanData) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewExportScanDataParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/scan_data_export/export_scan_data_parameters.go b/src/server/v2.0/restapi/operations/scan_data_export/export_scan_data_parameters.go new file mode 100644 index 000000000..af4102372 --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan_data_export/export_scan_data_parameters.go @@ -0,0 +1,150 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan_data_export + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewExportScanDataParams creates a new ExportScanDataParams object +// no default values defined in spec. +func NewExportScanDataParams() ExportScanDataParams { + + return ExportScanDataParams{} +} + +// ExportScanDataParams contains all the bound params for the export scan data operation +// typically these are obtained from a http.Request +// +// swagger:parameters exportScanData +type ExportScanDataParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The type of scan data to export + Required: true + In: header + */ + XScanDataType string + /*The criteria for the export + Required: true + In: body + */ + Criteria *models.ScanDataExportRequest +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewExportScanDataParams() beforehand. +func (o *ExportScanDataParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if err := o.bindXScanDataType(r.Header[http.CanonicalHeaderKey("X-Scan-Data-Type")], true, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.ScanDataExportRequest + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("criteria", "body", "")) + } else { + res = append(res, errors.NewParseError("criteria", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Criteria = &body + } + } + } else { + res = append(res, errors.Required("criteria", "body", "")) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *ExportScanDataParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *ExportScanDataParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindXScanDataType binds and validates parameter XScanDataType from header. +func (o *ExportScanDataParams) bindXScanDataType(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("X-Scan-Data-Type", "header", rawData) + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + + if err := validate.RequiredString("X-Scan-Data-Type", "header", raw); err != nil { + return err + } + + o.XScanDataType = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/scan_data_export/export_scan_data_responses.go b/src/server/v2.0/restapi/operations/scan_data_export/export_scan_data_responses.go new file mode 100644 index 000000000..46fdaf9d4 --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan_data_export/export_scan_data_responses.go @@ -0,0 +1,520 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan_data_export + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// ExportScanDataOKCode is the HTTP code returned for type ExportScanDataOK +const ExportScanDataOKCode int = 200 + +/*ExportScanDataOK Success. + +swagger:response exportScanDataOK +*/ +type ExportScanDataOK struct { + + /* + In: Body + */ + Payload *models.ScanDataExportJob `json:"body,omitempty"` +} + +// NewExportScanDataOK creates ExportScanDataOK with default headers values +func NewExportScanDataOK() *ExportScanDataOK { + + return &ExportScanDataOK{} +} + +// WithPayload adds the payload to the export scan data o k response +func (o *ExportScanDataOK) WithPayload(payload *models.ScanDataExportJob) *ExportScanDataOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the export scan data o k response +func (o *ExportScanDataOK) SetPayload(payload *models.ScanDataExportJob) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ExportScanDataOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ExportScanDataBadRequestCode is the HTTP code returned for type ExportScanDataBadRequest +const ExportScanDataBadRequestCode int = 400 + +/*ExportScanDataBadRequest Bad request + +swagger:response exportScanDataBadRequest +*/ +type ExportScanDataBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewExportScanDataBadRequest creates ExportScanDataBadRequest with default headers values +func NewExportScanDataBadRequest() *ExportScanDataBadRequest { + + return &ExportScanDataBadRequest{} +} + +// WithXRequestID adds the xRequestId to the export scan data bad request response +func (o *ExportScanDataBadRequest) WithXRequestID(xRequestID string) *ExportScanDataBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the export scan data bad request response +func (o *ExportScanDataBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the export scan data bad request response +func (o *ExportScanDataBadRequest) WithPayload(payload *models.Errors) *ExportScanDataBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the export scan data bad request response +func (o *ExportScanDataBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ExportScanDataBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ExportScanDataUnauthorizedCode is the HTTP code returned for type ExportScanDataUnauthorized +const ExportScanDataUnauthorizedCode int = 401 + +/*ExportScanDataUnauthorized Unauthorized + +swagger:response exportScanDataUnauthorized +*/ +type ExportScanDataUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewExportScanDataUnauthorized creates ExportScanDataUnauthorized with default headers values +func NewExportScanDataUnauthorized() *ExportScanDataUnauthorized { + + return &ExportScanDataUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the export scan data unauthorized response +func (o *ExportScanDataUnauthorized) WithXRequestID(xRequestID string) *ExportScanDataUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the export scan data unauthorized response +func (o *ExportScanDataUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the export scan data unauthorized response +func (o *ExportScanDataUnauthorized) WithPayload(payload *models.Errors) *ExportScanDataUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the export scan data unauthorized response +func (o *ExportScanDataUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ExportScanDataUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ExportScanDataForbiddenCode is the HTTP code returned for type ExportScanDataForbidden +const ExportScanDataForbiddenCode int = 403 + +/*ExportScanDataForbidden Forbidden + +swagger:response exportScanDataForbidden +*/ +type ExportScanDataForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewExportScanDataForbidden creates ExportScanDataForbidden with default headers values +func NewExportScanDataForbidden() *ExportScanDataForbidden { + + return &ExportScanDataForbidden{} +} + +// WithXRequestID adds the xRequestId to the export scan data forbidden response +func (o *ExportScanDataForbidden) WithXRequestID(xRequestID string) *ExportScanDataForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the export scan data forbidden response +func (o *ExportScanDataForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the export scan data forbidden response +func (o *ExportScanDataForbidden) WithPayload(payload *models.Errors) *ExportScanDataForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the export scan data forbidden response +func (o *ExportScanDataForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ExportScanDataForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ExportScanDataNotFoundCode is the HTTP code returned for type ExportScanDataNotFound +const ExportScanDataNotFoundCode int = 404 + +/*ExportScanDataNotFound Not found + +swagger:response exportScanDataNotFound +*/ +type ExportScanDataNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewExportScanDataNotFound creates ExportScanDataNotFound with default headers values +func NewExportScanDataNotFound() *ExportScanDataNotFound { + + return &ExportScanDataNotFound{} +} + +// WithXRequestID adds the xRequestId to the export scan data not found response +func (o *ExportScanDataNotFound) WithXRequestID(xRequestID string) *ExportScanDataNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the export scan data not found response +func (o *ExportScanDataNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the export scan data not found response +func (o *ExportScanDataNotFound) WithPayload(payload *models.Errors) *ExportScanDataNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the export scan data not found response +func (o *ExportScanDataNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ExportScanDataNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ExportScanDataMethodNotAllowedCode is the HTTP code returned for type ExportScanDataMethodNotAllowed +const ExportScanDataMethodNotAllowedCode int = 405 + +/*ExportScanDataMethodNotAllowed Method not allowed + +swagger:response exportScanDataMethodNotAllowed +*/ +type ExportScanDataMethodNotAllowed struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewExportScanDataMethodNotAllowed creates ExportScanDataMethodNotAllowed with default headers values +func NewExportScanDataMethodNotAllowed() *ExportScanDataMethodNotAllowed { + + return &ExportScanDataMethodNotAllowed{} +} + +// WithXRequestID adds the xRequestId to the export scan data method not allowed response +func (o *ExportScanDataMethodNotAllowed) WithXRequestID(xRequestID string) *ExportScanDataMethodNotAllowed { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the export scan data method not allowed response +func (o *ExportScanDataMethodNotAllowed) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the export scan data method not allowed response +func (o *ExportScanDataMethodNotAllowed) WithPayload(payload *models.Errors) *ExportScanDataMethodNotAllowed { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the export scan data method not allowed response +func (o *ExportScanDataMethodNotAllowed) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ExportScanDataMethodNotAllowed) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(405) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ExportScanDataConflictCode is the HTTP code returned for type ExportScanDataConflict +const ExportScanDataConflictCode int = 409 + +/*ExportScanDataConflict Conflict + +swagger:response exportScanDataConflict +*/ +type ExportScanDataConflict struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewExportScanDataConflict creates ExportScanDataConflict with default headers values +func NewExportScanDataConflict() *ExportScanDataConflict { + + return &ExportScanDataConflict{} +} + +// WithXRequestID adds the xRequestId to the export scan data conflict response +func (o *ExportScanDataConflict) WithXRequestID(xRequestID string) *ExportScanDataConflict { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the export scan data conflict response +func (o *ExportScanDataConflict) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the export scan data conflict response +func (o *ExportScanDataConflict) WithPayload(payload *models.Errors) *ExportScanDataConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the export scan data conflict response +func (o *ExportScanDataConflict) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ExportScanDataConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ExportScanDataInternalServerErrorCode is the HTTP code returned for type ExportScanDataInternalServerError +const ExportScanDataInternalServerErrorCode int = 500 + +/*ExportScanDataInternalServerError Internal server error + +swagger:response exportScanDataInternalServerError +*/ +type ExportScanDataInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewExportScanDataInternalServerError creates ExportScanDataInternalServerError with default headers values +func NewExportScanDataInternalServerError() *ExportScanDataInternalServerError { + + return &ExportScanDataInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the export scan data internal server error response +func (o *ExportScanDataInternalServerError) WithXRequestID(xRequestID string) *ExportScanDataInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the export scan data internal server error response +func (o *ExportScanDataInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the export scan data internal server error response +func (o *ExportScanDataInternalServerError) WithPayload(payload *models.Errors) *ExportScanDataInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the export scan data internal server error response +func (o *ExportScanDataInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ExportScanDataInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/scan_data_export/export_scan_data_urlbuilder.go b/src/server/v2.0/restapi/operations/scan_data_export/export_scan_data_urlbuilder.go new file mode 100644 index 000000000..7133b9e4f --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan_data_export/export_scan_data_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan_data_export + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// ExportScanDataURL generates an URL for the export scan data operation +type ExportScanDataURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ExportScanDataURL) WithBasePath(bp string) *ExportScanDataURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ExportScanDataURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ExportScanDataURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/export/cve" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ExportScanDataURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ExportScanDataURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ExportScanDataURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ExportScanDataURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ExportScanDataURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ExportScanDataURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/scan_data_export/get_scan_data_export_execution.go b/src/server/v2.0/restapi/operations/scan_data_export/get_scan_data_export_execution.go new file mode 100644 index 000000000..e625ed6f2 --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan_data_export/get_scan_data_export_execution.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan_data_export + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetScanDataExportExecutionHandlerFunc turns a function with the right signature into a get scan data export execution handler +type GetScanDataExportExecutionHandlerFunc func(GetScanDataExportExecutionParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetScanDataExportExecutionHandlerFunc) Handle(params GetScanDataExportExecutionParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetScanDataExportExecutionHandler interface for that can handle valid get scan data export execution params +type GetScanDataExportExecutionHandler interface { + Handle(GetScanDataExportExecutionParams, interface{}) middleware.Responder +} + +// NewGetScanDataExportExecution creates a new http.Handler for the get scan data export execution operation +func NewGetScanDataExportExecution(ctx *middleware.Context, handler GetScanDataExportExecutionHandler) *GetScanDataExportExecution { + return &GetScanDataExportExecution{Context: ctx, Handler: handler} +} + +/*GetScanDataExportExecution swagger:route GET /export/cve/execution/{execution_id} scan data export getScanDataExportExecution + +Get the specific scan data export execution + +Get the scan data export execution specified by ID + +*/ +type GetScanDataExportExecution struct { + Context *middleware.Context + Handler GetScanDataExportExecutionHandler +} + +func (o *GetScanDataExportExecution) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetScanDataExportExecutionParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/scan_data_export/get_scan_data_export_execution_list.go b/src/server/v2.0/restapi/operations/scan_data_export/get_scan_data_export_execution_list.go new file mode 100644 index 000000000..46c7ef6b1 --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan_data_export/get_scan_data_export_execution_list.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan_data_export + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetScanDataExportExecutionListHandlerFunc turns a function with the right signature into a get scan data export execution list handler +type GetScanDataExportExecutionListHandlerFunc func(GetScanDataExportExecutionListParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetScanDataExportExecutionListHandlerFunc) Handle(params GetScanDataExportExecutionListParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetScanDataExportExecutionListHandler interface for that can handle valid get scan data export execution list params +type GetScanDataExportExecutionListHandler interface { + Handle(GetScanDataExportExecutionListParams, interface{}) middleware.Responder +} + +// NewGetScanDataExportExecutionList creates a new http.Handler for the get scan data export execution list operation +func NewGetScanDataExportExecutionList(ctx *middleware.Context, handler GetScanDataExportExecutionListHandler) *GetScanDataExportExecutionList { + return &GetScanDataExportExecutionList{Context: ctx, Handler: handler} +} + +/*GetScanDataExportExecutionList swagger:route GET /export/cve/executions scan data export getScanDataExportExecutionList + +Get a list of specific scan data export execution jobs for a specified user + +Get a list of specific scan data export execution jobs for a specified user + +*/ +type GetScanDataExportExecutionList struct { + Context *middleware.Context + Handler GetScanDataExportExecutionListHandler +} + +func (o *GetScanDataExportExecutionList) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetScanDataExportExecutionListParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/scan_data_export/get_scan_data_export_execution_list_parameters.go b/src/server/v2.0/restapi/operations/scan_data_export/get_scan_data_export_execution_list_parameters.go new file mode 100644 index 000000000..62e8f921f --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan_data_export/get_scan_data_export_execution_list_parameters.go @@ -0,0 +1,89 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan_data_export + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewGetScanDataExportExecutionListParams creates a new GetScanDataExportExecutionListParams object +// no default values defined in spec. +func NewGetScanDataExportExecutionListParams() GetScanDataExportExecutionListParams { + + return GetScanDataExportExecutionListParams{} +} + +// GetScanDataExportExecutionListParams contains all the bound params for the get scan data export execution list operation +// typically these are obtained from a http.Request +// +// swagger:parameters getScanDataExportExecutionList +type GetScanDataExportExecutionListParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetScanDataExportExecutionListParams() beforehand. +func (o *GetScanDataExportExecutionListParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetScanDataExportExecutionListParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetScanDataExportExecutionListParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} diff --git a/src/server/v2.0/restapi/operations/scan_data_export/get_scan_data_export_execution_list_responses.go b/src/server/v2.0/restapi/operations/scan_data_export/get_scan_data_export_execution_list_responses.go new file mode 100644 index 000000000..12e03846e --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan_data_export/get_scan_data_export_execution_list_responses.go @@ -0,0 +1,322 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan_data_export + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetScanDataExportExecutionListOKCode is the HTTP code returned for type GetScanDataExportExecutionListOK +const GetScanDataExportExecutionListOKCode int = 200 + +/*GetScanDataExportExecutionListOK Success + +swagger:response getScanDataExportExecutionListOK +*/ +type GetScanDataExportExecutionListOK struct { + + /* + In: Body + */ + Payload *models.ScanDataExportExecutionList `json:"body,omitempty"` +} + +// NewGetScanDataExportExecutionListOK creates GetScanDataExportExecutionListOK with default headers values +func NewGetScanDataExportExecutionListOK() *GetScanDataExportExecutionListOK { + + return &GetScanDataExportExecutionListOK{} +} + +// WithPayload adds the payload to the get scan data export execution list o k response +func (o *GetScanDataExportExecutionListOK) WithPayload(payload *models.ScanDataExportExecutionList) *GetScanDataExportExecutionListOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get scan data export execution list o k response +func (o *GetScanDataExportExecutionListOK) SetPayload(payload *models.ScanDataExportExecutionList) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetScanDataExportExecutionListOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetScanDataExportExecutionListUnauthorizedCode is the HTTP code returned for type GetScanDataExportExecutionListUnauthorized +const GetScanDataExportExecutionListUnauthorizedCode int = 401 + +/*GetScanDataExportExecutionListUnauthorized Unauthorized + +swagger:response getScanDataExportExecutionListUnauthorized +*/ +type GetScanDataExportExecutionListUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetScanDataExportExecutionListUnauthorized creates GetScanDataExportExecutionListUnauthorized with default headers values +func NewGetScanDataExportExecutionListUnauthorized() *GetScanDataExportExecutionListUnauthorized { + + return &GetScanDataExportExecutionListUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the get scan data export execution list unauthorized response +func (o *GetScanDataExportExecutionListUnauthorized) WithXRequestID(xRequestID string) *GetScanDataExportExecutionListUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get scan data export execution list unauthorized response +func (o *GetScanDataExportExecutionListUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get scan data export execution list unauthorized response +func (o *GetScanDataExportExecutionListUnauthorized) WithPayload(payload *models.Errors) *GetScanDataExportExecutionListUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get scan data export execution list unauthorized response +func (o *GetScanDataExportExecutionListUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetScanDataExportExecutionListUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetScanDataExportExecutionListForbiddenCode is the HTTP code returned for type GetScanDataExportExecutionListForbidden +const GetScanDataExportExecutionListForbiddenCode int = 403 + +/*GetScanDataExportExecutionListForbidden Forbidden + +swagger:response getScanDataExportExecutionListForbidden +*/ +type GetScanDataExportExecutionListForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetScanDataExportExecutionListForbidden creates GetScanDataExportExecutionListForbidden with default headers values +func NewGetScanDataExportExecutionListForbidden() *GetScanDataExportExecutionListForbidden { + + return &GetScanDataExportExecutionListForbidden{} +} + +// WithXRequestID adds the xRequestId to the get scan data export execution list forbidden response +func (o *GetScanDataExportExecutionListForbidden) WithXRequestID(xRequestID string) *GetScanDataExportExecutionListForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get scan data export execution list forbidden response +func (o *GetScanDataExportExecutionListForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get scan data export execution list forbidden response +func (o *GetScanDataExportExecutionListForbidden) WithPayload(payload *models.Errors) *GetScanDataExportExecutionListForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get scan data export execution list forbidden response +func (o *GetScanDataExportExecutionListForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetScanDataExportExecutionListForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetScanDataExportExecutionListNotFoundCode is the HTTP code returned for type GetScanDataExportExecutionListNotFound +const GetScanDataExportExecutionListNotFoundCode int = 404 + +/*GetScanDataExportExecutionListNotFound Not found + +swagger:response getScanDataExportExecutionListNotFound +*/ +type GetScanDataExportExecutionListNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetScanDataExportExecutionListNotFound creates GetScanDataExportExecutionListNotFound with default headers values +func NewGetScanDataExportExecutionListNotFound() *GetScanDataExportExecutionListNotFound { + + return &GetScanDataExportExecutionListNotFound{} +} + +// WithXRequestID adds the xRequestId to the get scan data export execution list not found response +func (o *GetScanDataExportExecutionListNotFound) WithXRequestID(xRequestID string) *GetScanDataExportExecutionListNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get scan data export execution list not found response +func (o *GetScanDataExportExecutionListNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get scan data export execution list not found response +func (o *GetScanDataExportExecutionListNotFound) WithPayload(payload *models.Errors) *GetScanDataExportExecutionListNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get scan data export execution list not found response +func (o *GetScanDataExportExecutionListNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetScanDataExportExecutionListNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetScanDataExportExecutionListInternalServerErrorCode is the HTTP code returned for type GetScanDataExportExecutionListInternalServerError +const GetScanDataExportExecutionListInternalServerErrorCode int = 500 + +/*GetScanDataExportExecutionListInternalServerError Internal server error + +swagger:response getScanDataExportExecutionListInternalServerError +*/ +type GetScanDataExportExecutionListInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetScanDataExportExecutionListInternalServerError creates GetScanDataExportExecutionListInternalServerError with default headers values +func NewGetScanDataExportExecutionListInternalServerError() *GetScanDataExportExecutionListInternalServerError { + + return &GetScanDataExportExecutionListInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get scan data export execution list internal server error response +func (o *GetScanDataExportExecutionListInternalServerError) WithXRequestID(xRequestID string) *GetScanDataExportExecutionListInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get scan data export execution list internal server error response +func (o *GetScanDataExportExecutionListInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get scan data export execution list internal server error response +func (o *GetScanDataExportExecutionListInternalServerError) WithPayload(payload *models.Errors) *GetScanDataExportExecutionListInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get scan data export execution list internal server error response +func (o *GetScanDataExportExecutionListInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetScanDataExportExecutionListInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/scan_data_export/get_scan_data_export_execution_list_urlbuilder.go b/src/server/v2.0/restapi/operations/scan_data_export/get_scan_data_export_execution_list_urlbuilder.go new file mode 100644 index 000000000..1193e24a9 --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan_data_export/get_scan_data_export_execution_list_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan_data_export + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetScanDataExportExecutionListURL generates an URL for the get scan data export execution list operation +type GetScanDataExportExecutionListURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetScanDataExportExecutionListURL) WithBasePath(bp string) *GetScanDataExportExecutionListURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetScanDataExportExecutionListURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetScanDataExportExecutionListURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/export/cve/executions" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetScanDataExportExecutionListURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetScanDataExportExecutionListURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetScanDataExportExecutionListURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetScanDataExportExecutionListURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetScanDataExportExecutionListURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetScanDataExportExecutionListURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/scan_data_export/get_scan_data_export_execution_parameters.go b/src/server/v2.0/restapi/operations/scan_data_export/get_scan_data_export_execution_parameters.go new file mode 100644 index 000000000..9d7127a40 --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan_data_export/get_scan_data_export_execution_parameters.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan_data_export + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewGetScanDataExportExecutionParams creates a new GetScanDataExportExecutionParams object +// no default values defined in spec. +func NewGetScanDataExportExecutionParams() GetScanDataExportExecutionParams { + + return GetScanDataExportExecutionParams{} +} + +// GetScanDataExportExecutionParams contains all the bound params for the get scan data export execution operation +// typically these are obtained from a http.Request +// +// swagger:parameters getScanDataExportExecution +type GetScanDataExportExecutionParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*Execution ID + Required: true + In: path + */ + ExecutionID int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetScanDataExportExecutionParams() beforehand. +func (o *GetScanDataExportExecutionParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rExecutionID, rhkExecutionID, _ := route.Params.GetOK("execution_id") + if err := o.bindExecutionID(rExecutionID, rhkExecutionID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetScanDataExportExecutionParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetScanDataExportExecutionParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindExecutionID binds and validates parameter ExecutionID from path. +func (o *GetScanDataExportExecutionParams) bindExecutionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("execution_id", "path", "int64", raw) + } + o.ExecutionID = value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/scan_data_export/get_scan_data_export_execution_responses.go b/src/server/v2.0/restapi/operations/scan_data_export/get_scan_data_export_execution_responses.go new file mode 100644 index 000000000..1db8217b7 --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan_data_export/get_scan_data_export_execution_responses.go @@ -0,0 +1,322 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan_data_export + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetScanDataExportExecutionOKCode is the HTTP code returned for type GetScanDataExportExecutionOK +const GetScanDataExportExecutionOKCode int = 200 + +/*GetScanDataExportExecutionOK Success + +swagger:response getScanDataExportExecutionOK +*/ +type GetScanDataExportExecutionOK struct { + + /* + In: Body + */ + Payload *models.ScanDataExportExecution `json:"body,omitempty"` +} + +// NewGetScanDataExportExecutionOK creates GetScanDataExportExecutionOK with default headers values +func NewGetScanDataExportExecutionOK() *GetScanDataExportExecutionOK { + + return &GetScanDataExportExecutionOK{} +} + +// WithPayload adds the payload to the get scan data export execution o k response +func (o *GetScanDataExportExecutionOK) WithPayload(payload *models.ScanDataExportExecution) *GetScanDataExportExecutionOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get scan data export execution o k response +func (o *GetScanDataExportExecutionOK) SetPayload(payload *models.ScanDataExportExecution) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetScanDataExportExecutionOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetScanDataExportExecutionUnauthorizedCode is the HTTP code returned for type GetScanDataExportExecutionUnauthorized +const GetScanDataExportExecutionUnauthorizedCode int = 401 + +/*GetScanDataExportExecutionUnauthorized Unauthorized + +swagger:response getScanDataExportExecutionUnauthorized +*/ +type GetScanDataExportExecutionUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetScanDataExportExecutionUnauthorized creates GetScanDataExportExecutionUnauthorized with default headers values +func NewGetScanDataExportExecutionUnauthorized() *GetScanDataExportExecutionUnauthorized { + + return &GetScanDataExportExecutionUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the get scan data export execution unauthorized response +func (o *GetScanDataExportExecutionUnauthorized) WithXRequestID(xRequestID string) *GetScanDataExportExecutionUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get scan data export execution unauthorized response +func (o *GetScanDataExportExecutionUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get scan data export execution unauthorized response +func (o *GetScanDataExportExecutionUnauthorized) WithPayload(payload *models.Errors) *GetScanDataExportExecutionUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get scan data export execution unauthorized response +func (o *GetScanDataExportExecutionUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetScanDataExportExecutionUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetScanDataExportExecutionForbiddenCode is the HTTP code returned for type GetScanDataExportExecutionForbidden +const GetScanDataExportExecutionForbiddenCode int = 403 + +/*GetScanDataExportExecutionForbidden Forbidden + +swagger:response getScanDataExportExecutionForbidden +*/ +type GetScanDataExportExecutionForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetScanDataExportExecutionForbidden creates GetScanDataExportExecutionForbidden with default headers values +func NewGetScanDataExportExecutionForbidden() *GetScanDataExportExecutionForbidden { + + return &GetScanDataExportExecutionForbidden{} +} + +// WithXRequestID adds the xRequestId to the get scan data export execution forbidden response +func (o *GetScanDataExportExecutionForbidden) WithXRequestID(xRequestID string) *GetScanDataExportExecutionForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get scan data export execution forbidden response +func (o *GetScanDataExportExecutionForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get scan data export execution forbidden response +func (o *GetScanDataExportExecutionForbidden) WithPayload(payload *models.Errors) *GetScanDataExportExecutionForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get scan data export execution forbidden response +func (o *GetScanDataExportExecutionForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetScanDataExportExecutionForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetScanDataExportExecutionNotFoundCode is the HTTP code returned for type GetScanDataExportExecutionNotFound +const GetScanDataExportExecutionNotFoundCode int = 404 + +/*GetScanDataExportExecutionNotFound Not found + +swagger:response getScanDataExportExecutionNotFound +*/ +type GetScanDataExportExecutionNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetScanDataExportExecutionNotFound creates GetScanDataExportExecutionNotFound with default headers values +func NewGetScanDataExportExecutionNotFound() *GetScanDataExportExecutionNotFound { + + return &GetScanDataExportExecutionNotFound{} +} + +// WithXRequestID adds the xRequestId to the get scan data export execution not found response +func (o *GetScanDataExportExecutionNotFound) WithXRequestID(xRequestID string) *GetScanDataExportExecutionNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get scan data export execution not found response +func (o *GetScanDataExportExecutionNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get scan data export execution not found response +func (o *GetScanDataExportExecutionNotFound) WithPayload(payload *models.Errors) *GetScanDataExportExecutionNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get scan data export execution not found response +func (o *GetScanDataExportExecutionNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetScanDataExportExecutionNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetScanDataExportExecutionInternalServerErrorCode is the HTTP code returned for type GetScanDataExportExecutionInternalServerError +const GetScanDataExportExecutionInternalServerErrorCode int = 500 + +/*GetScanDataExportExecutionInternalServerError Internal server error + +swagger:response getScanDataExportExecutionInternalServerError +*/ +type GetScanDataExportExecutionInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetScanDataExportExecutionInternalServerError creates GetScanDataExportExecutionInternalServerError with default headers values +func NewGetScanDataExportExecutionInternalServerError() *GetScanDataExportExecutionInternalServerError { + + return &GetScanDataExportExecutionInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get scan data export execution internal server error response +func (o *GetScanDataExportExecutionInternalServerError) WithXRequestID(xRequestID string) *GetScanDataExportExecutionInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get scan data export execution internal server error response +func (o *GetScanDataExportExecutionInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get scan data export execution internal server error response +func (o *GetScanDataExportExecutionInternalServerError) WithPayload(payload *models.Errors) *GetScanDataExportExecutionInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get scan data export execution internal server error response +func (o *GetScanDataExportExecutionInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetScanDataExportExecutionInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/scan_data_export/get_scan_data_export_execution_urlbuilder.go b/src/server/v2.0/restapi/operations/scan_data_export/get_scan_data_export_execution_urlbuilder.go new file mode 100644 index 000000000..644079872 --- /dev/null +++ b/src/server/v2.0/restapi/operations/scan_data_export/get_scan_data_export_execution_urlbuilder.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan_data_export + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetScanDataExportExecutionURL generates an URL for the get scan data export execution operation +type GetScanDataExportExecutionURL struct { + ExecutionID int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetScanDataExportExecutionURL) WithBasePath(bp string) *GetScanDataExportExecutionURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetScanDataExportExecutionURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetScanDataExportExecutionURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/export/cve/execution/{execution_id}" + + executionID := swag.FormatInt64(o.ExecutionID) + if executionID != "" { + _path = strings.Replace(_path, "{execution_id}", executionID, -1) + } else { + return nil, errors.New("executionId is required on GetScanDataExportExecutionURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetScanDataExportExecutionURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetScanDataExportExecutionURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetScanDataExportExecutionURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetScanDataExportExecutionURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetScanDataExportExecutionURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetScanDataExportExecutionURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/scanner/create_scanner.go b/src/server/v2.0/restapi/operations/scanner/create_scanner.go new file mode 100644 index 000000000..c5347391d --- /dev/null +++ b/src/server/v2.0/restapi/operations/scanner/create_scanner.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scanner + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateScannerHandlerFunc turns a function with the right signature into a create scanner handler +type CreateScannerHandlerFunc func(CreateScannerParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateScannerHandlerFunc) Handle(params CreateScannerParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateScannerHandler interface for that can handle valid create scanner params +type CreateScannerHandler interface { + Handle(CreateScannerParams, interface{}) middleware.Responder +} + +// NewCreateScanner creates a new http.Handler for the create scanner operation +func NewCreateScanner(ctx *middleware.Context, handler CreateScannerHandler) *CreateScanner { + return &CreateScanner{Context: ctx, Handler: handler} +} + +/*CreateScanner swagger:route POST /scanners scanner createScanner + +Create a scanner registration + +Creats a new scanner registration with the given data. + + +*/ +type CreateScanner struct { + Context *middleware.Context + Handler CreateScannerHandler +} + +func (o *CreateScanner) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewCreateScannerParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/scanner/create_scanner_parameters.go b/src/server/v2.0/restapi/operations/scanner/create_scanner_parameters.go new file mode 100644 index 000000000..05396e8d6 --- /dev/null +++ b/src/server/v2.0/restapi/operations/scanner/create_scanner_parameters.go @@ -0,0 +1,120 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scanner + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewCreateScannerParams creates a new CreateScannerParams object +// no default values defined in spec. +func NewCreateScannerParams() CreateScannerParams { + + return CreateScannerParams{} +} + +// CreateScannerParams contains all the bound params for the create scanner operation +// typically these are obtained from a http.Request +// +// swagger:parameters createScanner +type CreateScannerParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*A scanner registration to be created. + Required: true + In: body + */ + Registration *models.ScannerRegistrationReq +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateScannerParams() beforehand. +func (o *CreateScannerParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.ScannerRegistrationReq + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("registration", "body", "")) + } else { + res = append(res, errors.NewParseError("registration", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Registration = &body + } + } + } else { + res = append(res, errors.Required("registration", "body", "")) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *CreateScannerParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *CreateScannerParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} diff --git a/src/server/v2.0/restapi/operations/scanner/create_scanner_responses.go b/src/server/v2.0/restapi/operations/scanner/create_scanner_responses.go new file mode 100644 index 000000000..b31b8089e --- /dev/null +++ b/src/server/v2.0/restapi/operations/scanner/create_scanner_responses.go @@ -0,0 +1,324 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scanner + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// CreateScannerCreatedCode is the HTTP code returned for type CreateScannerCreated +const CreateScannerCreatedCode int = 201 + +/*CreateScannerCreated Created successfully + +swagger:response createScannerCreated +*/ +type CreateScannerCreated struct { + /*The URL of the created resource + + */ + Location string `json:"Location"` +} + +// NewCreateScannerCreated creates CreateScannerCreated with default headers values +func NewCreateScannerCreated() *CreateScannerCreated { + + return &CreateScannerCreated{} +} + +// WithLocation adds the location to the create scanner created response +func (o *CreateScannerCreated) WithLocation(location string) *CreateScannerCreated { + o.Location = location + return o +} + +// SetLocation sets the location to the create scanner created response +func (o *CreateScannerCreated) SetLocation(location string) { + o.Location = location +} + +// WriteResponse to the client +func (o *CreateScannerCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Location + + location := o.Location + if location != "" { + rw.Header().Set("Location", location) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(201) +} + +// CreateScannerBadRequestCode is the HTTP code returned for type CreateScannerBadRequest +const CreateScannerBadRequestCode int = 400 + +/*CreateScannerBadRequest Bad request + +swagger:response createScannerBadRequest +*/ +type CreateScannerBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateScannerBadRequest creates CreateScannerBadRequest with default headers values +func NewCreateScannerBadRequest() *CreateScannerBadRequest { + + return &CreateScannerBadRequest{} +} + +// WithXRequestID adds the xRequestId to the create scanner bad request response +func (o *CreateScannerBadRequest) WithXRequestID(xRequestID string) *CreateScannerBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create scanner bad request response +func (o *CreateScannerBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create scanner bad request response +func (o *CreateScannerBadRequest) WithPayload(payload *models.Errors) *CreateScannerBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create scanner bad request response +func (o *CreateScannerBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateScannerBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateScannerUnauthorizedCode is the HTTP code returned for type CreateScannerUnauthorized +const CreateScannerUnauthorizedCode int = 401 + +/*CreateScannerUnauthorized Unauthorized + +swagger:response createScannerUnauthorized +*/ +type CreateScannerUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateScannerUnauthorized creates CreateScannerUnauthorized with default headers values +func NewCreateScannerUnauthorized() *CreateScannerUnauthorized { + + return &CreateScannerUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the create scanner unauthorized response +func (o *CreateScannerUnauthorized) WithXRequestID(xRequestID string) *CreateScannerUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create scanner unauthorized response +func (o *CreateScannerUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create scanner unauthorized response +func (o *CreateScannerUnauthorized) WithPayload(payload *models.Errors) *CreateScannerUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create scanner unauthorized response +func (o *CreateScannerUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateScannerUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateScannerForbiddenCode is the HTTP code returned for type CreateScannerForbidden +const CreateScannerForbiddenCode int = 403 + +/*CreateScannerForbidden Forbidden + +swagger:response createScannerForbidden +*/ +type CreateScannerForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateScannerForbidden creates CreateScannerForbidden with default headers values +func NewCreateScannerForbidden() *CreateScannerForbidden { + + return &CreateScannerForbidden{} +} + +// WithXRequestID adds the xRequestId to the create scanner forbidden response +func (o *CreateScannerForbidden) WithXRequestID(xRequestID string) *CreateScannerForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create scanner forbidden response +func (o *CreateScannerForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create scanner forbidden response +func (o *CreateScannerForbidden) WithPayload(payload *models.Errors) *CreateScannerForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create scanner forbidden response +func (o *CreateScannerForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateScannerForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateScannerInternalServerErrorCode is the HTTP code returned for type CreateScannerInternalServerError +const CreateScannerInternalServerErrorCode int = 500 + +/*CreateScannerInternalServerError Internal server error + +swagger:response createScannerInternalServerError +*/ +type CreateScannerInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateScannerInternalServerError creates CreateScannerInternalServerError with default headers values +func NewCreateScannerInternalServerError() *CreateScannerInternalServerError { + + return &CreateScannerInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the create scanner internal server error response +func (o *CreateScannerInternalServerError) WithXRequestID(xRequestID string) *CreateScannerInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create scanner internal server error response +func (o *CreateScannerInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create scanner internal server error response +func (o *CreateScannerInternalServerError) WithPayload(payload *models.Errors) *CreateScannerInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create scanner internal server error response +func (o *CreateScannerInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateScannerInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/scanner/create_scanner_urlbuilder.go b/src/server/v2.0/restapi/operations/scanner/create_scanner_urlbuilder.go new file mode 100644 index 000000000..3cf66c07d --- /dev/null +++ b/src/server/v2.0/restapi/operations/scanner/create_scanner_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scanner + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// CreateScannerURL generates an URL for the create scanner operation +type CreateScannerURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateScannerURL) WithBasePath(bp string) *CreateScannerURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateScannerURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateScannerURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/scanners" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateScannerURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateScannerURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateScannerURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateScannerURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateScannerURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateScannerURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/scanner/delete_scanner.go b/src/server/v2.0/restapi/operations/scanner/delete_scanner.go new file mode 100644 index 000000000..86c4aef10 --- /dev/null +++ b/src/server/v2.0/restapi/operations/scanner/delete_scanner.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scanner + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteScannerHandlerFunc turns a function with the right signature into a delete scanner handler +type DeleteScannerHandlerFunc func(DeleteScannerParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteScannerHandlerFunc) Handle(params DeleteScannerParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteScannerHandler interface for that can handle valid delete scanner params +type DeleteScannerHandler interface { + Handle(DeleteScannerParams, interface{}) middleware.Responder +} + +// NewDeleteScanner creates a new http.Handler for the delete scanner operation +func NewDeleteScanner(ctx *middleware.Context, handler DeleteScannerHandler) *DeleteScanner { + return &DeleteScanner{Context: ctx, Handler: handler} +} + +/*DeleteScanner swagger:route DELETE /scanners/{registration_id} scanner deleteScanner + +Delete a scanner registration + +Deletes the specified scanner registration. + + +*/ +type DeleteScanner struct { + Context *middleware.Context + Handler DeleteScannerHandler +} + +func (o *DeleteScanner) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewDeleteScannerParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/scanner/delete_scanner_parameters.go b/src/server/v2.0/restapi/operations/scanner/delete_scanner_parameters.go new file mode 100644 index 000000000..1c16e6d31 --- /dev/null +++ b/src/server/v2.0/restapi/operations/scanner/delete_scanner_parameters.go @@ -0,0 +1,114 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scanner + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewDeleteScannerParams creates a new DeleteScannerParams object +// no default values defined in spec. +func NewDeleteScannerParams() DeleteScannerParams { + + return DeleteScannerParams{} +} + +// DeleteScannerParams contains all the bound params for the delete scanner operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteScanner +type DeleteScannerParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The scanner registration identifier. + Required: true + In: path + */ + RegistrationID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteScannerParams() beforehand. +func (o *DeleteScannerParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rRegistrationID, rhkRegistrationID, _ := route.Params.GetOK("registration_id") + if err := o.bindRegistrationID(rRegistrationID, rhkRegistrationID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *DeleteScannerParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *DeleteScannerParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindRegistrationID binds and validates parameter RegistrationID from path. +func (o *DeleteScannerParams) bindRegistrationID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.RegistrationID = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/scanner/delete_scanner_responses.go b/src/server/v2.0/restapi/operations/scanner/delete_scanner_responses.go new file mode 100644 index 000000000..8bccc1f41 --- /dev/null +++ b/src/server/v2.0/restapi/operations/scanner/delete_scanner_responses.go @@ -0,0 +1,322 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scanner + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// DeleteScannerOKCode is the HTTP code returned for type DeleteScannerOK +const DeleteScannerOKCode int = 200 + +/*DeleteScannerOK Deleted successfully and return the deleted registration + +swagger:response deleteScannerOK +*/ +type DeleteScannerOK struct { + + /* + In: Body + */ + Payload *models.ScannerRegistration `json:"body,omitempty"` +} + +// NewDeleteScannerOK creates DeleteScannerOK with default headers values +func NewDeleteScannerOK() *DeleteScannerOK { + + return &DeleteScannerOK{} +} + +// WithPayload adds the payload to the delete scanner o k response +func (o *DeleteScannerOK) WithPayload(payload *models.ScannerRegistration) *DeleteScannerOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete scanner o k response +func (o *DeleteScannerOK) SetPayload(payload *models.ScannerRegistration) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteScannerOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteScannerUnauthorizedCode is the HTTP code returned for type DeleteScannerUnauthorized +const DeleteScannerUnauthorizedCode int = 401 + +/*DeleteScannerUnauthorized Unauthorized + +swagger:response deleteScannerUnauthorized +*/ +type DeleteScannerUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteScannerUnauthorized creates DeleteScannerUnauthorized with default headers values +func NewDeleteScannerUnauthorized() *DeleteScannerUnauthorized { + + return &DeleteScannerUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the delete scanner unauthorized response +func (o *DeleteScannerUnauthorized) WithXRequestID(xRequestID string) *DeleteScannerUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete scanner unauthorized response +func (o *DeleteScannerUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete scanner unauthorized response +func (o *DeleteScannerUnauthorized) WithPayload(payload *models.Errors) *DeleteScannerUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete scanner unauthorized response +func (o *DeleteScannerUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteScannerUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteScannerForbiddenCode is the HTTP code returned for type DeleteScannerForbidden +const DeleteScannerForbiddenCode int = 403 + +/*DeleteScannerForbidden Forbidden + +swagger:response deleteScannerForbidden +*/ +type DeleteScannerForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteScannerForbidden creates DeleteScannerForbidden with default headers values +func NewDeleteScannerForbidden() *DeleteScannerForbidden { + + return &DeleteScannerForbidden{} +} + +// WithXRequestID adds the xRequestId to the delete scanner forbidden response +func (o *DeleteScannerForbidden) WithXRequestID(xRequestID string) *DeleteScannerForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete scanner forbidden response +func (o *DeleteScannerForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete scanner forbidden response +func (o *DeleteScannerForbidden) WithPayload(payload *models.Errors) *DeleteScannerForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete scanner forbidden response +func (o *DeleteScannerForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteScannerForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteScannerNotFoundCode is the HTTP code returned for type DeleteScannerNotFound +const DeleteScannerNotFoundCode int = 404 + +/*DeleteScannerNotFound Not found + +swagger:response deleteScannerNotFound +*/ +type DeleteScannerNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteScannerNotFound creates DeleteScannerNotFound with default headers values +func NewDeleteScannerNotFound() *DeleteScannerNotFound { + + return &DeleteScannerNotFound{} +} + +// WithXRequestID adds the xRequestId to the delete scanner not found response +func (o *DeleteScannerNotFound) WithXRequestID(xRequestID string) *DeleteScannerNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete scanner not found response +func (o *DeleteScannerNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete scanner not found response +func (o *DeleteScannerNotFound) WithPayload(payload *models.Errors) *DeleteScannerNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete scanner not found response +func (o *DeleteScannerNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteScannerNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteScannerInternalServerErrorCode is the HTTP code returned for type DeleteScannerInternalServerError +const DeleteScannerInternalServerErrorCode int = 500 + +/*DeleteScannerInternalServerError Internal server error + +swagger:response deleteScannerInternalServerError +*/ +type DeleteScannerInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteScannerInternalServerError creates DeleteScannerInternalServerError with default headers values +func NewDeleteScannerInternalServerError() *DeleteScannerInternalServerError { + + return &DeleteScannerInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the delete scanner internal server error response +func (o *DeleteScannerInternalServerError) WithXRequestID(xRequestID string) *DeleteScannerInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete scanner internal server error response +func (o *DeleteScannerInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete scanner internal server error response +func (o *DeleteScannerInternalServerError) WithPayload(payload *models.Errors) *DeleteScannerInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete scanner internal server error response +func (o *DeleteScannerInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteScannerInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/scanner/delete_scanner_urlbuilder.go b/src/server/v2.0/restapi/operations/scanner/delete_scanner_urlbuilder.go new file mode 100644 index 000000000..eb075817b --- /dev/null +++ b/src/server/v2.0/restapi/operations/scanner/delete_scanner_urlbuilder.go @@ -0,0 +1,99 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scanner + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// DeleteScannerURL generates an URL for the delete scanner operation +type DeleteScannerURL struct { + RegistrationID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteScannerURL) WithBasePath(bp string) *DeleteScannerURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteScannerURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteScannerURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/scanners/{registration_id}" + + registrationID := o.RegistrationID + if registrationID != "" { + _path = strings.Replace(_path, "{registration_id}", registrationID, -1) + } else { + return nil, errors.New("registrationId is required on DeleteScannerURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteScannerURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteScannerURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteScannerURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteScannerURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteScannerURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteScannerURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/scanner/get_scanner.go b/src/server/v2.0/restapi/operations/scanner/get_scanner.go new file mode 100644 index 000000000..f562983e2 --- /dev/null +++ b/src/server/v2.0/restapi/operations/scanner/get_scanner.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scanner + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetScannerHandlerFunc turns a function with the right signature into a get scanner handler +type GetScannerHandlerFunc func(GetScannerParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetScannerHandlerFunc) Handle(params GetScannerParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetScannerHandler interface for that can handle valid get scanner params +type GetScannerHandler interface { + Handle(GetScannerParams, interface{}) middleware.Responder +} + +// NewGetScanner creates a new http.Handler for the get scanner operation +func NewGetScanner(ctx *middleware.Context, handler GetScannerHandler) *GetScanner { + return &GetScanner{Context: ctx, Handler: handler} +} + +/*GetScanner swagger:route GET /scanners/{registration_id} scanner getScanner + +Get a scanner registration details + +Retruns the details of the specified scanner registration. + + +*/ +type GetScanner struct { + Context *middleware.Context + Handler GetScannerHandler +} + +func (o *GetScanner) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetScannerParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/scanner/get_scanner_metadata.go b/src/server/v2.0/restapi/operations/scanner/get_scanner_metadata.go new file mode 100644 index 000000000..36c3d576e --- /dev/null +++ b/src/server/v2.0/restapi/operations/scanner/get_scanner_metadata.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scanner + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetScannerMetadataHandlerFunc turns a function with the right signature into a get scanner metadata handler +type GetScannerMetadataHandlerFunc func(GetScannerMetadataParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetScannerMetadataHandlerFunc) Handle(params GetScannerMetadataParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetScannerMetadataHandler interface for that can handle valid get scanner metadata params +type GetScannerMetadataHandler interface { + Handle(GetScannerMetadataParams, interface{}) middleware.Responder +} + +// NewGetScannerMetadata creates a new http.Handler for the get scanner metadata operation +func NewGetScannerMetadata(ctx *middleware.Context, handler GetScannerMetadataHandler) *GetScannerMetadata { + return &GetScannerMetadata{Context: ctx, Handler: handler} +} + +/*GetScannerMetadata swagger:route GET /scanners/{registration_id}/metadata scanner getScannerMetadata + +Get the metadata of the specified scanner registration + +Get the metadata of the specified scanner registration, including the capabilities and customized properties. + + +*/ +type GetScannerMetadata struct { + Context *middleware.Context + Handler GetScannerMetadataHandler +} + +func (o *GetScannerMetadata) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetScannerMetadataParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/scanner/get_scanner_metadata_parameters.go b/src/server/v2.0/restapi/operations/scanner/get_scanner_metadata_parameters.go new file mode 100644 index 000000000..7bfcb480d --- /dev/null +++ b/src/server/v2.0/restapi/operations/scanner/get_scanner_metadata_parameters.go @@ -0,0 +1,114 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scanner + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewGetScannerMetadataParams creates a new GetScannerMetadataParams object +// no default values defined in spec. +func NewGetScannerMetadataParams() GetScannerMetadataParams { + + return GetScannerMetadataParams{} +} + +// GetScannerMetadataParams contains all the bound params for the get scanner metadata operation +// typically these are obtained from a http.Request +// +// swagger:parameters getScannerMetadata +type GetScannerMetadataParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The scanner registration identifier. + Required: true + In: path + */ + RegistrationID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetScannerMetadataParams() beforehand. +func (o *GetScannerMetadataParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rRegistrationID, rhkRegistrationID, _ := route.Params.GetOK("registration_id") + if err := o.bindRegistrationID(rRegistrationID, rhkRegistrationID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetScannerMetadataParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetScannerMetadataParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindRegistrationID binds and validates parameter RegistrationID from path. +func (o *GetScannerMetadataParams) bindRegistrationID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.RegistrationID = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/scanner/get_scanner_metadata_responses.go b/src/server/v2.0/restapi/operations/scanner/get_scanner_metadata_responses.go new file mode 100644 index 000000000..843b0f91c --- /dev/null +++ b/src/server/v2.0/restapi/operations/scanner/get_scanner_metadata_responses.go @@ -0,0 +1,256 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scanner + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetScannerMetadataOKCode is the HTTP code returned for type GetScannerMetadataOK +const GetScannerMetadataOKCode int = 200 + +/*GetScannerMetadataOK The metadata of the specified scanner adapter + +swagger:response getScannerMetadataOK +*/ +type GetScannerMetadataOK struct { + + /* + In: Body + */ + Payload *models.ScannerAdapterMetadata `json:"body,omitempty"` +} + +// NewGetScannerMetadataOK creates GetScannerMetadataOK with default headers values +func NewGetScannerMetadataOK() *GetScannerMetadataOK { + + return &GetScannerMetadataOK{} +} + +// WithPayload adds the payload to the get scanner metadata o k response +func (o *GetScannerMetadataOK) WithPayload(payload *models.ScannerAdapterMetadata) *GetScannerMetadataOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get scanner metadata o k response +func (o *GetScannerMetadataOK) SetPayload(payload *models.ScannerAdapterMetadata) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetScannerMetadataOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetScannerMetadataUnauthorizedCode is the HTTP code returned for type GetScannerMetadataUnauthorized +const GetScannerMetadataUnauthorizedCode int = 401 + +/*GetScannerMetadataUnauthorized Unauthorized + +swagger:response getScannerMetadataUnauthorized +*/ +type GetScannerMetadataUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetScannerMetadataUnauthorized creates GetScannerMetadataUnauthorized with default headers values +func NewGetScannerMetadataUnauthorized() *GetScannerMetadataUnauthorized { + + return &GetScannerMetadataUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the get scanner metadata unauthorized response +func (o *GetScannerMetadataUnauthorized) WithXRequestID(xRequestID string) *GetScannerMetadataUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get scanner metadata unauthorized response +func (o *GetScannerMetadataUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get scanner metadata unauthorized response +func (o *GetScannerMetadataUnauthorized) WithPayload(payload *models.Errors) *GetScannerMetadataUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get scanner metadata unauthorized response +func (o *GetScannerMetadataUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetScannerMetadataUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetScannerMetadataForbiddenCode is the HTTP code returned for type GetScannerMetadataForbidden +const GetScannerMetadataForbiddenCode int = 403 + +/*GetScannerMetadataForbidden Forbidden + +swagger:response getScannerMetadataForbidden +*/ +type GetScannerMetadataForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetScannerMetadataForbidden creates GetScannerMetadataForbidden with default headers values +func NewGetScannerMetadataForbidden() *GetScannerMetadataForbidden { + + return &GetScannerMetadataForbidden{} +} + +// WithXRequestID adds the xRequestId to the get scanner metadata forbidden response +func (o *GetScannerMetadataForbidden) WithXRequestID(xRequestID string) *GetScannerMetadataForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get scanner metadata forbidden response +func (o *GetScannerMetadataForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get scanner metadata forbidden response +func (o *GetScannerMetadataForbidden) WithPayload(payload *models.Errors) *GetScannerMetadataForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get scanner metadata forbidden response +func (o *GetScannerMetadataForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetScannerMetadataForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetScannerMetadataInternalServerErrorCode is the HTTP code returned for type GetScannerMetadataInternalServerError +const GetScannerMetadataInternalServerErrorCode int = 500 + +/*GetScannerMetadataInternalServerError Internal server error + +swagger:response getScannerMetadataInternalServerError +*/ +type GetScannerMetadataInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetScannerMetadataInternalServerError creates GetScannerMetadataInternalServerError with default headers values +func NewGetScannerMetadataInternalServerError() *GetScannerMetadataInternalServerError { + + return &GetScannerMetadataInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get scanner metadata internal server error response +func (o *GetScannerMetadataInternalServerError) WithXRequestID(xRequestID string) *GetScannerMetadataInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get scanner metadata internal server error response +func (o *GetScannerMetadataInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get scanner metadata internal server error response +func (o *GetScannerMetadataInternalServerError) WithPayload(payload *models.Errors) *GetScannerMetadataInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get scanner metadata internal server error response +func (o *GetScannerMetadataInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetScannerMetadataInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/scanner/get_scanner_metadata_urlbuilder.go b/src/server/v2.0/restapi/operations/scanner/get_scanner_metadata_urlbuilder.go new file mode 100644 index 000000000..be6b14e6b --- /dev/null +++ b/src/server/v2.0/restapi/operations/scanner/get_scanner_metadata_urlbuilder.go @@ -0,0 +1,99 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scanner + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetScannerMetadataURL generates an URL for the get scanner metadata operation +type GetScannerMetadataURL struct { + RegistrationID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetScannerMetadataURL) WithBasePath(bp string) *GetScannerMetadataURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetScannerMetadataURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetScannerMetadataURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/scanners/{registration_id}/metadata" + + registrationID := o.RegistrationID + if registrationID != "" { + _path = strings.Replace(_path, "{registration_id}", registrationID, -1) + } else { + return nil, errors.New("registrationId is required on GetScannerMetadataURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetScannerMetadataURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetScannerMetadataURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetScannerMetadataURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetScannerMetadataURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetScannerMetadataURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetScannerMetadataURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/scanner/get_scanner_parameters.go b/src/server/v2.0/restapi/operations/scanner/get_scanner_parameters.go new file mode 100644 index 000000000..d33641eef --- /dev/null +++ b/src/server/v2.0/restapi/operations/scanner/get_scanner_parameters.go @@ -0,0 +1,114 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scanner + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewGetScannerParams creates a new GetScannerParams object +// no default values defined in spec. +func NewGetScannerParams() GetScannerParams { + + return GetScannerParams{} +} + +// GetScannerParams contains all the bound params for the get scanner operation +// typically these are obtained from a http.Request +// +// swagger:parameters getScanner +type GetScannerParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The scanner registration identifer. + Required: true + In: path + */ + RegistrationID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetScannerParams() beforehand. +func (o *GetScannerParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rRegistrationID, rhkRegistrationID, _ := route.Params.GetOK("registration_id") + if err := o.bindRegistrationID(rRegistrationID, rhkRegistrationID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetScannerParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetScannerParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindRegistrationID binds and validates parameter RegistrationID from path. +func (o *GetScannerParams) bindRegistrationID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.RegistrationID = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/scanner/get_scanner_responses.go b/src/server/v2.0/restapi/operations/scanner/get_scanner_responses.go new file mode 100644 index 000000000..c2b2c288a --- /dev/null +++ b/src/server/v2.0/restapi/operations/scanner/get_scanner_responses.go @@ -0,0 +1,322 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scanner + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetScannerOKCode is the HTTP code returned for type GetScannerOK +const GetScannerOKCode int = 200 + +/*GetScannerOK The details of the scanner registration. + +swagger:response getScannerOK +*/ +type GetScannerOK struct { + + /* + In: Body + */ + Payload *models.ScannerRegistration `json:"body,omitempty"` +} + +// NewGetScannerOK creates GetScannerOK with default headers values +func NewGetScannerOK() *GetScannerOK { + + return &GetScannerOK{} +} + +// WithPayload adds the payload to the get scanner o k response +func (o *GetScannerOK) WithPayload(payload *models.ScannerRegistration) *GetScannerOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get scanner o k response +func (o *GetScannerOK) SetPayload(payload *models.ScannerRegistration) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetScannerOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetScannerUnauthorizedCode is the HTTP code returned for type GetScannerUnauthorized +const GetScannerUnauthorizedCode int = 401 + +/*GetScannerUnauthorized Unauthorized + +swagger:response getScannerUnauthorized +*/ +type GetScannerUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetScannerUnauthorized creates GetScannerUnauthorized with default headers values +func NewGetScannerUnauthorized() *GetScannerUnauthorized { + + return &GetScannerUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the get scanner unauthorized response +func (o *GetScannerUnauthorized) WithXRequestID(xRequestID string) *GetScannerUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get scanner unauthorized response +func (o *GetScannerUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get scanner unauthorized response +func (o *GetScannerUnauthorized) WithPayload(payload *models.Errors) *GetScannerUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get scanner unauthorized response +func (o *GetScannerUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetScannerUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetScannerForbiddenCode is the HTTP code returned for type GetScannerForbidden +const GetScannerForbiddenCode int = 403 + +/*GetScannerForbidden Forbidden + +swagger:response getScannerForbidden +*/ +type GetScannerForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetScannerForbidden creates GetScannerForbidden with default headers values +func NewGetScannerForbidden() *GetScannerForbidden { + + return &GetScannerForbidden{} +} + +// WithXRequestID adds the xRequestId to the get scanner forbidden response +func (o *GetScannerForbidden) WithXRequestID(xRequestID string) *GetScannerForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get scanner forbidden response +func (o *GetScannerForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get scanner forbidden response +func (o *GetScannerForbidden) WithPayload(payload *models.Errors) *GetScannerForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get scanner forbidden response +func (o *GetScannerForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetScannerForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetScannerNotFoundCode is the HTTP code returned for type GetScannerNotFound +const GetScannerNotFoundCode int = 404 + +/*GetScannerNotFound Not found + +swagger:response getScannerNotFound +*/ +type GetScannerNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetScannerNotFound creates GetScannerNotFound with default headers values +func NewGetScannerNotFound() *GetScannerNotFound { + + return &GetScannerNotFound{} +} + +// WithXRequestID adds the xRequestId to the get scanner not found response +func (o *GetScannerNotFound) WithXRequestID(xRequestID string) *GetScannerNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get scanner not found response +func (o *GetScannerNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get scanner not found response +func (o *GetScannerNotFound) WithPayload(payload *models.Errors) *GetScannerNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get scanner not found response +func (o *GetScannerNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetScannerNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetScannerInternalServerErrorCode is the HTTP code returned for type GetScannerInternalServerError +const GetScannerInternalServerErrorCode int = 500 + +/*GetScannerInternalServerError Internal server error + +swagger:response getScannerInternalServerError +*/ +type GetScannerInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetScannerInternalServerError creates GetScannerInternalServerError with default headers values +func NewGetScannerInternalServerError() *GetScannerInternalServerError { + + return &GetScannerInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get scanner internal server error response +func (o *GetScannerInternalServerError) WithXRequestID(xRequestID string) *GetScannerInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get scanner internal server error response +func (o *GetScannerInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get scanner internal server error response +func (o *GetScannerInternalServerError) WithPayload(payload *models.Errors) *GetScannerInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get scanner internal server error response +func (o *GetScannerInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetScannerInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/scanner/get_scanner_urlbuilder.go b/src/server/v2.0/restapi/operations/scanner/get_scanner_urlbuilder.go new file mode 100644 index 000000000..4afc11efa --- /dev/null +++ b/src/server/v2.0/restapi/operations/scanner/get_scanner_urlbuilder.go @@ -0,0 +1,99 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scanner + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetScannerURL generates an URL for the get scanner operation +type GetScannerURL struct { + RegistrationID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetScannerURL) WithBasePath(bp string) *GetScannerURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetScannerURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetScannerURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/scanners/{registration_id}" + + registrationID := o.RegistrationID + if registrationID != "" { + _path = strings.Replace(_path, "{registration_id}", registrationID, -1) + } else { + return nil, errors.New("registrationId is required on GetScannerURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetScannerURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetScannerURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetScannerURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetScannerURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetScannerURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetScannerURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/scanner/list_scanners.go b/src/server/v2.0/restapi/operations/scanner/list_scanners.go new file mode 100644 index 000000000..54b9fddda --- /dev/null +++ b/src/server/v2.0/restapi/operations/scanner/list_scanners.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scanner + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ListScannersHandlerFunc turns a function with the right signature into a list scanners handler +type ListScannersHandlerFunc func(ListScannersParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ListScannersHandlerFunc) Handle(params ListScannersParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ListScannersHandler interface for that can handle valid list scanners params +type ListScannersHandler interface { + Handle(ListScannersParams, interface{}) middleware.Responder +} + +// NewListScanners creates a new http.Handler for the list scanners operation +func NewListScanners(ctx *middleware.Context, handler ListScannersHandler) *ListScanners { + return &ListScanners{Context: ctx, Handler: handler} +} + +/*ListScanners swagger:route GET /scanners scanner listScanners + +List scanner registrations + +Returns a list of currently configured scanner registrations. + + +*/ +type ListScanners struct { + Context *middleware.Context + Handler ListScannersHandler +} + +func (o *ListScanners) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewListScannersParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/scanner/list_scanners_parameters.go b/src/server/v2.0/restapi/operations/scanner/list_scanners_parameters.go new file mode 100644 index 000000000..82f9d7b3b --- /dev/null +++ b/src/server/v2.0/restapi/operations/scanner/list_scanners_parameters.go @@ -0,0 +1,239 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scanner + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewListScannersParams creates a new ListScannersParams object +// with the default values initialized. +func NewListScannersParams() ListScannersParams { + + var ( + // initialize parameters with default values + + pageDefault = int64(1) + pageSizeDefault = int64(10) + ) + + return ListScannersParams{ + Page: &pageDefault, + + PageSize: &pageSizeDefault, + } +} + +// ListScannersParams contains all the bound params for the list scanners operation +// typically these are obtained from a http.Request +// +// swagger:parameters listScanners +type ListScannersParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The page number + In: query + Default: 1 + */ + Page *int64 + /*The size of per page + Maximum: 100 + In: query + Default: 10 + */ + PageSize *int64 + /*Query string to query resources. Supported query patterns are "exact match(k=v)", "fuzzy match(k=~v)", "range(k=[min~max])", "list with union releationship(k={v1 v2 v3})" and "list with intersetion relationship(k=(v1 v2 v3))". The value of range and list can be string(enclosed by " or '), integer or time(in format "2020-04-09 02:36:00"). All of these query patterns should be put in the query string "q=xxx" and splitted by ",". e.g. q=k1=v1,k2=~v2,k3=[min~max] + In: query + */ + Q *string + /*Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + In: query + */ + Sort *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewListScannersParams() beforehand. +func (o *ListScannersParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + qPage, qhkPage, _ := qs.GetOK("page") + if err := o.bindPage(qPage, qhkPage, route.Formats); err != nil { + res = append(res, err) + } + + qPageSize, qhkPageSize, _ := qs.GetOK("page_size") + if err := o.bindPageSize(qPageSize, qhkPageSize, route.Formats); err != nil { + res = append(res, err) + } + + qQ, qhkQ, _ := qs.GetOK("q") + if err := o.bindQ(qQ, qhkQ, route.Formats); err != nil { + res = append(res, err) + } + + qSort, qhkSort, _ := qs.GetOK("sort") + if err := o.bindSort(qSort, qhkSort, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *ListScannersParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *ListScannersParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindPage binds and validates parameter Page from query. +func (o *ListScannersParams) bindPage(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListScannersParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page", "query", "int64", raw) + } + o.Page = &value + + return nil +} + +// bindPageSize binds and validates parameter PageSize from query. +func (o *ListScannersParams) bindPageSize(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListScannersParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page_size", "query", "int64", raw) + } + o.PageSize = &value + + if err := o.validatePageSize(formats); err != nil { + return err + } + + return nil +} + +// validatePageSize carries on validations for parameter PageSize +func (o *ListScannersParams) validatePageSize(formats strfmt.Registry) error { + + if err := validate.MaximumInt("page_size", "query", int64(*o.PageSize), 100, false); err != nil { + return err + } + + return nil +} + +// bindQ binds and validates parameter Q from query. +func (o *ListScannersParams) bindQ(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Q = &raw + + return nil +} + +// bindSort binds and validates parameter Sort from query. +func (o *ListScannersParams) bindSort(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Sort = &raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/scanner/list_scanners_responses.go b/src/server/v2.0/restapi/operations/scanner/list_scanners_responses.go new file mode 100644 index 000000000..4406cdc0b --- /dev/null +++ b/src/server/v2.0/restapi/operations/scanner/list_scanners_responses.go @@ -0,0 +1,370 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scanner + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/swag" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// ListScannersOKCode is the HTTP code returned for type ListScannersOK +const ListScannersOKCode int = 200 + +/*ListScannersOK A list of scanner registrations. + +swagger:response listScannersOK +*/ +type ListScannersOK struct { + /*Link to previous page and next page + + */ + Link string `json:"Link"` + /*The total count of available items + + */ + XTotalCount int64 `json:"X-Total-Count"` + + /* + In: Body + */ + Payload []*models.ScannerRegistration `json:"body,omitempty"` +} + +// NewListScannersOK creates ListScannersOK with default headers values +func NewListScannersOK() *ListScannersOK { + + return &ListScannersOK{} +} + +// WithLink adds the link to the list scanners o k response +func (o *ListScannersOK) WithLink(link string) *ListScannersOK { + o.Link = link + return o +} + +// SetLink sets the link to the list scanners o k response +func (o *ListScannersOK) SetLink(link string) { + o.Link = link +} + +// WithXTotalCount adds the xTotalCount to the list scanners o k response +func (o *ListScannersOK) WithXTotalCount(xTotalCount int64) *ListScannersOK { + o.XTotalCount = xTotalCount + return o +} + +// SetXTotalCount sets the xTotalCount to the list scanners o k response +func (o *ListScannersOK) SetXTotalCount(xTotalCount int64) { + o.XTotalCount = xTotalCount +} + +// WithPayload adds the payload to the list scanners o k response +func (o *ListScannersOK) WithPayload(payload []*models.ScannerRegistration) *ListScannersOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list scanners o k response +func (o *ListScannersOK) SetPayload(payload []*models.ScannerRegistration) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListScannersOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Link + + link := o.Link + if link != "" { + rw.Header().Set("Link", link) + } + + // response header X-Total-Count + + xTotalCount := swag.FormatInt64(o.XTotalCount) + if xTotalCount != "" { + rw.Header().Set("X-Total-Count", xTotalCount) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = make([]*models.ScannerRegistration, 0, 50) + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ListScannersBadRequestCode is the HTTP code returned for type ListScannersBadRequest +const ListScannersBadRequestCode int = 400 + +/*ListScannersBadRequest Bad request + +swagger:response listScannersBadRequest +*/ +type ListScannersBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListScannersBadRequest creates ListScannersBadRequest with default headers values +func NewListScannersBadRequest() *ListScannersBadRequest { + + return &ListScannersBadRequest{} +} + +// WithXRequestID adds the xRequestId to the list scanners bad request response +func (o *ListScannersBadRequest) WithXRequestID(xRequestID string) *ListScannersBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list scanners bad request response +func (o *ListScannersBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list scanners bad request response +func (o *ListScannersBadRequest) WithPayload(payload *models.Errors) *ListScannersBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list scanners bad request response +func (o *ListScannersBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListScannersBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListScannersUnauthorizedCode is the HTTP code returned for type ListScannersUnauthorized +const ListScannersUnauthorizedCode int = 401 + +/*ListScannersUnauthorized Unauthorized + +swagger:response listScannersUnauthorized +*/ +type ListScannersUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListScannersUnauthorized creates ListScannersUnauthorized with default headers values +func NewListScannersUnauthorized() *ListScannersUnauthorized { + + return &ListScannersUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the list scanners unauthorized response +func (o *ListScannersUnauthorized) WithXRequestID(xRequestID string) *ListScannersUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list scanners unauthorized response +func (o *ListScannersUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list scanners unauthorized response +func (o *ListScannersUnauthorized) WithPayload(payload *models.Errors) *ListScannersUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list scanners unauthorized response +func (o *ListScannersUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListScannersUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListScannersForbiddenCode is the HTTP code returned for type ListScannersForbidden +const ListScannersForbiddenCode int = 403 + +/*ListScannersForbidden Forbidden + +swagger:response listScannersForbidden +*/ +type ListScannersForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListScannersForbidden creates ListScannersForbidden with default headers values +func NewListScannersForbidden() *ListScannersForbidden { + + return &ListScannersForbidden{} +} + +// WithXRequestID adds the xRequestId to the list scanners forbidden response +func (o *ListScannersForbidden) WithXRequestID(xRequestID string) *ListScannersForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list scanners forbidden response +func (o *ListScannersForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list scanners forbidden response +func (o *ListScannersForbidden) WithPayload(payload *models.Errors) *ListScannersForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list scanners forbidden response +func (o *ListScannersForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListScannersForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListScannersInternalServerErrorCode is the HTTP code returned for type ListScannersInternalServerError +const ListScannersInternalServerErrorCode int = 500 + +/*ListScannersInternalServerError Internal server error + +swagger:response listScannersInternalServerError +*/ +type ListScannersInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListScannersInternalServerError creates ListScannersInternalServerError with default headers values +func NewListScannersInternalServerError() *ListScannersInternalServerError { + + return &ListScannersInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the list scanners internal server error response +func (o *ListScannersInternalServerError) WithXRequestID(xRequestID string) *ListScannersInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list scanners internal server error response +func (o *ListScannersInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list scanners internal server error response +func (o *ListScannersInternalServerError) WithPayload(payload *models.Errors) *ListScannersInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list scanners internal server error response +func (o *ListScannersInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListScannersInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/scanner/list_scanners_urlbuilder.go b/src/server/v2.0/restapi/operations/scanner/list_scanners_urlbuilder.go new file mode 100644 index 000000000..95615b87c --- /dev/null +++ b/src/server/v2.0/restapi/operations/scanner/list_scanners_urlbuilder.go @@ -0,0 +1,132 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scanner + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// ListScannersURL generates an URL for the list scanners operation +type ListScannersURL struct { + Page *int64 + PageSize *int64 + Q *string + Sort *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListScannersURL) WithBasePath(bp string) *ListScannersURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListScannersURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ListScannersURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/scanners" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var pageQ string + if o.Page != nil { + pageQ = swag.FormatInt64(*o.Page) + } + if pageQ != "" { + qs.Set("page", pageQ) + } + + var pageSizeQ string + if o.PageSize != nil { + pageSizeQ = swag.FormatInt64(*o.PageSize) + } + if pageSizeQ != "" { + qs.Set("page_size", pageSizeQ) + } + + var qQ string + if o.Q != nil { + qQ = *o.Q + } + if qQ != "" { + qs.Set("q", qQ) + } + + var sortQ string + if o.Sort != nil { + sortQ = *o.Sort + } + if sortQ != "" { + qs.Set("sort", sortQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ListScannersURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ListScannersURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ListScannersURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ListScannersURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ListScannersURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ListScannersURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/scanner/ping_scanner.go b/src/server/v2.0/restapi/operations/scanner/ping_scanner.go new file mode 100644 index 000000000..833316338 --- /dev/null +++ b/src/server/v2.0/restapi/operations/scanner/ping_scanner.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scanner + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// PingScannerHandlerFunc turns a function with the right signature into a ping scanner handler +type PingScannerHandlerFunc func(PingScannerParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn PingScannerHandlerFunc) Handle(params PingScannerParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// PingScannerHandler interface for that can handle valid ping scanner params +type PingScannerHandler interface { + Handle(PingScannerParams, interface{}) middleware.Responder +} + +// NewPingScanner creates a new http.Handler for the ping scanner operation +func NewPingScanner(ctx *middleware.Context, handler PingScannerHandler) *PingScanner { + return &PingScanner{Context: ctx, Handler: handler} +} + +/*PingScanner swagger:route POST /scanners/ping scanner pingScanner + +Tests scanner registration settings + +Pings scanner adapter to test endpoint URL and authorization settings. + + +*/ +type PingScanner struct { + Context *middleware.Context + Handler PingScannerHandler +} + +func (o *PingScanner) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewPingScannerParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/scanner/ping_scanner_parameters.go b/src/server/v2.0/restapi/operations/scanner/ping_scanner_parameters.go new file mode 100644 index 000000000..f4fd5617c --- /dev/null +++ b/src/server/v2.0/restapi/operations/scanner/ping_scanner_parameters.go @@ -0,0 +1,120 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scanner + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewPingScannerParams creates a new PingScannerParams object +// no default values defined in spec. +func NewPingScannerParams() PingScannerParams { + + return PingScannerParams{} +} + +// PingScannerParams contains all the bound params for the ping scanner operation +// typically these are obtained from a http.Request +// +// swagger:parameters pingScanner +type PingScannerParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*A scanner registration settings to be tested. + Required: true + In: body + */ + Settings *models.ScannerRegistrationSettings +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewPingScannerParams() beforehand. +func (o *PingScannerParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.ScannerRegistrationSettings + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("settings", "body", "")) + } else { + res = append(res, errors.NewParseError("settings", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Settings = &body + } + } + } else { + res = append(res, errors.Required("settings", "body", "")) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *PingScannerParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *PingScannerParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} diff --git a/src/server/v2.0/restapi/operations/scanner/ping_scanner_responses.go b/src/server/v2.0/restapi/operations/scanner/ping_scanner_responses.go new file mode 100644 index 000000000..caaa4c3ee --- /dev/null +++ b/src/server/v2.0/restapi/operations/scanner/ping_scanner_responses.go @@ -0,0 +1,324 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scanner + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// PingScannerOKCode is the HTTP code returned for type PingScannerOK +const PingScannerOKCode int = 200 + +/*PingScannerOK Success + +swagger:response pingScannerOK +*/ +type PingScannerOK struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewPingScannerOK creates PingScannerOK with default headers values +func NewPingScannerOK() *PingScannerOK { + + return &PingScannerOK{} +} + +// WithXRequestID adds the xRequestId to the ping scanner o k response +func (o *PingScannerOK) WithXRequestID(xRequestID string) *PingScannerOK { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the ping scanner o k response +func (o *PingScannerOK) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *PingScannerOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// PingScannerBadRequestCode is the HTTP code returned for type PingScannerBadRequest +const PingScannerBadRequestCode int = 400 + +/*PingScannerBadRequest Bad request + +swagger:response pingScannerBadRequest +*/ +type PingScannerBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewPingScannerBadRequest creates PingScannerBadRequest with default headers values +func NewPingScannerBadRequest() *PingScannerBadRequest { + + return &PingScannerBadRequest{} +} + +// WithXRequestID adds the xRequestId to the ping scanner bad request response +func (o *PingScannerBadRequest) WithXRequestID(xRequestID string) *PingScannerBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the ping scanner bad request response +func (o *PingScannerBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the ping scanner bad request response +func (o *PingScannerBadRequest) WithPayload(payload *models.Errors) *PingScannerBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the ping scanner bad request response +func (o *PingScannerBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PingScannerBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PingScannerUnauthorizedCode is the HTTP code returned for type PingScannerUnauthorized +const PingScannerUnauthorizedCode int = 401 + +/*PingScannerUnauthorized Unauthorized + +swagger:response pingScannerUnauthorized +*/ +type PingScannerUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewPingScannerUnauthorized creates PingScannerUnauthorized with default headers values +func NewPingScannerUnauthorized() *PingScannerUnauthorized { + + return &PingScannerUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the ping scanner unauthorized response +func (o *PingScannerUnauthorized) WithXRequestID(xRequestID string) *PingScannerUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the ping scanner unauthorized response +func (o *PingScannerUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the ping scanner unauthorized response +func (o *PingScannerUnauthorized) WithPayload(payload *models.Errors) *PingScannerUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the ping scanner unauthorized response +func (o *PingScannerUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PingScannerUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PingScannerForbiddenCode is the HTTP code returned for type PingScannerForbidden +const PingScannerForbiddenCode int = 403 + +/*PingScannerForbidden Forbidden + +swagger:response pingScannerForbidden +*/ +type PingScannerForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewPingScannerForbidden creates PingScannerForbidden with default headers values +func NewPingScannerForbidden() *PingScannerForbidden { + + return &PingScannerForbidden{} +} + +// WithXRequestID adds the xRequestId to the ping scanner forbidden response +func (o *PingScannerForbidden) WithXRequestID(xRequestID string) *PingScannerForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the ping scanner forbidden response +func (o *PingScannerForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the ping scanner forbidden response +func (o *PingScannerForbidden) WithPayload(payload *models.Errors) *PingScannerForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the ping scanner forbidden response +func (o *PingScannerForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PingScannerForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PingScannerInternalServerErrorCode is the HTTP code returned for type PingScannerInternalServerError +const PingScannerInternalServerErrorCode int = 500 + +/*PingScannerInternalServerError Internal server error + +swagger:response pingScannerInternalServerError +*/ +type PingScannerInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewPingScannerInternalServerError creates PingScannerInternalServerError with default headers values +func NewPingScannerInternalServerError() *PingScannerInternalServerError { + + return &PingScannerInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the ping scanner internal server error response +func (o *PingScannerInternalServerError) WithXRequestID(xRequestID string) *PingScannerInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the ping scanner internal server error response +func (o *PingScannerInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the ping scanner internal server error response +func (o *PingScannerInternalServerError) WithPayload(payload *models.Errors) *PingScannerInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the ping scanner internal server error response +func (o *PingScannerInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PingScannerInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/scanner/ping_scanner_urlbuilder.go b/src/server/v2.0/restapi/operations/scanner/ping_scanner_urlbuilder.go new file mode 100644 index 000000000..e4b4b9779 --- /dev/null +++ b/src/server/v2.0/restapi/operations/scanner/ping_scanner_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scanner + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// PingScannerURL generates an URL for the ping scanner operation +type PingScannerURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *PingScannerURL) WithBasePath(bp string) *PingScannerURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *PingScannerURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *PingScannerURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/scanners/ping" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *PingScannerURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *PingScannerURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *PingScannerURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on PingScannerURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on PingScannerURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *PingScannerURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/scanner/set_scanner_as_default.go b/src/server/v2.0/restapi/operations/scanner/set_scanner_as_default.go new file mode 100644 index 000000000..2269c274b --- /dev/null +++ b/src/server/v2.0/restapi/operations/scanner/set_scanner_as_default.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scanner + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// SetScannerAsDefaultHandlerFunc turns a function with the right signature into a set scanner as default handler +type SetScannerAsDefaultHandlerFunc func(SetScannerAsDefaultParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn SetScannerAsDefaultHandlerFunc) Handle(params SetScannerAsDefaultParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// SetScannerAsDefaultHandler interface for that can handle valid set scanner as default params +type SetScannerAsDefaultHandler interface { + Handle(SetScannerAsDefaultParams, interface{}) middleware.Responder +} + +// NewSetScannerAsDefault creates a new http.Handler for the set scanner as default operation +func NewSetScannerAsDefault(ctx *middleware.Context, handler SetScannerAsDefaultHandler) *SetScannerAsDefault { + return &SetScannerAsDefault{Context: ctx, Handler: handler} +} + +/*SetScannerAsDefault swagger:route PATCH /scanners/{registration_id} scanner setScannerAsDefault + +Set system default scanner registration + +Set the specified scanner registration as the system default one. + + +*/ +type SetScannerAsDefault struct { + Context *middleware.Context + Handler SetScannerAsDefaultHandler +} + +func (o *SetScannerAsDefault) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewSetScannerAsDefaultParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/scanner/set_scanner_as_default_parameters.go b/src/server/v2.0/restapi/operations/scanner/set_scanner_as_default_parameters.go new file mode 100644 index 000000000..fe90fd65f --- /dev/null +++ b/src/server/v2.0/restapi/operations/scanner/set_scanner_as_default_parameters.go @@ -0,0 +1,145 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scanner + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewSetScannerAsDefaultParams creates a new SetScannerAsDefaultParams object +// no default values defined in spec. +func NewSetScannerAsDefaultParams() SetScannerAsDefaultParams { + + return SetScannerAsDefaultParams{} +} + +// SetScannerAsDefaultParams contains all the bound params for the set scanner as default operation +// typically these are obtained from a http.Request +// +// swagger:parameters setScannerAsDefault +type SetScannerAsDefaultParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /* + Required: true + In: body + */ + Payload *models.IsDefault + /*The scanner registration identifier. + Required: true + In: path + */ + RegistrationID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewSetScannerAsDefaultParams() beforehand. +func (o *SetScannerAsDefaultParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.IsDefault + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("payload", "body", "")) + } else { + res = append(res, errors.NewParseError("payload", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Payload = &body + } + } + } else { + res = append(res, errors.Required("payload", "body", "")) + } + rRegistrationID, rhkRegistrationID, _ := route.Params.GetOK("registration_id") + if err := o.bindRegistrationID(rRegistrationID, rhkRegistrationID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *SetScannerAsDefaultParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *SetScannerAsDefaultParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindRegistrationID binds and validates parameter RegistrationID from path. +func (o *SetScannerAsDefaultParams) bindRegistrationID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.RegistrationID = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/scanner/set_scanner_as_default_responses.go b/src/server/v2.0/restapi/operations/scanner/set_scanner_as_default_responses.go new file mode 100644 index 000000000..5155e5446 --- /dev/null +++ b/src/server/v2.0/restapi/operations/scanner/set_scanner_as_default_responses.go @@ -0,0 +1,236 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scanner + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// SetScannerAsDefaultOKCode is the HTTP code returned for type SetScannerAsDefaultOK +const SetScannerAsDefaultOKCode int = 200 + +/*SetScannerAsDefaultOK Successfully set the specified scanner registration as system default + +swagger:response setScannerAsDefaultOK +*/ +type SetScannerAsDefaultOK struct { +} + +// NewSetScannerAsDefaultOK creates SetScannerAsDefaultOK with default headers values +func NewSetScannerAsDefaultOK() *SetScannerAsDefaultOK { + + return &SetScannerAsDefaultOK{} +} + +// WriteResponse to the client +func (o *SetScannerAsDefaultOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// SetScannerAsDefaultUnauthorizedCode is the HTTP code returned for type SetScannerAsDefaultUnauthorized +const SetScannerAsDefaultUnauthorizedCode int = 401 + +/*SetScannerAsDefaultUnauthorized Unauthorized + +swagger:response setScannerAsDefaultUnauthorized +*/ +type SetScannerAsDefaultUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewSetScannerAsDefaultUnauthorized creates SetScannerAsDefaultUnauthorized with default headers values +func NewSetScannerAsDefaultUnauthorized() *SetScannerAsDefaultUnauthorized { + + return &SetScannerAsDefaultUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the set scanner as default unauthorized response +func (o *SetScannerAsDefaultUnauthorized) WithXRequestID(xRequestID string) *SetScannerAsDefaultUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the set scanner as default unauthorized response +func (o *SetScannerAsDefaultUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the set scanner as default unauthorized response +func (o *SetScannerAsDefaultUnauthorized) WithPayload(payload *models.Errors) *SetScannerAsDefaultUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the set scanner as default unauthorized response +func (o *SetScannerAsDefaultUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *SetScannerAsDefaultUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// SetScannerAsDefaultForbiddenCode is the HTTP code returned for type SetScannerAsDefaultForbidden +const SetScannerAsDefaultForbiddenCode int = 403 + +/*SetScannerAsDefaultForbidden Forbidden + +swagger:response setScannerAsDefaultForbidden +*/ +type SetScannerAsDefaultForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewSetScannerAsDefaultForbidden creates SetScannerAsDefaultForbidden with default headers values +func NewSetScannerAsDefaultForbidden() *SetScannerAsDefaultForbidden { + + return &SetScannerAsDefaultForbidden{} +} + +// WithXRequestID adds the xRequestId to the set scanner as default forbidden response +func (o *SetScannerAsDefaultForbidden) WithXRequestID(xRequestID string) *SetScannerAsDefaultForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the set scanner as default forbidden response +func (o *SetScannerAsDefaultForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the set scanner as default forbidden response +func (o *SetScannerAsDefaultForbidden) WithPayload(payload *models.Errors) *SetScannerAsDefaultForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the set scanner as default forbidden response +func (o *SetScannerAsDefaultForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *SetScannerAsDefaultForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// SetScannerAsDefaultInternalServerErrorCode is the HTTP code returned for type SetScannerAsDefaultInternalServerError +const SetScannerAsDefaultInternalServerErrorCode int = 500 + +/*SetScannerAsDefaultInternalServerError Internal server error + +swagger:response setScannerAsDefaultInternalServerError +*/ +type SetScannerAsDefaultInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewSetScannerAsDefaultInternalServerError creates SetScannerAsDefaultInternalServerError with default headers values +func NewSetScannerAsDefaultInternalServerError() *SetScannerAsDefaultInternalServerError { + + return &SetScannerAsDefaultInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the set scanner as default internal server error response +func (o *SetScannerAsDefaultInternalServerError) WithXRequestID(xRequestID string) *SetScannerAsDefaultInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the set scanner as default internal server error response +func (o *SetScannerAsDefaultInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the set scanner as default internal server error response +func (o *SetScannerAsDefaultInternalServerError) WithPayload(payload *models.Errors) *SetScannerAsDefaultInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the set scanner as default internal server error response +func (o *SetScannerAsDefaultInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *SetScannerAsDefaultInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/scanner/set_scanner_as_default_urlbuilder.go b/src/server/v2.0/restapi/operations/scanner/set_scanner_as_default_urlbuilder.go new file mode 100644 index 000000000..d11a0b043 --- /dev/null +++ b/src/server/v2.0/restapi/operations/scanner/set_scanner_as_default_urlbuilder.go @@ -0,0 +1,99 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scanner + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// SetScannerAsDefaultURL generates an URL for the set scanner as default operation +type SetScannerAsDefaultURL struct { + RegistrationID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *SetScannerAsDefaultURL) WithBasePath(bp string) *SetScannerAsDefaultURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *SetScannerAsDefaultURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *SetScannerAsDefaultURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/scanners/{registration_id}" + + registrationID := o.RegistrationID + if registrationID != "" { + _path = strings.Replace(_path, "{registration_id}", registrationID, -1) + } else { + return nil, errors.New("registrationId is required on SetScannerAsDefaultURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *SetScannerAsDefaultURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *SetScannerAsDefaultURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *SetScannerAsDefaultURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on SetScannerAsDefaultURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on SetScannerAsDefaultURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *SetScannerAsDefaultURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/scanner/update_scanner.go b/src/server/v2.0/restapi/operations/scanner/update_scanner.go new file mode 100644 index 000000000..f4392c60e --- /dev/null +++ b/src/server/v2.0/restapi/operations/scanner/update_scanner.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scanner + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// UpdateScannerHandlerFunc turns a function with the right signature into a update scanner handler +type UpdateScannerHandlerFunc func(UpdateScannerParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn UpdateScannerHandlerFunc) Handle(params UpdateScannerParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// UpdateScannerHandler interface for that can handle valid update scanner params +type UpdateScannerHandler interface { + Handle(UpdateScannerParams, interface{}) middleware.Responder +} + +// NewUpdateScanner creates a new http.Handler for the update scanner operation +func NewUpdateScanner(ctx *middleware.Context, handler UpdateScannerHandler) *UpdateScanner { + return &UpdateScanner{Context: ctx, Handler: handler} +} + +/*UpdateScanner swagger:route PUT /scanners/{registration_id} scanner updateScanner + +Update a scanner registration + +Updates the specified scanner registration. + + +*/ +type UpdateScanner struct { + Context *middleware.Context + Handler UpdateScannerHandler +} + +func (o *UpdateScanner) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewUpdateScannerParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/scanner/update_scanner_parameters.go b/src/server/v2.0/restapi/operations/scanner/update_scanner_parameters.go new file mode 100644 index 000000000..f3356b20b --- /dev/null +++ b/src/server/v2.0/restapi/operations/scanner/update_scanner_parameters.go @@ -0,0 +1,145 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scanner + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewUpdateScannerParams creates a new UpdateScannerParams object +// no default values defined in spec. +func NewUpdateScannerParams() UpdateScannerParams { + + return UpdateScannerParams{} +} + +// UpdateScannerParams contains all the bound params for the update scanner operation +// typically these are obtained from a http.Request +// +// swagger:parameters updateScanner +type UpdateScannerParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*A scanner registraiton to be updated. + Required: true + In: body + */ + Registration *models.ScannerRegistrationReq + /*The scanner registration identifier. + Required: true + In: path + */ + RegistrationID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewUpdateScannerParams() beforehand. +func (o *UpdateScannerParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.ScannerRegistrationReq + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("registration", "body", "")) + } else { + res = append(res, errors.NewParseError("registration", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Registration = &body + } + } + } else { + res = append(res, errors.Required("registration", "body", "")) + } + rRegistrationID, rhkRegistrationID, _ := route.Params.GetOK("registration_id") + if err := o.bindRegistrationID(rRegistrationID, rhkRegistrationID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *UpdateScannerParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *UpdateScannerParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindRegistrationID binds and validates parameter RegistrationID from path. +func (o *UpdateScannerParams) bindRegistrationID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.RegistrationID = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/scanner/update_scanner_responses.go b/src/server/v2.0/restapi/operations/scanner/update_scanner_responses.go new file mode 100644 index 000000000..baa161bf6 --- /dev/null +++ b/src/server/v2.0/restapi/operations/scanner/update_scanner_responses.go @@ -0,0 +1,324 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scanner + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// UpdateScannerOKCode is the HTTP code returned for type UpdateScannerOK +const UpdateScannerOKCode int = 200 + +/*UpdateScannerOK Success + +swagger:response updateScannerOK +*/ +type UpdateScannerOK struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewUpdateScannerOK creates UpdateScannerOK with default headers values +func NewUpdateScannerOK() *UpdateScannerOK { + + return &UpdateScannerOK{} +} + +// WithXRequestID adds the xRequestId to the update scanner o k response +func (o *UpdateScannerOK) WithXRequestID(xRequestID string) *UpdateScannerOK { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update scanner o k response +func (o *UpdateScannerOK) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *UpdateScannerOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// UpdateScannerUnauthorizedCode is the HTTP code returned for type UpdateScannerUnauthorized +const UpdateScannerUnauthorizedCode int = 401 + +/*UpdateScannerUnauthorized Unauthorized + +swagger:response updateScannerUnauthorized +*/ +type UpdateScannerUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateScannerUnauthorized creates UpdateScannerUnauthorized with default headers values +func NewUpdateScannerUnauthorized() *UpdateScannerUnauthorized { + + return &UpdateScannerUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the update scanner unauthorized response +func (o *UpdateScannerUnauthorized) WithXRequestID(xRequestID string) *UpdateScannerUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update scanner unauthorized response +func (o *UpdateScannerUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update scanner unauthorized response +func (o *UpdateScannerUnauthorized) WithPayload(payload *models.Errors) *UpdateScannerUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update scanner unauthorized response +func (o *UpdateScannerUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateScannerUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateScannerForbiddenCode is the HTTP code returned for type UpdateScannerForbidden +const UpdateScannerForbiddenCode int = 403 + +/*UpdateScannerForbidden Forbidden + +swagger:response updateScannerForbidden +*/ +type UpdateScannerForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateScannerForbidden creates UpdateScannerForbidden with default headers values +func NewUpdateScannerForbidden() *UpdateScannerForbidden { + + return &UpdateScannerForbidden{} +} + +// WithXRequestID adds the xRequestId to the update scanner forbidden response +func (o *UpdateScannerForbidden) WithXRequestID(xRequestID string) *UpdateScannerForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update scanner forbidden response +func (o *UpdateScannerForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update scanner forbidden response +func (o *UpdateScannerForbidden) WithPayload(payload *models.Errors) *UpdateScannerForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update scanner forbidden response +func (o *UpdateScannerForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateScannerForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateScannerNotFoundCode is the HTTP code returned for type UpdateScannerNotFound +const UpdateScannerNotFoundCode int = 404 + +/*UpdateScannerNotFound Not found + +swagger:response updateScannerNotFound +*/ +type UpdateScannerNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateScannerNotFound creates UpdateScannerNotFound with default headers values +func NewUpdateScannerNotFound() *UpdateScannerNotFound { + + return &UpdateScannerNotFound{} +} + +// WithXRequestID adds the xRequestId to the update scanner not found response +func (o *UpdateScannerNotFound) WithXRequestID(xRequestID string) *UpdateScannerNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update scanner not found response +func (o *UpdateScannerNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update scanner not found response +func (o *UpdateScannerNotFound) WithPayload(payload *models.Errors) *UpdateScannerNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update scanner not found response +func (o *UpdateScannerNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateScannerNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateScannerInternalServerErrorCode is the HTTP code returned for type UpdateScannerInternalServerError +const UpdateScannerInternalServerErrorCode int = 500 + +/*UpdateScannerInternalServerError Internal server error + +swagger:response updateScannerInternalServerError +*/ +type UpdateScannerInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateScannerInternalServerError creates UpdateScannerInternalServerError with default headers values +func NewUpdateScannerInternalServerError() *UpdateScannerInternalServerError { + + return &UpdateScannerInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the update scanner internal server error response +func (o *UpdateScannerInternalServerError) WithXRequestID(xRequestID string) *UpdateScannerInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update scanner internal server error response +func (o *UpdateScannerInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update scanner internal server error response +func (o *UpdateScannerInternalServerError) WithPayload(payload *models.Errors) *UpdateScannerInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update scanner internal server error response +func (o *UpdateScannerInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateScannerInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/scanner/update_scanner_urlbuilder.go b/src/server/v2.0/restapi/operations/scanner/update_scanner_urlbuilder.go new file mode 100644 index 000000000..dbfc6d91a --- /dev/null +++ b/src/server/v2.0/restapi/operations/scanner/update_scanner_urlbuilder.go @@ -0,0 +1,99 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scanner + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// UpdateScannerURL generates an URL for the update scanner operation +type UpdateScannerURL struct { + RegistrationID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdateScannerURL) WithBasePath(bp string) *UpdateScannerURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdateScannerURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *UpdateScannerURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/scanners/{registration_id}" + + registrationID := o.RegistrationID + if registrationID != "" { + _path = strings.Replace(_path, "{registration_id}", registrationID, -1) + } else { + return nil, errors.New("registrationId is required on UpdateScannerURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *UpdateScannerURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *UpdateScannerURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *UpdateScannerURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on UpdateScannerURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on UpdateScannerURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *UpdateScannerURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/schedule/get_schedule_paused.go b/src/server/v2.0/restapi/operations/schedule/get_schedule_paused.go new file mode 100644 index 000000000..6a58cd30d --- /dev/null +++ b/src/server/v2.0/restapi/operations/schedule/get_schedule_paused.go @@ -0,0 +1,71 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package schedule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetSchedulePausedHandlerFunc turns a function with the right signature into a get schedule paused handler +type GetSchedulePausedHandlerFunc func(GetSchedulePausedParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetSchedulePausedHandlerFunc) Handle(params GetSchedulePausedParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetSchedulePausedHandler interface for that can handle valid get schedule paused params +type GetSchedulePausedHandler interface { + Handle(GetSchedulePausedParams, interface{}) middleware.Responder +} + +// NewGetSchedulePaused creates a new http.Handler for the get schedule paused operation +func NewGetSchedulePaused(ctx *middleware.Context, handler GetSchedulePausedHandler) *GetSchedulePaused { + return &GetSchedulePaused{Context: ctx, Handler: handler} +} + +/*GetSchedulePaused swagger:route GET /schedules/{job_type}/paused schedule getSchedulePaused + +Get scheduler paused status + +*/ +type GetSchedulePaused struct { + Context *middleware.Context + Handler GetSchedulePausedHandler +} + +func (o *GetSchedulePaused) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetSchedulePausedParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/schedule/get_schedule_paused_parameters.go b/src/server/v2.0/restapi/operations/schedule/get_schedule_paused_parameters.go new file mode 100644 index 000000000..403025273 --- /dev/null +++ b/src/server/v2.0/restapi/operations/schedule/get_schedule_paused_parameters.go @@ -0,0 +1,114 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package schedule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewGetSchedulePausedParams creates a new GetSchedulePausedParams object +// no default values defined in spec. +func NewGetSchedulePausedParams() GetSchedulePausedParams { + + return GetSchedulePausedParams{} +} + +// GetSchedulePausedParams contains all the bound params for the get schedule paused operation +// typically these are obtained from a http.Request +// +// swagger:parameters getSchedulePaused +type GetSchedulePausedParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The type of the job. 'all' stands for all job types, current only support query with all + Required: true + In: path + */ + JobType string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetSchedulePausedParams() beforehand. +func (o *GetSchedulePausedParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rJobType, rhkJobType, _ := route.Params.GetOK("job_type") + if err := o.bindJobType(rJobType, rhkJobType, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetSchedulePausedParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetSchedulePausedParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindJobType binds and validates parameter JobType from path. +func (o *GetSchedulePausedParams) bindJobType(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.JobType = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/schedule/get_schedule_paused_responses.go b/src/server/v2.0/restapi/operations/schedule/get_schedule_paused_responses.go new file mode 100644 index 000000000..ab445a2ee --- /dev/null +++ b/src/server/v2.0/restapi/operations/schedule/get_schedule_paused_responses.go @@ -0,0 +1,322 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package schedule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetSchedulePausedOKCode is the HTTP code returned for type GetSchedulePausedOK +const GetSchedulePausedOKCode int = 200 + +/*GetSchedulePausedOK Get scheduler status successfully. + +swagger:response getSchedulePausedOK +*/ +type GetSchedulePausedOK struct { + + /* + In: Body + */ + Payload *models.SchedulerStatus `json:"body,omitempty"` +} + +// NewGetSchedulePausedOK creates GetSchedulePausedOK with default headers values +func NewGetSchedulePausedOK() *GetSchedulePausedOK { + + return &GetSchedulePausedOK{} +} + +// WithPayload adds the payload to the get schedule paused o k response +func (o *GetSchedulePausedOK) WithPayload(payload *models.SchedulerStatus) *GetSchedulePausedOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get schedule paused o k response +func (o *GetSchedulePausedOK) SetPayload(payload *models.SchedulerStatus) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetSchedulePausedOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetSchedulePausedUnauthorizedCode is the HTTP code returned for type GetSchedulePausedUnauthorized +const GetSchedulePausedUnauthorizedCode int = 401 + +/*GetSchedulePausedUnauthorized Unauthorized + +swagger:response getSchedulePausedUnauthorized +*/ +type GetSchedulePausedUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetSchedulePausedUnauthorized creates GetSchedulePausedUnauthorized with default headers values +func NewGetSchedulePausedUnauthorized() *GetSchedulePausedUnauthorized { + + return &GetSchedulePausedUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the get schedule paused unauthorized response +func (o *GetSchedulePausedUnauthorized) WithXRequestID(xRequestID string) *GetSchedulePausedUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get schedule paused unauthorized response +func (o *GetSchedulePausedUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get schedule paused unauthorized response +func (o *GetSchedulePausedUnauthorized) WithPayload(payload *models.Errors) *GetSchedulePausedUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get schedule paused unauthorized response +func (o *GetSchedulePausedUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetSchedulePausedUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetSchedulePausedForbiddenCode is the HTTP code returned for type GetSchedulePausedForbidden +const GetSchedulePausedForbiddenCode int = 403 + +/*GetSchedulePausedForbidden Forbidden + +swagger:response getSchedulePausedForbidden +*/ +type GetSchedulePausedForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetSchedulePausedForbidden creates GetSchedulePausedForbidden with default headers values +func NewGetSchedulePausedForbidden() *GetSchedulePausedForbidden { + + return &GetSchedulePausedForbidden{} +} + +// WithXRequestID adds the xRequestId to the get schedule paused forbidden response +func (o *GetSchedulePausedForbidden) WithXRequestID(xRequestID string) *GetSchedulePausedForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get schedule paused forbidden response +func (o *GetSchedulePausedForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get schedule paused forbidden response +func (o *GetSchedulePausedForbidden) WithPayload(payload *models.Errors) *GetSchedulePausedForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get schedule paused forbidden response +func (o *GetSchedulePausedForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetSchedulePausedForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetSchedulePausedNotFoundCode is the HTTP code returned for type GetSchedulePausedNotFound +const GetSchedulePausedNotFoundCode int = 404 + +/*GetSchedulePausedNotFound Not found + +swagger:response getSchedulePausedNotFound +*/ +type GetSchedulePausedNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetSchedulePausedNotFound creates GetSchedulePausedNotFound with default headers values +func NewGetSchedulePausedNotFound() *GetSchedulePausedNotFound { + + return &GetSchedulePausedNotFound{} +} + +// WithXRequestID adds the xRequestId to the get schedule paused not found response +func (o *GetSchedulePausedNotFound) WithXRequestID(xRequestID string) *GetSchedulePausedNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get schedule paused not found response +func (o *GetSchedulePausedNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get schedule paused not found response +func (o *GetSchedulePausedNotFound) WithPayload(payload *models.Errors) *GetSchedulePausedNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get schedule paused not found response +func (o *GetSchedulePausedNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetSchedulePausedNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetSchedulePausedInternalServerErrorCode is the HTTP code returned for type GetSchedulePausedInternalServerError +const GetSchedulePausedInternalServerErrorCode int = 500 + +/*GetSchedulePausedInternalServerError Internal server error + +swagger:response getSchedulePausedInternalServerError +*/ +type GetSchedulePausedInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetSchedulePausedInternalServerError creates GetSchedulePausedInternalServerError with default headers values +func NewGetSchedulePausedInternalServerError() *GetSchedulePausedInternalServerError { + + return &GetSchedulePausedInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get schedule paused internal server error response +func (o *GetSchedulePausedInternalServerError) WithXRequestID(xRequestID string) *GetSchedulePausedInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get schedule paused internal server error response +func (o *GetSchedulePausedInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get schedule paused internal server error response +func (o *GetSchedulePausedInternalServerError) WithPayload(payload *models.Errors) *GetSchedulePausedInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get schedule paused internal server error response +func (o *GetSchedulePausedInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetSchedulePausedInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/schedule/get_schedule_paused_urlbuilder.go b/src/server/v2.0/restapi/operations/schedule/get_schedule_paused_urlbuilder.go new file mode 100644 index 000000000..485e458f4 --- /dev/null +++ b/src/server/v2.0/restapi/operations/schedule/get_schedule_paused_urlbuilder.go @@ -0,0 +1,99 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package schedule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetSchedulePausedURL generates an URL for the get schedule paused operation +type GetSchedulePausedURL struct { + JobType string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetSchedulePausedURL) WithBasePath(bp string) *GetSchedulePausedURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetSchedulePausedURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetSchedulePausedURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/schedules/{job_type}/paused" + + jobType := o.JobType + if jobType != "" { + _path = strings.Replace(_path, "{job_type}", jobType, -1) + } else { + return nil, errors.New("jobType is required on GetSchedulePausedURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetSchedulePausedURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetSchedulePausedURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetSchedulePausedURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetSchedulePausedURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetSchedulePausedURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetSchedulePausedURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/schedule/list_schedules.go b/src/server/v2.0/restapi/operations/schedule/list_schedules.go new file mode 100644 index 000000000..009bc1efd --- /dev/null +++ b/src/server/v2.0/restapi/operations/schedule/list_schedules.go @@ -0,0 +1,71 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package schedule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ListSchedulesHandlerFunc turns a function with the right signature into a list schedules handler +type ListSchedulesHandlerFunc func(ListSchedulesParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ListSchedulesHandlerFunc) Handle(params ListSchedulesParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ListSchedulesHandler interface for that can handle valid list schedules params +type ListSchedulesHandler interface { + Handle(ListSchedulesParams, interface{}) middleware.Responder +} + +// NewListSchedules creates a new http.Handler for the list schedules operation +func NewListSchedules(ctx *middleware.Context, handler ListSchedulesHandler) *ListSchedules { + return &ListSchedules{Context: ctx, Handler: handler} +} + +/*ListSchedules swagger:route GET /schedules schedule listSchedules + +List schedules + +*/ +type ListSchedules struct { + Context *middleware.Context + Handler ListSchedulesHandler +} + +func (o *ListSchedules) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewListSchedulesParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/schedule/list_schedules_parameters.go b/src/server/v2.0/restapi/operations/schedule/list_schedules_parameters.go new file mode 100644 index 000000000..9ef754881 --- /dev/null +++ b/src/server/v2.0/restapi/operations/schedule/list_schedules_parameters.go @@ -0,0 +1,185 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package schedule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewListSchedulesParams creates a new ListSchedulesParams object +// with the default values initialized. +func NewListSchedulesParams() ListSchedulesParams { + + var ( + // initialize parameters with default values + + pageDefault = int64(1) + pageSizeDefault = int64(10) + ) + + return ListSchedulesParams{ + Page: &pageDefault, + + PageSize: &pageSizeDefault, + } +} + +// ListSchedulesParams contains all the bound params for the list schedules operation +// typically these are obtained from a http.Request +// +// swagger:parameters listSchedules +type ListSchedulesParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The page number + In: query + Default: 1 + */ + Page *int64 + /*The size of per page + Maximum: 100 + In: query + Default: 10 + */ + PageSize *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewListSchedulesParams() beforehand. +func (o *ListSchedulesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + qPage, qhkPage, _ := qs.GetOK("page") + if err := o.bindPage(qPage, qhkPage, route.Formats); err != nil { + res = append(res, err) + } + + qPageSize, qhkPageSize, _ := qs.GetOK("page_size") + if err := o.bindPageSize(qPageSize, qhkPageSize, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *ListSchedulesParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *ListSchedulesParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindPage binds and validates parameter Page from query. +func (o *ListSchedulesParams) bindPage(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListSchedulesParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page", "query", "int64", raw) + } + o.Page = &value + + return nil +} + +// bindPageSize binds and validates parameter PageSize from query. +func (o *ListSchedulesParams) bindPageSize(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListSchedulesParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page_size", "query", "int64", raw) + } + o.PageSize = &value + + if err := o.validatePageSize(formats); err != nil { + return err + } + + return nil +} + +// validatePageSize carries on validations for parameter PageSize +func (o *ListSchedulesParams) validatePageSize(formats strfmt.Registry) error { + + if err := validate.MaximumInt("page_size", "query", int64(*o.PageSize), 100, false); err != nil { + return err + } + + return nil +} diff --git a/src/server/v2.0/restapi/operations/schedule/list_schedules_responses.go b/src/server/v2.0/restapi/operations/schedule/list_schedules_responses.go new file mode 100644 index 000000000..aaac9ea26 --- /dev/null +++ b/src/server/v2.0/restapi/operations/schedule/list_schedules_responses.go @@ -0,0 +1,370 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package schedule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/swag" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// ListSchedulesOKCode is the HTTP code returned for type ListSchedulesOK +const ListSchedulesOKCode int = 200 + +/*ListSchedulesOK list schedule successfully. + +swagger:response listSchedulesOK +*/ +type ListSchedulesOK struct { + /*Link to previous page and next page + + */ + Link string `json:"Link"` + /*The total count of available items + + */ + XTotalCount int64 `json:"X-Total-Count"` + + /* + In: Body + */ + Payload []*models.ScheduleTask `json:"body,omitempty"` +} + +// NewListSchedulesOK creates ListSchedulesOK with default headers values +func NewListSchedulesOK() *ListSchedulesOK { + + return &ListSchedulesOK{} +} + +// WithLink adds the link to the list schedules o k response +func (o *ListSchedulesOK) WithLink(link string) *ListSchedulesOK { + o.Link = link + return o +} + +// SetLink sets the link to the list schedules o k response +func (o *ListSchedulesOK) SetLink(link string) { + o.Link = link +} + +// WithXTotalCount adds the xTotalCount to the list schedules o k response +func (o *ListSchedulesOK) WithXTotalCount(xTotalCount int64) *ListSchedulesOK { + o.XTotalCount = xTotalCount + return o +} + +// SetXTotalCount sets the xTotalCount to the list schedules o k response +func (o *ListSchedulesOK) SetXTotalCount(xTotalCount int64) { + o.XTotalCount = xTotalCount +} + +// WithPayload adds the payload to the list schedules o k response +func (o *ListSchedulesOK) WithPayload(payload []*models.ScheduleTask) *ListSchedulesOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list schedules o k response +func (o *ListSchedulesOK) SetPayload(payload []*models.ScheduleTask) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListSchedulesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Link + + link := o.Link + if link != "" { + rw.Header().Set("Link", link) + } + + // response header X-Total-Count + + xTotalCount := swag.FormatInt64(o.XTotalCount) + if xTotalCount != "" { + rw.Header().Set("X-Total-Count", xTotalCount) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = make([]*models.ScheduleTask, 0, 50) + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ListSchedulesUnauthorizedCode is the HTTP code returned for type ListSchedulesUnauthorized +const ListSchedulesUnauthorizedCode int = 401 + +/*ListSchedulesUnauthorized Unauthorized + +swagger:response listSchedulesUnauthorized +*/ +type ListSchedulesUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListSchedulesUnauthorized creates ListSchedulesUnauthorized with default headers values +func NewListSchedulesUnauthorized() *ListSchedulesUnauthorized { + + return &ListSchedulesUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the list schedules unauthorized response +func (o *ListSchedulesUnauthorized) WithXRequestID(xRequestID string) *ListSchedulesUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list schedules unauthorized response +func (o *ListSchedulesUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list schedules unauthorized response +func (o *ListSchedulesUnauthorized) WithPayload(payload *models.Errors) *ListSchedulesUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list schedules unauthorized response +func (o *ListSchedulesUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListSchedulesUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListSchedulesForbiddenCode is the HTTP code returned for type ListSchedulesForbidden +const ListSchedulesForbiddenCode int = 403 + +/*ListSchedulesForbidden Forbidden + +swagger:response listSchedulesForbidden +*/ +type ListSchedulesForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListSchedulesForbidden creates ListSchedulesForbidden with default headers values +func NewListSchedulesForbidden() *ListSchedulesForbidden { + + return &ListSchedulesForbidden{} +} + +// WithXRequestID adds the xRequestId to the list schedules forbidden response +func (o *ListSchedulesForbidden) WithXRequestID(xRequestID string) *ListSchedulesForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list schedules forbidden response +func (o *ListSchedulesForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list schedules forbidden response +func (o *ListSchedulesForbidden) WithPayload(payload *models.Errors) *ListSchedulesForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list schedules forbidden response +func (o *ListSchedulesForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListSchedulesForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListSchedulesNotFoundCode is the HTTP code returned for type ListSchedulesNotFound +const ListSchedulesNotFoundCode int = 404 + +/*ListSchedulesNotFound Not found + +swagger:response listSchedulesNotFound +*/ +type ListSchedulesNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListSchedulesNotFound creates ListSchedulesNotFound with default headers values +func NewListSchedulesNotFound() *ListSchedulesNotFound { + + return &ListSchedulesNotFound{} +} + +// WithXRequestID adds the xRequestId to the list schedules not found response +func (o *ListSchedulesNotFound) WithXRequestID(xRequestID string) *ListSchedulesNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list schedules not found response +func (o *ListSchedulesNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list schedules not found response +func (o *ListSchedulesNotFound) WithPayload(payload *models.Errors) *ListSchedulesNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list schedules not found response +func (o *ListSchedulesNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListSchedulesNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListSchedulesInternalServerErrorCode is the HTTP code returned for type ListSchedulesInternalServerError +const ListSchedulesInternalServerErrorCode int = 500 + +/*ListSchedulesInternalServerError Internal server error + +swagger:response listSchedulesInternalServerError +*/ +type ListSchedulesInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListSchedulesInternalServerError creates ListSchedulesInternalServerError with default headers values +func NewListSchedulesInternalServerError() *ListSchedulesInternalServerError { + + return &ListSchedulesInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the list schedules internal server error response +func (o *ListSchedulesInternalServerError) WithXRequestID(xRequestID string) *ListSchedulesInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list schedules internal server error response +func (o *ListSchedulesInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list schedules internal server error response +func (o *ListSchedulesInternalServerError) WithPayload(payload *models.Errors) *ListSchedulesInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list schedules internal server error response +func (o *ListSchedulesInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListSchedulesInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/schedule/list_schedules_urlbuilder.go b/src/server/v2.0/restapi/operations/schedule/list_schedules_urlbuilder.go new file mode 100644 index 000000000..0d09ecc55 --- /dev/null +++ b/src/server/v2.0/restapi/operations/schedule/list_schedules_urlbuilder.go @@ -0,0 +1,114 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package schedule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// ListSchedulesURL generates an URL for the list schedules operation +type ListSchedulesURL struct { + Page *int64 + PageSize *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListSchedulesURL) WithBasePath(bp string) *ListSchedulesURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListSchedulesURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ListSchedulesURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/schedules" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var pageQ string + if o.Page != nil { + pageQ = swag.FormatInt64(*o.Page) + } + if pageQ != "" { + qs.Set("page", pageQ) + } + + var pageSizeQ string + if o.PageSize != nil { + pageSizeQ = swag.FormatInt64(*o.PageSize) + } + if pageSizeQ != "" { + qs.Set("page_size", pageSizeQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ListSchedulesURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ListSchedulesURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ListSchedulesURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ListSchedulesURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ListSchedulesURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ListSchedulesURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/search/search.go b/src/server/v2.0/restapi/operations/search/search.go new file mode 100644 index 000000000..6ae00ddb4 --- /dev/null +++ b/src/server/v2.0/restapi/operations/search/search.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package search + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// SearchHandlerFunc turns a function with the right signature into a search handler +type SearchHandlerFunc func(SearchParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn SearchHandlerFunc) Handle(params SearchParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// SearchHandler interface for that can handle valid search params +type SearchHandler interface { + Handle(SearchParams, interface{}) middleware.Responder +} + +// NewSearch creates a new http.Handler for the search operation +func NewSearch(ctx *middleware.Context, handler SearchHandler) *Search { + return &Search{Context: ctx, Handler: handler} +} + +/*Search swagger:route GET /search search search + +Search for projects, repositories and helm charts + +The Search endpoint returns information about the projects, repositories and helm charts offered at public status or related to the current logged in user. The response includes the project, repository list and charts in a proper display order. + +*/ +type Search struct { + Context *middleware.Context + Handler SearchHandler +} + +func (o *Search) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewSearchParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/search/search_parameters.go b/src/server/v2.0/restapi/operations/search/search_parameters.go new file mode 100644 index 000000000..10f686958 --- /dev/null +++ b/src/server/v2.0/restapi/operations/search/search_parameters.go @@ -0,0 +1,123 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package search + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewSearchParams creates a new SearchParams object +// no default values defined in spec. +func NewSearchParams() SearchParams { + + return SearchParams{} +} + +// SearchParams contains all the bound params for the search operation +// typically these are obtained from a http.Request +// +// swagger:parameters search +type SearchParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*Search parameter for project and repository name. + Required: true + In: query + */ + Q string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewSearchParams() beforehand. +func (o *SearchParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + qQ, qhkQ, _ := qs.GetOK("q") + if err := o.bindQ(qQ, qhkQ, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *SearchParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *SearchParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindQ binds and validates parameter Q from query. +func (o *SearchParams) bindQ(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("q", "query", rawData) + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // AllowEmptyValue: false + if err := validate.RequiredString("q", "query", raw); err != nil { + return err + } + + o.Q = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/search/search_responses.go b/src/server/v2.0/restapi/operations/search/search_responses.go new file mode 100644 index 000000000..2cda56bbf --- /dev/null +++ b/src/server/v2.0/restapi/operations/search/search_responses.go @@ -0,0 +1,124 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package search + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// SearchOKCode is the HTTP code returned for type SearchOK +const SearchOKCode int = 200 + +/*SearchOK An array of search results + +swagger:response searchOK +*/ +type SearchOK struct { + + /* + In: Body + */ + Payload *models.Search `json:"body,omitempty"` +} + +// NewSearchOK creates SearchOK with default headers values +func NewSearchOK() *SearchOK { + + return &SearchOK{} +} + +// WithPayload adds the payload to the search o k response +func (o *SearchOK) WithPayload(payload *models.Search) *SearchOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the search o k response +func (o *SearchOK) SetPayload(payload *models.Search) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *SearchOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// SearchInternalServerErrorCode is the HTTP code returned for type SearchInternalServerError +const SearchInternalServerErrorCode int = 500 + +/*SearchInternalServerError Internal server error + +swagger:response searchInternalServerError +*/ +type SearchInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewSearchInternalServerError creates SearchInternalServerError with default headers values +func NewSearchInternalServerError() *SearchInternalServerError { + + return &SearchInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the search internal server error response +func (o *SearchInternalServerError) WithXRequestID(xRequestID string) *SearchInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the search internal server error response +func (o *SearchInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the search internal server error response +func (o *SearchInternalServerError) WithPayload(payload *models.Errors) *SearchInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the search internal server error response +func (o *SearchInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *SearchInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/search/search_urlbuilder.go b/src/server/v2.0/restapi/operations/search/search_urlbuilder.go new file mode 100644 index 000000000..cd1234448 --- /dev/null +++ b/src/server/v2.0/restapi/operations/search/search_urlbuilder.go @@ -0,0 +1,100 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package search + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// SearchURL generates an URL for the search operation +type SearchURL struct { + Q string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *SearchURL) WithBasePath(bp string) *SearchURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *SearchURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *SearchURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/search" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + qQ := o.Q + if qQ != "" { + qs.Set("q", qQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *SearchURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *SearchURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *SearchURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on SearchURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on SearchURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *SearchURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/statistic/get_statistic.go b/src/server/v2.0/restapi/operations/statistic/get_statistic.go new file mode 100644 index 000000000..e0df161f4 --- /dev/null +++ b/src/server/v2.0/restapi/operations/statistic/get_statistic.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package statistic + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetStatisticHandlerFunc turns a function with the right signature into a get statistic handler +type GetStatisticHandlerFunc func(GetStatisticParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetStatisticHandlerFunc) Handle(params GetStatisticParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetStatisticHandler interface for that can handle valid get statistic params +type GetStatisticHandler interface { + Handle(GetStatisticParams, interface{}) middleware.Responder +} + +// NewGetStatistic creates a new http.Handler for the get statistic operation +func NewGetStatistic(ctx *middleware.Context, handler GetStatisticHandler) *GetStatistic { + return &GetStatistic{Context: ctx, Handler: handler} +} + +/*GetStatistic swagger:route GET /statistics statistic getStatistic + +Get the statistic information about the projects and repositories + +Get the statistic information about the projects and repositories + +*/ +type GetStatistic struct { + Context *middleware.Context + Handler GetStatisticHandler +} + +func (o *GetStatistic) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetStatisticParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/statistic/get_statistic_parameters.go b/src/server/v2.0/restapi/operations/statistic/get_statistic_parameters.go new file mode 100644 index 000000000..be0fa8492 --- /dev/null +++ b/src/server/v2.0/restapi/operations/statistic/get_statistic_parameters.go @@ -0,0 +1,89 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package statistic + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewGetStatisticParams creates a new GetStatisticParams object +// no default values defined in spec. +func NewGetStatisticParams() GetStatisticParams { + + return GetStatisticParams{} +} + +// GetStatisticParams contains all the bound params for the get statistic operation +// typically these are obtained from a http.Request +// +// swagger:parameters getStatistic +type GetStatisticParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetStatisticParams() beforehand. +func (o *GetStatisticParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetStatisticParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetStatisticParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} diff --git a/src/server/v2.0/restapi/operations/statistic/get_statistic_responses.go b/src/server/v2.0/restapi/operations/statistic/get_statistic_responses.go new file mode 100644 index 000000000..94c7fc7a2 --- /dev/null +++ b/src/server/v2.0/restapi/operations/statistic/get_statistic_responses.go @@ -0,0 +1,190 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package statistic + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetStatisticOKCode is the HTTP code returned for type GetStatisticOK +const GetStatisticOKCode int = 200 + +/*GetStatisticOK The statistic information + +swagger:response getStatisticOK +*/ +type GetStatisticOK struct { + + /* + In: Body + */ + Payload *models.Statistic `json:"body,omitempty"` +} + +// NewGetStatisticOK creates GetStatisticOK with default headers values +func NewGetStatisticOK() *GetStatisticOK { + + return &GetStatisticOK{} +} + +// WithPayload adds the payload to the get statistic o k response +func (o *GetStatisticOK) WithPayload(payload *models.Statistic) *GetStatisticOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get statistic o k response +func (o *GetStatisticOK) SetPayload(payload *models.Statistic) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetStatisticOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetStatisticUnauthorizedCode is the HTTP code returned for type GetStatisticUnauthorized +const GetStatisticUnauthorizedCode int = 401 + +/*GetStatisticUnauthorized Unauthorized + +swagger:response getStatisticUnauthorized +*/ +type GetStatisticUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetStatisticUnauthorized creates GetStatisticUnauthorized with default headers values +func NewGetStatisticUnauthorized() *GetStatisticUnauthorized { + + return &GetStatisticUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the get statistic unauthorized response +func (o *GetStatisticUnauthorized) WithXRequestID(xRequestID string) *GetStatisticUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get statistic unauthorized response +func (o *GetStatisticUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get statistic unauthorized response +func (o *GetStatisticUnauthorized) WithPayload(payload *models.Errors) *GetStatisticUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get statistic unauthorized response +func (o *GetStatisticUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetStatisticUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetStatisticInternalServerErrorCode is the HTTP code returned for type GetStatisticInternalServerError +const GetStatisticInternalServerErrorCode int = 500 + +/*GetStatisticInternalServerError Internal server error + +swagger:response getStatisticInternalServerError +*/ +type GetStatisticInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetStatisticInternalServerError creates GetStatisticInternalServerError with default headers values +func NewGetStatisticInternalServerError() *GetStatisticInternalServerError { + + return &GetStatisticInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get statistic internal server error response +func (o *GetStatisticInternalServerError) WithXRequestID(xRequestID string) *GetStatisticInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get statistic internal server error response +func (o *GetStatisticInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get statistic internal server error response +func (o *GetStatisticInternalServerError) WithPayload(payload *models.Errors) *GetStatisticInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get statistic internal server error response +func (o *GetStatisticInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetStatisticInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/statistic/get_statistic_urlbuilder.go b/src/server/v2.0/restapi/operations/statistic/get_statistic_urlbuilder.go new file mode 100644 index 000000000..59eec1f6b --- /dev/null +++ b/src/server/v2.0/restapi/operations/statistic/get_statistic_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package statistic + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetStatisticURL generates an URL for the get statistic operation +type GetStatisticURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetStatisticURL) WithBasePath(bp string) *GetStatisticURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetStatisticURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetStatisticURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/statistics" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetStatisticURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetStatisticURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetStatisticURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetStatisticURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetStatisticURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetStatisticURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/system_cve_allowlist/get_system_cve_allowlist.go b/src/server/v2.0/restapi/operations/system_cve_allowlist/get_system_cve_allowlist.go new file mode 100644 index 000000000..4a77e61f3 --- /dev/null +++ b/src/server/v2.0/restapi/operations/system_cve_allowlist/get_system_cve_allowlist.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package system_cve_allowlist + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetSystemCVEAllowlistHandlerFunc turns a function with the right signature into a get system CVE allowlist handler +type GetSystemCVEAllowlistHandlerFunc func(GetSystemCVEAllowlistParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetSystemCVEAllowlistHandlerFunc) Handle(params GetSystemCVEAllowlistParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetSystemCVEAllowlistHandler interface for that can handle valid get system CVE allowlist params +type GetSystemCVEAllowlistHandler interface { + Handle(GetSystemCVEAllowlistParams, interface{}) middleware.Responder +} + +// NewGetSystemCVEAllowlist creates a new http.Handler for the get system CVE allowlist operation +func NewGetSystemCVEAllowlist(ctx *middleware.Context, handler GetSystemCVEAllowlistHandler) *GetSystemCVEAllowlist { + return &GetSystemCVEAllowlist{Context: ctx, Handler: handler} +} + +/*GetSystemCVEAllowlist swagger:route GET /system/CVEAllowlist SystemCVEAllowlist getSystemCveAllowlist + +Get the system level allowlist of CVE. + +Get the system level allowlist of CVE. This API can be called by all authenticated users. + +*/ +type GetSystemCVEAllowlist struct { + Context *middleware.Context + Handler GetSystemCVEAllowlistHandler +} + +func (o *GetSystemCVEAllowlist) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetSystemCVEAllowlistParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/system_cve_allowlist/get_system_cve_allowlist_parameters.go b/src/server/v2.0/restapi/operations/system_cve_allowlist/get_system_cve_allowlist_parameters.go new file mode 100644 index 000000000..124f365cd --- /dev/null +++ b/src/server/v2.0/restapi/operations/system_cve_allowlist/get_system_cve_allowlist_parameters.go @@ -0,0 +1,89 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package system_cve_allowlist + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewGetSystemCVEAllowlistParams creates a new GetSystemCVEAllowlistParams object +// no default values defined in spec. +func NewGetSystemCVEAllowlistParams() GetSystemCVEAllowlistParams { + + return GetSystemCVEAllowlistParams{} +} + +// GetSystemCVEAllowlistParams contains all the bound params for the get system CVE allowlist operation +// typically these are obtained from a http.Request +// +// swagger:parameters getSystemCVEAllowlist +type GetSystemCVEAllowlistParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetSystemCVEAllowlistParams() beforehand. +func (o *GetSystemCVEAllowlistParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetSystemCVEAllowlistParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetSystemCVEAllowlistParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} diff --git a/src/server/v2.0/restapi/operations/system_cve_allowlist/get_system_cve_allowlist_responses.go b/src/server/v2.0/restapi/operations/system_cve_allowlist/get_system_cve_allowlist_responses.go new file mode 100644 index 000000000..33be147d5 --- /dev/null +++ b/src/server/v2.0/restapi/operations/system_cve_allowlist/get_system_cve_allowlist_responses.go @@ -0,0 +1,190 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package system_cve_allowlist + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetSystemCVEAllowlistOKCode is the HTTP code returned for type GetSystemCVEAllowlistOK +const GetSystemCVEAllowlistOKCode int = 200 + +/*GetSystemCVEAllowlistOK Successfully retrieved the CVE allowlist. + +swagger:response getSystemCveAllowlistOK +*/ +type GetSystemCVEAllowlistOK struct { + + /* + In: Body + */ + Payload *models.CVEAllowlist `json:"body,omitempty"` +} + +// NewGetSystemCVEAllowlistOK creates GetSystemCVEAllowlistOK with default headers values +func NewGetSystemCVEAllowlistOK() *GetSystemCVEAllowlistOK { + + return &GetSystemCVEAllowlistOK{} +} + +// WithPayload adds the payload to the get system Cve allowlist o k response +func (o *GetSystemCVEAllowlistOK) WithPayload(payload *models.CVEAllowlist) *GetSystemCVEAllowlistOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get system Cve allowlist o k response +func (o *GetSystemCVEAllowlistOK) SetPayload(payload *models.CVEAllowlist) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetSystemCVEAllowlistOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetSystemCVEAllowlistUnauthorizedCode is the HTTP code returned for type GetSystemCVEAllowlistUnauthorized +const GetSystemCVEAllowlistUnauthorizedCode int = 401 + +/*GetSystemCVEAllowlistUnauthorized Unauthorized + +swagger:response getSystemCveAllowlistUnauthorized +*/ +type GetSystemCVEAllowlistUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetSystemCVEAllowlistUnauthorized creates GetSystemCVEAllowlistUnauthorized with default headers values +func NewGetSystemCVEAllowlistUnauthorized() *GetSystemCVEAllowlistUnauthorized { + + return &GetSystemCVEAllowlistUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the get system Cve allowlist unauthorized response +func (o *GetSystemCVEAllowlistUnauthorized) WithXRequestID(xRequestID string) *GetSystemCVEAllowlistUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get system Cve allowlist unauthorized response +func (o *GetSystemCVEAllowlistUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get system Cve allowlist unauthorized response +func (o *GetSystemCVEAllowlistUnauthorized) WithPayload(payload *models.Errors) *GetSystemCVEAllowlistUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get system Cve allowlist unauthorized response +func (o *GetSystemCVEAllowlistUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetSystemCVEAllowlistUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetSystemCVEAllowlistInternalServerErrorCode is the HTTP code returned for type GetSystemCVEAllowlistInternalServerError +const GetSystemCVEAllowlistInternalServerErrorCode int = 500 + +/*GetSystemCVEAllowlistInternalServerError Internal server error + +swagger:response getSystemCveAllowlistInternalServerError +*/ +type GetSystemCVEAllowlistInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetSystemCVEAllowlistInternalServerError creates GetSystemCVEAllowlistInternalServerError with default headers values +func NewGetSystemCVEAllowlistInternalServerError() *GetSystemCVEAllowlistInternalServerError { + + return &GetSystemCVEAllowlistInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get system Cve allowlist internal server error response +func (o *GetSystemCVEAllowlistInternalServerError) WithXRequestID(xRequestID string) *GetSystemCVEAllowlistInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get system Cve allowlist internal server error response +func (o *GetSystemCVEAllowlistInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get system Cve allowlist internal server error response +func (o *GetSystemCVEAllowlistInternalServerError) WithPayload(payload *models.Errors) *GetSystemCVEAllowlistInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get system Cve allowlist internal server error response +func (o *GetSystemCVEAllowlistInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetSystemCVEAllowlistInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/system_cve_allowlist/get_system_cve_allowlist_urlbuilder.go b/src/server/v2.0/restapi/operations/system_cve_allowlist/get_system_cve_allowlist_urlbuilder.go new file mode 100644 index 000000000..758f8c323 --- /dev/null +++ b/src/server/v2.0/restapi/operations/system_cve_allowlist/get_system_cve_allowlist_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package system_cve_allowlist + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetSystemCVEAllowlistURL generates an URL for the get system CVE allowlist operation +type GetSystemCVEAllowlistURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetSystemCVEAllowlistURL) WithBasePath(bp string) *GetSystemCVEAllowlistURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetSystemCVEAllowlistURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetSystemCVEAllowlistURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/system/CVEAllowlist" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetSystemCVEAllowlistURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetSystemCVEAllowlistURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetSystemCVEAllowlistURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetSystemCVEAllowlistURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetSystemCVEAllowlistURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetSystemCVEAllowlistURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/system_cve_allowlist/put_system_cve_allowlist.go b/src/server/v2.0/restapi/operations/system_cve_allowlist/put_system_cve_allowlist.go new file mode 100644 index 000000000..ec9e0a7cb --- /dev/null +++ b/src/server/v2.0/restapi/operations/system_cve_allowlist/put_system_cve_allowlist.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package system_cve_allowlist + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// PutSystemCVEAllowlistHandlerFunc turns a function with the right signature into a put system CVE allowlist handler +type PutSystemCVEAllowlistHandlerFunc func(PutSystemCVEAllowlistParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn PutSystemCVEAllowlistHandlerFunc) Handle(params PutSystemCVEAllowlistParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// PutSystemCVEAllowlistHandler interface for that can handle valid put system CVE allowlist params +type PutSystemCVEAllowlistHandler interface { + Handle(PutSystemCVEAllowlistParams, interface{}) middleware.Responder +} + +// NewPutSystemCVEAllowlist creates a new http.Handler for the put system CVE allowlist operation +func NewPutSystemCVEAllowlist(ctx *middleware.Context, handler PutSystemCVEAllowlistHandler) *PutSystemCVEAllowlist { + return &PutSystemCVEAllowlist{Context: ctx, Handler: handler} +} + +/*PutSystemCVEAllowlist swagger:route PUT /system/CVEAllowlist SystemCVEAllowlist putSystemCveAllowlist + +Update the system level allowlist of CVE. + +This API overwrites the system level allowlist of CVE with the list in request body. Only system Admin has permission to call this API. + +*/ +type PutSystemCVEAllowlist struct { + Context *middleware.Context + Handler PutSystemCVEAllowlistHandler +} + +func (o *PutSystemCVEAllowlist) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewPutSystemCVEAllowlistParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/system_cve_allowlist/put_system_cve_allowlist_parameters.go b/src/server/v2.0/restapi/operations/system_cve_allowlist/put_system_cve_allowlist_parameters.go new file mode 100644 index 000000000..adcbf98ba --- /dev/null +++ b/src/server/v2.0/restapi/operations/system_cve_allowlist/put_system_cve_allowlist_parameters.go @@ -0,0 +1,112 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package system_cve_allowlist + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewPutSystemCVEAllowlistParams creates a new PutSystemCVEAllowlistParams object +// no default values defined in spec. +func NewPutSystemCVEAllowlistParams() PutSystemCVEAllowlistParams { + + return PutSystemCVEAllowlistParams{} +} + +// PutSystemCVEAllowlistParams contains all the bound params for the put system CVE allowlist operation +// typically these are obtained from a http.Request +// +// swagger:parameters putSystemCVEAllowlist +type PutSystemCVEAllowlistParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The allowlist with new content + In: body + */ + Allowlist *models.CVEAllowlist +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewPutSystemCVEAllowlistParams() beforehand. +func (o *PutSystemCVEAllowlistParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.CVEAllowlist + if err := route.Consumer.Consume(r.Body, &body); err != nil { + res = append(res, errors.NewParseError("allowlist", "body", "", err)) + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Allowlist = &body + } + } + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *PutSystemCVEAllowlistParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *PutSystemCVEAllowlistParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} diff --git a/src/server/v2.0/restapi/operations/system_cve_allowlist/put_system_cve_allowlist_responses.go b/src/server/v2.0/restapi/operations/system_cve_allowlist/put_system_cve_allowlist_responses.go new file mode 100644 index 000000000..f3b033bf8 --- /dev/null +++ b/src/server/v2.0/restapi/operations/system_cve_allowlist/put_system_cve_allowlist_responses.go @@ -0,0 +1,236 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package system_cve_allowlist + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// PutSystemCVEAllowlistOKCode is the HTTP code returned for type PutSystemCVEAllowlistOK +const PutSystemCVEAllowlistOKCode int = 200 + +/*PutSystemCVEAllowlistOK Successfully updated the CVE allowlist. + +swagger:response putSystemCveAllowlistOK +*/ +type PutSystemCVEAllowlistOK struct { +} + +// NewPutSystemCVEAllowlistOK creates PutSystemCVEAllowlistOK with default headers values +func NewPutSystemCVEAllowlistOK() *PutSystemCVEAllowlistOK { + + return &PutSystemCVEAllowlistOK{} +} + +// WriteResponse to the client +func (o *PutSystemCVEAllowlistOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// PutSystemCVEAllowlistUnauthorizedCode is the HTTP code returned for type PutSystemCVEAllowlistUnauthorized +const PutSystemCVEAllowlistUnauthorizedCode int = 401 + +/*PutSystemCVEAllowlistUnauthorized Unauthorized + +swagger:response putSystemCveAllowlistUnauthorized +*/ +type PutSystemCVEAllowlistUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewPutSystemCVEAllowlistUnauthorized creates PutSystemCVEAllowlistUnauthorized with default headers values +func NewPutSystemCVEAllowlistUnauthorized() *PutSystemCVEAllowlistUnauthorized { + + return &PutSystemCVEAllowlistUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the put system Cve allowlist unauthorized response +func (o *PutSystemCVEAllowlistUnauthorized) WithXRequestID(xRequestID string) *PutSystemCVEAllowlistUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the put system Cve allowlist unauthorized response +func (o *PutSystemCVEAllowlistUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the put system Cve allowlist unauthorized response +func (o *PutSystemCVEAllowlistUnauthorized) WithPayload(payload *models.Errors) *PutSystemCVEAllowlistUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the put system Cve allowlist unauthorized response +func (o *PutSystemCVEAllowlistUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PutSystemCVEAllowlistUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PutSystemCVEAllowlistForbiddenCode is the HTTP code returned for type PutSystemCVEAllowlistForbidden +const PutSystemCVEAllowlistForbiddenCode int = 403 + +/*PutSystemCVEAllowlistForbidden Forbidden + +swagger:response putSystemCveAllowlistForbidden +*/ +type PutSystemCVEAllowlistForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewPutSystemCVEAllowlistForbidden creates PutSystemCVEAllowlistForbidden with default headers values +func NewPutSystemCVEAllowlistForbidden() *PutSystemCVEAllowlistForbidden { + + return &PutSystemCVEAllowlistForbidden{} +} + +// WithXRequestID adds the xRequestId to the put system Cve allowlist forbidden response +func (o *PutSystemCVEAllowlistForbidden) WithXRequestID(xRequestID string) *PutSystemCVEAllowlistForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the put system Cve allowlist forbidden response +func (o *PutSystemCVEAllowlistForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the put system Cve allowlist forbidden response +func (o *PutSystemCVEAllowlistForbidden) WithPayload(payload *models.Errors) *PutSystemCVEAllowlistForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the put system Cve allowlist forbidden response +func (o *PutSystemCVEAllowlistForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PutSystemCVEAllowlistForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PutSystemCVEAllowlistInternalServerErrorCode is the HTTP code returned for type PutSystemCVEAllowlistInternalServerError +const PutSystemCVEAllowlistInternalServerErrorCode int = 500 + +/*PutSystemCVEAllowlistInternalServerError Internal server error + +swagger:response putSystemCveAllowlistInternalServerError +*/ +type PutSystemCVEAllowlistInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewPutSystemCVEAllowlistInternalServerError creates PutSystemCVEAllowlistInternalServerError with default headers values +func NewPutSystemCVEAllowlistInternalServerError() *PutSystemCVEAllowlistInternalServerError { + + return &PutSystemCVEAllowlistInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the put system Cve allowlist internal server error response +func (o *PutSystemCVEAllowlistInternalServerError) WithXRequestID(xRequestID string) *PutSystemCVEAllowlistInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the put system Cve allowlist internal server error response +func (o *PutSystemCVEAllowlistInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the put system Cve allowlist internal server error response +func (o *PutSystemCVEAllowlistInternalServerError) WithPayload(payload *models.Errors) *PutSystemCVEAllowlistInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the put system Cve allowlist internal server error response +func (o *PutSystemCVEAllowlistInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PutSystemCVEAllowlistInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/system_cve_allowlist/put_system_cve_allowlist_urlbuilder.go b/src/server/v2.0/restapi/operations/system_cve_allowlist/put_system_cve_allowlist_urlbuilder.go new file mode 100644 index 000000000..c5d7b9e04 --- /dev/null +++ b/src/server/v2.0/restapi/operations/system_cve_allowlist/put_system_cve_allowlist_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package system_cve_allowlist + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// PutSystemCVEAllowlistURL generates an URL for the put system CVE allowlist operation +type PutSystemCVEAllowlistURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *PutSystemCVEAllowlistURL) WithBasePath(bp string) *PutSystemCVEAllowlistURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *PutSystemCVEAllowlistURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *PutSystemCVEAllowlistURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/system/CVEAllowlist" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *PutSystemCVEAllowlistURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *PutSystemCVEAllowlistURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *PutSystemCVEAllowlistURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on PutSystemCVEAllowlistURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on PutSystemCVEAllowlistURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *PutSystemCVEAllowlistURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/systeminfo/get_cert.go b/src/server/v2.0/restapi/operations/systeminfo/get_cert.go new file mode 100644 index 000000000..9e12e3c4c --- /dev/null +++ b/src/server/v2.0/restapi/operations/systeminfo/get_cert.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package systeminfo + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetCertHandlerFunc turns a function with the right signature into a get cert handler +type GetCertHandlerFunc func(GetCertParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetCertHandlerFunc) Handle(params GetCertParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetCertHandler interface for that can handle valid get cert params +type GetCertHandler interface { + Handle(GetCertParams, interface{}) middleware.Responder +} + +// NewGetCert creates a new http.Handler for the get cert operation +func NewGetCert(ctx *middleware.Context, handler GetCertHandler) *GetCert { + return &GetCert{Context: ctx, Handler: handler} +} + +/*GetCert swagger:route GET /systeminfo/getcert systeminfo getCert + +Get default root certificate. + +This endpoint is for downloading a default root certificate. + + +*/ +type GetCert struct { + Context *middleware.Context + Handler GetCertHandler +} + +func (o *GetCert) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetCertParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/systeminfo/get_cert_parameters.go b/src/server/v2.0/restapi/operations/systeminfo/get_cert_parameters.go new file mode 100644 index 000000000..2749e3954 --- /dev/null +++ b/src/server/v2.0/restapi/operations/systeminfo/get_cert_parameters.go @@ -0,0 +1,89 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package systeminfo + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewGetCertParams creates a new GetCertParams object +// no default values defined in spec. +func NewGetCertParams() GetCertParams { + + return GetCertParams{} +} + +// GetCertParams contains all the bound params for the get cert operation +// typically these are obtained from a http.Request +// +// swagger:parameters getCert +type GetCertParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetCertParams() beforehand. +func (o *GetCertParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetCertParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetCertParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} diff --git a/src/server/v2.0/restapi/operations/systeminfo/get_cert_responses.go b/src/server/v2.0/restapi/operations/systeminfo/get_cert_responses.go new file mode 100644 index 000000000..f37160f4f --- /dev/null +++ b/src/server/v2.0/restapi/operations/systeminfo/get_cert_responses.go @@ -0,0 +1,169 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package systeminfo + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetCertOKCode is the HTTP code returned for type GetCertOK +const GetCertOKCode int = 200 + +/*GetCertOK Get default root certificate successfully. + +swagger:response getCertOK +*/ +type GetCertOK struct { + /*To set the filename of the downloaded file. + + */ + ContentDisposition string `json:"Content-Disposition"` + + /* + In: Body + */ + Payload io.ReadCloser `json:"body,omitempty"` +} + +// NewGetCertOK creates GetCertOK with default headers values +func NewGetCertOK() *GetCertOK { + + return &GetCertOK{} +} + +// WithContentDisposition adds the contentDisposition to the get cert o k response +func (o *GetCertOK) WithContentDisposition(contentDisposition string) *GetCertOK { + o.ContentDisposition = contentDisposition + return o +} + +// SetContentDisposition sets the contentDisposition to the get cert o k response +func (o *GetCertOK) SetContentDisposition(contentDisposition string) { + o.ContentDisposition = contentDisposition +} + +// WithPayload adds the payload to the get cert o k response +func (o *GetCertOK) WithPayload(payload io.ReadCloser) *GetCertOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get cert o k response +func (o *GetCertOK) SetPayload(payload io.ReadCloser) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetCertOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Content-Disposition + + contentDisposition := o.ContentDisposition + if contentDisposition != "" { + rw.Header().Set("Content-Disposition", contentDisposition) + } + + rw.WriteHeader(200) + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// GetCertNotFoundCode is the HTTP code returned for type GetCertNotFound +const GetCertNotFoundCode int = 404 + +/*GetCertNotFound Not found the default root certificate. + +swagger:response getCertNotFound +*/ +type GetCertNotFound struct { +} + +// NewGetCertNotFound creates GetCertNotFound with default headers values +func NewGetCertNotFound() *GetCertNotFound { + + return &GetCertNotFound{} +} + +// WriteResponse to the client +func (o *GetCertNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(404) +} + +// GetCertInternalServerErrorCode is the HTTP code returned for type GetCertInternalServerError +const GetCertInternalServerErrorCode int = 500 + +/*GetCertInternalServerError Internal server error + +swagger:response getCertInternalServerError +*/ +type GetCertInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetCertInternalServerError creates GetCertInternalServerError with default headers values +func NewGetCertInternalServerError() *GetCertInternalServerError { + + return &GetCertInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get cert internal server error response +func (o *GetCertInternalServerError) WithXRequestID(xRequestID string) *GetCertInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get cert internal server error response +func (o *GetCertInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get cert internal server error response +func (o *GetCertInternalServerError) WithPayload(payload *models.Errors) *GetCertInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get cert internal server error response +func (o *GetCertInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetCertInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/systeminfo/get_cert_urlbuilder.go b/src/server/v2.0/restapi/operations/systeminfo/get_cert_urlbuilder.go new file mode 100644 index 000000000..6da306c8c --- /dev/null +++ b/src/server/v2.0/restapi/operations/systeminfo/get_cert_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package systeminfo + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetCertURL generates an URL for the get cert operation +type GetCertURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetCertURL) WithBasePath(bp string) *GetCertURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetCertURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetCertURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/systeminfo/getcert" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetCertURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetCertURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetCertURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetCertURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetCertURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetCertURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/systeminfo/get_system_info.go b/src/server/v2.0/restapi/operations/systeminfo/get_system_info.go new file mode 100644 index 000000000..294e6e5e1 --- /dev/null +++ b/src/server/v2.0/restapi/operations/systeminfo/get_system_info.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package systeminfo + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetSystemInfoHandlerFunc turns a function with the right signature into a get system info handler +type GetSystemInfoHandlerFunc func(GetSystemInfoParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetSystemInfoHandlerFunc) Handle(params GetSystemInfoParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetSystemInfoHandler interface for that can handle valid get system info params +type GetSystemInfoHandler interface { + Handle(GetSystemInfoParams, interface{}) middleware.Responder +} + +// NewGetSystemInfo creates a new http.Handler for the get system info operation +func NewGetSystemInfo(ctx *middleware.Context, handler GetSystemInfoHandler) *GetSystemInfo { + return &GetSystemInfo{Context: ctx, Handler: handler} +} + +/*GetSystemInfo swagger:route GET /systeminfo systeminfo getSystemInfo + +Get general system info + +This API is for retrieving general system info, this can be called by anonymous request. Some attributes will be omitted in the response when this API is called by anonymous request. + + +*/ +type GetSystemInfo struct { + Context *middleware.Context + Handler GetSystemInfoHandler +} + +func (o *GetSystemInfo) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetSystemInfoParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/systeminfo/get_system_info_parameters.go b/src/server/v2.0/restapi/operations/systeminfo/get_system_info_parameters.go new file mode 100644 index 000000000..349fcded3 --- /dev/null +++ b/src/server/v2.0/restapi/operations/systeminfo/get_system_info_parameters.go @@ -0,0 +1,89 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package systeminfo + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewGetSystemInfoParams creates a new GetSystemInfoParams object +// no default values defined in spec. +func NewGetSystemInfoParams() GetSystemInfoParams { + + return GetSystemInfoParams{} +} + +// GetSystemInfoParams contains all the bound params for the get system info operation +// typically these are obtained from a http.Request +// +// swagger:parameters getSystemInfo +type GetSystemInfoParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetSystemInfoParams() beforehand. +func (o *GetSystemInfoParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetSystemInfoParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetSystemInfoParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} diff --git a/src/server/v2.0/restapi/operations/systeminfo/get_system_info_responses.go b/src/server/v2.0/restapi/operations/systeminfo/get_system_info_responses.go new file mode 100644 index 000000000..2c604db03 --- /dev/null +++ b/src/server/v2.0/restapi/operations/systeminfo/get_system_info_responses.go @@ -0,0 +1,124 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package systeminfo + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetSystemInfoOKCode is the HTTP code returned for type GetSystemInfoOK +const GetSystemInfoOKCode int = 200 + +/*GetSystemInfoOK Get general info successfully. + +swagger:response getSystemInfoOK +*/ +type GetSystemInfoOK struct { + + /* + In: Body + */ + Payload *models.GeneralInfo `json:"body,omitempty"` +} + +// NewGetSystemInfoOK creates GetSystemInfoOK with default headers values +func NewGetSystemInfoOK() *GetSystemInfoOK { + + return &GetSystemInfoOK{} +} + +// WithPayload adds the payload to the get system info o k response +func (o *GetSystemInfoOK) WithPayload(payload *models.GeneralInfo) *GetSystemInfoOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get system info o k response +func (o *GetSystemInfoOK) SetPayload(payload *models.GeneralInfo) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetSystemInfoOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetSystemInfoInternalServerErrorCode is the HTTP code returned for type GetSystemInfoInternalServerError +const GetSystemInfoInternalServerErrorCode int = 500 + +/*GetSystemInfoInternalServerError Internal server error + +swagger:response getSystemInfoInternalServerError +*/ +type GetSystemInfoInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetSystemInfoInternalServerError creates GetSystemInfoInternalServerError with default headers values +func NewGetSystemInfoInternalServerError() *GetSystemInfoInternalServerError { + + return &GetSystemInfoInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get system info internal server error response +func (o *GetSystemInfoInternalServerError) WithXRequestID(xRequestID string) *GetSystemInfoInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get system info internal server error response +func (o *GetSystemInfoInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get system info internal server error response +func (o *GetSystemInfoInternalServerError) WithPayload(payload *models.Errors) *GetSystemInfoInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get system info internal server error response +func (o *GetSystemInfoInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetSystemInfoInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/systeminfo/get_system_info_urlbuilder.go b/src/server/v2.0/restapi/operations/systeminfo/get_system_info_urlbuilder.go new file mode 100644 index 000000000..bce4930b9 --- /dev/null +++ b/src/server/v2.0/restapi/operations/systeminfo/get_system_info_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package systeminfo + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetSystemInfoURL generates an URL for the get system info operation +type GetSystemInfoURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetSystemInfoURL) WithBasePath(bp string) *GetSystemInfoURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetSystemInfoURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetSystemInfoURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/systeminfo" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetSystemInfoURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetSystemInfoURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetSystemInfoURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetSystemInfoURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetSystemInfoURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetSystemInfoURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/systeminfo/get_volumes.go b/src/server/v2.0/restapi/operations/systeminfo/get_volumes.go new file mode 100644 index 000000000..0b21966d8 --- /dev/null +++ b/src/server/v2.0/restapi/operations/systeminfo/get_volumes.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package systeminfo + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetVolumesHandlerFunc turns a function with the right signature into a get volumes handler +type GetVolumesHandlerFunc func(GetVolumesParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetVolumesHandlerFunc) Handle(params GetVolumesParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetVolumesHandler interface for that can handle valid get volumes params +type GetVolumesHandler interface { + Handle(GetVolumesParams, interface{}) middleware.Responder +} + +// NewGetVolumes creates a new http.Handler for the get volumes operation +func NewGetVolumes(ctx *middleware.Context, handler GetVolumesHandler) *GetVolumes { + return &GetVolumes{Context: ctx, Handler: handler} +} + +/*GetVolumes swagger:route GET /systeminfo/volumes systeminfo getVolumes + +Get system volume info (total/free size). + +This endpoint is for retrieving system volume info that only provides for admin user. Note that the response only reflects the storage status of local disk. + + +*/ +type GetVolumes struct { + Context *middleware.Context + Handler GetVolumesHandler +} + +func (o *GetVolumes) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetVolumesParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/systeminfo/get_volumes_parameters.go b/src/server/v2.0/restapi/operations/systeminfo/get_volumes_parameters.go new file mode 100644 index 000000000..4454f8b00 --- /dev/null +++ b/src/server/v2.0/restapi/operations/systeminfo/get_volumes_parameters.go @@ -0,0 +1,89 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package systeminfo + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewGetVolumesParams creates a new GetVolumesParams object +// no default values defined in spec. +func NewGetVolumesParams() GetVolumesParams { + + return GetVolumesParams{} +} + +// GetVolumesParams contains all the bound params for the get volumes operation +// typically these are obtained from a http.Request +// +// swagger:parameters getVolumes +type GetVolumesParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetVolumesParams() beforehand. +func (o *GetVolumesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetVolumesParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetVolumesParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} diff --git a/src/server/v2.0/restapi/operations/systeminfo/get_volumes_responses.go b/src/server/v2.0/restapi/operations/systeminfo/get_volumes_responses.go new file mode 100644 index 000000000..1b3e1790e --- /dev/null +++ b/src/server/v2.0/restapi/operations/systeminfo/get_volumes_responses.go @@ -0,0 +1,322 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package systeminfo + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetVolumesOKCode is the HTTP code returned for type GetVolumesOK +const GetVolumesOKCode int = 200 + +/*GetVolumesOK Get system volumes successfully. + +swagger:response getVolumesOK +*/ +type GetVolumesOK struct { + + /* + In: Body + */ + Payload *models.SystemInfo `json:"body,omitempty"` +} + +// NewGetVolumesOK creates GetVolumesOK with default headers values +func NewGetVolumesOK() *GetVolumesOK { + + return &GetVolumesOK{} +} + +// WithPayload adds the payload to the get volumes o k response +func (o *GetVolumesOK) WithPayload(payload *models.SystemInfo) *GetVolumesOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get volumes o k response +func (o *GetVolumesOK) SetPayload(payload *models.SystemInfo) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetVolumesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetVolumesUnauthorizedCode is the HTTP code returned for type GetVolumesUnauthorized +const GetVolumesUnauthorizedCode int = 401 + +/*GetVolumesUnauthorized Unauthorized + +swagger:response getVolumesUnauthorized +*/ +type GetVolumesUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetVolumesUnauthorized creates GetVolumesUnauthorized with default headers values +func NewGetVolumesUnauthorized() *GetVolumesUnauthorized { + + return &GetVolumesUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the get volumes unauthorized response +func (o *GetVolumesUnauthorized) WithXRequestID(xRequestID string) *GetVolumesUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get volumes unauthorized response +func (o *GetVolumesUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get volumes unauthorized response +func (o *GetVolumesUnauthorized) WithPayload(payload *models.Errors) *GetVolumesUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get volumes unauthorized response +func (o *GetVolumesUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetVolumesUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetVolumesForbiddenCode is the HTTP code returned for type GetVolumesForbidden +const GetVolumesForbiddenCode int = 403 + +/*GetVolumesForbidden Forbidden + +swagger:response getVolumesForbidden +*/ +type GetVolumesForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetVolumesForbidden creates GetVolumesForbidden with default headers values +func NewGetVolumesForbidden() *GetVolumesForbidden { + + return &GetVolumesForbidden{} +} + +// WithXRequestID adds the xRequestId to the get volumes forbidden response +func (o *GetVolumesForbidden) WithXRequestID(xRequestID string) *GetVolumesForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get volumes forbidden response +func (o *GetVolumesForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get volumes forbidden response +func (o *GetVolumesForbidden) WithPayload(payload *models.Errors) *GetVolumesForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get volumes forbidden response +func (o *GetVolumesForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetVolumesForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetVolumesNotFoundCode is the HTTP code returned for type GetVolumesNotFound +const GetVolumesNotFoundCode int = 404 + +/*GetVolumesNotFound Not found + +swagger:response getVolumesNotFound +*/ +type GetVolumesNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetVolumesNotFound creates GetVolumesNotFound with default headers values +func NewGetVolumesNotFound() *GetVolumesNotFound { + + return &GetVolumesNotFound{} +} + +// WithXRequestID adds the xRequestId to the get volumes not found response +func (o *GetVolumesNotFound) WithXRequestID(xRequestID string) *GetVolumesNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get volumes not found response +func (o *GetVolumesNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get volumes not found response +func (o *GetVolumesNotFound) WithPayload(payload *models.Errors) *GetVolumesNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get volumes not found response +func (o *GetVolumesNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetVolumesNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetVolumesInternalServerErrorCode is the HTTP code returned for type GetVolumesInternalServerError +const GetVolumesInternalServerErrorCode int = 500 + +/*GetVolumesInternalServerError Internal server error + +swagger:response getVolumesInternalServerError +*/ +type GetVolumesInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetVolumesInternalServerError creates GetVolumesInternalServerError with default headers values +func NewGetVolumesInternalServerError() *GetVolumesInternalServerError { + + return &GetVolumesInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get volumes internal server error response +func (o *GetVolumesInternalServerError) WithXRequestID(xRequestID string) *GetVolumesInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get volumes internal server error response +func (o *GetVolumesInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get volumes internal server error response +func (o *GetVolumesInternalServerError) WithPayload(payload *models.Errors) *GetVolumesInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get volumes internal server error response +func (o *GetVolumesInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetVolumesInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/systeminfo/get_volumes_urlbuilder.go b/src/server/v2.0/restapi/operations/systeminfo/get_volumes_urlbuilder.go new file mode 100644 index 000000000..b1b64ec40 --- /dev/null +++ b/src/server/v2.0/restapi/operations/systeminfo/get_volumes_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package systeminfo + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetVolumesURL generates an URL for the get volumes operation +type GetVolumesURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetVolumesURL) WithBasePath(bp string) *GetVolumesURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetVolumesURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetVolumesURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/systeminfo/volumes" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetVolumesURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetVolumesURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetVolumesURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetVolumesURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetVolumesURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetVolumesURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/user/create_user.go b/src/server/v2.0/restapi/operations/user/create_user.go new file mode 100644 index 000000000..52e704251 --- /dev/null +++ b/src/server/v2.0/restapi/operations/user/create_user.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateUserHandlerFunc turns a function with the right signature into a create user handler +type CreateUserHandlerFunc func(CreateUserParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateUserHandlerFunc) Handle(params CreateUserParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateUserHandler interface for that can handle valid create user params +type CreateUserHandler interface { + Handle(CreateUserParams, interface{}) middleware.Responder +} + +// NewCreateUser creates a new http.Handler for the create user operation +func NewCreateUser(ctx *middleware.Context, handler CreateUserHandler) *CreateUser { + return &CreateUser{Context: ctx, Handler: handler} +} + +/*CreateUser swagger:route POST /users user createUser + +Create a local user. + +This API can be used only when the authentication mode is for local DB. When self registration is disabled. + +*/ +type CreateUser struct { + Context *middleware.Context + Handler CreateUserHandler +} + +func (o *CreateUser) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewCreateUserParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/user/create_user_parameters.go b/src/server/v2.0/restapi/operations/user/create_user_parameters.go new file mode 100644 index 000000000..1b12869ac --- /dev/null +++ b/src/server/v2.0/restapi/operations/user/create_user_parameters.go @@ -0,0 +1,120 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewCreateUserParams creates a new CreateUserParams object +// no default values defined in spec. +func NewCreateUserParams() CreateUserParams { + + return CreateUserParams{} +} + +// CreateUserParams contains all the bound params for the create user operation +// typically these are obtained from a http.Request +// +// swagger:parameters createUser +type CreateUserParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The new user + Required: true + In: body + */ + UserReq *models.UserCreationReq +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateUserParams() beforehand. +func (o *CreateUserParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.UserCreationReq + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("userReq", "body", "")) + } else { + res = append(res, errors.NewParseError("userReq", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.UserReq = &body + } + } + } else { + res = append(res, errors.Required("userReq", "body", "")) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *CreateUserParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *CreateUserParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} diff --git a/src/server/v2.0/restapi/operations/user/create_user_responses.go b/src/server/v2.0/restapi/operations/user/create_user_responses.go new file mode 100644 index 000000000..7ca6a19f9 --- /dev/null +++ b/src/server/v2.0/restapi/operations/user/create_user_responses.go @@ -0,0 +1,370 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// CreateUserCreatedCode is the HTTP code returned for type CreateUserCreated +const CreateUserCreatedCode int = 201 + +/*CreateUserCreated Created + +swagger:response createUserCreated +*/ +type CreateUserCreated struct { + /*The location of the resource + + */ + Location string `json:"Location"` + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewCreateUserCreated creates CreateUserCreated with default headers values +func NewCreateUserCreated() *CreateUserCreated { + + return &CreateUserCreated{} +} + +// WithLocation adds the location to the create user created response +func (o *CreateUserCreated) WithLocation(location string) *CreateUserCreated { + o.Location = location + return o +} + +// SetLocation sets the location to the create user created response +func (o *CreateUserCreated) SetLocation(location string) { + o.Location = location +} + +// WithXRequestID adds the xRequestId to the create user created response +func (o *CreateUserCreated) WithXRequestID(xRequestID string) *CreateUserCreated { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create user created response +func (o *CreateUserCreated) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *CreateUserCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Location + + location := o.Location + if location != "" { + rw.Header().Set("Location", location) + } + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(201) +} + +// CreateUserBadRequestCode is the HTTP code returned for type CreateUserBadRequest +const CreateUserBadRequestCode int = 400 + +/*CreateUserBadRequest Bad request + +swagger:response createUserBadRequest +*/ +type CreateUserBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateUserBadRequest creates CreateUserBadRequest with default headers values +func NewCreateUserBadRequest() *CreateUserBadRequest { + + return &CreateUserBadRequest{} +} + +// WithXRequestID adds the xRequestId to the create user bad request response +func (o *CreateUserBadRequest) WithXRequestID(xRequestID string) *CreateUserBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create user bad request response +func (o *CreateUserBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create user bad request response +func (o *CreateUserBadRequest) WithPayload(payload *models.Errors) *CreateUserBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create user bad request response +func (o *CreateUserBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateUserBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateUserUnauthorizedCode is the HTTP code returned for type CreateUserUnauthorized +const CreateUserUnauthorizedCode int = 401 + +/*CreateUserUnauthorized Unauthorized + +swagger:response createUserUnauthorized +*/ +type CreateUserUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateUserUnauthorized creates CreateUserUnauthorized with default headers values +func NewCreateUserUnauthorized() *CreateUserUnauthorized { + + return &CreateUserUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the create user unauthorized response +func (o *CreateUserUnauthorized) WithXRequestID(xRequestID string) *CreateUserUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create user unauthorized response +func (o *CreateUserUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create user unauthorized response +func (o *CreateUserUnauthorized) WithPayload(payload *models.Errors) *CreateUserUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create user unauthorized response +func (o *CreateUserUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateUserUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateUserForbiddenCode is the HTTP code returned for type CreateUserForbidden +const CreateUserForbiddenCode int = 403 + +/*CreateUserForbidden When the self registration is disabled, non-admin does not have permission to create user. When self registration is enabled, this API can only be called from UI portal, calling it via script will get a 403 error. + +swagger:response createUserForbidden +*/ +type CreateUserForbidden struct { +} + +// NewCreateUserForbidden creates CreateUserForbidden with default headers values +func NewCreateUserForbidden() *CreateUserForbidden { + + return &CreateUserForbidden{} +} + +// WriteResponse to the client +func (o *CreateUserForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(403) +} + +// CreateUserConflictCode is the HTTP code returned for type CreateUserConflict +const CreateUserConflictCode int = 409 + +/*CreateUserConflict Conflict + +swagger:response createUserConflict +*/ +type CreateUserConflict struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateUserConflict creates CreateUserConflict with default headers values +func NewCreateUserConflict() *CreateUserConflict { + + return &CreateUserConflict{} +} + +// WithXRequestID adds the xRequestId to the create user conflict response +func (o *CreateUserConflict) WithXRequestID(xRequestID string) *CreateUserConflict { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create user conflict response +func (o *CreateUserConflict) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create user conflict response +func (o *CreateUserConflict) WithPayload(payload *models.Errors) *CreateUserConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create user conflict response +func (o *CreateUserConflict) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateUserConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateUserInternalServerErrorCode is the HTTP code returned for type CreateUserInternalServerError +const CreateUserInternalServerErrorCode int = 500 + +/*CreateUserInternalServerError Internal server error + +swagger:response createUserInternalServerError +*/ +type CreateUserInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateUserInternalServerError creates CreateUserInternalServerError with default headers values +func NewCreateUserInternalServerError() *CreateUserInternalServerError { + + return &CreateUserInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the create user internal server error response +func (o *CreateUserInternalServerError) WithXRequestID(xRequestID string) *CreateUserInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create user internal server error response +func (o *CreateUserInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create user internal server error response +func (o *CreateUserInternalServerError) WithPayload(payload *models.Errors) *CreateUserInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create user internal server error response +func (o *CreateUserInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateUserInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/user/create_user_urlbuilder.go b/src/server/v2.0/restapi/operations/user/create_user_urlbuilder.go new file mode 100644 index 000000000..dbf26fa85 --- /dev/null +++ b/src/server/v2.0/restapi/operations/user/create_user_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// CreateUserURL generates an URL for the create user operation +type CreateUserURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateUserURL) WithBasePath(bp string) *CreateUserURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateUserURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateUserURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/users" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateUserURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateUserURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateUserURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateUserURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateUserURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateUserURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/user/delete_user.go b/src/server/v2.0/restapi/operations/user/delete_user.go new file mode 100644 index 000000000..5ffe518e8 --- /dev/null +++ b/src/server/v2.0/restapi/operations/user/delete_user.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteUserHandlerFunc turns a function with the right signature into a delete user handler +type DeleteUserHandlerFunc func(DeleteUserParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteUserHandlerFunc) Handle(params DeleteUserParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteUserHandler interface for that can handle valid delete user params +type DeleteUserHandler interface { + Handle(DeleteUserParams, interface{}) middleware.Responder +} + +// NewDeleteUser creates a new http.Handler for the delete user operation +func NewDeleteUser(ctx *middleware.Context, handler DeleteUserHandler) *DeleteUser { + return &DeleteUser{Context: ctx, Handler: handler} +} + +/*DeleteUser swagger:route DELETE /users/{user_id} user deleteUser + +Mark a registered user as be removed. + +This endpoint let administrator of Harbor mark a registered user as removed.It actually won't be deleted from DB. + + +*/ +type DeleteUser struct { + Context *middleware.Context + Handler DeleteUserHandler +} + +func (o *DeleteUser) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewDeleteUserParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/user/delete_user_parameters.go b/src/server/v2.0/restapi/operations/user/delete_user_parameters.go new file mode 100644 index 000000000..2e3817c19 --- /dev/null +++ b/src/server/v2.0/restapi/operations/user/delete_user_parameters.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewDeleteUserParams creates a new DeleteUserParams object +// no default values defined in spec. +func NewDeleteUserParams() DeleteUserParams { + + return DeleteUserParams{} +} + +// DeleteUserParams contains all the bound params for the delete user operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteUser +type DeleteUserParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*User ID for marking as to be removed. + Required: true + In: path + */ + UserID int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteUserParams() beforehand. +func (o *DeleteUserParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rUserID, rhkUserID, _ := route.Params.GetOK("user_id") + if err := o.bindUserID(rUserID, rhkUserID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *DeleteUserParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *DeleteUserParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindUserID binds and validates parameter UserID from path. +func (o *DeleteUserParams) bindUserID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("user_id", "path", "int64", raw) + } + o.UserID = value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/user/delete_user_responses.go b/src/server/v2.0/restapi/operations/user/delete_user_responses.go new file mode 100644 index 000000000..e67e1371d --- /dev/null +++ b/src/server/v2.0/restapi/operations/user/delete_user_responses.go @@ -0,0 +1,324 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// DeleteUserOKCode is the HTTP code returned for type DeleteUserOK +const DeleteUserOKCode int = 200 + +/*DeleteUserOK Success + +swagger:response deleteUserOK +*/ +type DeleteUserOK struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewDeleteUserOK creates DeleteUserOK with default headers values +func NewDeleteUserOK() *DeleteUserOK { + + return &DeleteUserOK{} +} + +// WithXRequestID adds the xRequestId to the delete user o k response +func (o *DeleteUserOK) WithXRequestID(xRequestID string) *DeleteUserOK { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete user o k response +func (o *DeleteUserOK) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *DeleteUserOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// DeleteUserUnauthorizedCode is the HTTP code returned for type DeleteUserUnauthorized +const DeleteUserUnauthorizedCode int = 401 + +/*DeleteUserUnauthorized Unauthorized + +swagger:response deleteUserUnauthorized +*/ +type DeleteUserUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteUserUnauthorized creates DeleteUserUnauthorized with default headers values +func NewDeleteUserUnauthorized() *DeleteUserUnauthorized { + + return &DeleteUserUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the delete user unauthorized response +func (o *DeleteUserUnauthorized) WithXRequestID(xRequestID string) *DeleteUserUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete user unauthorized response +func (o *DeleteUserUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete user unauthorized response +func (o *DeleteUserUnauthorized) WithPayload(payload *models.Errors) *DeleteUserUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete user unauthorized response +func (o *DeleteUserUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteUserUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteUserForbiddenCode is the HTTP code returned for type DeleteUserForbidden +const DeleteUserForbiddenCode int = 403 + +/*DeleteUserForbidden Forbidden + +swagger:response deleteUserForbidden +*/ +type DeleteUserForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteUserForbidden creates DeleteUserForbidden with default headers values +func NewDeleteUserForbidden() *DeleteUserForbidden { + + return &DeleteUserForbidden{} +} + +// WithXRequestID adds the xRequestId to the delete user forbidden response +func (o *DeleteUserForbidden) WithXRequestID(xRequestID string) *DeleteUserForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete user forbidden response +func (o *DeleteUserForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete user forbidden response +func (o *DeleteUserForbidden) WithPayload(payload *models.Errors) *DeleteUserForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete user forbidden response +func (o *DeleteUserForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteUserForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteUserNotFoundCode is the HTTP code returned for type DeleteUserNotFound +const DeleteUserNotFoundCode int = 404 + +/*DeleteUserNotFound Not found + +swagger:response deleteUserNotFound +*/ +type DeleteUserNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteUserNotFound creates DeleteUserNotFound with default headers values +func NewDeleteUserNotFound() *DeleteUserNotFound { + + return &DeleteUserNotFound{} +} + +// WithXRequestID adds the xRequestId to the delete user not found response +func (o *DeleteUserNotFound) WithXRequestID(xRequestID string) *DeleteUserNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete user not found response +func (o *DeleteUserNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete user not found response +func (o *DeleteUserNotFound) WithPayload(payload *models.Errors) *DeleteUserNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete user not found response +func (o *DeleteUserNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteUserNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteUserInternalServerErrorCode is the HTTP code returned for type DeleteUserInternalServerError +const DeleteUserInternalServerErrorCode int = 500 + +/*DeleteUserInternalServerError Internal server error + +swagger:response deleteUserInternalServerError +*/ +type DeleteUserInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteUserInternalServerError creates DeleteUserInternalServerError with default headers values +func NewDeleteUserInternalServerError() *DeleteUserInternalServerError { + + return &DeleteUserInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the delete user internal server error response +func (o *DeleteUserInternalServerError) WithXRequestID(xRequestID string) *DeleteUserInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete user internal server error response +func (o *DeleteUserInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete user internal server error response +func (o *DeleteUserInternalServerError) WithPayload(payload *models.Errors) *DeleteUserInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete user internal server error response +func (o *DeleteUserInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteUserInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/user/delete_user_urlbuilder.go b/src/server/v2.0/restapi/operations/user/delete_user_urlbuilder.go new file mode 100644 index 000000000..92f683fd4 --- /dev/null +++ b/src/server/v2.0/restapi/operations/user/delete_user_urlbuilder.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteUserURL generates an URL for the delete user operation +type DeleteUserURL struct { + UserID int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteUserURL) WithBasePath(bp string) *DeleteUserURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteUserURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteUserURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/users/{user_id}" + + userID := swag.FormatInt64(o.UserID) + if userID != "" { + _path = strings.Replace(_path, "{user_id}", userID, -1) + } else { + return nil, errors.New("userId is required on DeleteUserURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteUserURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteUserURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteUserURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteUserURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteUserURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteUserURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/user/get_current_user_info.go b/src/server/v2.0/restapi/operations/user/get_current_user_info.go new file mode 100644 index 000000000..416e8a81b --- /dev/null +++ b/src/server/v2.0/restapi/operations/user/get_current_user_info.go @@ -0,0 +1,71 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetCurrentUserInfoHandlerFunc turns a function with the right signature into a get current user info handler +type GetCurrentUserInfoHandlerFunc func(GetCurrentUserInfoParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetCurrentUserInfoHandlerFunc) Handle(params GetCurrentUserInfoParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetCurrentUserInfoHandler interface for that can handle valid get current user info params +type GetCurrentUserInfoHandler interface { + Handle(GetCurrentUserInfoParams, interface{}) middleware.Responder +} + +// NewGetCurrentUserInfo creates a new http.Handler for the get current user info operation +func NewGetCurrentUserInfo(ctx *middleware.Context, handler GetCurrentUserInfoHandler) *GetCurrentUserInfo { + return &GetCurrentUserInfo{Context: ctx, Handler: handler} +} + +/*GetCurrentUserInfo swagger:route GET /users/current user getCurrentUserInfo + +Get current user info. + +*/ +type GetCurrentUserInfo struct { + Context *middleware.Context + Handler GetCurrentUserInfoHandler +} + +func (o *GetCurrentUserInfo) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetCurrentUserInfoParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/user/get_current_user_info_parameters.go b/src/server/v2.0/restapi/operations/user/get_current_user_info_parameters.go new file mode 100644 index 000000000..433e0d003 --- /dev/null +++ b/src/server/v2.0/restapi/operations/user/get_current_user_info_parameters.go @@ -0,0 +1,89 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewGetCurrentUserInfoParams creates a new GetCurrentUserInfoParams object +// no default values defined in spec. +func NewGetCurrentUserInfoParams() GetCurrentUserInfoParams { + + return GetCurrentUserInfoParams{} +} + +// GetCurrentUserInfoParams contains all the bound params for the get current user info operation +// typically these are obtained from a http.Request +// +// swagger:parameters getCurrentUserInfo +type GetCurrentUserInfoParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetCurrentUserInfoParams() beforehand. +func (o *GetCurrentUserInfoParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetCurrentUserInfoParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetCurrentUserInfoParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} diff --git a/src/server/v2.0/restapi/operations/user/get_current_user_info_responses.go b/src/server/v2.0/restapi/operations/user/get_current_user_info_responses.go new file mode 100644 index 000000000..2a4137b44 --- /dev/null +++ b/src/server/v2.0/restapi/operations/user/get_current_user_info_responses.go @@ -0,0 +1,190 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetCurrentUserInfoOKCode is the HTTP code returned for type GetCurrentUserInfoOK +const GetCurrentUserInfoOKCode int = 200 + +/*GetCurrentUserInfoOK Get current user information successfully. + +swagger:response getCurrentUserInfoOK +*/ +type GetCurrentUserInfoOK struct { + + /* + In: Body + */ + Payload *models.UserResp `json:"body,omitempty"` +} + +// NewGetCurrentUserInfoOK creates GetCurrentUserInfoOK with default headers values +func NewGetCurrentUserInfoOK() *GetCurrentUserInfoOK { + + return &GetCurrentUserInfoOK{} +} + +// WithPayload adds the payload to the get current user info o k response +func (o *GetCurrentUserInfoOK) WithPayload(payload *models.UserResp) *GetCurrentUserInfoOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get current user info o k response +func (o *GetCurrentUserInfoOK) SetPayload(payload *models.UserResp) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetCurrentUserInfoOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetCurrentUserInfoUnauthorizedCode is the HTTP code returned for type GetCurrentUserInfoUnauthorized +const GetCurrentUserInfoUnauthorizedCode int = 401 + +/*GetCurrentUserInfoUnauthorized Unauthorized + +swagger:response getCurrentUserInfoUnauthorized +*/ +type GetCurrentUserInfoUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetCurrentUserInfoUnauthorized creates GetCurrentUserInfoUnauthorized with default headers values +func NewGetCurrentUserInfoUnauthorized() *GetCurrentUserInfoUnauthorized { + + return &GetCurrentUserInfoUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the get current user info unauthorized response +func (o *GetCurrentUserInfoUnauthorized) WithXRequestID(xRequestID string) *GetCurrentUserInfoUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get current user info unauthorized response +func (o *GetCurrentUserInfoUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get current user info unauthorized response +func (o *GetCurrentUserInfoUnauthorized) WithPayload(payload *models.Errors) *GetCurrentUserInfoUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get current user info unauthorized response +func (o *GetCurrentUserInfoUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetCurrentUserInfoUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetCurrentUserInfoInternalServerErrorCode is the HTTP code returned for type GetCurrentUserInfoInternalServerError +const GetCurrentUserInfoInternalServerErrorCode int = 500 + +/*GetCurrentUserInfoInternalServerError Internal server error + +swagger:response getCurrentUserInfoInternalServerError +*/ +type GetCurrentUserInfoInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetCurrentUserInfoInternalServerError creates GetCurrentUserInfoInternalServerError with default headers values +func NewGetCurrentUserInfoInternalServerError() *GetCurrentUserInfoInternalServerError { + + return &GetCurrentUserInfoInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get current user info internal server error response +func (o *GetCurrentUserInfoInternalServerError) WithXRequestID(xRequestID string) *GetCurrentUserInfoInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get current user info internal server error response +func (o *GetCurrentUserInfoInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get current user info internal server error response +func (o *GetCurrentUserInfoInternalServerError) WithPayload(payload *models.Errors) *GetCurrentUserInfoInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get current user info internal server error response +func (o *GetCurrentUserInfoInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetCurrentUserInfoInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/user/get_current_user_info_urlbuilder.go b/src/server/v2.0/restapi/operations/user/get_current_user_info_urlbuilder.go new file mode 100644 index 000000000..31dc5cb2a --- /dev/null +++ b/src/server/v2.0/restapi/operations/user/get_current_user_info_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetCurrentUserInfoURL generates an URL for the get current user info operation +type GetCurrentUserInfoURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetCurrentUserInfoURL) WithBasePath(bp string) *GetCurrentUserInfoURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetCurrentUserInfoURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetCurrentUserInfoURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/users/current" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetCurrentUserInfoURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetCurrentUserInfoURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetCurrentUserInfoURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetCurrentUserInfoURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetCurrentUserInfoURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetCurrentUserInfoURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/user/get_current_user_permissions.go b/src/server/v2.0/restapi/operations/user/get_current_user_permissions.go new file mode 100644 index 000000000..17899d0c8 --- /dev/null +++ b/src/server/v2.0/restapi/operations/user/get_current_user_permissions.go @@ -0,0 +1,71 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetCurrentUserPermissionsHandlerFunc turns a function with the right signature into a get current user permissions handler +type GetCurrentUserPermissionsHandlerFunc func(GetCurrentUserPermissionsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetCurrentUserPermissionsHandlerFunc) Handle(params GetCurrentUserPermissionsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetCurrentUserPermissionsHandler interface for that can handle valid get current user permissions params +type GetCurrentUserPermissionsHandler interface { + Handle(GetCurrentUserPermissionsParams, interface{}) middleware.Responder +} + +// NewGetCurrentUserPermissions creates a new http.Handler for the get current user permissions operation +func NewGetCurrentUserPermissions(ctx *middleware.Context, handler GetCurrentUserPermissionsHandler) *GetCurrentUserPermissions { + return &GetCurrentUserPermissions{Context: ctx, Handler: handler} +} + +/*GetCurrentUserPermissions swagger:route GET /users/current/permissions user getCurrentUserPermissions + +Get current user permissions. + +*/ +type GetCurrentUserPermissions struct { + Context *middleware.Context + Handler GetCurrentUserPermissionsHandler +} + +func (o *GetCurrentUserPermissions) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetCurrentUserPermissionsParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/user/get_current_user_permissions_parameters.go b/src/server/v2.0/restapi/operations/user/get_current_user_permissions_parameters.go new file mode 100644 index 000000000..e6f486714 --- /dev/null +++ b/src/server/v2.0/restapi/operations/user/get_current_user_permissions_parameters.go @@ -0,0 +1,153 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewGetCurrentUserPermissionsParams creates a new GetCurrentUserPermissionsParams object +// no default values defined in spec. +func NewGetCurrentUserPermissionsParams() GetCurrentUserPermissionsParams { + + return GetCurrentUserPermissionsParams{} +} + +// GetCurrentUserPermissionsParams contains all the bound params for the get current user permissions operation +// typically these are obtained from a http.Request +// +// swagger:parameters getCurrentUserPermissions +type GetCurrentUserPermissionsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*If true, the resources in the response are relative to the scope, + eg for resource '/project/1/repository' if relative is 'true' then the resource in response will be 'repository'. + + In: query + */ + Relative *bool + /*The scope for the permission + In: query + */ + Scope *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetCurrentUserPermissionsParams() beforehand. +func (o *GetCurrentUserPermissionsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + qRelative, qhkRelative, _ := qs.GetOK("relative") + if err := o.bindRelative(qRelative, qhkRelative, route.Formats); err != nil { + res = append(res, err) + } + + qScope, qhkScope, _ := qs.GetOK("scope") + if err := o.bindScope(qScope, qhkScope, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetCurrentUserPermissionsParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetCurrentUserPermissionsParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindRelative binds and validates parameter Relative from query. +func (o *GetCurrentUserPermissionsParams) bindRelative(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("relative", "query", "bool", raw) + } + o.Relative = &value + + return nil +} + +// bindScope binds and validates parameter Scope from query. +func (o *GetCurrentUserPermissionsParams) bindScope(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Scope = &raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/user/get_current_user_permissions_responses.go b/src/server/v2.0/restapi/operations/user/get_current_user_permissions_responses.go new file mode 100644 index 000000000..4df771511 --- /dev/null +++ b/src/server/v2.0/restapi/operations/user/get_current_user_permissions_responses.go @@ -0,0 +1,109 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetCurrentUserPermissionsOKCode is the HTTP code returned for type GetCurrentUserPermissionsOK +const GetCurrentUserPermissionsOKCode int = 200 + +/*GetCurrentUserPermissionsOK Get current user permission successfully. + +swagger:response getCurrentUserPermissionsOK +*/ +type GetCurrentUserPermissionsOK struct { + + /* + In: Body + */ + Payload []*models.Permission `json:"body,omitempty"` +} + +// NewGetCurrentUserPermissionsOK creates GetCurrentUserPermissionsOK with default headers values +func NewGetCurrentUserPermissionsOK() *GetCurrentUserPermissionsOK { + + return &GetCurrentUserPermissionsOK{} +} + +// WithPayload adds the payload to the get current user permissions o k response +func (o *GetCurrentUserPermissionsOK) WithPayload(payload []*models.Permission) *GetCurrentUserPermissionsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get current user permissions o k response +func (o *GetCurrentUserPermissionsOK) SetPayload(payload []*models.Permission) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetCurrentUserPermissionsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = make([]*models.Permission, 0, 50) + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// GetCurrentUserPermissionsUnauthorizedCode is the HTTP code returned for type GetCurrentUserPermissionsUnauthorized +const GetCurrentUserPermissionsUnauthorizedCode int = 401 + +/*GetCurrentUserPermissionsUnauthorized User need to log in first. + +swagger:response getCurrentUserPermissionsUnauthorized +*/ +type GetCurrentUserPermissionsUnauthorized struct { +} + +// NewGetCurrentUserPermissionsUnauthorized creates GetCurrentUserPermissionsUnauthorized with default headers values +func NewGetCurrentUserPermissionsUnauthorized() *GetCurrentUserPermissionsUnauthorized { + + return &GetCurrentUserPermissionsUnauthorized{} +} + +// WriteResponse to the client +func (o *GetCurrentUserPermissionsUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(401) +} + +// GetCurrentUserPermissionsInternalServerErrorCode is the HTTP code returned for type GetCurrentUserPermissionsInternalServerError +const GetCurrentUserPermissionsInternalServerErrorCode int = 500 + +/*GetCurrentUserPermissionsInternalServerError Internal errors. + +swagger:response getCurrentUserPermissionsInternalServerError +*/ +type GetCurrentUserPermissionsInternalServerError struct { +} + +// NewGetCurrentUserPermissionsInternalServerError creates GetCurrentUserPermissionsInternalServerError with default headers values +func NewGetCurrentUserPermissionsInternalServerError() *GetCurrentUserPermissionsInternalServerError { + + return &GetCurrentUserPermissionsInternalServerError{} +} + +// WriteResponse to the client +func (o *GetCurrentUserPermissionsInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(500) +} diff --git a/src/server/v2.0/restapi/operations/user/get_current_user_permissions_urlbuilder.go b/src/server/v2.0/restapi/operations/user/get_current_user_permissions_urlbuilder.go new file mode 100644 index 000000000..cfff59854 --- /dev/null +++ b/src/server/v2.0/restapi/operations/user/get_current_user_permissions_urlbuilder.go @@ -0,0 +1,114 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// GetCurrentUserPermissionsURL generates an URL for the get current user permissions operation +type GetCurrentUserPermissionsURL struct { + Relative *bool + Scope *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetCurrentUserPermissionsURL) WithBasePath(bp string) *GetCurrentUserPermissionsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetCurrentUserPermissionsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetCurrentUserPermissionsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/users/current/permissions" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var relativeQ string + if o.Relative != nil { + relativeQ = swag.FormatBool(*o.Relative) + } + if relativeQ != "" { + qs.Set("relative", relativeQ) + } + + var scopeQ string + if o.Scope != nil { + scopeQ = *o.Scope + } + if scopeQ != "" { + qs.Set("scope", scopeQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetCurrentUserPermissionsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetCurrentUserPermissionsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetCurrentUserPermissionsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetCurrentUserPermissionsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetCurrentUserPermissionsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetCurrentUserPermissionsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/user/get_user.go b/src/server/v2.0/restapi/operations/user/get_user.go new file mode 100644 index 000000000..b3aaea9b6 --- /dev/null +++ b/src/server/v2.0/restapi/operations/user/get_user.go @@ -0,0 +1,71 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetUserHandlerFunc turns a function with the right signature into a get user handler +type GetUserHandlerFunc func(GetUserParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetUserHandlerFunc) Handle(params GetUserParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetUserHandler interface for that can handle valid get user params +type GetUserHandler interface { + Handle(GetUserParams, interface{}) middleware.Responder +} + +// NewGetUser creates a new http.Handler for the get user operation +func NewGetUser(ctx *middleware.Context, handler GetUserHandler) *GetUser { + return &GetUser{Context: ctx, Handler: handler} +} + +/*GetUser swagger:route GET /users/{user_id} user getUser + +Get a user's profile. + +*/ +type GetUser struct { + Context *middleware.Context + Handler GetUserHandler +} + +func (o *GetUser) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetUserParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/user/get_user_parameters.go b/src/server/v2.0/restapi/operations/user/get_user_parameters.go new file mode 100644 index 000000000..9c1c79f93 --- /dev/null +++ b/src/server/v2.0/restapi/operations/user/get_user_parameters.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewGetUserParams creates a new GetUserParams object +// no default values defined in spec. +func NewGetUserParams() GetUserParams { + + return GetUserParams{} +} + +// GetUserParams contains all the bound params for the get user operation +// typically these are obtained from a http.Request +// +// swagger:parameters getUser +type GetUserParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /* + Required: true + In: path + */ + UserID int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetUserParams() beforehand. +func (o *GetUserParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rUserID, rhkUserID, _ := route.Params.GetOK("user_id") + if err := o.bindUserID(rUserID, rhkUserID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetUserParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetUserParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindUserID binds and validates parameter UserID from path. +func (o *GetUserParams) bindUserID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("user_id", "path", "int64", raw) + } + o.UserID = value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/user/get_user_responses.go b/src/server/v2.0/restapi/operations/user/get_user_responses.go new file mode 100644 index 000000000..3e1cdd4e1 --- /dev/null +++ b/src/server/v2.0/restapi/operations/user/get_user_responses.go @@ -0,0 +1,322 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetUserOKCode is the HTTP code returned for type GetUserOK +const GetUserOKCode int = 200 + +/*GetUserOK Get user's info successfully. + +swagger:response getUserOK +*/ +type GetUserOK struct { + + /* + In: Body + */ + Payload *models.UserResp `json:"body,omitempty"` +} + +// NewGetUserOK creates GetUserOK with default headers values +func NewGetUserOK() *GetUserOK { + + return &GetUserOK{} +} + +// WithPayload adds the payload to the get user o k response +func (o *GetUserOK) WithPayload(payload *models.UserResp) *GetUserOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get user o k response +func (o *GetUserOK) SetPayload(payload *models.UserResp) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetUserOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetUserUnauthorizedCode is the HTTP code returned for type GetUserUnauthorized +const GetUserUnauthorizedCode int = 401 + +/*GetUserUnauthorized Unauthorized + +swagger:response getUserUnauthorized +*/ +type GetUserUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetUserUnauthorized creates GetUserUnauthorized with default headers values +func NewGetUserUnauthorized() *GetUserUnauthorized { + + return &GetUserUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the get user unauthorized response +func (o *GetUserUnauthorized) WithXRequestID(xRequestID string) *GetUserUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get user unauthorized response +func (o *GetUserUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get user unauthorized response +func (o *GetUserUnauthorized) WithPayload(payload *models.Errors) *GetUserUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get user unauthorized response +func (o *GetUserUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetUserUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetUserForbiddenCode is the HTTP code returned for type GetUserForbidden +const GetUserForbiddenCode int = 403 + +/*GetUserForbidden Forbidden + +swagger:response getUserForbidden +*/ +type GetUserForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetUserForbidden creates GetUserForbidden with default headers values +func NewGetUserForbidden() *GetUserForbidden { + + return &GetUserForbidden{} +} + +// WithXRequestID adds the xRequestId to the get user forbidden response +func (o *GetUserForbidden) WithXRequestID(xRequestID string) *GetUserForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get user forbidden response +func (o *GetUserForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get user forbidden response +func (o *GetUserForbidden) WithPayload(payload *models.Errors) *GetUserForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get user forbidden response +func (o *GetUserForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetUserForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetUserNotFoundCode is the HTTP code returned for type GetUserNotFound +const GetUserNotFoundCode int = 404 + +/*GetUserNotFound Not found + +swagger:response getUserNotFound +*/ +type GetUserNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetUserNotFound creates GetUserNotFound with default headers values +func NewGetUserNotFound() *GetUserNotFound { + + return &GetUserNotFound{} +} + +// WithXRequestID adds the xRequestId to the get user not found response +func (o *GetUserNotFound) WithXRequestID(xRequestID string) *GetUserNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get user not found response +func (o *GetUserNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get user not found response +func (o *GetUserNotFound) WithPayload(payload *models.Errors) *GetUserNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get user not found response +func (o *GetUserNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetUserNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetUserInternalServerErrorCode is the HTTP code returned for type GetUserInternalServerError +const GetUserInternalServerErrorCode int = 500 + +/*GetUserInternalServerError Internal server error + +swagger:response getUserInternalServerError +*/ +type GetUserInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetUserInternalServerError creates GetUserInternalServerError with default headers values +func NewGetUserInternalServerError() *GetUserInternalServerError { + + return &GetUserInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get user internal server error response +func (o *GetUserInternalServerError) WithXRequestID(xRequestID string) *GetUserInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get user internal server error response +func (o *GetUserInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get user internal server error response +func (o *GetUserInternalServerError) WithPayload(payload *models.Errors) *GetUserInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get user internal server error response +func (o *GetUserInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetUserInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/user/get_user_urlbuilder.go b/src/server/v2.0/restapi/operations/user/get_user_urlbuilder.go new file mode 100644 index 000000000..17ec3e691 --- /dev/null +++ b/src/server/v2.0/restapi/operations/user/get_user_urlbuilder.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetUserURL generates an URL for the get user operation +type GetUserURL struct { + UserID int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetUserURL) WithBasePath(bp string) *GetUserURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetUserURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetUserURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/users/{user_id}" + + userID := swag.FormatInt64(o.UserID) + if userID != "" { + _path = strings.Replace(_path, "{user_id}", userID, -1) + } else { + return nil, errors.New("userId is required on GetUserURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetUserURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetUserURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetUserURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetUserURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetUserURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetUserURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/user/list_users.go b/src/server/v2.0/restapi/operations/user/list_users.go new file mode 100644 index 000000000..56a63ea7b --- /dev/null +++ b/src/server/v2.0/restapi/operations/user/list_users.go @@ -0,0 +1,71 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ListUsersHandlerFunc turns a function with the right signature into a list users handler +type ListUsersHandlerFunc func(ListUsersParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ListUsersHandlerFunc) Handle(params ListUsersParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ListUsersHandler interface for that can handle valid list users params +type ListUsersHandler interface { + Handle(ListUsersParams, interface{}) middleware.Responder +} + +// NewListUsers creates a new http.Handler for the list users operation +func NewListUsers(ctx *middleware.Context, handler ListUsersHandler) *ListUsers { + return &ListUsers{Context: ctx, Handler: handler} +} + +/*ListUsers swagger:route GET /users user listUsers + +List users + +*/ +type ListUsers struct { + Context *middleware.Context + Handler ListUsersHandler +} + +func (o *ListUsers) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewListUsersParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/user/list_users_parameters.go b/src/server/v2.0/restapi/operations/user/list_users_parameters.go new file mode 100644 index 000000000..93c04f373 --- /dev/null +++ b/src/server/v2.0/restapi/operations/user/list_users_parameters.go @@ -0,0 +1,239 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewListUsersParams creates a new ListUsersParams object +// with the default values initialized. +func NewListUsersParams() ListUsersParams { + + var ( + // initialize parameters with default values + + pageDefault = int64(1) + pageSizeDefault = int64(10) + ) + + return ListUsersParams{ + Page: &pageDefault, + + PageSize: &pageSizeDefault, + } +} + +// ListUsersParams contains all the bound params for the list users operation +// typically these are obtained from a http.Request +// +// swagger:parameters listUsers +type ListUsersParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The page number + In: query + Default: 1 + */ + Page *int64 + /*The size of per page + Maximum: 100 + In: query + Default: 10 + */ + PageSize *int64 + /*Query string to query resources. Supported query patterns are "exact match(k=v)", "fuzzy match(k=~v)", "range(k=[min~max])", "list with union releationship(k={v1 v2 v3})" and "list with intersetion relationship(k=(v1 v2 v3))". The value of range and list can be string(enclosed by " or '), integer or time(in format "2020-04-09 02:36:00"). All of these query patterns should be put in the query string "q=xxx" and splitted by ",". e.g. q=k1=v1,k2=~v2,k3=[min~max] + In: query + */ + Q *string + /*Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + In: query + */ + Sort *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewListUsersParams() beforehand. +func (o *ListUsersParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + qPage, qhkPage, _ := qs.GetOK("page") + if err := o.bindPage(qPage, qhkPage, route.Formats); err != nil { + res = append(res, err) + } + + qPageSize, qhkPageSize, _ := qs.GetOK("page_size") + if err := o.bindPageSize(qPageSize, qhkPageSize, route.Formats); err != nil { + res = append(res, err) + } + + qQ, qhkQ, _ := qs.GetOK("q") + if err := o.bindQ(qQ, qhkQ, route.Formats); err != nil { + res = append(res, err) + } + + qSort, qhkSort, _ := qs.GetOK("sort") + if err := o.bindSort(qSort, qhkSort, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *ListUsersParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *ListUsersParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindPage binds and validates parameter Page from query. +func (o *ListUsersParams) bindPage(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListUsersParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page", "query", "int64", raw) + } + o.Page = &value + + return nil +} + +// bindPageSize binds and validates parameter PageSize from query. +func (o *ListUsersParams) bindPageSize(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListUsersParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page_size", "query", "int64", raw) + } + o.PageSize = &value + + if err := o.validatePageSize(formats); err != nil { + return err + } + + return nil +} + +// validatePageSize carries on validations for parameter PageSize +func (o *ListUsersParams) validatePageSize(formats strfmt.Registry) error { + + if err := validate.MaximumInt("page_size", "query", int64(*o.PageSize), 100, false); err != nil { + return err + } + + return nil +} + +// bindQ binds and validates parameter Q from query. +func (o *ListUsersParams) bindQ(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Q = &raw + + return nil +} + +// bindSort binds and validates parameter Sort from query. +func (o *ListUsersParams) bindSort(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Sort = &raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/user/list_users_responses.go b/src/server/v2.0/restapi/operations/user/list_users_responses.go new file mode 100644 index 000000000..fe30c6029 --- /dev/null +++ b/src/server/v2.0/restapi/operations/user/list_users_responses.go @@ -0,0 +1,304 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/swag" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// ListUsersOKCode is the HTTP code returned for type ListUsersOK +const ListUsersOKCode int = 200 + +/*ListUsersOK return the list of users. + +swagger:response listUsersOK +*/ +type ListUsersOK struct { + /*Link to previous page and next page + + */ + Link string `json:"Link"` + /*The total count of users + + */ + XTotalCount int64 `json:"X-Total-Count"` + + /* + In: Body + */ + Payload []*models.UserResp `json:"body,omitempty"` +} + +// NewListUsersOK creates ListUsersOK with default headers values +func NewListUsersOK() *ListUsersOK { + + return &ListUsersOK{} +} + +// WithLink adds the link to the list users o k response +func (o *ListUsersOK) WithLink(link string) *ListUsersOK { + o.Link = link + return o +} + +// SetLink sets the link to the list users o k response +func (o *ListUsersOK) SetLink(link string) { + o.Link = link +} + +// WithXTotalCount adds the xTotalCount to the list users o k response +func (o *ListUsersOK) WithXTotalCount(xTotalCount int64) *ListUsersOK { + o.XTotalCount = xTotalCount + return o +} + +// SetXTotalCount sets the xTotalCount to the list users o k response +func (o *ListUsersOK) SetXTotalCount(xTotalCount int64) { + o.XTotalCount = xTotalCount +} + +// WithPayload adds the payload to the list users o k response +func (o *ListUsersOK) WithPayload(payload []*models.UserResp) *ListUsersOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list users o k response +func (o *ListUsersOK) SetPayload(payload []*models.UserResp) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListUsersOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Link + + link := o.Link + if link != "" { + rw.Header().Set("Link", link) + } + + // response header X-Total-Count + + xTotalCount := swag.FormatInt64(o.XTotalCount) + if xTotalCount != "" { + rw.Header().Set("X-Total-Count", xTotalCount) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = make([]*models.UserResp, 0, 50) + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ListUsersUnauthorizedCode is the HTTP code returned for type ListUsersUnauthorized +const ListUsersUnauthorizedCode int = 401 + +/*ListUsersUnauthorized Unauthorized + +swagger:response listUsersUnauthorized +*/ +type ListUsersUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListUsersUnauthorized creates ListUsersUnauthorized with default headers values +func NewListUsersUnauthorized() *ListUsersUnauthorized { + + return &ListUsersUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the list users unauthorized response +func (o *ListUsersUnauthorized) WithXRequestID(xRequestID string) *ListUsersUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list users unauthorized response +func (o *ListUsersUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list users unauthorized response +func (o *ListUsersUnauthorized) WithPayload(payload *models.Errors) *ListUsersUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list users unauthorized response +func (o *ListUsersUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListUsersUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListUsersForbiddenCode is the HTTP code returned for type ListUsersForbidden +const ListUsersForbiddenCode int = 403 + +/*ListUsersForbidden Forbidden + +swagger:response listUsersForbidden +*/ +type ListUsersForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListUsersForbidden creates ListUsersForbidden with default headers values +func NewListUsersForbidden() *ListUsersForbidden { + + return &ListUsersForbidden{} +} + +// WithXRequestID adds the xRequestId to the list users forbidden response +func (o *ListUsersForbidden) WithXRequestID(xRequestID string) *ListUsersForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list users forbidden response +func (o *ListUsersForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list users forbidden response +func (o *ListUsersForbidden) WithPayload(payload *models.Errors) *ListUsersForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list users forbidden response +func (o *ListUsersForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListUsersForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListUsersInternalServerErrorCode is the HTTP code returned for type ListUsersInternalServerError +const ListUsersInternalServerErrorCode int = 500 + +/*ListUsersInternalServerError Internal server error + +swagger:response listUsersInternalServerError +*/ +type ListUsersInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListUsersInternalServerError creates ListUsersInternalServerError with default headers values +func NewListUsersInternalServerError() *ListUsersInternalServerError { + + return &ListUsersInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the list users internal server error response +func (o *ListUsersInternalServerError) WithXRequestID(xRequestID string) *ListUsersInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list users internal server error response +func (o *ListUsersInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list users internal server error response +func (o *ListUsersInternalServerError) WithPayload(payload *models.Errors) *ListUsersInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list users internal server error response +func (o *ListUsersInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListUsersInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/user/list_users_urlbuilder.go b/src/server/v2.0/restapi/operations/user/list_users_urlbuilder.go new file mode 100644 index 000000000..1809e9c7d --- /dev/null +++ b/src/server/v2.0/restapi/operations/user/list_users_urlbuilder.go @@ -0,0 +1,132 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// ListUsersURL generates an URL for the list users operation +type ListUsersURL struct { + Page *int64 + PageSize *int64 + Q *string + Sort *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListUsersURL) WithBasePath(bp string) *ListUsersURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListUsersURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ListUsersURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/users" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var pageQ string + if o.Page != nil { + pageQ = swag.FormatInt64(*o.Page) + } + if pageQ != "" { + qs.Set("page", pageQ) + } + + var pageSizeQ string + if o.PageSize != nil { + pageSizeQ = swag.FormatInt64(*o.PageSize) + } + if pageSizeQ != "" { + qs.Set("page_size", pageSizeQ) + } + + var qQ string + if o.Q != nil { + qQ = *o.Q + } + if qQ != "" { + qs.Set("q", qQ) + } + + var sortQ string + if o.Sort != nil { + sortQ = *o.Sort + } + if sortQ != "" { + qs.Set("sort", sortQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ListUsersURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ListUsersURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ListUsersURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ListUsersURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ListUsersURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ListUsersURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/user/search_users.go b/src/server/v2.0/restapi/operations/user/search_users.go new file mode 100644 index 000000000..a7c5ef0b6 --- /dev/null +++ b/src/server/v2.0/restapi/operations/user/search_users.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// SearchUsersHandlerFunc turns a function with the right signature into a search users handler +type SearchUsersHandlerFunc func(SearchUsersParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn SearchUsersHandlerFunc) Handle(params SearchUsersParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// SearchUsersHandler interface for that can handle valid search users params +type SearchUsersHandler interface { + Handle(SearchUsersParams, interface{}) middleware.Responder +} + +// NewSearchUsers creates a new http.Handler for the search users operation +func NewSearchUsers(ctx *middleware.Context, handler SearchUsersHandler) *SearchUsers { + return &SearchUsers{Context: ctx, Handler: handler} +} + +/*SearchUsers swagger:route GET /users/search user searchUsers + +Search users by username + +This endpoint is to search the users by username. It's open for all authenticated requests. + + +*/ +type SearchUsers struct { + Context *middleware.Context + Handler SearchUsersHandler +} + +func (o *SearchUsers) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewSearchUsersParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/user/search_users_parameters.go b/src/server/v2.0/restapi/operations/user/search_users_parameters.go new file mode 100644 index 000000000..69ff23bb4 --- /dev/null +++ b/src/server/v2.0/restapi/operations/user/search_users_parameters.go @@ -0,0 +1,216 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewSearchUsersParams creates a new SearchUsersParams object +// with the default values initialized. +func NewSearchUsersParams() SearchUsersParams { + + var ( + // initialize parameters with default values + + pageDefault = int64(1) + pageSizeDefault = int64(10) + ) + + return SearchUsersParams{ + Page: &pageDefault, + + PageSize: &pageSizeDefault, + } +} + +// SearchUsersParams contains all the bound params for the search users operation +// typically these are obtained from a http.Request +// +// swagger:parameters searchUsers +type SearchUsersParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The page number + In: query + Default: 1 + */ + Page *int64 + /*The size of per page + Maximum: 100 + In: query + Default: 10 + */ + PageSize *int64 + /*Username for filtering results. + Required: true + In: query + */ + Username string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewSearchUsersParams() beforehand. +func (o *SearchUsersParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + qPage, qhkPage, _ := qs.GetOK("page") + if err := o.bindPage(qPage, qhkPage, route.Formats); err != nil { + res = append(res, err) + } + + qPageSize, qhkPageSize, _ := qs.GetOK("page_size") + if err := o.bindPageSize(qPageSize, qhkPageSize, route.Formats); err != nil { + res = append(res, err) + } + + qUsername, qhkUsername, _ := qs.GetOK("username") + if err := o.bindUsername(qUsername, qhkUsername, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *SearchUsersParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *SearchUsersParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindPage binds and validates parameter Page from query. +func (o *SearchUsersParams) bindPage(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewSearchUsersParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page", "query", "int64", raw) + } + o.Page = &value + + return nil +} + +// bindPageSize binds and validates parameter PageSize from query. +func (o *SearchUsersParams) bindPageSize(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewSearchUsersParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page_size", "query", "int64", raw) + } + o.PageSize = &value + + if err := o.validatePageSize(formats); err != nil { + return err + } + + return nil +} + +// validatePageSize carries on validations for parameter PageSize +func (o *SearchUsersParams) validatePageSize(formats strfmt.Registry) error { + + if err := validate.MaximumInt("page_size", "query", int64(*o.PageSize), 100, false); err != nil { + return err + } + + return nil +} + +// bindUsername binds and validates parameter Username from query. +func (o *SearchUsersParams) bindUsername(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("username", "query", rawData) + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // AllowEmptyValue: false + if err := validate.RequiredString("username", "query", raw); err != nil { + return err + } + + o.Username = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/user/search_users_responses.go b/src/server/v2.0/restapi/operations/user/search_users_responses.go new file mode 100644 index 000000000..d267db9a3 --- /dev/null +++ b/src/server/v2.0/restapi/operations/user/search_users_responses.go @@ -0,0 +1,238 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/swag" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// SearchUsersOKCode is the HTTP code returned for type SearchUsersOK +const SearchUsersOKCode int = 200 + +/*SearchUsersOK Search users by username successfully. + +swagger:response searchUsersOK +*/ +type SearchUsersOK struct { + /*Link to previous page and next page + + */ + Link string `json:"Link"` + /*The total count of available items + + */ + XTotalCount int64 `json:"X-Total-Count"` + + /* + In: Body + */ + Payload []*models.UserSearchRespItem `json:"body,omitempty"` +} + +// NewSearchUsersOK creates SearchUsersOK with default headers values +func NewSearchUsersOK() *SearchUsersOK { + + return &SearchUsersOK{} +} + +// WithLink adds the link to the search users o k response +func (o *SearchUsersOK) WithLink(link string) *SearchUsersOK { + o.Link = link + return o +} + +// SetLink sets the link to the search users o k response +func (o *SearchUsersOK) SetLink(link string) { + o.Link = link +} + +// WithXTotalCount adds the xTotalCount to the search users o k response +func (o *SearchUsersOK) WithXTotalCount(xTotalCount int64) *SearchUsersOK { + o.XTotalCount = xTotalCount + return o +} + +// SetXTotalCount sets the xTotalCount to the search users o k response +func (o *SearchUsersOK) SetXTotalCount(xTotalCount int64) { + o.XTotalCount = xTotalCount +} + +// WithPayload adds the payload to the search users o k response +func (o *SearchUsersOK) WithPayload(payload []*models.UserSearchRespItem) *SearchUsersOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the search users o k response +func (o *SearchUsersOK) SetPayload(payload []*models.UserSearchRespItem) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *SearchUsersOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Link + + link := o.Link + if link != "" { + rw.Header().Set("Link", link) + } + + // response header X-Total-Count + + xTotalCount := swag.FormatInt64(o.XTotalCount) + if xTotalCount != "" { + rw.Header().Set("X-Total-Count", xTotalCount) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = make([]*models.UserSearchRespItem, 0, 50) + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// SearchUsersUnauthorizedCode is the HTTP code returned for type SearchUsersUnauthorized +const SearchUsersUnauthorizedCode int = 401 + +/*SearchUsersUnauthorized Unauthorized + +swagger:response searchUsersUnauthorized +*/ +type SearchUsersUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewSearchUsersUnauthorized creates SearchUsersUnauthorized with default headers values +func NewSearchUsersUnauthorized() *SearchUsersUnauthorized { + + return &SearchUsersUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the search users unauthorized response +func (o *SearchUsersUnauthorized) WithXRequestID(xRequestID string) *SearchUsersUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the search users unauthorized response +func (o *SearchUsersUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the search users unauthorized response +func (o *SearchUsersUnauthorized) WithPayload(payload *models.Errors) *SearchUsersUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the search users unauthorized response +func (o *SearchUsersUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *SearchUsersUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// SearchUsersInternalServerErrorCode is the HTTP code returned for type SearchUsersInternalServerError +const SearchUsersInternalServerErrorCode int = 500 + +/*SearchUsersInternalServerError Internal server error + +swagger:response searchUsersInternalServerError +*/ +type SearchUsersInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewSearchUsersInternalServerError creates SearchUsersInternalServerError with default headers values +func NewSearchUsersInternalServerError() *SearchUsersInternalServerError { + + return &SearchUsersInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the search users internal server error response +func (o *SearchUsersInternalServerError) WithXRequestID(xRequestID string) *SearchUsersInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the search users internal server error response +func (o *SearchUsersInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the search users internal server error response +func (o *SearchUsersInternalServerError) WithPayload(payload *models.Errors) *SearchUsersInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the search users internal server error response +func (o *SearchUsersInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *SearchUsersInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/user/search_users_urlbuilder.go b/src/server/v2.0/restapi/operations/user/search_users_urlbuilder.go new file mode 100644 index 000000000..dc3fb9cc8 --- /dev/null +++ b/src/server/v2.0/restapi/operations/user/search_users_urlbuilder.go @@ -0,0 +1,120 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// SearchUsersURL generates an URL for the search users operation +type SearchUsersURL struct { + Page *int64 + PageSize *int64 + Username string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *SearchUsersURL) WithBasePath(bp string) *SearchUsersURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *SearchUsersURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *SearchUsersURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/users/search" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var pageQ string + if o.Page != nil { + pageQ = swag.FormatInt64(*o.Page) + } + if pageQ != "" { + qs.Set("page", pageQ) + } + + var pageSizeQ string + if o.PageSize != nil { + pageSizeQ = swag.FormatInt64(*o.PageSize) + } + if pageSizeQ != "" { + qs.Set("page_size", pageSizeQ) + } + + usernameQ := o.Username + if usernameQ != "" { + qs.Set("username", usernameQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *SearchUsersURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *SearchUsersURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *SearchUsersURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on SearchUsersURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on SearchUsersURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *SearchUsersURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/user/set_cli_secret.go b/src/server/v2.0/restapi/operations/user/set_cli_secret.go new file mode 100644 index 000000000..8a85bca43 --- /dev/null +++ b/src/server/v2.0/restapi/operations/user/set_cli_secret.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// SetCliSecretHandlerFunc turns a function with the right signature into a set cli secret handler +type SetCliSecretHandlerFunc func(SetCliSecretParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn SetCliSecretHandlerFunc) Handle(params SetCliSecretParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// SetCliSecretHandler interface for that can handle valid set cli secret params +type SetCliSecretHandler interface { + Handle(SetCliSecretParams, interface{}) middleware.Responder +} + +// NewSetCliSecret creates a new http.Handler for the set cli secret operation +func NewSetCliSecret(ctx *middleware.Context, handler SetCliSecretHandler) *SetCliSecret { + return &SetCliSecret{Context: ctx, Handler: handler} +} + +/*SetCliSecret swagger:route PUT /users/{user_id}/cli_secret user setCliSecret + +Set CLI secret for a user. + +This endpoint let user generate a new CLI secret for himself. This API only works when auth mode is set to 'OIDC'. Once this API returns with successful status, the old secret will be invalid, as there will be only one CLI secret for a user. + +*/ +type SetCliSecret struct { + Context *middleware.Context + Handler SetCliSecretHandler +} + +func (o *SetCliSecret) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewSetCliSecretParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/user/set_cli_secret_parameters.go b/src/server/v2.0/restapi/operations/user/set_cli_secret_parameters.go new file mode 100644 index 000000000..12e26efb6 --- /dev/null +++ b/src/server/v2.0/restapi/operations/user/set_cli_secret_parameters.go @@ -0,0 +1,150 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewSetCliSecretParams creates a new SetCliSecretParams object +// no default values defined in spec. +func NewSetCliSecretParams() SetCliSecretParams { + + return SetCliSecretParams{} +} + +// SetCliSecretParams contains all the bound params for the set cli secret operation +// typically these are obtained from a http.Request +// +// swagger:parameters setCliSecret +type SetCliSecretParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /* + Required: true + In: body + */ + Secret *models.OIDCCliSecretReq + /*User ID + Required: true + In: path + */ + UserID int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewSetCliSecretParams() beforehand. +func (o *SetCliSecretParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.OIDCCliSecretReq + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("secret", "body", "")) + } else { + res = append(res, errors.NewParseError("secret", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Secret = &body + } + } + } else { + res = append(res, errors.Required("secret", "body", "")) + } + rUserID, rhkUserID, _ := route.Params.GetOK("user_id") + if err := o.bindUserID(rUserID, rhkUserID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *SetCliSecretParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *SetCliSecretParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindUserID binds and validates parameter UserID from path. +func (o *SetCliSecretParams) bindUserID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("user_id", "path", "int64", raw) + } + o.UserID = value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/user/set_cli_secret_responses.go b/src/server/v2.0/restapi/operations/user/set_cli_secret_responses.go new file mode 100644 index 000000000..e25511992 --- /dev/null +++ b/src/server/v2.0/restapi/operations/user/set_cli_secret_responses.go @@ -0,0 +1,350 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// SetCliSecretOKCode is the HTTP code returned for type SetCliSecretOK +const SetCliSecretOKCode int = 200 + +/*SetCliSecretOK The secret is successfully updated + +swagger:response setCliSecretOK +*/ +type SetCliSecretOK struct { +} + +// NewSetCliSecretOK creates SetCliSecretOK with default headers values +func NewSetCliSecretOK() *SetCliSecretOK { + + return &SetCliSecretOK{} +} + +// WriteResponse to the client +func (o *SetCliSecretOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// SetCliSecretBadRequestCode is the HTTP code returned for type SetCliSecretBadRequest +const SetCliSecretBadRequestCode int = 400 + +/*SetCliSecretBadRequest Invalid user ID. Or user is not onboarded via OIDC authentication. Or the secret does not meet the standard. + +swagger:response setCliSecretBadRequest +*/ +type SetCliSecretBadRequest struct { +} + +// NewSetCliSecretBadRequest creates SetCliSecretBadRequest with default headers values +func NewSetCliSecretBadRequest() *SetCliSecretBadRequest { + + return &SetCliSecretBadRequest{} +} + +// WriteResponse to the client +func (o *SetCliSecretBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(400) +} + +// SetCliSecretUnauthorizedCode is the HTTP code returned for type SetCliSecretUnauthorized +const SetCliSecretUnauthorizedCode int = 401 + +/*SetCliSecretUnauthorized Unauthorized + +swagger:response setCliSecretUnauthorized +*/ +type SetCliSecretUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewSetCliSecretUnauthorized creates SetCliSecretUnauthorized with default headers values +func NewSetCliSecretUnauthorized() *SetCliSecretUnauthorized { + + return &SetCliSecretUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the set cli secret unauthorized response +func (o *SetCliSecretUnauthorized) WithXRequestID(xRequestID string) *SetCliSecretUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the set cli secret unauthorized response +func (o *SetCliSecretUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the set cli secret unauthorized response +func (o *SetCliSecretUnauthorized) WithPayload(payload *models.Errors) *SetCliSecretUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the set cli secret unauthorized response +func (o *SetCliSecretUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *SetCliSecretUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// SetCliSecretForbiddenCode is the HTTP code returned for type SetCliSecretForbidden +const SetCliSecretForbiddenCode int = 403 + +/*SetCliSecretForbidden Forbidden + +swagger:response setCliSecretForbidden +*/ +type SetCliSecretForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewSetCliSecretForbidden creates SetCliSecretForbidden with default headers values +func NewSetCliSecretForbidden() *SetCliSecretForbidden { + + return &SetCliSecretForbidden{} +} + +// WithXRequestID adds the xRequestId to the set cli secret forbidden response +func (o *SetCliSecretForbidden) WithXRequestID(xRequestID string) *SetCliSecretForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the set cli secret forbidden response +func (o *SetCliSecretForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the set cli secret forbidden response +func (o *SetCliSecretForbidden) WithPayload(payload *models.Errors) *SetCliSecretForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the set cli secret forbidden response +func (o *SetCliSecretForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *SetCliSecretForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// SetCliSecretNotFoundCode is the HTTP code returned for type SetCliSecretNotFound +const SetCliSecretNotFoundCode int = 404 + +/*SetCliSecretNotFound Not found + +swagger:response setCliSecretNotFound +*/ +type SetCliSecretNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewSetCliSecretNotFound creates SetCliSecretNotFound with default headers values +func NewSetCliSecretNotFound() *SetCliSecretNotFound { + + return &SetCliSecretNotFound{} +} + +// WithXRequestID adds the xRequestId to the set cli secret not found response +func (o *SetCliSecretNotFound) WithXRequestID(xRequestID string) *SetCliSecretNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the set cli secret not found response +func (o *SetCliSecretNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the set cli secret not found response +func (o *SetCliSecretNotFound) WithPayload(payload *models.Errors) *SetCliSecretNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the set cli secret not found response +func (o *SetCliSecretNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *SetCliSecretNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// SetCliSecretPreconditionFailedCode is the HTTP code returned for type SetCliSecretPreconditionFailed +const SetCliSecretPreconditionFailedCode int = 412 + +/*SetCliSecretPreconditionFailed The auth mode of the system is not "oidc_auth", or the user is not onboarded via OIDC AuthN. + +swagger:response setCliSecretPreconditionFailed +*/ +type SetCliSecretPreconditionFailed struct { +} + +// NewSetCliSecretPreconditionFailed creates SetCliSecretPreconditionFailed with default headers values +func NewSetCliSecretPreconditionFailed() *SetCliSecretPreconditionFailed { + + return &SetCliSecretPreconditionFailed{} +} + +// WriteResponse to the client +func (o *SetCliSecretPreconditionFailed) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(412) +} + +// SetCliSecretInternalServerErrorCode is the HTTP code returned for type SetCliSecretInternalServerError +const SetCliSecretInternalServerErrorCode int = 500 + +/*SetCliSecretInternalServerError Internal server error + +swagger:response setCliSecretInternalServerError +*/ +type SetCliSecretInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewSetCliSecretInternalServerError creates SetCliSecretInternalServerError with default headers values +func NewSetCliSecretInternalServerError() *SetCliSecretInternalServerError { + + return &SetCliSecretInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the set cli secret internal server error response +func (o *SetCliSecretInternalServerError) WithXRequestID(xRequestID string) *SetCliSecretInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the set cli secret internal server error response +func (o *SetCliSecretInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the set cli secret internal server error response +func (o *SetCliSecretInternalServerError) WithPayload(payload *models.Errors) *SetCliSecretInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the set cli secret internal server error response +func (o *SetCliSecretInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *SetCliSecretInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/user/set_cli_secret_urlbuilder.go b/src/server/v2.0/restapi/operations/user/set_cli_secret_urlbuilder.go new file mode 100644 index 000000000..1b2ecb43c --- /dev/null +++ b/src/server/v2.0/restapi/operations/user/set_cli_secret_urlbuilder.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// SetCliSecretURL generates an URL for the set cli secret operation +type SetCliSecretURL struct { + UserID int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *SetCliSecretURL) WithBasePath(bp string) *SetCliSecretURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *SetCliSecretURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *SetCliSecretURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/users/{user_id}/cli_secret" + + userID := swag.FormatInt64(o.UserID) + if userID != "" { + _path = strings.Replace(_path, "{user_id}", userID, -1) + } else { + return nil, errors.New("userId is required on SetCliSecretURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *SetCliSecretURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *SetCliSecretURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *SetCliSecretURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on SetCliSecretURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on SetCliSecretURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *SetCliSecretURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/user/set_user_sys_admin.go b/src/server/v2.0/restapi/operations/user/set_user_sys_admin.go new file mode 100644 index 000000000..c916be8f6 --- /dev/null +++ b/src/server/v2.0/restapi/operations/user/set_user_sys_admin.go @@ -0,0 +1,71 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// SetUserSysAdminHandlerFunc turns a function with the right signature into a set user sys admin handler +type SetUserSysAdminHandlerFunc func(SetUserSysAdminParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn SetUserSysAdminHandlerFunc) Handle(params SetUserSysAdminParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// SetUserSysAdminHandler interface for that can handle valid set user sys admin params +type SetUserSysAdminHandler interface { + Handle(SetUserSysAdminParams, interface{}) middleware.Responder +} + +// NewSetUserSysAdmin creates a new http.Handler for the set user sys admin operation +func NewSetUserSysAdmin(ctx *middleware.Context, handler SetUserSysAdminHandler) *SetUserSysAdmin { + return &SetUserSysAdmin{Context: ctx, Handler: handler} +} + +/*SetUserSysAdmin swagger:route PUT /users/{user_id}/sysadmin user setUserSysAdmin + +Update a registered user to change to be an administrator of Harbor. + +*/ +type SetUserSysAdmin struct { + Context *middleware.Context + Handler SetUserSysAdminHandler +} + +func (o *SetUserSysAdmin) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewSetUserSysAdminParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/user/set_user_sys_admin_parameters.go b/src/server/v2.0/restapi/operations/user/set_user_sys_admin_parameters.go new file mode 100644 index 000000000..2375da783 --- /dev/null +++ b/src/server/v2.0/restapi/operations/user/set_user_sys_admin_parameters.go @@ -0,0 +1,150 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewSetUserSysAdminParams creates a new SetUserSysAdminParams object +// no default values defined in spec. +func NewSetUserSysAdminParams() SetUserSysAdminParams { + + return SetUserSysAdminParams{} +} + +// SetUserSysAdminParams contains all the bound params for the set user sys admin operation +// typically these are obtained from a http.Request +// +// swagger:parameters setUserSysAdmin +type SetUserSysAdminParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*Toggle a user to admin or not. + Required: true + In: body + */ + SysadminFlag *models.UserSysAdminFlag + /* + Required: true + In: path + */ + UserID int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewSetUserSysAdminParams() beforehand. +func (o *SetUserSysAdminParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.UserSysAdminFlag + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("sysadminFlag", "body", "")) + } else { + res = append(res, errors.NewParseError("sysadminFlag", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.SysadminFlag = &body + } + } + } else { + res = append(res, errors.Required("sysadminFlag", "body", "")) + } + rUserID, rhkUserID, _ := route.Params.GetOK("user_id") + if err := o.bindUserID(rUserID, rhkUserID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *SetUserSysAdminParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *SetUserSysAdminParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindUserID binds and validates parameter UserID from path. +func (o *SetUserSysAdminParams) bindUserID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("user_id", "path", "int64", raw) + } + o.UserID = value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/user/set_user_sys_admin_responses.go b/src/server/v2.0/restapi/operations/user/set_user_sys_admin_responses.go new file mode 100644 index 000000000..4223bd3f3 --- /dev/null +++ b/src/server/v2.0/restapi/operations/user/set_user_sys_admin_responses.go @@ -0,0 +1,282 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// SetUserSysAdminOKCode is the HTTP code returned for type SetUserSysAdminOK +const SetUserSysAdminOKCode int = 200 + +/*SetUserSysAdminOK Success + +swagger:response setUserSysAdminOK +*/ +type SetUserSysAdminOK struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewSetUserSysAdminOK creates SetUserSysAdminOK with default headers values +func NewSetUserSysAdminOK() *SetUserSysAdminOK { + + return &SetUserSysAdminOK{} +} + +// WithXRequestID adds the xRequestId to the set user sys admin o k response +func (o *SetUserSysAdminOK) WithXRequestID(xRequestID string) *SetUserSysAdminOK { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the set user sys admin o k response +func (o *SetUserSysAdminOK) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *SetUserSysAdminOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// SetUserSysAdminUnauthorizedCode is the HTTP code returned for type SetUserSysAdminUnauthorized +const SetUserSysAdminUnauthorizedCode int = 401 + +/*SetUserSysAdminUnauthorized Unauthorized + +swagger:response setUserSysAdminUnauthorized +*/ +type SetUserSysAdminUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewSetUserSysAdminUnauthorized creates SetUserSysAdminUnauthorized with default headers values +func NewSetUserSysAdminUnauthorized() *SetUserSysAdminUnauthorized { + + return &SetUserSysAdminUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the set user sys admin unauthorized response +func (o *SetUserSysAdminUnauthorized) WithXRequestID(xRequestID string) *SetUserSysAdminUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the set user sys admin unauthorized response +func (o *SetUserSysAdminUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the set user sys admin unauthorized response +func (o *SetUserSysAdminUnauthorized) WithPayload(payload *models.Errors) *SetUserSysAdminUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the set user sys admin unauthorized response +func (o *SetUserSysAdminUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *SetUserSysAdminUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// SetUserSysAdminForbiddenCode is the HTTP code returned for type SetUserSysAdminForbidden +const SetUserSysAdminForbiddenCode int = 403 + +/*SetUserSysAdminForbidden Forbidden + +swagger:response setUserSysAdminForbidden +*/ +type SetUserSysAdminForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewSetUserSysAdminForbidden creates SetUserSysAdminForbidden with default headers values +func NewSetUserSysAdminForbidden() *SetUserSysAdminForbidden { + + return &SetUserSysAdminForbidden{} +} + +// WithXRequestID adds the xRequestId to the set user sys admin forbidden response +func (o *SetUserSysAdminForbidden) WithXRequestID(xRequestID string) *SetUserSysAdminForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the set user sys admin forbidden response +func (o *SetUserSysAdminForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the set user sys admin forbidden response +func (o *SetUserSysAdminForbidden) WithPayload(payload *models.Errors) *SetUserSysAdminForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the set user sys admin forbidden response +func (o *SetUserSysAdminForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *SetUserSysAdminForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// SetUserSysAdminNotFoundCode is the HTTP code returned for type SetUserSysAdminNotFound +const SetUserSysAdminNotFoundCode int = 404 + +/*SetUserSysAdminNotFound Not found + +swagger:response setUserSysAdminNotFound +*/ +type SetUserSysAdminNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewSetUserSysAdminNotFound creates SetUserSysAdminNotFound with default headers values +func NewSetUserSysAdminNotFound() *SetUserSysAdminNotFound { + + return &SetUserSysAdminNotFound{} +} + +// WithXRequestID adds the xRequestId to the set user sys admin not found response +func (o *SetUserSysAdminNotFound) WithXRequestID(xRequestID string) *SetUserSysAdminNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the set user sys admin not found response +func (o *SetUserSysAdminNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the set user sys admin not found response +func (o *SetUserSysAdminNotFound) WithPayload(payload *models.Errors) *SetUserSysAdminNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the set user sys admin not found response +func (o *SetUserSysAdminNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *SetUserSysAdminNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// SetUserSysAdminInternalServerErrorCode is the HTTP code returned for type SetUserSysAdminInternalServerError +const SetUserSysAdminInternalServerErrorCode int = 500 + +/*SetUserSysAdminInternalServerError Unexpected internal errors. + +swagger:response setUserSysAdminInternalServerError +*/ +type SetUserSysAdminInternalServerError struct { +} + +// NewSetUserSysAdminInternalServerError creates SetUserSysAdminInternalServerError with default headers values +func NewSetUserSysAdminInternalServerError() *SetUserSysAdminInternalServerError { + + return &SetUserSysAdminInternalServerError{} +} + +// WriteResponse to the client +func (o *SetUserSysAdminInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(500) +} diff --git a/src/server/v2.0/restapi/operations/user/set_user_sys_admin_urlbuilder.go b/src/server/v2.0/restapi/operations/user/set_user_sys_admin_urlbuilder.go new file mode 100644 index 000000000..a8512becc --- /dev/null +++ b/src/server/v2.0/restapi/operations/user/set_user_sys_admin_urlbuilder.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// SetUserSysAdminURL generates an URL for the set user sys admin operation +type SetUserSysAdminURL struct { + UserID int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *SetUserSysAdminURL) WithBasePath(bp string) *SetUserSysAdminURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *SetUserSysAdminURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *SetUserSysAdminURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/users/{user_id}/sysadmin" + + userID := swag.FormatInt64(o.UserID) + if userID != "" { + _path = strings.Replace(_path, "{user_id}", userID, -1) + } else { + return nil, errors.New("userId is required on SetUserSysAdminURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *SetUserSysAdminURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *SetUserSysAdminURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *SetUserSysAdminURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on SetUserSysAdminURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on SetUserSysAdminURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *SetUserSysAdminURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/user/update_user_password.go b/src/server/v2.0/restapi/operations/user/update_user_password.go new file mode 100644 index 000000000..a79cce23c --- /dev/null +++ b/src/server/v2.0/restapi/operations/user/update_user_password.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// UpdateUserPasswordHandlerFunc turns a function with the right signature into a update user password handler +type UpdateUserPasswordHandlerFunc func(UpdateUserPasswordParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn UpdateUserPasswordHandlerFunc) Handle(params UpdateUserPasswordParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// UpdateUserPasswordHandler interface for that can handle valid update user password params +type UpdateUserPasswordHandler interface { + Handle(UpdateUserPasswordParams, interface{}) middleware.Responder +} + +// NewUpdateUserPassword creates a new http.Handler for the update user password operation +func NewUpdateUserPassword(ctx *middleware.Context, handler UpdateUserPasswordHandler) *UpdateUserPassword { + return &UpdateUserPassword{Context: ctx, Handler: handler} +} + +/*UpdateUserPassword swagger:route PUT /users/{user_id}/password user updateUserPassword + +Change the password on a user that already exists. + +This endpoint is for user to update password. Users with the admin role can change any user's password. Regular users can change only their own password. + + +*/ +type UpdateUserPassword struct { + Context *middleware.Context + Handler UpdateUserPasswordHandler +} + +func (o *UpdateUserPassword) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewUpdateUserPasswordParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/user/update_user_password_parameters.go b/src/server/v2.0/restapi/operations/user/update_user_password_parameters.go new file mode 100644 index 000000000..9b9530ee5 --- /dev/null +++ b/src/server/v2.0/restapi/operations/user/update_user_password_parameters.go @@ -0,0 +1,150 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewUpdateUserPasswordParams creates a new UpdateUserPasswordParams object +// no default values defined in spec. +func NewUpdateUserPasswordParams() UpdateUserPasswordParams { + + return UpdateUserPasswordParams{} +} + +// UpdateUserPasswordParams contains all the bound params for the update user password operation +// typically these are obtained from a http.Request +// +// swagger:parameters updateUserPassword +type UpdateUserPasswordParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*Password to be updated, the attribute 'old_password' is optional when the API is called by the system administrator. + Required: true + In: body + */ + Password *models.PasswordReq + /* + Required: true + In: path + */ + UserID int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewUpdateUserPasswordParams() beforehand. +func (o *UpdateUserPasswordParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.PasswordReq + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("password", "body", "")) + } else { + res = append(res, errors.NewParseError("password", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Password = &body + } + } + } else { + res = append(res, errors.Required("password", "body", "")) + } + rUserID, rhkUserID, _ := route.Params.GetOK("user_id") + if err := o.bindUserID(rUserID, rhkUserID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *UpdateUserPasswordParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *UpdateUserPasswordParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindUserID binds and validates parameter UserID from path. +func (o *UpdateUserPasswordParams) bindUserID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("user_id", "path", "int64", raw) + } + o.UserID = value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/user/update_user_password_responses.go b/src/server/v2.0/restapi/operations/user/update_user_password_responses.go new file mode 100644 index 000000000..b85b3f3a1 --- /dev/null +++ b/src/server/v2.0/restapi/operations/user/update_user_password_responses.go @@ -0,0 +1,240 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// UpdateUserPasswordOKCode is the HTTP code returned for type UpdateUserPasswordOK +const UpdateUserPasswordOKCode int = 200 + +/*UpdateUserPasswordOK Success + +swagger:response updateUserPasswordOK +*/ +type UpdateUserPasswordOK struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewUpdateUserPasswordOK creates UpdateUserPasswordOK with default headers values +func NewUpdateUserPasswordOK() *UpdateUserPasswordOK { + + return &UpdateUserPasswordOK{} +} + +// WithXRequestID adds the xRequestId to the update user password o k response +func (o *UpdateUserPasswordOK) WithXRequestID(xRequestID string) *UpdateUserPasswordOK { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update user password o k response +func (o *UpdateUserPasswordOK) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *UpdateUserPasswordOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// UpdateUserPasswordBadRequestCode is the HTTP code returned for type UpdateUserPasswordBadRequest +const UpdateUserPasswordBadRequestCode int = 400 + +/*UpdateUserPasswordBadRequest Invalid user ID; Password does not meet requirement + +swagger:response updateUserPasswordBadRequest +*/ +type UpdateUserPasswordBadRequest struct { +} + +// NewUpdateUserPasswordBadRequest creates UpdateUserPasswordBadRequest with default headers values +func NewUpdateUserPasswordBadRequest() *UpdateUserPasswordBadRequest { + + return &UpdateUserPasswordBadRequest{} +} + +// WriteResponse to the client +func (o *UpdateUserPasswordBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(400) +} + +// UpdateUserPasswordUnauthorizedCode is the HTTP code returned for type UpdateUserPasswordUnauthorized +const UpdateUserPasswordUnauthorizedCode int = 401 + +/*UpdateUserPasswordUnauthorized Unauthorized + +swagger:response updateUserPasswordUnauthorized +*/ +type UpdateUserPasswordUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateUserPasswordUnauthorized creates UpdateUserPasswordUnauthorized with default headers values +func NewUpdateUserPasswordUnauthorized() *UpdateUserPasswordUnauthorized { + + return &UpdateUserPasswordUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the update user password unauthorized response +func (o *UpdateUserPasswordUnauthorized) WithXRequestID(xRequestID string) *UpdateUserPasswordUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update user password unauthorized response +func (o *UpdateUserPasswordUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update user password unauthorized response +func (o *UpdateUserPasswordUnauthorized) WithPayload(payload *models.Errors) *UpdateUserPasswordUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update user password unauthorized response +func (o *UpdateUserPasswordUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateUserPasswordUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateUserPasswordForbiddenCode is the HTTP code returned for type UpdateUserPasswordForbidden +const UpdateUserPasswordForbiddenCode int = 403 + +/*UpdateUserPasswordForbidden The caller does not have permission to update the password of the user with given ID, or the old password in request body is not correct. + +swagger:response updateUserPasswordForbidden +*/ +type UpdateUserPasswordForbidden struct { +} + +// NewUpdateUserPasswordForbidden creates UpdateUserPasswordForbidden with default headers values +func NewUpdateUserPasswordForbidden() *UpdateUserPasswordForbidden { + + return &UpdateUserPasswordForbidden{} +} + +// WriteResponse to the client +func (o *UpdateUserPasswordForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(403) +} + +// UpdateUserPasswordInternalServerErrorCode is the HTTP code returned for type UpdateUserPasswordInternalServerError +const UpdateUserPasswordInternalServerErrorCode int = 500 + +/*UpdateUserPasswordInternalServerError Internal server error + +swagger:response updateUserPasswordInternalServerError +*/ +type UpdateUserPasswordInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateUserPasswordInternalServerError creates UpdateUserPasswordInternalServerError with default headers values +func NewUpdateUserPasswordInternalServerError() *UpdateUserPasswordInternalServerError { + + return &UpdateUserPasswordInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the update user password internal server error response +func (o *UpdateUserPasswordInternalServerError) WithXRequestID(xRequestID string) *UpdateUserPasswordInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update user password internal server error response +func (o *UpdateUserPasswordInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update user password internal server error response +func (o *UpdateUserPasswordInternalServerError) WithPayload(payload *models.Errors) *UpdateUserPasswordInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update user password internal server error response +func (o *UpdateUserPasswordInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateUserPasswordInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/user/update_user_password_urlbuilder.go b/src/server/v2.0/restapi/operations/user/update_user_password_urlbuilder.go new file mode 100644 index 000000000..ac2eaf194 --- /dev/null +++ b/src/server/v2.0/restapi/operations/user/update_user_password_urlbuilder.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// UpdateUserPasswordURL generates an URL for the update user password operation +type UpdateUserPasswordURL struct { + UserID int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdateUserPasswordURL) WithBasePath(bp string) *UpdateUserPasswordURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdateUserPasswordURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *UpdateUserPasswordURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/users/{user_id}/password" + + userID := swag.FormatInt64(o.UserID) + if userID != "" { + _path = strings.Replace(_path, "{user_id}", userID, -1) + } else { + return nil, errors.New("userId is required on UpdateUserPasswordURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *UpdateUserPasswordURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *UpdateUserPasswordURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *UpdateUserPasswordURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on UpdateUserPasswordURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on UpdateUserPasswordURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *UpdateUserPasswordURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/user/update_user_profile.go b/src/server/v2.0/restapi/operations/user/update_user_profile.go new file mode 100644 index 000000000..6715cf868 --- /dev/null +++ b/src/server/v2.0/restapi/operations/user/update_user_profile.go @@ -0,0 +1,71 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// UpdateUserProfileHandlerFunc turns a function with the right signature into a update user profile handler +type UpdateUserProfileHandlerFunc func(UpdateUserProfileParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn UpdateUserProfileHandlerFunc) Handle(params UpdateUserProfileParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// UpdateUserProfileHandler interface for that can handle valid update user profile params +type UpdateUserProfileHandler interface { + Handle(UpdateUserProfileParams, interface{}) middleware.Responder +} + +// NewUpdateUserProfile creates a new http.Handler for the update user profile operation +func NewUpdateUserProfile(ctx *middleware.Context, handler UpdateUserProfileHandler) *UpdateUserProfile { + return &UpdateUserProfile{Context: ctx, Handler: handler} +} + +/*UpdateUserProfile swagger:route PUT /users/{user_id} user updateUserProfile + +Update user's profile. + +*/ +type UpdateUserProfile struct { + Context *middleware.Context + Handler UpdateUserProfileHandler +} + +func (o *UpdateUserProfile) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewUpdateUserProfileParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/user/update_user_profile_parameters.go b/src/server/v2.0/restapi/operations/user/update_user_profile_parameters.go new file mode 100644 index 000000000..6785a656b --- /dev/null +++ b/src/server/v2.0/restapi/operations/user/update_user_profile_parameters.go @@ -0,0 +1,150 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewUpdateUserProfileParams creates a new UpdateUserProfileParams object +// no default values defined in spec. +func NewUpdateUserProfileParams() UpdateUserProfileParams { + + return UpdateUserProfileParams{} +} + +// UpdateUserProfileParams contains all the bound params for the update user profile operation +// typically these are obtained from a http.Request +// +// swagger:parameters updateUserProfile +type UpdateUserProfileParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*Only email, realname and comment can be modified. + Required: true + In: body + */ + Profile *models.UserProfile + /*Registered user ID + Required: true + In: path + */ + UserID int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewUpdateUserProfileParams() beforehand. +func (o *UpdateUserProfileParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.UserProfile + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("profile", "body", "")) + } else { + res = append(res, errors.NewParseError("profile", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Profile = &body + } + } + } else { + res = append(res, errors.Required("profile", "body", "")) + } + rUserID, rhkUserID, _ := route.Params.GetOK("user_id") + if err := o.bindUserID(rUserID, rhkUserID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *UpdateUserProfileParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *UpdateUserProfileParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindUserID binds and validates parameter UserID from path. +func (o *UpdateUserProfileParams) bindUserID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("user_id", "path", "int64", raw) + } + o.UserID = value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/user/update_user_profile_responses.go b/src/server/v2.0/restapi/operations/user/update_user_profile_responses.go new file mode 100644 index 000000000..9cd1dd2c8 --- /dev/null +++ b/src/server/v2.0/restapi/operations/user/update_user_profile_responses.go @@ -0,0 +1,324 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// UpdateUserProfileOKCode is the HTTP code returned for type UpdateUserProfileOK +const UpdateUserProfileOKCode int = 200 + +/*UpdateUserProfileOK Success + +swagger:response updateUserProfileOK +*/ +type UpdateUserProfileOK struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewUpdateUserProfileOK creates UpdateUserProfileOK with default headers values +func NewUpdateUserProfileOK() *UpdateUserProfileOK { + + return &UpdateUserProfileOK{} +} + +// WithXRequestID adds the xRequestId to the update user profile o k response +func (o *UpdateUserProfileOK) WithXRequestID(xRequestID string) *UpdateUserProfileOK { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update user profile o k response +func (o *UpdateUserProfileOK) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *UpdateUserProfileOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// UpdateUserProfileUnauthorizedCode is the HTTP code returned for type UpdateUserProfileUnauthorized +const UpdateUserProfileUnauthorizedCode int = 401 + +/*UpdateUserProfileUnauthorized Unauthorized + +swagger:response updateUserProfileUnauthorized +*/ +type UpdateUserProfileUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateUserProfileUnauthorized creates UpdateUserProfileUnauthorized with default headers values +func NewUpdateUserProfileUnauthorized() *UpdateUserProfileUnauthorized { + + return &UpdateUserProfileUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the update user profile unauthorized response +func (o *UpdateUserProfileUnauthorized) WithXRequestID(xRequestID string) *UpdateUserProfileUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update user profile unauthorized response +func (o *UpdateUserProfileUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update user profile unauthorized response +func (o *UpdateUserProfileUnauthorized) WithPayload(payload *models.Errors) *UpdateUserProfileUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update user profile unauthorized response +func (o *UpdateUserProfileUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateUserProfileUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateUserProfileForbiddenCode is the HTTP code returned for type UpdateUserProfileForbidden +const UpdateUserProfileForbiddenCode int = 403 + +/*UpdateUserProfileForbidden Forbidden + +swagger:response updateUserProfileForbidden +*/ +type UpdateUserProfileForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateUserProfileForbidden creates UpdateUserProfileForbidden with default headers values +func NewUpdateUserProfileForbidden() *UpdateUserProfileForbidden { + + return &UpdateUserProfileForbidden{} +} + +// WithXRequestID adds the xRequestId to the update user profile forbidden response +func (o *UpdateUserProfileForbidden) WithXRequestID(xRequestID string) *UpdateUserProfileForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update user profile forbidden response +func (o *UpdateUserProfileForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update user profile forbidden response +func (o *UpdateUserProfileForbidden) WithPayload(payload *models.Errors) *UpdateUserProfileForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update user profile forbidden response +func (o *UpdateUserProfileForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateUserProfileForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateUserProfileNotFoundCode is the HTTP code returned for type UpdateUserProfileNotFound +const UpdateUserProfileNotFoundCode int = 404 + +/*UpdateUserProfileNotFound Not found + +swagger:response updateUserProfileNotFound +*/ +type UpdateUserProfileNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateUserProfileNotFound creates UpdateUserProfileNotFound with default headers values +func NewUpdateUserProfileNotFound() *UpdateUserProfileNotFound { + + return &UpdateUserProfileNotFound{} +} + +// WithXRequestID adds the xRequestId to the update user profile not found response +func (o *UpdateUserProfileNotFound) WithXRequestID(xRequestID string) *UpdateUserProfileNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update user profile not found response +func (o *UpdateUserProfileNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update user profile not found response +func (o *UpdateUserProfileNotFound) WithPayload(payload *models.Errors) *UpdateUserProfileNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update user profile not found response +func (o *UpdateUserProfileNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateUserProfileNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateUserProfileInternalServerErrorCode is the HTTP code returned for type UpdateUserProfileInternalServerError +const UpdateUserProfileInternalServerErrorCode int = 500 + +/*UpdateUserProfileInternalServerError Internal server error + +swagger:response updateUserProfileInternalServerError +*/ +type UpdateUserProfileInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateUserProfileInternalServerError creates UpdateUserProfileInternalServerError with default headers values +func NewUpdateUserProfileInternalServerError() *UpdateUserProfileInternalServerError { + + return &UpdateUserProfileInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the update user profile internal server error response +func (o *UpdateUserProfileInternalServerError) WithXRequestID(xRequestID string) *UpdateUserProfileInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update user profile internal server error response +func (o *UpdateUserProfileInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update user profile internal server error response +func (o *UpdateUserProfileInternalServerError) WithPayload(payload *models.Errors) *UpdateUserProfileInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update user profile internal server error response +func (o *UpdateUserProfileInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateUserProfileInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/user/update_user_profile_urlbuilder.go b/src/server/v2.0/restapi/operations/user/update_user_profile_urlbuilder.go new file mode 100644 index 000000000..7833c67f9 --- /dev/null +++ b/src/server/v2.0/restapi/operations/user/update_user_profile_urlbuilder.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// UpdateUserProfileURL generates an URL for the update user profile operation +type UpdateUserProfileURL struct { + UserID int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdateUserProfileURL) WithBasePath(bp string) *UpdateUserProfileURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdateUserProfileURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *UpdateUserProfileURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/users/{user_id}" + + userID := swag.FormatInt64(o.UserID) + if userID != "" { + _path = strings.Replace(_path, "{user_id}", userID, -1) + } else { + return nil, errors.New("userId is required on UpdateUserProfileURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *UpdateUserProfileURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *UpdateUserProfileURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *UpdateUserProfileURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on UpdateUserProfileURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on UpdateUserProfileURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *UpdateUserProfileURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/usergroup/create_user_group.go b/src/server/v2.0/restapi/operations/usergroup/create_user_group.go new file mode 100644 index 000000000..c7df8fa0f --- /dev/null +++ b/src/server/v2.0/restapi/operations/usergroup/create_user_group.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package usergroup + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateUserGroupHandlerFunc turns a function with the right signature into a create user group handler +type CreateUserGroupHandlerFunc func(CreateUserGroupParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateUserGroupHandlerFunc) Handle(params CreateUserGroupParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateUserGroupHandler interface for that can handle valid create user group params +type CreateUserGroupHandler interface { + Handle(CreateUserGroupParams, interface{}) middleware.Responder +} + +// NewCreateUserGroup creates a new http.Handler for the create user group operation +func NewCreateUserGroup(ctx *middleware.Context, handler CreateUserGroupHandler) *CreateUserGroup { + return &CreateUserGroup{Context: ctx, Handler: handler} +} + +/*CreateUserGroup swagger:route POST /usergroups usergroup createUserGroup + +Create user group + +Create user group information + +*/ +type CreateUserGroup struct { + Context *middleware.Context + Handler CreateUserGroupHandler +} + +func (o *CreateUserGroup) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewCreateUserGroupParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/usergroup/create_user_group_parameters.go b/src/server/v2.0/restapi/operations/usergroup/create_user_group_parameters.go new file mode 100644 index 000000000..e696d284b --- /dev/null +++ b/src/server/v2.0/restapi/operations/usergroup/create_user_group_parameters.go @@ -0,0 +1,112 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package usergroup + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewCreateUserGroupParams creates a new CreateUserGroupParams object +// no default values defined in spec. +func NewCreateUserGroupParams() CreateUserGroupParams { + + return CreateUserGroupParams{} +} + +// CreateUserGroupParams contains all the bound params for the create user group operation +// typically these are obtained from a http.Request +// +// swagger:parameters createUserGroup +type CreateUserGroupParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /* + In: body + */ + Usergroup *models.UserGroup +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateUserGroupParams() beforehand. +func (o *CreateUserGroupParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.UserGroup + if err := route.Consumer.Consume(r.Body, &body); err != nil { + res = append(res, errors.NewParseError("usergroup", "body", "", err)) + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Usergroup = &body + } + } + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *CreateUserGroupParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *CreateUserGroupParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} diff --git a/src/server/v2.0/restapi/operations/usergroup/create_user_group_responses.go b/src/server/v2.0/restapi/operations/usergroup/create_user_group_responses.go new file mode 100644 index 000000000..3c4fbf8e0 --- /dev/null +++ b/src/server/v2.0/restapi/operations/usergroup/create_user_group_responses.go @@ -0,0 +1,390 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package usergroup + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// CreateUserGroupCreatedCode is the HTTP code returned for type CreateUserGroupCreated +const CreateUserGroupCreatedCode int = 201 + +/*CreateUserGroupCreated User group created successfully. + +swagger:response createUserGroupCreated +*/ +type CreateUserGroupCreated struct { + /*The URL of the created resource + + */ + Location string `json:"Location"` +} + +// NewCreateUserGroupCreated creates CreateUserGroupCreated with default headers values +func NewCreateUserGroupCreated() *CreateUserGroupCreated { + + return &CreateUserGroupCreated{} +} + +// WithLocation adds the location to the create user group created response +func (o *CreateUserGroupCreated) WithLocation(location string) *CreateUserGroupCreated { + o.Location = location + return o +} + +// SetLocation sets the location to the create user group created response +func (o *CreateUserGroupCreated) SetLocation(location string) { + o.Location = location +} + +// WriteResponse to the client +func (o *CreateUserGroupCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Location + + location := o.Location + if location != "" { + rw.Header().Set("Location", location) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(201) +} + +// CreateUserGroupBadRequestCode is the HTTP code returned for type CreateUserGroupBadRequest +const CreateUserGroupBadRequestCode int = 400 + +/*CreateUserGroupBadRequest Bad request + +swagger:response createUserGroupBadRequest +*/ +type CreateUserGroupBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateUserGroupBadRequest creates CreateUserGroupBadRequest with default headers values +func NewCreateUserGroupBadRequest() *CreateUserGroupBadRequest { + + return &CreateUserGroupBadRequest{} +} + +// WithXRequestID adds the xRequestId to the create user group bad request response +func (o *CreateUserGroupBadRequest) WithXRequestID(xRequestID string) *CreateUserGroupBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create user group bad request response +func (o *CreateUserGroupBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create user group bad request response +func (o *CreateUserGroupBadRequest) WithPayload(payload *models.Errors) *CreateUserGroupBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create user group bad request response +func (o *CreateUserGroupBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateUserGroupBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateUserGroupUnauthorizedCode is the HTTP code returned for type CreateUserGroupUnauthorized +const CreateUserGroupUnauthorizedCode int = 401 + +/*CreateUserGroupUnauthorized Unauthorized + +swagger:response createUserGroupUnauthorized +*/ +type CreateUserGroupUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateUserGroupUnauthorized creates CreateUserGroupUnauthorized with default headers values +func NewCreateUserGroupUnauthorized() *CreateUserGroupUnauthorized { + + return &CreateUserGroupUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the create user group unauthorized response +func (o *CreateUserGroupUnauthorized) WithXRequestID(xRequestID string) *CreateUserGroupUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create user group unauthorized response +func (o *CreateUserGroupUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create user group unauthorized response +func (o *CreateUserGroupUnauthorized) WithPayload(payload *models.Errors) *CreateUserGroupUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create user group unauthorized response +func (o *CreateUserGroupUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateUserGroupUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateUserGroupForbiddenCode is the HTTP code returned for type CreateUserGroupForbidden +const CreateUserGroupForbiddenCode int = 403 + +/*CreateUserGroupForbidden Forbidden + +swagger:response createUserGroupForbidden +*/ +type CreateUserGroupForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateUserGroupForbidden creates CreateUserGroupForbidden with default headers values +func NewCreateUserGroupForbidden() *CreateUserGroupForbidden { + + return &CreateUserGroupForbidden{} +} + +// WithXRequestID adds the xRequestId to the create user group forbidden response +func (o *CreateUserGroupForbidden) WithXRequestID(xRequestID string) *CreateUserGroupForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create user group forbidden response +func (o *CreateUserGroupForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create user group forbidden response +func (o *CreateUserGroupForbidden) WithPayload(payload *models.Errors) *CreateUserGroupForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create user group forbidden response +func (o *CreateUserGroupForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateUserGroupForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateUserGroupConflictCode is the HTTP code returned for type CreateUserGroupConflict +const CreateUserGroupConflictCode int = 409 + +/*CreateUserGroupConflict Conflict + +swagger:response createUserGroupConflict +*/ +type CreateUserGroupConflict struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateUserGroupConflict creates CreateUserGroupConflict with default headers values +func NewCreateUserGroupConflict() *CreateUserGroupConflict { + + return &CreateUserGroupConflict{} +} + +// WithXRequestID adds the xRequestId to the create user group conflict response +func (o *CreateUserGroupConflict) WithXRequestID(xRequestID string) *CreateUserGroupConflict { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create user group conflict response +func (o *CreateUserGroupConflict) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create user group conflict response +func (o *CreateUserGroupConflict) WithPayload(payload *models.Errors) *CreateUserGroupConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create user group conflict response +func (o *CreateUserGroupConflict) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateUserGroupConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateUserGroupInternalServerErrorCode is the HTTP code returned for type CreateUserGroupInternalServerError +const CreateUserGroupInternalServerErrorCode int = 500 + +/*CreateUserGroupInternalServerError Internal server error + +swagger:response createUserGroupInternalServerError +*/ +type CreateUserGroupInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateUserGroupInternalServerError creates CreateUserGroupInternalServerError with default headers values +func NewCreateUserGroupInternalServerError() *CreateUserGroupInternalServerError { + + return &CreateUserGroupInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the create user group internal server error response +func (o *CreateUserGroupInternalServerError) WithXRequestID(xRequestID string) *CreateUserGroupInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create user group internal server error response +func (o *CreateUserGroupInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create user group internal server error response +func (o *CreateUserGroupInternalServerError) WithPayload(payload *models.Errors) *CreateUserGroupInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create user group internal server error response +func (o *CreateUserGroupInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateUserGroupInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/usergroup/create_user_group_urlbuilder.go b/src/server/v2.0/restapi/operations/usergroup/create_user_group_urlbuilder.go new file mode 100644 index 000000000..8dbbb0cac --- /dev/null +++ b/src/server/v2.0/restapi/operations/usergroup/create_user_group_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package usergroup + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// CreateUserGroupURL generates an URL for the create user group operation +type CreateUserGroupURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateUserGroupURL) WithBasePath(bp string) *CreateUserGroupURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateUserGroupURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateUserGroupURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/usergroups" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateUserGroupURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateUserGroupURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateUserGroupURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateUserGroupURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateUserGroupURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateUserGroupURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/usergroup/delete_user_group.go b/src/server/v2.0/restapi/operations/usergroup/delete_user_group.go new file mode 100644 index 000000000..9a899109a --- /dev/null +++ b/src/server/v2.0/restapi/operations/usergroup/delete_user_group.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package usergroup + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteUserGroupHandlerFunc turns a function with the right signature into a delete user group handler +type DeleteUserGroupHandlerFunc func(DeleteUserGroupParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteUserGroupHandlerFunc) Handle(params DeleteUserGroupParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteUserGroupHandler interface for that can handle valid delete user group params +type DeleteUserGroupHandler interface { + Handle(DeleteUserGroupParams, interface{}) middleware.Responder +} + +// NewDeleteUserGroup creates a new http.Handler for the delete user group operation +func NewDeleteUserGroup(ctx *middleware.Context, handler DeleteUserGroupHandler) *DeleteUserGroup { + return &DeleteUserGroup{Context: ctx, Handler: handler} +} + +/*DeleteUserGroup swagger:route DELETE /usergroups/{group_id} usergroup deleteUserGroup + +Delete user group + +Delete user group + +*/ +type DeleteUserGroup struct { + Context *middleware.Context + Handler DeleteUserGroupHandler +} + +func (o *DeleteUserGroup) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewDeleteUserGroupParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/usergroup/delete_user_group_parameters.go b/src/server/v2.0/restapi/operations/usergroup/delete_user_group_parameters.go new file mode 100644 index 000000000..0bd3eccea --- /dev/null +++ b/src/server/v2.0/restapi/operations/usergroup/delete_user_group_parameters.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package usergroup + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewDeleteUserGroupParams creates a new DeleteUserGroupParams object +// no default values defined in spec. +func NewDeleteUserGroupParams() DeleteUserGroupParams { + + return DeleteUserGroupParams{} +} + +// DeleteUserGroupParams contains all the bound params for the delete user group operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteUserGroup +type DeleteUserGroupParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /* + Required: true + In: path + */ + GroupID int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteUserGroupParams() beforehand. +func (o *DeleteUserGroupParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rGroupID, rhkGroupID, _ := route.Params.GetOK("group_id") + if err := o.bindGroupID(rGroupID, rhkGroupID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *DeleteUserGroupParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *DeleteUserGroupParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindGroupID binds and validates parameter GroupID from path. +func (o *DeleteUserGroupParams) bindGroupID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("group_id", "path", "int64", raw) + } + o.GroupID = value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/usergroup/delete_user_group_responses.go b/src/server/v2.0/restapi/operations/usergroup/delete_user_group_responses.go new file mode 100644 index 000000000..ee7dd85e7 --- /dev/null +++ b/src/server/v2.0/restapi/operations/usergroup/delete_user_group_responses.go @@ -0,0 +1,324 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package usergroup + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// DeleteUserGroupOKCode is the HTTP code returned for type DeleteUserGroupOK +const DeleteUserGroupOKCode int = 200 + +/*DeleteUserGroupOK Success + +swagger:response deleteUserGroupOK +*/ +type DeleteUserGroupOK struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewDeleteUserGroupOK creates DeleteUserGroupOK with default headers values +func NewDeleteUserGroupOK() *DeleteUserGroupOK { + + return &DeleteUserGroupOK{} +} + +// WithXRequestID adds the xRequestId to the delete user group o k response +func (o *DeleteUserGroupOK) WithXRequestID(xRequestID string) *DeleteUserGroupOK { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete user group o k response +func (o *DeleteUserGroupOK) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *DeleteUserGroupOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// DeleteUserGroupBadRequestCode is the HTTP code returned for type DeleteUserGroupBadRequest +const DeleteUserGroupBadRequestCode int = 400 + +/*DeleteUserGroupBadRequest Bad request + +swagger:response deleteUserGroupBadRequest +*/ +type DeleteUserGroupBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteUserGroupBadRequest creates DeleteUserGroupBadRequest with default headers values +func NewDeleteUserGroupBadRequest() *DeleteUserGroupBadRequest { + + return &DeleteUserGroupBadRequest{} +} + +// WithXRequestID adds the xRequestId to the delete user group bad request response +func (o *DeleteUserGroupBadRequest) WithXRequestID(xRequestID string) *DeleteUserGroupBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete user group bad request response +func (o *DeleteUserGroupBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete user group bad request response +func (o *DeleteUserGroupBadRequest) WithPayload(payload *models.Errors) *DeleteUserGroupBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete user group bad request response +func (o *DeleteUserGroupBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteUserGroupBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteUserGroupUnauthorizedCode is the HTTP code returned for type DeleteUserGroupUnauthorized +const DeleteUserGroupUnauthorizedCode int = 401 + +/*DeleteUserGroupUnauthorized Unauthorized + +swagger:response deleteUserGroupUnauthorized +*/ +type DeleteUserGroupUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteUserGroupUnauthorized creates DeleteUserGroupUnauthorized with default headers values +func NewDeleteUserGroupUnauthorized() *DeleteUserGroupUnauthorized { + + return &DeleteUserGroupUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the delete user group unauthorized response +func (o *DeleteUserGroupUnauthorized) WithXRequestID(xRequestID string) *DeleteUserGroupUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete user group unauthorized response +func (o *DeleteUserGroupUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete user group unauthorized response +func (o *DeleteUserGroupUnauthorized) WithPayload(payload *models.Errors) *DeleteUserGroupUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete user group unauthorized response +func (o *DeleteUserGroupUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteUserGroupUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteUserGroupForbiddenCode is the HTTP code returned for type DeleteUserGroupForbidden +const DeleteUserGroupForbiddenCode int = 403 + +/*DeleteUserGroupForbidden Forbidden + +swagger:response deleteUserGroupForbidden +*/ +type DeleteUserGroupForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteUserGroupForbidden creates DeleteUserGroupForbidden with default headers values +func NewDeleteUserGroupForbidden() *DeleteUserGroupForbidden { + + return &DeleteUserGroupForbidden{} +} + +// WithXRequestID adds the xRequestId to the delete user group forbidden response +func (o *DeleteUserGroupForbidden) WithXRequestID(xRequestID string) *DeleteUserGroupForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete user group forbidden response +func (o *DeleteUserGroupForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete user group forbidden response +func (o *DeleteUserGroupForbidden) WithPayload(payload *models.Errors) *DeleteUserGroupForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete user group forbidden response +func (o *DeleteUserGroupForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteUserGroupForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteUserGroupInternalServerErrorCode is the HTTP code returned for type DeleteUserGroupInternalServerError +const DeleteUserGroupInternalServerErrorCode int = 500 + +/*DeleteUserGroupInternalServerError Internal server error + +swagger:response deleteUserGroupInternalServerError +*/ +type DeleteUserGroupInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteUserGroupInternalServerError creates DeleteUserGroupInternalServerError with default headers values +func NewDeleteUserGroupInternalServerError() *DeleteUserGroupInternalServerError { + + return &DeleteUserGroupInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the delete user group internal server error response +func (o *DeleteUserGroupInternalServerError) WithXRequestID(xRequestID string) *DeleteUserGroupInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete user group internal server error response +func (o *DeleteUserGroupInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete user group internal server error response +func (o *DeleteUserGroupInternalServerError) WithPayload(payload *models.Errors) *DeleteUserGroupInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete user group internal server error response +func (o *DeleteUserGroupInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteUserGroupInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/usergroup/delete_user_group_urlbuilder.go b/src/server/v2.0/restapi/operations/usergroup/delete_user_group_urlbuilder.go new file mode 100644 index 000000000..e2f7ce9eb --- /dev/null +++ b/src/server/v2.0/restapi/operations/usergroup/delete_user_group_urlbuilder.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package usergroup + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteUserGroupURL generates an URL for the delete user group operation +type DeleteUserGroupURL struct { + GroupID int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteUserGroupURL) WithBasePath(bp string) *DeleteUserGroupURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteUserGroupURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteUserGroupURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/usergroups/{group_id}" + + groupID := swag.FormatInt64(o.GroupID) + if groupID != "" { + _path = strings.Replace(_path, "{group_id}", groupID, -1) + } else { + return nil, errors.New("groupId is required on DeleteUserGroupURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteUserGroupURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteUserGroupURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteUserGroupURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteUserGroupURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteUserGroupURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteUserGroupURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/usergroup/get_user_group.go b/src/server/v2.0/restapi/operations/usergroup/get_user_group.go new file mode 100644 index 000000000..90e4b27d4 --- /dev/null +++ b/src/server/v2.0/restapi/operations/usergroup/get_user_group.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package usergroup + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetUserGroupHandlerFunc turns a function with the right signature into a get user group handler +type GetUserGroupHandlerFunc func(GetUserGroupParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetUserGroupHandlerFunc) Handle(params GetUserGroupParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetUserGroupHandler interface for that can handle valid get user group params +type GetUserGroupHandler interface { + Handle(GetUserGroupParams, interface{}) middleware.Responder +} + +// NewGetUserGroup creates a new http.Handler for the get user group operation +func NewGetUserGroup(ctx *middleware.Context, handler GetUserGroupHandler) *GetUserGroup { + return &GetUserGroup{Context: ctx, Handler: handler} +} + +/*GetUserGroup swagger:route GET /usergroups/{group_id} usergroup getUserGroup + +Get user group information + +Get user group information + +*/ +type GetUserGroup struct { + Context *middleware.Context + Handler GetUserGroupHandler +} + +func (o *GetUserGroup) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetUserGroupParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/usergroup/get_user_group_parameters.go b/src/server/v2.0/restapi/operations/usergroup/get_user_group_parameters.go new file mode 100644 index 000000000..223e89d85 --- /dev/null +++ b/src/server/v2.0/restapi/operations/usergroup/get_user_group_parameters.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package usergroup + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewGetUserGroupParams creates a new GetUserGroupParams object +// no default values defined in spec. +func NewGetUserGroupParams() GetUserGroupParams { + + return GetUserGroupParams{} +} + +// GetUserGroupParams contains all the bound params for the get user group operation +// typically these are obtained from a http.Request +// +// swagger:parameters getUserGroup +type GetUserGroupParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*Group ID + Required: true + In: path + */ + GroupID int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetUserGroupParams() beforehand. +func (o *GetUserGroupParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rGroupID, rhkGroupID, _ := route.Params.GetOK("group_id") + if err := o.bindGroupID(rGroupID, rhkGroupID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetUserGroupParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetUserGroupParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindGroupID binds and validates parameter GroupID from path. +func (o *GetUserGroupParams) bindGroupID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("group_id", "path", "int64", raw) + } + o.GroupID = value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/usergroup/get_user_group_responses.go b/src/server/v2.0/restapi/operations/usergroup/get_user_group_responses.go new file mode 100644 index 000000000..82ebfc884 --- /dev/null +++ b/src/server/v2.0/restapi/operations/usergroup/get_user_group_responses.go @@ -0,0 +1,388 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package usergroup + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetUserGroupOKCode is the HTTP code returned for type GetUserGroupOK +const GetUserGroupOKCode int = 200 + +/*GetUserGroupOK User group get successfully. + +swagger:response getUserGroupOK +*/ +type GetUserGroupOK struct { + + /* + In: Body + */ + Payload *models.UserGroup `json:"body,omitempty"` +} + +// NewGetUserGroupOK creates GetUserGroupOK with default headers values +func NewGetUserGroupOK() *GetUserGroupOK { + + return &GetUserGroupOK{} +} + +// WithPayload adds the payload to the get user group o k response +func (o *GetUserGroupOK) WithPayload(payload *models.UserGroup) *GetUserGroupOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get user group o k response +func (o *GetUserGroupOK) SetPayload(payload *models.UserGroup) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetUserGroupOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetUserGroupBadRequestCode is the HTTP code returned for type GetUserGroupBadRequest +const GetUserGroupBadRequestCode int = 400 + +/*GetUserGroupBadRequest Bad request + +swagger:response getUserGroupBadRequest +*/ +type GetUserGroupBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetUserGroupBadRequest creates GetUserGroupBadRequest with default headers values +func NewGetUserGroupBadRequest() *GetUserGroupBadRequest { + + return &GetUserGroupBadRequest{} +} + +// WithXRequestID adds the xRequestId to the get user group bad request response +func (o *GetUserGroupBadRequest) WithXRequestID(xRequestID string) *GetUserGroupBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get user group bad request response +func (o *GetUserGroupBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get user group bad request response +func (o *GetUserGroupBadRequest) WithPayload(payload *models.Errors) *GetUserGroupBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get user group bad request response +func (o *GetUserGroupBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetUserGroupBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetUserGroupUnauthorizedCode is the HTTP code returned for type GetUserGroupUnauthorized +const GetUserGroupUnauthorizedCode int = 401 + +/*GetUserGroupUnauthorized Unauthorized + +swagger:response getUserGroupUnauthorized +*/ +type GetUserGroupUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetUserGroupUnauthorized creates GetUserGroupUnauthorized with default headers values +func NewGetUserGroupUnauthorized() *GetUserGroupUnauthorized { + + return &GetUserGroupUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the get user group unauthorized response +func (o *GetUserGroupUnauthorized) WithXRequestID(xRequestID string) *GetUserGroupUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get user group unauthorized response +func (o *GetUserGroupUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get user group unauthorized response +func (o *GetUserGroupUnauthorized) WithPayload(payload *models.Errors) *GetUserGroupUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get user group unauthorized response +func (o *GetUserGroupUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetUserGroupUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetUserGroupForbiddenCode is the HTTP code returned for type GetUserGroupForbidden +const GetUserGroupForbiddenCode int = 403 + +/*GetUserGroupForbidden Forbidden + +swagger:response getUserGroupForbidden +*/ +type GetUserGroupForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetUserGroupForbidden creates GetUserGroupForbidden with default headers values +func NewGetUserGroupForbidden() *GetUserGroupForbidden { + + return &GetUserGroupForbidden{} +} + +// WithXRequestID adds the xRequestId to the get user group forbidden response +func (o *GetUserGroupForbidden) WithXRequestID(xRequestID string) *GetUserGroupForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get user group forbidden response +func (o *GetUserGroupForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get user group forbidden response +func (o *GetUserGroupForbidden) WithPayload(payload *models.Errors) *GetUserGroupForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get user group forbidden response +func (o *GetUserGroupForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetUserGroupForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetUserGroupNotFoundCode is the HTTP code returned for type GetUserGroupNotFound +const GetUserGroupNotFoundCode int = 404 + +/*GetUserGroupNotFound Not found + +swagger:response getUserGroupNotFound +*/ +type GetUserGroupNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetUserGroupNotFound creates GetUserGroupNotFound with default headers values +func NewGetUserGroupNotFound() *GetUserGroupNotFound { + + return &GetUserGroupNotFound{} +} + +// WithXRequestID adds the xRequestId to the get user group not found response +func (o *GetUserGroupNotFound) WithXRequestID(xRequestID string) *GetUserGroupNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get user group not found response +func (o *GetUserGroupNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get user group not found response +func (o *GetUserGroupNotFound) WithPayload(payload *models.Errors) *GetUserGroupNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get user group not found response +func (o *GetUserGroupNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetUserGroupNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetUserGroupInternalServerErrorCode is the HTTP code returned for type GetUserGroupInternalServerError +const GetUserGroupInternalServerErrorCode int = 500 + +/*GetUserGroupInternalServerError Internal server error + +swagger:response getUserGroupInternalServerError +*/ +type GetUserGroupInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetUserGroupInternalServerError creates GetUserGroupInternalServerError with default headers values +func NewGetUserGroupInternalServerError() *GetUserGroupInternalServerError { + + return &GetUserGroupInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get user group internal server error response +func (o *GetUserGroupInternalServerError) WithXRequestID(xRequestID string) *GetUserGroupInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get user group internal server error response +func (o *GetUserGroupInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get user group internal server error response +func (o *GetUserGroupInternalServerError) WithPayload(payload *models.Errors) *GetUserGroupInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get user group internal server error response +func (o *GetUserGroupInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetUserGroupInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/usergroup/get_user_group_urlbuilder.go b/src/server/v2.0/restapi/operations/usergroup/get_user_group_urlbuilder.go new file mode 100644 index 000000000..9d140ad37 --- /dev/null +++ b/src/server/v2.0/restapi/operations/usergroup/get_user_group_urlbuilder.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package usergroup + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetUserGroupURL generates an URL for the get user group operation +type GetUserGroupURL struct { + GroupID int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetUserGroupURL) WithBasePath(bp string) *GetUserGroupURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetUserGroupURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetUserGroupURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/usergroups/{group_id}" + + groupID := swag.FormatInt64(o.GroupID) + if groupID != "" { + _path = strings.Replace(_path, "{group_id}", groupID, -1) + } else { + return nil, errors.New("groupId is required on GetUserGroupURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetUserGroupURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetUserGroupURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetUserGroupURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetUserGroupURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetUserGroupURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetUserGroupURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/usergroup/list_user_groups.go b/src/server/v2.0/restapi/operations/usergroup/list_user_groups.go new file mode 100644 index 000000000..b1010712c --- /dev/null +++ b/src/server/v2.0/restapi/operations/usergroup/list_user_groups.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package usergroup + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ListUserGroupsHandlerFunc turns a function with the right signature into a list user groups handler +type ListUserGroupsHandlerFunc func(ListUserGroupsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ListUserGroupsHandlerFunc) Handle(params ListUserGroupsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ListUserGroupsHandler interface for that can handle valid list user groups params +type ListUserGroupsHandler interface { + Handle(ListUserGroupsParams, interface{}) middleware.Responder +} + +// NewListUserGroups creates a new http.Handler for the list user groups operation +func NewListUserGroups(ctx *middleware.Context, handler ListUserGroupsHandler) *ListUserGroups { + return &ListUserGroups{Context: ctx, Handler: handler} +} + +/*ListUserGroups swagger:route GET /usergroups usergroup listUserGroups + +Get all user groups information + +Get all user groups information, it is open for system admin + +*/ +type ListUserGroups struct { + Context *middleware.Context + Handler ListUserGroupsHandler +} + +func (o *ListUserGroups) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewListUserGroupsParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/usergroup/list_user_groups_parameters.go b/src/server/v2.0/restapi/operations/usergroup/list_user_groups_parameters.go new file mode 100644 index 000000000..d739be0cc --- /dev/null +++ b/src/server/v2.0/restapi/operations/usergroup/list_user_groups_parameters.go @@ -0,0 +1,239 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package usergroup + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewListUserGroupsParams creates a new ListUserGroupsParams object +// with the default values initialized. +func NewListUserGroupsParams() ListUserGroupsParams { + + var ( + // initialize parameters with default values + + pageDefault = int64(1) + pageSizeDefault = int64(10) + ) + + return ListUserGroupsParams{ + Page: &pageDefault, + + PageSize: &pageSizeDefault, + } +} + +// ListUserGroupsParams contains all the bound params for the list user groups operation +// typically these are obtained from a http.Request +// +// swagger:parameters listUserGroups +type ListUserGroupsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*group name need to search, fuzzy matches + In: query + */ + GroupName *string + /*search with ldap group DN + In: query + */ + LdapGroupDn *string + /*The page number + In: query + Default: 1 + */ + Page *int64 + /*The size of per page + Maximum: 100 + In: query + Default: 10 + */ + PageSize *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewListUserGroupsParams() beforehand. +func (o *ListUserGroupsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + qGroupName, qhkGroupName, _ := qs.GetOK("group_name") + if err := o.bindGroupName(qGroupName, qhkGroupName, route.Formats); err != nil { + res = append(res, err) + } + + qLdapGroupDn, qhkLdapGroupDn, _ := qs.GetOK("ldap_group_dn") + if err := o.bindLdapGroupDn(qLdapGroupDn, qhkLdapGroupDn, route.Formats); err != nil { + res = append(res, err) + } + + qPage, qhkPage, _ := qs.GetOK("page") + if err := o.bindPage(qPage, qhkPage, route.Formats); err != nil { + res = append(res, err) + } + + qPageSize, qhkPageSize, _ := qs.GetOK("page_size") + if err := o.bindPageSize(qPageSize, qhkPageSize, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *ListUserGroupsParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *ListUserGroupsParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindGroupName binds and validates parameter GroupName from query. +func (o *ListUserGroupsParams) bindGroupName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.GroupName = &raw + + return nil +} + +// bindLdapGroupDn binds and validates parameter LdapGroupDn from query. +func (o *ListUserGroupsParams) bindLdapGroupDn(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.LdapGroupDn = &raw + + return nil +} + +// bindPage binds and validates parameter Page from query. +func (o *ListUserGroupsParams) bindPage(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListUserGroupsParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page", "query", "int64", raw) + } + o.Page = &value + + return nil +} + +// bindPageSize binds and validates parameter PageSize from query. +func (o *ListUserGroupsParams) bindPageSize(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListUserGroupsParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page_size", "query", "int64", raw) + } + o.PageSize = &value + + if err := o.validatePageSize(formats); err != nil { + return err + } + + return nil +} + +// validatePageSize carries on validations for parameter PageSize +func (o *ListUserGroupsParams) validatePageSize(formats strfmt.Registry) error { + + if err := validate.MaximumInt("page_size", "query", int64(*o.PageSize), 100, false); err != nil { + return err + } + + return nil +} diff --git a/src/server/v2.0/restapi/operations/usergroup/list_user_groups_responses.go b/src/server/v2.0/restapi/operations/usergroup/list_user_groups_responses.go new file mode 100644 index 000000000..5a554f721 --- /dev/null +++ b/src/server/v2.0/restapi/operations/usergroup/list_user_groups_responses.go @@ -0,0 +1,304 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package usergroup + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/swag" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// ListUserGroupsOKCode is the HTTP code returned for type ListUserGroupsOK +const ListUserGroupsOKCode int = 200 + +/*ListUserGroupsOK Get user group successfully. + +swagger:response listUserGroupsOK +*/ +type ListUserGroupsOK struct { + /*Link to previous page and next page + + */ + Link string `json:"Link"` + /*The total count of available items + + */ + XTotalCount int64 `json:"X-Total-Count"` + + /* + In: Body + */ + Payload []*models.UserGroup `json:"body,omitempty"` +} + +// NewListUserGroupsOK creates ListUserGroupsOK with default headers values +func NewListUserGroupsOK() *ListUserGroupsOK { + + return &ListUserGroupsOK{} +} + +// WithLink adds the link to the list user groups o k response +func (o *ListUserGroupsOK) WithLink(link string) *ListUserGroupsOK { + o.Link = link + return o +} + +// SetLink sets the link to the list user groups o k response +func (o *ListUserGroupsOK) SetLink(link string) { + o.Link = link +} + +// WithXTotalCount adds the xTotalCount to the list user groups o k response +func (o *ListUserGroupsOK) WithXTotalCount(xTotalCount int64) *ListUserGroupsOK { + o.XTotalCount = xTotalCount + return o +} + +// SetXTotalCount sets the xTotalCount to the list user groups o k response +func (o *ListUserGroupsOK) SetXTotalCount(xTotalCount int64) { + o.XTotalCount = xTotalCount +} + +// WithPayload adds the payload to the list user groups o k response +func (o *ListUserGroupsOK) WithPayload(payload []*models.UserGroup) *ListUserGroupsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list user groups o k response +func (o *ListUserGroupsOK) SetPayload(payload []*models.UserGroup) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListUserGroupsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Link + + link := o.Link + if link != "" { + rw.Header().Set("Link", link) + } + + // response header X-Total-Count + + xTotalCount := swag.FormatInt64(o.XTotalCount) + if xTotalCount != "" { + rw.Header().Set("X-Total-Count", xTotalCount) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = make([]*models.UserGroup, 0, 50) + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ListUserGroupsUnauthorizedCode is the HTTP code returned for type ListUserGroupsUnauthorized +const ListUserGroupsUnauthorizedCode int = 401 + +/*ListUserGroupsUnauthorized Unauthorized + +swagger:response listUserGroupsUnauthorized +*/ +type ListUserGroupsUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListUserGroupsUnauthorized creates ListUserGroupsUnauthorized with default headers values +func NewListUserGroupsUnauthorized() *ListUserGroupsUnauthorized { + + return &ListUserGroupsUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the list user groups unauthorized response +func (o *ListUserGroupsUnauthorized) WithXRequestID(xRequestID string) *ListUserGroupsUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list user groups unauthorized response +func (o *ListUserGroupsUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list user groups unauthorized response +func (o *ListUserGroupsUnauthorized) WithPayload(payload *models.Errors) *ListUserGroupsUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list user groups unauthorized response +func (o *ListUserGroupsUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListUserGroupsUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListUserGroupsForbiddenCode is the HTTP code returned for type ListUserGroupsForbidden +const ListUserGroupsForbiddenCode int = 403 + +/*ListUserGroupsForbidden Forbidden + +swagger:response listUserGroupsForbidden +*/ +type ListUserGroupsForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListUserGroupsForbidden creates ListUserGroupsForbidden with default headers values +func NewListUserGroupsForbidden() *ListUserGroupsForbidden { + + return &ListUserGroupsForbidden{} +} + +// WithXRequestID adds the xRequestId to the list user groups forbidden response +func (o *ListUserGroupsForbidden) WithXRequestID(xRequestID string) *ListUserGroupsForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list user groups forbidden response +func (o *ListUserGroupsForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list user groups forbidden response +func (o *ListUserGroupsForbidden) WithPayload(payload *models.Errors) *ListUserGroupsForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list user groups forbidden response +func (o *ListUserGroupsForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListUserGroupsForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListUserGroupsInternalServerErrorCode is the HTTP code returned for type ListUserGroupsInternalServerError +const ListUserGroupsInternalServerErrorCode int = 500 + +/*ListUserGroupsInternalServerError Internal server error + +swagger:response listUserGroupsInternalServerError +*/ +type ListUserGroupsInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListUserGroupsInternalServerError creates ListUserGroupsInternalServerError with default headers values +func NewListUserGroupsInternalServerError() *ListUserGroupsInternalServerError { + + return &ListUserGroupsInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the list user groups internal server error response +func (o *ListUserGroupsInternalServerError) WithXRequestID(xRequestID string) *ListUserGroupsInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list user groups internal server error response +func (o *ListUserGroupsInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list user groups internal server error response +func (o *ListUserGroupsInternalServerError) WithPayload(payload *models.Errors) *ListUserGroupsInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list user groups internal server error response +func (o *ListUserGroupsInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListUserGroupsInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/usergroup/list_user_groups_urlbuilder.go b/src/server/v2.0/restapi/operations/usergroup/list_user_groups_urlbuilder.go new file mode 100644 index 000000000..13e461675 --- /dev/null +++ b/src/server/v2.0/restapi/operations/usergroup/list_user_groups_urlbuilder.go @@ -0,0 +1,132 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package usergroup + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// ListUserGroupsURL generates an URL for the list user groups operation +type ListUserGroupsURL struct { + GroupName *string + LdapGroupDn *string + Page *int64 + PageSize *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListUserGroupsURL) WithBasePath(bp string) *ListUserGroupsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListUserGroupsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ListUserGroupsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/usergroups" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var groupNameQ string + if o.GroupName != nil { + groupNameQ = *o.GroupName + } + if groupNameQ != "" { + qs.Set("group_name", groupNameQ) + } + + var ldapGroupDnQ string + if o.LdapGroupDn != nil { + ldapGroupDnQ = *o.LdapGroupDn + } + if ldapGroupDnQ != "" { + qs.Set("ldap_group_dn", ldapGroupDnQ) + } + + var pageQ string + if o.Page != nil { + pageQ = swag.FormatInt64(*o.Page) + } + if pageQ != "" { + qs.Set("page", pageQ) + } + + var pageSizeQ string + if o.PageSize != nil { + pageSizeQ = swag.FormatInt64(*o.PageSize) + } + if pageSizeQ != "" { + qs.Set("page_size", pageSizeQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ListUserGroupsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ListUserGroupsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ListUserGroupsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ListUserGroupsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ListUserGroupsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ListUserGroupsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/usergroup/search_user_groups.go b/src/server/v2.0/restapi/operations/usergroup/search_user_groups.go new file mode 100644 index 000000000..018760bc5 --- /dev/null +++ b/src/server/v2.0/restapi/operations/usergroup/search_user_groups.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package usergroup + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// SearchUserGroupsHandlerFunc turns a function with the right signature into a search user groups handler +type SearchUserGroupsHandlerFunc func(SearchUserGroupsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn SearchUserGroupsHandlerFunc) Handle(params SearchUserGroupsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// SearchUserGroupsHandler interface for that can handle valid search user groups params +type SearchUserGroupsHandler interface { + Handle(SearchUserGroupsParams, interface{}) middleware.Responder +} + +// NewSearchUserGroups creates a new http.Handler for the search user groups operation +func NewSearchUserGroups(ctx *middleware.Context, handler SearchUserGroupsHandler) *SearchUserGroups { + return &SearchUserGroups{Context: ctx, Handler: handler} +} + +/*SearchUserGroups swagger:route GET /usergroups/search usergroup searchUserGroups + +Search groups by groupname + +This endpoint is to search groups by group name. It's open for all authenticated requests. + + +*/ +type SearchUserGroups struct { + Context *middleware.Context + Handler SearchUserGroupsHandler +} + +func (o *SearchUserGroups) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewSearchUserGroupsParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/usergroup/search_user_groups_parameters.go b/src/server/v2.0/restapi/operations/usergroup/search_user_groups_parameters.go new file mode 100644 index 000000000..8051b3009 --- /dev/null +++ b/src/server/v2.0/restapi/operations/usergroup/search_user_groups_parameters.go @@ -0,0 +1,216 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package usergroup + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewSearchUserGroupsParams creates a new SearchUserGroupsParams object +// with the default values initialized. +func NewSearchUserGroupsParams() SearchUserGroupsParams { + + var ( + // initialize parameters with default values + + pageDefault = int64(1) + pageSizeDefault = int64(10) + ) + + return SearchUserGroupsParams{ + Page: &pageDefault, + + PageSize: &pageSizeDefault, + } +} + +// SearchUserGroupsParams contains all the bound params for the search user groups operation +// typically these are obtained from a http.Request +// +// swagger:parameters searchUserGroups +type SearchUserGroupsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*Group name for filtering results. + Required: true + In: query + */ + Groupname string + /*The page number + In: query + Default: 1 + */ + Page *int64 + /*The size of per page + Maximum: 100 + In: query + Default: 10 + */ + PageSize *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewSearchUserGroupsParams() beforehand. +func (o *SearchUserGroupsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + qGroupname, qhkGroupname, _ := qs.GetOK("groupname") + if err := o.bindGroupname(qGroupname, qhkGroupname, route.Formats); err != nil { + res = append(res, err) + } + + qPage, qhkPage, _ := qs.GetOK("page") + if err := o.bindPage(qPage, qhkPage, route.Formats); err != nil { + res = append(res, err) + } + + qPageSize, qhkPageSize, _ := qs.GetOK("page_size") + if err := o.bindPageSize(qPageSize, qhkPageSize, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *SearchUserGroupsParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *SearchUserGroupsParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindGroupname binds and validates parameter Groupname from query. +func (o *SearchUserGroupsParams) bindGroupname(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("groupname", "query", rawData) + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // AllowEmptyValue: false + if err := validate.RequiredString("groupname", "query", raw); err != nil { + return err + } + + o.Groupname = raw + + return nil +} + +// bindPage binds and validates parameter Page from query. +func (o *SearchUserGroupsParams) bindPage(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewSearchUserGroupsParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page", "query", "int64", raw) + } + o.Page = &value + + return nil +} + +// bindPageSize binds and validates parameter PageSize from query. +func (o *SearchUserGroupsParams) bindPageSize(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewSearchUserGroupsParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page_size", "query", "int64", raw) + } + o.PageSize = &value + + if err := o.validatePageSize(formats); err != nil { + return err + } + + return nil +} + +// validatePageSize carries on validations for parameter PageSize +func (o *SearchUserGroupsParams) validatePageSize(formats strfmt.Registry) error { + + if err := validate.MaximumInt("page_size", "query", int64(*o.PageSize), 100, false); err != nil { + return err + } + + return nil +} diff --git a/src/server/v2.0/restapi/operations/usergroup/search_user_groups_responses.go b/src/server/v2.0/restapi/operations/usergroup/search_user_groups_responses.go new file mode 100644 index 000000000..da9226ab0 --- /dev/null +++ b/src/server/v2.0/restapi/operations/usergroup/search_user_groups_responses.go @@ -0,0 +1,238 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package usergroup + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/swag" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// SearchUserGroupsOKCode is the HTTP code returned for type SearchUserGroupsOK +const SearchUserGroupsOKCode int = 200 + +/*SearchUserGroupsOK Search groups successfully. + +swagger:response searchUserGroupsOK +*/ +type SearchUserGroupsOK struct { + /*Link to previous page and next page + + */ + Link string `json:"Link"` + /*The total count of available items + + */ + XTotalCount int64 `json:"X-Total-Count"` + + /* + In: Body + */ + Payload []*models.UserGroupSearchItem `json:"body,omitempty"` +} + +// NewSearchUserGroupsOK creates SearchUserGroupsOK with default headers values +func NewSearchUserGroupsOK() *SearchUserGroupsOK { + + return &SearchUserGroupsOK{} +} + +// WithLink adds the link to the search user groups o k response +func (o *SearchUserGroupsOK) WithLink(link string) *SearchUserGroupsOK { + o.Link = link + return o +} + +// SetLink sets the link to the search user groups o k response +func (o *SearchUserGroupsOK) SetLink(link string) { + o.Link = link +} + +// WithXTotalCount adds the xTotalCount to the search user groups o k response +func (o *SearchUserGroupsOK) WithXTotalCount(xTotalCount int64) *SearchUserGroupsOK { + o.XTotalCount = xTotalCount + return o +} + +// SetXTotalCount sets the xTotalCount to the search user groups o k response +func (o *SearchUserGroupsOK) SetXTotalCount(xTotalCount int64) { + o.XTotalCount = xTotalCount +} + +// WithPayload adds the payload to the search user groups o k response +func (o *SearchUserGroupsOK) WithPayload(payload []*models.UserGroupSearchItem) *SearchUserGroupsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the search user groups o k response +func (o *SearchUserGroupsOK) SetPayload(payload []*models.UserGroupSearchItem) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *SearchUserGroupsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Link + + link := o.Link + if link != "" { + rw.Header().Set("Link", link) + } + + // response header X-Total-Count + + xTotalCount := swag.FormatInt64(o.XTotalCount) + if xTotalCount != "" { + rw.Header().Set("X-Total-Count", xTotalCount) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = make([]*models.UserGroupSearchItem, 0, 50) + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// SearchUserGroupsUnauthorizedCode is the HTTP code returned for type SearchUserGroupsUnauthorized +const SearchUserGroupsUnauthorizedCode int = 401 + +/*SearchUserGroupsUnauthorized Unauthorized + +swagger:response searchUserGroupsUnauthorized +*/ +type SearchUserGroupsUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewSearchUserGroupsUnauthorized creates SearchUserGroupsUnauthorized with default headers values +func NewSearchUserGroupsUnauthorized() *SearchUserGroupsUnauthorized { + + return &SearchUserGroupsUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the search user groups unauthorized response +func (o *SearchUserGroupsUnauthorized) WithXRequestID(xRequestID string) *SearchUserGroupsUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the search user groups unauthorized response +func (o *SearchUserGroupsUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the search user groups unauthorized response +func (o *SearchUserGroupsUnauthorized) WithPayload(payload *models.Errors) *SearchUserGroupsUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the search user groups unauthorized response +func (o *SearchUserGroupsUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *SearchUserGroupsUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// SearchUserGroupsInternalServerErrorCode is the HTTP code returned for type SearchUserGroupsInternalServerError +const SearchUserGroupsInternalServerErrorCode int = 500 + +/*SearchUserGroupsInternalServerError Internal server error + +swagger:response searchUserGroupsInternalServerError +*/ +type SearchUserGroupsInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewSearchUserGroupsInternalServerError creates SearchUserGroupsInternalServerError with default headers values +func NewSearchUserGroupsInternalServerError() *SearchUserGroupsInternalServerError { + + return &SearchUserGroupsInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the search user groups internal server error response +func (o *SearchUserGroupsInternalServerError) WithXRequestID(xRequestID string) *SearchUserGroupsInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the search user groups internal server error response +func (o *SearchUserGroupsInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the search user groups internal server error response +func (o *SearchUserGroupsInternalServerError) WithPayload(payload *models.Errors) *SearchUserGroupsInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the search user groups internal server error response +func (o *SearchUserGroupsInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *SearchUserGroupsInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/usergroup/search_user_groups_urlbuilder.go b/src/server/v2.0/restapi/operations/usergroup/search_user_groups_urlbuilder.go new file mode 100644 index 000000000..82f64ef07 --- /dev/null +++ b/src/server/v2.0/restapi/operations/usergroup/search_user_groups_urlbuilder.go @@ -0,0 +1,120 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package usergroup + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// SearchUserGroupsURL generates an URL for the search user groups operation +type SearchUserGroupsURL struct { + Groupname string + Page *int64 + PageSize *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *SearchUserGroupsURL) WithBasePath(bp string) *SearchUserGroupsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *SearchUserGroupsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *SearchUserGroupsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/usergroups/search" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + groupnameQ := o.Groupname + if groupnameQ != "" { + qs.Set("groupname", groupnameQ) + } + + var pageQ string + if o.Page != nil { + pageQ = swag.FormatInt64(*o.Page) + } + if pageQ != "" { + qs.Set("page", pageQ) + } + + var pageSizeQ string + if o.PageSize != nil { + pageSizeQ = swag.FormatInt64(*o.PageSize) + } + if pageSizeQ != "" { + qs.Set("page_size", pageSizeQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *SearchUserGroupsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *SearchUserGroupsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *SearchUserGroupsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on SearchUserGroupsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on SearchUserGroupsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *SearchUserGroupsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/usergroup/update_user_group.go b/src/server/v2.0/restapi/operations/usergroup/update_user_group.go new file mode 100644 index 000000000..e560bf35f --- /dev/null +++ b/src/server/v2.0/restapi/operations/usergroup/update_user_group.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package usergroup + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// UpdateUserGroupHandlerFunc turns a function with the right signature into a update user group handler +type UpdateUserGroupHandlerFunc func(UpdateUserGroupParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn UpdateUserGroupHandlerFunc) Handle(params UpdateUserGroupParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// UpdateUserGroupHandler interface for that can handle valid update user group params +type UpdateUserGroupHandler interface { + Handle(UpdateUserGroupParams, interface{}) middleware.Responder +} + +// NewUpdateUserGroup creates a new http.Handler for the update user group operation +func NewUpdateUserGroup(ctx *middleware.Context, handler UpdateUserGroupHandler) *UpdateUserGroup { + return &UpdateUserGroup{Context: ctx, Handler: handler} +} + +/*UpdateUserGroup swagger:route PUT /usergroups/{group_id} usergroup updateUserGroup + +Update group information + +Update user group information + +*/ +type UpdateUserGroup struct { + Context *middleware.Context + Handler UpdateUserGroupHandler +} + +func (o *UpdateUserGroup) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewUpdateUserGroupParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/usergroup/update_user_group_parameters.go b/src/server/v2.0/restapi/operations/usergroup/update_user_group_parameters.go new file mode 100644 index 000000000..4d575f0aa --- /dev/null +++ b/src/server/v2.0/restapi/operations/usergroup/update_user_group_parameters.go @@ -0,0 +1,142 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package usergroup + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewUpdateUserGroupParams creates a new UpdateUserGroupParams object +// no default values defined in spec. +func NewUpdateUserGroupParams() UpdateUserGroupParams { + + return UpdateUserGroupParams{} +} + +// UpdateUserGroupParams contains all the bound params for the update user group operation +// typically these are obtained from a http.Request +// +// swagger:parameters updateUserGroup +type UpdateUserGroupParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*Group ID + Required: true + In: path + */ + GroupID int64 + /* + In: body + */ + Usergroup *models.UserGroup +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewUpdateUserGroupParams() beforehand. +func (o *UpdateUserGroupParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rGroupID, rhkGroupID, _ := route.Params.GetOK("group_id") + if err := o.bindGroupID(rGroupID, rhkGroupID, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.UserGroup + if err := route.Consumer.Consume(r.Body, &body); err != nil { + res = append(res, errors.NewParseError("usergroup", "body", "", err)) + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Usergroup = &body + } + } + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *UpdateUserGroupParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *UpdateUserGroupParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindGroupID binds and validates parameter GroupID from path. +func (o *UpdateUserGroupParams) bindGroupID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("group_id", "path", "int64", raw) + } + o.GroupID = value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/usergroup/update_user_group_responses.go b/src/server/v2.0/restapi/operations/usergroup/update_user_group_responses.go new file mode 100644 index 000000000..54e62bd03 --- /dev/null +++ b/src/server/v2.0/restapi/operations/usergroup/update_user_group_responses.go @@ -0,0 +1,390 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package usergroup + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// UpdateUserGroupOKCode is the HTTP code returned for type UpdateUserGroupOK +const UpdateUserGroupOKCode int = 200 + +/*UpdateUserGroupOK Success + +swagger:response updateUserGroupOK +*/ +type UpdateUserGroupOK struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewUpdateUserGroupOK creates UpdateUserGroupOK with default headers values +func NewUpdateUserGroupOK() *UpdateUserGroupOK { + + return &UpdateUserGroupOK{} +} + +// WithXRequestID adds the xRequestId to the update user group o k response +func (o *UpdateUserGroupOK) WithXRequestID(xRequestID string) *UpdateUserGroupOK { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update user group o k response +func (o *UpdateUserGroupOK) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *UpdateUserGroupOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// UpdateUserGroupBadRequestCode is the HTTP code returned for type UpdateUserGroupBadRequest +const UpdateUserGroupBadRequestCode int = 400 + +/*UpdateUserGroupBadRequest Bad request + +swagger:response updateUserGroupBadRequest +*/ +type UpdateUserGroupBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateUserGroupBadRequest creates UpdateUserGroupBadRequest with default headers values +func NewUpdateUserGroupBadRequest() *UpdateUserGroupBadRequest { + + return &UpdateUserGroupBadRequest{} +} + +// WithXRequestID adds the xRequestId to the update user group bad request response +func (o *UpdateUserGroupBadRequest) WithXRequestID(xRequestID string) *UpdateUserGroupBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update user group bad request response +func (o *UpdateUserGroupBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update user group bad request response +func (o *UpdateUserGroupBadRequest) WithPayload(payload *models.Errors) *UpdateUserGroupBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update user group bad request response +func (o *UpdateUserGroupBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateUserGroupBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateUserGroupUnauthorizedCode is the HTTP code returned for type UpdateUserGroupUnauthorized +const UpdateUserGroupUnauthorizedCode int = 401 + +/*UpdateUserGroupUnauthorized Unauthorized + +swagger:response updateUserGroupUnauthorized +*/ +type UpdateUserGroupUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateUserGroupUnauthorized creates UpdateUserGroupUnauthorized with default headers values +func NewUpdateUserGroupUnauthorized() *UpdateUserGroupUnauthorized { + + return &UpdateUserGroupUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the update user group unauthorized response +func (o *UpdateUserGroupUnauthorized) WithXRequestID(xRequestID string) *UpdateUserGroupUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update user group unauthorized response +func (o *UpdateUserGroupUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update user group unauthorized response +func (o *UpdateUserGroupUnauthorized) WithPayload(payload *models.Errors) *UpdateUserGroupUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update user group unauthorized response +func (o *UpdateUserGroupUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateUserGroupUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateUserGroupForbiddenCode is the HTTP code returned for type UpdateUserGroupForbidden +const UpdateUserGroupForbiddenCode int = 403 + +/*UpdateUserGroupForbidden Forbidden + +swagger:response updateUserGroupForbidden +*/ +type UpdateUserGroupForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateUserGroupForbidden creates UpdateUserGroupForbidden with default headers values +func NewUpdateUserGroupForbidden() *UpdateUserGroupForbidden { + + return &UpdateUserGroupForbidden{} +} + +// WithXRequestID adds the xRequestId to the update user group forbidden response +func (o *UpdateUserGroupForbidden) WithXRequestID(xRequestID string) *UpdateUserGroupForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update user group forbidden response +func (o *UpdateUserGroupForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update user group forbidden response +func (o *UpdateUserGroupForbidden) WithPayload(payload *models.Errors) *UpdateUserGroupForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update user group forbidden response +func (o *UpdateUserGroupForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateUserGroupForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateUserGroupNotFoundCode is the HTTP code returned for type UpdateUserGroupNotFound +const UpdateUserGroupNotFoundCode int = 404 + +/*UpdateUserGroupNotFound Not found + +swagger:response updateUserGroupNotFound +*/ +type UpdateUserGroupNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateUserGroupNotFound creates UpdateUserGroupNotFound with default headers values +func NewUpdateUserGroupNotFound() *UpdateUserGroupNotFound { + + return &UpdateUserGroupNotFound{} +} + +// WithXRequestID adds the xRequestId to the update user group not found response +func (o *UpdateUserGroupNotFound) WithXRequestID(xRequestID string) *UpdateUserGroupNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update user group not found response +func (o *UpdateUserGroupNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update user group not found response +func (o *UpdateUserGroupNotFound) WithPayload(payload *models.Errors) *UpdateUserGroupNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update user group not found response +func (o *UpdateUserGroupNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateUserGroupNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateUserGroupInternalServerErrorCode is the HTTP code returned for type UpdateUserGroupInternalServerError +const UpdateUserGroupInternalServerErrorCode int = 500 + +/*UpdateUserGroupInternalServerError Internal server error + +swagger:response updateUserGroupInternalServerError +*/ +type UpdateUserGroupInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateUserGroupInternalServerError creates UpdateUserGroupInternalServerError with default headers values +func NewUpdateUserGroupInternalServerError() *UpdateUserGroupInternalServerError { + + return &UpdateUserGroupInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the update user group internal server error response +func (o *UpdateUserGroupInternalServerError) WithXRequestID(xRequestID string) *UpdateUserGroupInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update user group internal server error response +func (o *UpdateUserGroupInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update user group internal server error response +func (o *UpdateUserGroupInternalServerError) WithPayload(payload *models.Errors) *UpdateUserGroupInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update user group internal server error response +func (o *UpdateUserGroupInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateUserGroupInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/usergroup/update_user_group_urlbuilder.go b/src/server/v2.0/restapi/operations/usergroup/update_user_group_urlbuilder.go new file mode 100644 index 000000000..ab17ad622 --- /dev/null +++ b/src/server/v2.0/restapi/operations/usergroup/update_user_group_urlbuilder.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package usergroup + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// UpdateUserGroupURL generates an URL for the update user group operation +type UpdateUserGroupURL struct { + GroupID int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdateUserGroupURL) WithBasePath(bp string) *UpdateUserGroupURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdateUserGroupURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *UpdateUserGroupURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/usergroups/{group_id}" + + groupID := swag.FormatInt64(o.GroupID) + if groupID != "" { + _path = strings.Replace(_path, "{group_id}", groupID, -1) + } else { + return nil, errors.New("groupId is required on UpdateUserGroupURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *UpdateUserGroupURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *UpdateUserGroupURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *UpdateUserGroupURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on UpdateUserGroupURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on UpdateUserGroupURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *UpdateUserGroupURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/webhook/create_webhook_policy_of_project.go b/src/server/v2.0/restapi/operations/webhook/create_webhook_policy_of_project.go new file mode 100644 index 000000000..1b11e3608 --- /dev/null +++ b/src/server/v2.0/restapi/operations/webhook/create_webhook_policy_of_project.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package webhook + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateWebhookPolicyOfProjectHandlerFunc turns a function with the right signature into a create webhook policy of project handler +type CreateWebhookPolicyOfProjectHandlerFunc func(CreateWebhookPolicyOfProjectParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateWebhookPolicyOfProjectHandlerFunc) Handle(params CreateWebhookPolicyOfProjectParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateWebhookPolicyOfProjectHandler interface for that can handle valid create webhook policy of project params +type CreateWebhookPolicyOfProjectHandler interface { + Handle(CreateWebhookPolicyOfProjectParams, interface{}) middleware.Responder +} + +// NewCreateWebhookPolicyOfProject creates a new http.Handler for the create webhook policy of project operation +func NewCreateWebhookPolicyOfProject(ctx *middleware.Context, handler CreateWebhookPolicyOfProjectHandler) *CreateWebhookPolicyOfProject { + return &CreateWebhookPolicyOfProject{Context: ctx, Handler: handler} +} + +/*CreateWebhookPolicyOfProject swagger:route POST /projects/{project_name_or_id}/webhook/policies webhook createWebhookPolicyOfProject + +Create project webhook policy. + +This endpoint create a webhook policy if the project does not have one. + + +*/ +type CreateWebhookPolicyOfProject struct { + Context *middleware.Context + Handler CreateWebhookPolicyOfProjectHandler +} + +func (o *CreateWebhookPolicyOfProject) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewCreateWebhookPolicyOfProjectParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/webhook/create_webhook_policy_of_project_parameters.go b/src/server/v2.0/restapi/operations/webhook/create_webhook_policy_of_project_parameters.go new file mode 100644 index 000000000..b601fff88 --- /dev/null +++ b/src/server/v2.0/restapi/operations/webhook/create_webhook_policy_of_project_parameters.go @@ -0,0 +1,186 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package webhook + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewCreateWebhookPolicyOfProjectParams creates a new CreateWebhookPolicyOfProjectParams object +// with the default values initialized. +func NewCreateWebhookPolicyOfProjectParams() CreateWebhookPolicyOfProjectParams { + + var ( + // initialize parameters with default values + + xIsResourceNameDefault = bool(false) + ) + + return CreateWebhookPolicyOfProjectParams{ + XIsResourceName: &xIsResourceNameDefault, + } +} + +// CreateWebhookPolicyOfProjectParams contains all the bound params for the create webhook policy of project operation +// typically these are obtained from a http.Request +// +// swagger:parameters CreateWebhookPolicyOfProject +type CreateWebhookPolicyOfProjectParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name. + In: header + Default: false + */ + XIsResourceName *bool + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*Properties "targets" and "event_types" needed. + Required: true + In: body + */ + Policy *models.WebhookPolicy + /*The name or id of the project + Required: true + In: path + */ + ProjectNameOrID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateWebhookPolicyOfProjectParams() beforehand. +func (o *CreateWebhookPolicyOfProjectParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXIsResourceName(r.Header[http.CanonicalHeaderKey("X-Is-Resource-Name")], true, route.Formats); err != nil { + res = append(res, err) + } + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.WebhookPolicy + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("policy", "body", "")) + } else { + res = append(res, errors.NewParseError("policy", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Policy = &body + } + } + } else { + res = append(res, errors.Required("policy", "body", "")) + } + rProjectNameOrID, rhkProjectNameOrID, _ := route.Params.GetOK("project_name_or_id") + if err := o.bindProjectNameOrID(rProjectNameOrID, rhkProjectNameOrID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXIsResourceName binds and validates parameter XIsResourceName from header. +func (o *CreateWebhookPolicyOfProjectParams) bindXIsResourceName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateWebhookPolicyOfProjectParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("X-Is-Resource-Name", "header", "bool", raw) + } + o.XIsResourceName = &value + + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *CreateWebhookPolicyOfProjectParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *CreateWebhookPolicyOfProjectParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindProjectNameOrID binds and validates parameter ProjectNameOrID from path. +func (o *CreateWebhookPolicyOfProjectParams) bindProjectNameOrID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectNameOrID = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/webhook/create_webhook_policy_of_project_responses.go b/src/server/v2.0/restapi/operations/webhook/create_webhook_policy_of_project_responses.go new file mode 100644 index 000000000..d825af90c --- /dev/null +++ b/src/server/v2.0/restapi/operations/webhook/create_webhook_policy_of_project_responses.go @@ -0,0 +1,346 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package webhook + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// CreateWebhookPolicyOfProjectCreatedCode is the HTTP code returned for type CreateWebhookPolicyOfProjectCreated +const CreateWebhookPolicyOfProjectCreatedCode int = 201 + +/*CreateWebhookPolicyOfProjectCreated Project webhook policy create successfully. + +swagger:response createWebhookPolicyOfProjectCreated +*/ +type CreateWebhookPolicyOfProjectCreated struct { + /*The location of the resource + + */ + Location string `json:"Location"` + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewCreateWebhookPolicyOfProjectCreated creates CreateWebhookPolicyOfProjectCreated with default headers values +func NewCreateWebhookPolicyOfProjectCreated() *CreateWebhookPolicyOfProjectCreated { + + return &CreateWebhookPolicyOfProjectCreated{} +} + +// WithLocation adds the location to the create webhook policy of project created response +func (o *CreateWebhookPolicyOfProjectCreated) WithLocation(location string) *CreateWebhookPolicyOfProjectCreated { + o.Location = location + return o +} + +// SetLocation sets the location to the create webhook policy of project created response +func (o *CreateWebhookPolicyOfProjectCreated) SetLocation(location string) { + o.Location = location +} + +// WithXRequestID adds the xRequestId to the create webhook policy of project created response +func (o *CreateWebhookPolicyOfProjectCreated) WithXRequestID(xRequestID string) *CreateWebhookPolicyOfProjectCreated { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create webhook policy of project created response +func (o *CreateWebhookPolicyOfProjectCreated) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *CreateWebhookPolicyOfProjectCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Location + + location := o.Location + if location != "" { + rw.Header().Set("Location", location) + } + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(201) +} + +// CreateWebhookPolicyOfProjectBadRequestCode is the HTTP code returned for type CreateWebhookPolicyOfProjectBadRequest +const CreateWebhookPolicyOfProjectBadRequestCode int = 400 + +/*CreateWebhookPolicyOfProjectBadRequest Bad request + +swagger:response createWebhookPolicyOfProjectBadRequest +*/ +type CreateWebhookPolicyOfProjectBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateWebhookPolicyOfProjectBadRequest creates CreateWebhookPolicyOfProjectBadRequest with default headers values +func NewCreateWebhookPolicyOfProjectBadRequest() *CreateWebhookPolicyOfProjectBadRequest { + + return &CreateWebhookPolicyOfProjectBadRequest{} +} + +// WithXRequestID adds the xRequestId to the create webhook policy of project bad request response +func (o *CreateWebhookPolicyOfProjectBadRequest) WithXRequestID(xRequestID string) *CreateWebhookPolicyOfProjectBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create webhook policy of project bad request response +func (o *CreateWebhookPolicyOfProjectBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create webhook policy of project bad request response +func (o *CreateWebhookPolicyOfProjectBadRequest) WithPayload(payload *models.Errors) *CreateWebhookPolicyOfProjectBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create webhook policy of project bad request response +func (o *CreateWebhookPolicyOfProjectBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateWebhookPolicyOfProjectBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateWebhookPolicyOfProjectUnauthorizedCode is the HTTP code returned for type CreateWebhookPolicyOfProjectUnauthorized +const CreateWebhookPolicyOfProjectUnauthorizedCode int = 401 + +/*CreateWebhookPolicyOfProjectUnauthorized Unauthorized + +swagger:response createWebhookPolicyOfProjectUnauthorized +*/ +type CreateWebhookPolicyOfProjectUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateWebhookPolicyOfProjectUnauthorized creates CreateWebhookPolicyOfProjectUnauthorized with default headers values +func NewCreateWebhookPolicyOfProjectUnauthorized() *CreateWebhookPolicyOfProjectUnauthorized { + + return &CreateWebhookPolicyOfProjectUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the create webhook policy of project unauthorized response +func (o *CreateWebhookPolicyOfProjectUnauthorized) WithXRequestID(xRequestID string) *CreateWebhookPolicyOfProjectUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create webhook policy of project unauthorized response +func (o *CreateWebhookPolicyOfProjectUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create webhook policy of project unauthorized response +func (o *CreateWebhookPolicyOfProjectUnauthorized) WithPayload(payload *models.Errors) *CreateWebhookPolicyOfProjectUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create webhook policy of project unauthorized response +func (o *CreateWebhookPolicyOfProjectUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateWebhookPolicyOfProjectUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateWebhookPolicyOfProjectForbiddenCode is the HTTP code returned for type CreateWebhookPolicyOfProjectForbidden +const CreateWebhookPolicyOfProjectForbiddenCode int = 403 + +/*CreateWebhookPolicyOfProjectForbidden Forbidden + +swagger:response createWebhookPolicyOfProjectForbidden +*/ +type CreateWebhookPolicyOfProjectForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateWebhookPolicyOfProjectForbidden creates CreateWebhookPolicyOfProjectForbidden with default headers values +func NewCreateWebhookPolicyOfProjectForbidden() *CreateWebhookPolicyOfProjectForbidden { + + return &CreateWebhookPolicyOfProjectForbidden{} +} + +// WithXRequestID adds the xRequestId to the create webhook policy of project forbidden response +func (o *CreateWebhookPolicyOfProjectForbidden) WithXRequestID(xRequestID string) *CreateWebhookPolicyOfProjectForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create webhook policy of project forbidden response +func (o *CreateWebhookPolicyOfProjectForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create webhook policy of project forbidden response +func (o *CreateWebhookPolicyOfProjectForbidden) WithPayload(payload *models.Errors) *CreateWebhookPolicyOfProjectForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create webhook policy of project forbidden response +func (o *CreateWebhookPolicyOfProjectForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateWebhookPolicyOfProjectForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateWebhookPolicyOfProjectInternalServerErrorCode is the HTTP code returned for type CreateWebhookPolicyOfProjectInternalServerError +const CreateWebhookPolicyOfProjectInternalServerErrorCode int = 500 + +/*CreateWebhookPolicyOfProjectInternalServerError Internal server error + +swagger:response createWebhookPolicyOfProjectInternalServerError +*/ +type CreateWebhookPolicyOfProjectInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewCreateWebhookPolicyOfProjectInternalServerError creates CreateWebhookPolicyOfProjectInternalServerError with default headers values +func NewCreateWebhookPolicyOfProjectInternalServerError() *CreateWebhookPolicyOfProjectInternalServerError { + + return &CreateWebhookPolicyOfProjectInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the create webhook policy of project internal server error response +func (o *CreateWebhookPolicyOfProjectInternalServerError) WithXRequestID(xRequestID string) *CreateWebhookPolicyOfProjectInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the create webhook policy of project internal server error response +func (o *CreateWebhookPolicyOfProjectInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the create webhook policy of project internal server error response +func (o *CreateWebhookPolicyOfProjectInternalServerError) WithPayload(payload *models.Errors) *CreateWebhookPolicyOfProjectInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create webhook policy of project internal server error response +func (o *CreateWebhookPolicyOfProjectInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateWebhookPolicyOfProjectInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/webhook/create_webhook_policy_of_project_urlbuilder.go b/src/server/v2.0/restapi/operations/webhook/create_webhook_policy_of_project_urlbuilder.go new file mode 100644 index 000000000..9293df214 --- /dev/null +++ b/src/server/v2.0/restapi/operations/webhook/create_webhook_policy_of_project_urlbuilder.go @@ -0,0 +1,99 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package webhook + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// CreateWebhookPolicyOfProjectURL generates an URL for the create webhook policy of project operation +type CreateWebhookPolicyOfProjectURL struct { + ProjectNameOrID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateWebhookPolicyOfProjectURL) WithBasePath(bp string) *CreateWebhookPolicyOfProjectURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateWebhookPolicyOfProjectURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateWebhookPolicyOfProjectURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name_or_id}/webhook/policies" + + projectNameOrID := o.ProjectNameOrID + if projectNameOrID != "" { + _path = strings.Replace(_path, "{project_name_or_id}", projectNameOrID, -1) + } else { + return nil, errors.New("projectNameOrId is required on CreateWebhookPolicyOfProjectURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateWebhookPolicyOfProjectURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateWebhookPolicyOfProjectURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateWebhookPolicyOfProjectURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateWebhookPolicyOfProjectURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateWebhookPolicyOfProjectURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateWebhookPolicyOfProjectURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/webhook/delete_webhook_policy_of_project.go b/src/server/v2.0/restapi/operations/webhook/delete_webhook_policy_of_project.go new file mode 100644 index 000000000..aaf2c60e7 --- /dev/null +++ b/src/server/v2.0/restapi/operations/webhook/delete_webhook_policy_of_project.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package webhook + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteWebhookPolicyOfProjectHandlerFunc turns a function with the right signature into a delete webhook policy of project handler +type DeleteWebhookPolicyOfProjectHandlerFunc func(DeleteWebhookPolicyOfProjectParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteWebhookPolicyOfProjectHandlerFunc) Handle(params DeleteWebhookPolicyOfProjectParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteWebhookPolicyOfProjectHandler interface for that can handle valid delete webhook policy of project params +type DeleteWebhookPolicyOfProjectHandler interface { + Handle(DeleteWebhookPolicyOfProjectParams, interface{}) middleware.Responder +} + +// NewDeleteWebhookPolicyOfProject creates a new http.Handler for the delete webhook policy of project operation +func NewDeleteWebhookPolicyOfProject(ctx *middleware.Context, handler DeleteWebhookPolicyOfProjectHandler) *DeleteWebhookPolicyOfProject { + return &DeleteWebhookPolicyOfProject{Context: ctx, Handler: handler} +} + +/*DeleteWebhookPolicyOfProject swagger:route DELETE /projects/{project_name_or_id}/webhook/policies/{webhook_policy_id} webhook deleteWebhookPolicyOfProject + +Delete webhook policy of a project + +This endpoint is aimed to delete webhookpolicy of a project. + + +*/ +type DeleteWebhookPolicyOfProject struct { + Context *middleware.Context + Handler DeleteWebhookPolicyOfProjectHandler +} + +func (o *DeleteWebhookPolicyOfProject) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewDeleteWebhookPolicyOfProjectParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/webhook/delete_webhook_policy_of_project_parameters.go b/src/server/v2.0/restapi/operations/webhook/delete_webhook_policy_of_project_parameters.go new file mode 100644 index 000000000..a20889a06 --- /dev/null +++ b/src/server/v2.0/restapi/operations/webhook/delete_webhook_policy_of_project_parameters.go @@ -0,0 +1,184 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package webhook + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewDeleteWebhookPolicyOfProjectParams creates a new DeleteWebhookPolicyOfProjectParams object +// with the default values initialized. +func NewDeleteWebhookPolicyOfProjectParams() DeleteWebhookPolicyOfProjectParams { + + var ( + // initialize parameters with default values + + xIsResourceNameDefault = bool(false) + ) + + return DeleteWebhookPolicyOfProjectParams{ + XIsResourceName: &xIsResourceNameDefault, + } +} + +// DeleteWebhookPolicyOfProjectParams contains all the bound params for the delete webhook policy of project operation +// typically these are obtained from a http.Request +// +// swagger:parameters DeleteWebhookPolicyOfProject +type DeleteWebhookPolicyOfProjectParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name. + In: header + Default: false + */ + XIsResourceName *bool + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The name or id of the project + Required: true + In: path + */ + ProjectNameOrID string + /*The ID of the webhook policy + Required: true + In: path + */ + WebhookPolicyID int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteWebhookPolicyOfProjectParams() beforehand. +func (o *DeleteWebhookPolicyOfProjectParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXIsResourceName(r.Header[http.CanonicalHeaderKey("X-Is-Resource-Name")], true, route.Formats); err != nil { + res = append(res, err) + } + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rProjectNameOrID, rhkProjectNameOrID, _ := route.Params.GetOK("project_name_or_id") + if err := o.bindProjectNameOrID(rProjectNameOrID, rhkProjectNameOrID, route.Formats); err != nil { + res = append(res, err) + } + + rWebhookPolicyID, rhkWebhookPolicyID, _ := route.Params.GetOK("webhook_policy_id") + if err := o.bindWebhookPolicyID(rWebhookPolicyID, rhkWebhookPolicyID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXIsResourceName binds and validates parameter XIsResourceName from header. +func (o *DeleteWebhookPolicyOfProjectParams) bindXIsResourceName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteWebhookPolicyOfProjectParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("X-Is-Resource-Name", "header", "bool", raw) + } + o.XIsResourceName = &value + + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *DeleteWebhookPolicyOfProjectParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *DeleteWebhookPolicyOfProjectParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindProjectNameOrID binds and validates parameter ProjectNameOrID from path. +func (o *DeleteWebhookPolicyOfProjectParams) bindProjectNameOrID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectNameOrID = raw + + return nil +} + +// bindWebhookPolicyID binds and validates parameter WebhookPolicyID from path. +func (o *DeleteWebhookPolicyOfProjectParams) bindWebhookPolicyID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("webhook_policy_id", "path", "int64", raw) + } + o.WebhookPolicyID = value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/webhook/delete_webhook_policy_of_project_responses.go b/src/server/v2.0/restapi/operations/webhook/delete_webhook_policy_of_project_responses.go new file mode 100644 index 000000000..a23043cc7 --- /dev/null +++ b/src/server/v2.0/restapi/operations/webhook/delete_webhook_policy_of_project_responses.go @@ -0,0 +1,390 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package webhook + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// DeleteWebhookPolicyOfProjectOKCode is the HTTP code returned for type DeleteWebhookPolicyOfProjectOK +const DeleteWebhookPolicyOfProjectOKCode int = 200 + +/*DeleteWebhookPolicyOfProjectOK Success + +swagger:response deleteWebhookPolicyOfProjectOK +*/ +type DeleteWebhookPolicyOfProjectOK struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewDeleteWebhookPolicyOfProjectOK creates DeleteWebhookPolicyOfProjectOK with default headers values +func NewDeleteWebhookPolicyOfProjectOK() *DeleteWebhookPolicyOfProjectOK { + + return &DeleteWebhookPolicyOfProjectOK{} +} + +// WithXRequestID adds the xRequestId to the delete webhook policy of project o k response +func (o *DeleteWebhookPolicyOfProjectOK) WithXRequestID(xRequestID string) *DeleteWebhookPolicyOfProjectOK { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete webhook policy of project o k response +func (o *DeleteWebhookPolicyOfProjectOK) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *DeleteWebhookPolicyOfProjectOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// DeleteWebhookPolicyOfProjectBadRequestCode is the HTTP code returned for type DeleteWebhookPolicyOfProjectBadRequest +const DeleteWebhookPolicyOfProjectBadRequestCode int = 400 + +/*DeleteWebhookPolicyOfProjectBadRequest Bad request + +swagger:response deleteWebhookPolicyOfProjectBadRequest +*/ +type DeleteWebhookPolicyOfProjectBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteWebhookPolicyOfProjectBadRequest creates DeleteWebhookPolicyOfProjectBadRequest with default headers values +func NewDeleteWebhookPolicyOfProjectBadRequest() *DeleteWebhookPolicyOfProjectBadRequest { + + return &DeleteWebhookPolicyOfProjectBadRequest{} +} + +// WithXRequestID adds the xRequestId to the delete webhook policy of project bad request response +func (o *DeleteWebhookPolicyOfProjectBadRequest) WithXRequestID(xRequestID string) *DeleteWebhookPolicyOfProjectBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete webhook policy of project bad request response +func (o *DeleteWebhookPolicyOfProjectBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete webhook policy of project bad request response +func (o *DeleteWebhookPolicyOfProjectBadRequest) WithPayload(payload *models.Errors) *DeleteWebhookPolicyOfProjectBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete webhook policy of project bad request response +func (o *DeleteWebhookPolicyOfProjectBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteWebhookPolicyOfProjectBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteWebhookPolicyOfProjectUnauthorizedCode is the HTTP code returned for type DeleteWebhookPolicyOfProjectUnauthorized +const DeleteWebhookPolicyOfProjectUnauthorizedCode int = 401 + +/*DeleteWebhookPolicyOfProjectUnauthorized Unauthorized + +swagger:response deleteWebhookPolicyOfProjectUnauthorized +*/ +type DeleteWebhookPolicyOfProjectUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteWebhookPolicyOfProjectUnauthorized creates DeleteWebhookPolicyOfProjectUnauthorized with default headers values +func NewDeleteWebhookPolicyOfProjectUnauthorized() *DeleteWebhookPolicyOfProjectUnauthorized { + + return &DeleteWebhookPolicyOfProjectUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the delete webhook policy of project unauthorized response +func (o *DeleteWebhookPolicyOfProjectUnauthorized) WithXRequestID(xRequestID string) *DeleteWebhookPolicyOfProjectUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete webhook policy of project unauthorized response +func (o *DeleteWebhookPolicyOfProjectUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete webhook policy of project unauthorized response +func (o *DeleteWebhookPolicyOfProjectUnauthorized) WithPayload(payload *models.Errors) *DeleteWebhookPolicyOfProjectUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete webhook policy of project unauthorized response +func (o *DeleteWebhookPolicyOfProjectUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteWebhookPolicyOfProjectUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteWebhookPolicyOfProjectForbiddenCode is the HTTP code returned for type DeleteWebhookPolicyOfProjectForbidden +const DeleteWebhookPolicyOfProjectForbiddenCode int = 403 + +/*DeleteWebhookPolicyOfProjectForbidden Forbidden + +swagger:response deleteWebhookPolicyOfProjectForbidden +*/ +type DeleteWebhookPolicyOfProjectForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteWebhookPolicyOfProjectForbidden creates DeleteWebhookPolicyOfProjectForbidden with default headers values +func NewDeleteWebhookPolicyOfProjectForbidden() *DeleteWebhookPolicyOfProjectForbidden { + + return &DeleteWebhookPolicyOfProjectForbidden{} +} + +// WithXRequestID adds the xRequestId to the delete webhook policy of project forbidden response +func (o *DeleteWebhookPolicyOfProjectForbidden) WithXRequestID(xRequestID string) *DeleteWebhookPolicyOfProjectForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete webhook policy of project forbidden response +func (o *DeleteWebhookPolicyOfProjectForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete webhook policy of project forbidden response +func (o *DeleteWebhookPolicyOfProjectForbidden) WithPayload(payload *models.Errors) *DeleteWebhookPolicyOfProjectForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete webhook policy of project forbidden response +func (o *DeleteWebhookPolicyOfProjectForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteWebhookPolicyOfProjectForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteWebhookPolicyOfProjectNotFoundCode is the HTTP code returned for type DeleteWebhookPolicyOfProjectNotFound +const DeleteWebhookPolicyOfProjectNotFoundCode int = 404 + +/*DeleteWebhookPolicyOfProjectNotFound Not found + +swagger:response deleteWebhookPolicyOfProjectNotFound +*/ +type DeleteWebhookPolicyOfProjectNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteWebhookPolicyOfProjectNotFound creates DeleteWebhookPolicyOfProjectNotFound with default headers values +func NewDeleteWebhookPolicyOfProjectNotFound() *DeleteWebhookPolicyOfProjectNotFound { + + return &DeleteWebhookPolicyOfProjectNotFound{} +} + +// WithXRequestID adds the xRequestId to the delete webhook policy of project not found response +func (o *DeleteWebhookPolicyOfProjectNotFound) WithXRequestID(xRequestID string) *DeleteWebhookPolicyOfProjectNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete webhook policy of project not found response +func (o *DeleteWebhookPolicyOfProjectNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete webhook policy of project not found response +func (o *DeleteWebhookPolicyOfProjectNotFound) WithPayload(payload *models.Errors) *DeleteWebhookPolicyOfProjectNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete webhook policy of project not found response +func (o *DeleteWebhookPolicyOfProjectNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteWebhookPolicyOfProjectNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteWebhookPolicyOfProjectInternalServerErrorCode is the HTTP code returned for type DeleteWebhookPolicyOfProjectInternalServerError +const DeleteWebhookPolicyOfProjectInternalServerErrorCode int = 500 + +/*DeleteWebhookPolicyOfProjectInternalServerError Internal server error + +swagger:response deleteWebhookPolicyOfProjectInternalServerError +*/ +type DeleteWebhookPolicyOfProjectInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewDeleteWebhookPolicyOfProjectInternalServerError creates DeleteWebhookPolicyOfProjectInternalServerError with default headers values +func NewDeleteWebhookPolicyOfProjectInternalServerError() *DeleteWebhookPolicyOfProjectInternalServerError { + + return &DeleteWebhookPolicyOfProjectInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the delete webhook policy of project internal server error response +func (o *DeleteWebhookPolicyOfProjectInternalServerError) WithXRequestID(xRequestID string) *DeleteWebhookPolicyOfProjectInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the delete webhook policy of project internal server error response +func (o *DeleteWebhookPolicyOfProjectInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the delete webhook policy of project internal server error response +func (o *DeleteWebhookPolicyOfProjectInternalServerError) WithPayload(payload *models.Errors) *DeleteWebhookPolicyOfProjectInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete webhook policy of project internal server error response +func (o *DeleteWebhookPolicyOfProjectInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteWebhookPolicyOfProjectInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/webhook/delete_webhook_policy_of_project_urlbuilder.go b/src/server/v2.0/restapi/operations/webhook/delete_webhook_policy_of_project_urlbuilder.go new file mode 100644 index 000000000..9e1cbd3da --- /dev/null +++ b/src/server/v2.0/restapi/operations/webhook/delete_webhook_policy_of_project_urlbuilder.go @@ -0,0 +1,109 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package webhook + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteWebhookPolicyOfProjectURL generates an URL for the delete webhook policy of project operation +type DeleteWebhookPolicyOfProjectURL struct { + ProjectNameOrID string + WebhookPolicyID int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteWebhookPolicyOfProjectURL) WithBasePath(bp string) *DeleteWebhookPolicyOfProjectURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteWebhookPolicyOfProjectURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteWebhookPolicyOfProjectURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}" + + projectNameOrID := o.ProjectNameOrID + if projectNameOrID != "" { + _path = strings.Replace(_path, "{project_name_or_id}", projectNameOrID, -1) + } else { + return nil, errors.New("projectNameOrId is required on DeleteWebhookPolicyOfProjectURL") + } + + webhookPolicyID := swag.FormatInt64(o.WebhookPolicyID) + if webhookPolicyID != "" { + _path = strings.Replace(_path, "{webhook_policy_id}", webhookPolicyID, -1) + } else { + return nil, errors.New("webhookPolicyId is required on DeleteWebhookPolicyOfProjectURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteWebhookPolicyOfProjectURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteWebhookPolicyOfProjectURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteWebhookPolicyOfProjectURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteWebhookPolicyOfProjectURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteWebhookPolicyOfProjectURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteWebhookPolicyOfProjectURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/webhook/get_supported_event_types.go b/src/server/v2.0/restapi/operations/webhook/get_supported_event_types.go new file mode 100644 index 000000000..60e0c01d6 --- /dev/null +++ b/src/server/v2.0/restapi/operations/webhook/get_supported_event_types.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package webhook + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetSupportedEventTypesHandlerFunc turns a function with the right signature into a get supported event types handler +type GetSupportedEventTypesHandlerFunc func(GetSupportedEventTypesParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetSupportedEventTypesHandlerFunc) Handle(params GetSupportedEventTypesParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetSupportedEventTypesHandler interface for that can handle valid get supported event types params +type GetSupportedEventTypesHandler interface { + Handle(GetSupportedEventTypesParams, interface{}) middleware.Responder +} + +// NewGetSupportedEventTypes creates a new http.Handler for the get supported event types operation +func NewGetSupportedEventTypes(ctx *middleware.Context, handler GetSupportedEventTypesHandler) *GetSupportedEventTypes { + return &GetSupportedEventTypes{Context: ctx, Handler: handler} +} + +/*GetSupportedEventTypes swagger:route GET /projects/{project_name_or_id}/webhook/events webhook getSupportedEventTypes + +Get supported event types and notify types. + +Get supportted event types and notify types. + +*/ +type GetSupportedEventTypes struct { + Context *middleware.Context + Handler GetSupportedEventTypesHandler +} + +func (o *GetSupportedEventTypes) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetSupportedEventTypesParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/webhook/get_supported_event_types_parameters.go b/src/server/v2.0/restapi/operations/webhook/get_supported_event_types_parameters.go new file mode 100644 index 000000000..47cdf7ebe --- /dev/null +++ b/src/server/v2.0/restapi/operations/webhook/get_supported_event_types_parameters.go @@ -0,0 +1,155 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package webhook + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewGetSupportedEventTypesParams creates a new GetSupportedEventTypesParams object +// with the default values initialized. +func NewGetSupportedEventTypesParams() GetSupportedEventTypesParams { + + var ( + // initialize parameters with default values + + xIsResourceNameDefault = bool(false) + ) + + return GetSupportedEventTypesParams{ + XIsResourceName: &xIsResourceNameDefault, + } +} + +// GetSupportedEventTypesParams contains all the bound params for the get supported event types operation +// typically these are obtained from a http.Request +// +// swagger:parameters GetSupportedEventTypes +type GetSupportedEventTypesParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name. + In: header + Default: false + */ + XIsResourceName *bool + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The name or id of the project + Required: true + In: path + */ + ProjectNameOrID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetSupportedEventTypesParams() beforehand. +func (o *GetSupportedEventTypesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXIsResourceName(r.Header[http.CanonicalHeaderKey("X-Is-Resource-Name")], true, route.Formats); err != nil { + res = append(res, err) + } + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rProjectNameOrID, rhkProjectNameOrID, _ := route.Params.GetOK("project_name_or_id") + if err := o.bindProjectNameOrID(rProjectNameOrID, rhkProjectNameOrID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXIsResourceName binds and validates parameter XIsResourceName from header. +func (o *GetSupportedEventTypesParams) bindXIsResourceName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewGetSupportedEventTypesParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("X-Is-Resource-Name", "header", "bool", raw) + } + o.XIsResourceName = &value + + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetSupportedEventTypesParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetSupportedEventTypesParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindProjectNameOrID binds and validates parameter ProjectNameOrID from path. +func (o *GetSupportedEventTypesParams) bindProjectNameOrID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectNameOrID = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/webhook/get_supported_event_types_responses.go b/src/server/v2.0/restapi/operations/webhook/get_supported_event_types_responses.go new file mode 100644 index 000000000..dea557956 --- /dev/null +++ b/src/server/v2.0/restapi/operations/webhook/get_supported_event_types_responses.go @@ -0,0 +1,256 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package webhook + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetSupportedEventTypesOKCode is the HTTP code returned for type GetSupportedEventTypesOK +const GetSupportedEventTypesOKCode int = 200 + +/*GetSupportedEventTypesOK Success + +swagger:response getSupportedEventTypesOK +*/ +type GetSupportedEventTypesOK struct { + + /* + In: Body + */ + Payload *models.SupportedWebhookEventTypes `json:"body,omitempty"` +} + +// NewGetSupportedEventTypesOK creates GetSupportedEventTypesOK with default headers values +func NewGetSupportedEventTypesOK() *GetSupportedEventTypesOK { + + return &GetSupportedEventTypesOK{} +} + +// WithPayload adds the payload to the get supported event types o k response +func (o *GetSupportedEventTypesOK) WithPayload(payload *models.SupportedWebhookEventTypes) *GetSupportedEventTypesOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get supported event types o k response +func (o *GetSupportedEventTypesOK) SetPayload(payload *models.SupportedWebhookEventTypes) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetSupportedEventTypesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetSupportedEventTypesUnauthorizedCode is the HTTP code returned for type GetSupportedEventTypesUnauthorized +const GetSupportedEventTypesUnauthorizedCode int = 401 + +/*GetSupportedEventTypesUnauthorized Unauthorized + +swagger:response getSupportedEventTypesUnauthorized +*/ +type GetSupportedEventTypesUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetSupportedEventTypesUnauthorized creates GetSupportedEventTypesUnauthorized with default headers values +func NewGetSupportedEventTypesUnauthorized() *GetSupportedEventTypesUnauthorized { + + return &GetSupportedEventTypesUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the get supported event types unauthorized response +func (o *GetSupportedEventTypesUnauthorized) WithXRequestID(xRequestID string) *GetSupportedEventTypesUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get supported event types unauthorized response +func (o *GetSupportedEventTypesUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get supported event types unauthorized response +func (o *GetSupportedEventTypesUnauthorized) WithPayload(payload *models.Errors) *GetSupportedEventTypesUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get supported event types unauthorized response +func (o *GetSupportedEventTypesUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetSupportedEventTypesUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetSupportedEventTypesForbiddenCode is the HTTP code returned for type GetSupportedEventTypesForbidden +const GetSupportedEventTypesForbiddenCode int = 403 + +/*GetSupportedEventTypesForbidden Forbidden + +swagger:response getSupportedEventTypesForbidden +*/ +type GetSupportedEventTypesForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetSupportedEventTypesForbidden creates GetSupportedEventTypesForbidden with default headers values +func NewGetSupportedEventTypesForbidden() *GetSupportedEventTypesForbidden { + + return &GetSupportedEventTypesForbidden{} +} + +// WithXRequestID adds the xRequestId to the get supported event types forbidden response +func (o *GetSupportedEventTypesForbidden) WithXRequestID(xRequestID string) *GetSupportedEventTypesForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get supported event types forbidden response +func (o *GetSupportedEventTypesForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get supported event types forbidden response +func (o *GetSupportedEventTypesForbidden) WithPayload(payload *models.Errors) *GetSupportedEventTypesForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get supported event types forbidden response +func (o *GetSupportedEventTypesForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetSupportedEventTypesForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetSupportedEventTypesInternalServerErrorCode is the HTTP code returned for type GetSupportedEventTypesInternalServerError +const GetSupportedEventTypesInternalServerErrorCode int = 500 + +/*GetSupportedEventTypesInternalServerError Internal server error + +swagger:response getSupportedEventTypesInternalServerError +*/ +type GetSupportedEventTypesInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetSupportedEventTypesInternalServerError creates GetSupportedEventTypesInternalServerError with default headers values +func NewGetSupportedEventTypesInternalServerError() *GetSupportedEventTypesInternalServerError { + + return &GetSupportedEventTypesInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get supported event types internal server error response +func (o *GetSupportedEventTypesInternalServerError) WithXRequestID(xRequestID string) *GetSupportedEventTypesInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get supported event types internal server error response +func (o *GetSupportedEventTypesInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get supported event types internal server error response +func (o *GetSupportedEventTypesInternalServerError) WithPayload(payload *models.Errors) *GetSupportedEventTypesInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get supported event types internal server error response +func (o *GetSupportedEventTypesInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetSupportedEventTypesInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/webhook/get_supported_event_types_urlbuilder.go b/src/server/v2.0/restapi/operations/webhook/get_supported_event_types_urlbuilder.go new file mode 100644 index 000000000..90de132a2 --- /dev/null +++ b/src/server/v2.0/restapi/operations/webhook/get_supported_event_types_urlbuilder.go @@ -0,0 +1,99 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package webhook + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetSupportedEventTypesURL generates an URL for the get supported event types operation +type GetSupportedEventTypesURL struct { + ProjectNameOrID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetSupportedEventTypesURL) WithBasePath(bp string) *GetSupportedEventTypesURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetSupportedEventTypesURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetSupportedEventTypesURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name_or_id}/webhook/events" + + projectNameOrID := o.ProjectNameOrID + if projectNameOrID != "" { + _path = strings.Replace(_path, "{project_name_or_id}", projectNameOrID, -1) + } else { + return nil, errors.New("projectNameOrId is required on GetSupportedEventTypesURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetSupportedEventTypesURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetSupportedEventTypesURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetSupportedEventTypesURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetSupportedEventTypesURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetSupportedEventTypesURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetSupportedEventTypesURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/webhook/get_webhook_policy_of_project.go b/src/server/v2.0/restapi/operations/webhook/get_webhook_policy_of_project.go new file mode 100644 index 000000000..e37ff98d2 --- /dev/null +++ b/src/server/v2.0/restapi/operations/webhook/get_webhook_policy_of_project.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package webhook + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetWebhookPolicyOfProjectHandlerFunc turns a function with the right signature into a get webhook policy of project handler +type GetWebhookPolicyOfProjectHandlerFunc func(GetWebhookPolicyOfProjectParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetWebhookPolicyOfProjectHandlerFunc) Handle(params GetWebhookPolicyOfProjectParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetWebhookPolicyOfProjectHandler interface for that can handle valid get webhook policy of project params +type GetWebhookPolicyOfProjectHandler interface { + Handle(GetWebhookPolicyOfProjectParams, interface{}) middleware.Responder +} + +// NewGetWebhookPolicyOfProject creates a new http.Handler for the get webhook policy of project operation +func NewGetWebhookPolicyOfProject(ctx *middleware.Context, handler GetWebhookPolicyOfProjectHandler) *GetWebhookPolicyOfProject { + return &GetWebhookPolicyOfProject{Context: ctx, Handler: handler} +} + +/*GetWebhookPolicyOfProject swagger:route GET /projects/{project_name_or_id}/webhook/policies/{webhook_policy_id} webhook getWebhookPolicyOfProject + +Get project webhook policy + +This endpoint returns specified webhook policy of a project. + + +*/ +type GetWebhookPolicyOfProject struct { + Context *middleware.Context + Handler GetWebhookPolicyOfProjectHandler +} + +func (o *GetWebhookPolicyOfProject) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetWebhookPolicyOfProjectParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/webhook/get_webhook_policy_of_project_parameters.go b/src/server/v2.0/restapi/operations/webhook/get_webhook_policy_of_project_parameters.go new file mode 100644 index 000000000..72ce31784 --- /dev/null +++ b/src/server/v2.0/restapi/operations/webhook/get_webhook_policy_of_project_parameters.go @@ -0,0 +1,184 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package webhook + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewGetWebhookPolicyOfProjectParams creates a new GetWebhookPolicyOfProjectParams object +// with the default values initialized. +func NewGetWebhookPolicyOfProjectParams() GetWebhookPolicyOfProjectParams { + + var ( + // initialize parameters with default values + + xIsResourceNameDefault = bool(false) + ) + + return GetWebhookPolicyOfProjectParams{ + XIsResourceName: &xIsResourceNameDefault, + } +} + +// GetWebhookPolicyOfProjectParams contains all the bound params for the get webhook policy of project operation +// typically these are obtained from a http.Request +// +// swagger:parameters GetWebhookPolicyOfProject +type GetWebhookPolicyOfProjectParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name. + In: header + Default: false + */ + XIsResourceName *bool + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The name or id of the project + Required: true + In: path + */ + ProjectNameOrID string + /*The ID of the webhook policy + Required: true + In: path + */ + WebhookPolicyID int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetWebhookPolicyOfProjectParams() beforehand. +func (o *GetWebhookPolicyOfProjectParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXIsResourceName(r.Header[http.CanonicalHeaderKey("X-Is-Resource-Name")], true, route.Formats); err != nil { + res = append(res, err) + } + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rProjectNameOrID, rhkProjectNameOrID, _ := route.Params.GetOK("project_name_or_id") + if err := o.bindProjectNameOrID(rProjectNameOrID, rhkProjectNameOrID, route.Formats); err != nil { + res = append(res, err) + } + + rWebhookPolicyID, rhkWebhookPolicyID, _ := route.Params.GetOK("webhook_policy_id") + if err := o.bindWebhookPolicyID(rWebhookPolicyID, rhkWebhookPolicyID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXIsResourceName binds and validates parameter XIsResourceName from header. +func (o *GetWebhookPolicyOfProjectParams) bindXIsResourceName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewGetWebhookPolicyOfProjectParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("X-Is-Resource-Name", "header", "bool", raw) + } + o.XIsResourceName = &value + + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *GetWebhookPolicyOfProjectParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *GetWebhookPolicyOfProjectParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindProjectNameOrID binds and validates parameter ProjectNameOrID from path. +func (o *GetWebhookPolicyOfProjectParams) bindProjectNameOrID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectNameOrID = raw + + return nil +} + +// bindWebhookPolicyID binds and validates parameter WebhookPolicyID from path. +func (o *GetWebhookPolicyOfProjectParams) bindWebhookPolicyID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("webhook_policy_id", "path", "int64", raw) + } + o.WebhookPolicyID = value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/webhook/get_webhook_policy_of_project_responses.go b/src/server/v2.0/restapi/operations/webhook/get_webhook_policy_of_project_responses.go new file mode 100644 index 000000000..2c5c18cbe --- /dev/null +++ b/src/server/v2.0/restapi/operations/webhook/get_webhook_policy_of_project_responses.go @@ -0,0 +1,388 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package webhook + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// GetWebhookPolicyOfProjectOKCode is the HTTP code returned for type GetWebhookPolicyOfProjectOK +const GetWebhookPolicyOfProjectOKCode int = 200 + +/*GetWebhookPolicyOfProjectOK Get webhook policy successfully. + +swagger:response getWebhookPolicyOfProjectOK +*/ +type GetWebhookPolicyOfProjectOK struct { + + /* + In: Body + */ + Payload *models.WebhookPolicy `json:"body,omitempty"` +} + +// NewGetWebhookPolicyOfProjectOK creates GetWebhookPolicyOfProjectOK with default headers values +func NewGetWebhookPolicyOfProjectOK() *GetWebhookPolicyOfProjectOK { + + return &GetWebhookPolicyOfProjectOK{} +} + +// WithPayload adds the payload to the get webhook policy of project o k response +func (o *GetWebhookPolicyOfProjectOK) WithPayload(payload *models.WebhookPolicy) *GetWebhookPolicyOfProjectOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get webhook policy of project o k response +func (o *GetWebhookPolicyOfProjectOK) SetPayload(payload *models.WebhookPolicy) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetWebhookPolicyOfProjectOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetWebhookPolicyOfProjectBadRequestCode is the HTTP code returned for type GetWebhookPolicyOfProjectBadRequest +const GetWebhookPolicyOfProjectBadRequestCode int = 400 + +/*GetWebhookPolicyOfProjectBadRequest Bad request + +swagger:response getWebhookPolicyOfProjectBadRequest +*/ +type GetWebhookPolicyOfProjectBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetWebhookPolicyOfProjectBadRequest creates GetWebhookPolicyOfProjectBadRequest with default headers values +func NewGetWebhookPolicyOfProjectBadRequest() *GetWebhookPolicyOfProjectBadRequest { + + return &GetWebhookPolicyOfProjectBadRequest{} +} + +// WithXRequestID adds the xRequestId to the get webhook policy of project bad request response +func (o *GetWebhookPolicyOfProjectBadRequest) WithXRequestID(xRequestID string) *GetWebhookPolicyOfProjectBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get webhook policy of project bad request response +func (o *GetWebhookPolicyOfProjectBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get webhook policy of project bad request response +func (o *GetWebhookPolicyOfProjectBadRequest) WithPayload(payload *models.Errors) *GetWebhookPolicyOfProjectBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get webhook policy of project bad request response +func (o *GetWebhookPolicyOfProjectBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetWebhookPolicyOfProjectBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetWebhookPolicyOfProjectUnauthorizedCode is the HTTP code returned for type GetWebhookPolicyOfProjectUnauthorized +const GetWebhookPolicyOfProjectUnauthorizedCode int = 401 + +/*GetWebhookPolicyOfProjectUnauthorized Unauthorized + +swagger:response getWebhookPolicyOfProjectUnauthorized +*/ +type GetWebhookPolicyOfProjectUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetWebhookPolicyOfProjectUnauthorized creates GetWebhookPolicyOfProjectUnauthorized with default headers values +func NewGetWebhookPolicyOfProjectUnauthorized() *GetWebhookPolicyOfProjectUnauthorized { + + return &GetWebhookPolicyOfProjectUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the get webhook policy of project unauthorized response +func (o *GetWebhookPolicyOfProjectUnauthorized) WithXRequestID(xRequestID string) *GetWebhookPolicyOfProjectUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get webhook policy of project unauthorized response +func (o *GetWebhookPolicyOfProjectUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get webhook policy of project unauthorized response +func (o *GetWebhookPolicyOfProjectUnauthorized) WithPayload(payload *models.Errors) *GetWebhookPolicyOfProjectUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get webhook policy of project unauthorized response +func (o *GetWebhookPolicyOfProjectUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetWebhookPolicyOfProjectUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetWebhookPolicyOfProjectForbiddenCode is the HTTP code returned for type GetWebhookPolicyOfProjectForbidden +const GetWebhookPolicyOfProjectForbiddenCode int = 403 + +/*GetWebhookPolicyOfProjectForbidden Forbidden + +swagger:response getWebhookPolicyOfProjectForbidden +*/ +type GetWebhookPolicyOfProjectForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetWebhookPolicyOfProjectForbidden creates GetWebhookPolicyOfProjectForbidden with default headers values +func NewGetWebhookPolicyOfProjectForbidden() *GetWebhookPolicyOfProjectForbidden { + + return &GetWebhookPolicyOfProjectForbidden{} +} + +// WithXRequestID adds the xRequestId to the get webhook policy of project forbidden response +func (o *GetWebhookPolicyOfProjectForbidden) WithXRequestID(xRequestID string) *GetWebhookPolicyOfProjectForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get webhook policy of project forbidden response +func (o *GetWebhookPolicyOfProjectForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get webhook policy of project forbidden response +func (o *GetWebhookPolicyOfProjectForbidden) WithPayload(payload *models.Errors) *GetWebhookPolicyOfProjectForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get webhook policy of project forbidden response +func (o *GetWebhookPolicyOfProjectForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetWebhookPolicyOfProjectForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetWebhookPolicyOfProjectNotFoundCode is the HTTP code returned for type GetWebhookPolicyOfProjectNotFound +const GetWebhookPolicyOfProjectNotFoundCode int = 404 + +/*GetWebhookPolicyOfProjectNotFound Not found + +swagger:response getWebhookPolicyOfProjectNotFound +*/ +type GetWebhookPolicyOfProjectNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetWebhookPolicyOfProjectNotFound creates GetWebhookPolicyOfProjectNotFound with default headers values +func NewGetWebhookPolicyOfProjectNotFound() *GetWebhookPolicyOfProjectNotFound { + + return &GetWebhookPolicyOfProjectNotFound{} +} + +// WithXRequestID adds the xRequestId to the get webhook policy of project not found response +func (o *GetWebhookPolicyOfProjectNotFound) WithXRequestID(xRequestID string) *GetWebhookPolicyOfProjectNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get webhook policy of project not found response +func (o *GetWebhookPolicyOfProjectNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get webhook policy of project not found response +func (o *GetWebhookPolicyOfProjectNotFound) WithPayload(payload *models.Errors) *GetWebhookPolicyOfProjectNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get webhook policy of project not found response +func (o *GetWebhookPolicyOfProjectNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetWebhookPolicyOfProjectNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetWebhookPolicyOfProjectInternalServerErrorCode is the HTTP code returned for type GetWebhookPolicyOfProjectInternalServerError +const GetWebhookPolicyOfProjectInternalServerErrorCode int = 500 + +/*GetWebhookPolicyOfProjectInternalServerError Internal server error + +swagger:response getWebhookPolicyOfProjectInternalServerError +*/ +type GetWebhookPolicyOfProjectInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewGetWebhookPolicyOfProjectInternalServerError creates GetWebhookPolicyOfProjectInternalServerError with default headers values +func NewGetWebhookPolicyOfProjectInternalServerError() *GetWebhookPolicyOfProjectInternalServerError { + + return &GetWebhookPolicyOfProjectInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the get webhook policy of project internal server error response +func (o *GetWebhookPolicyOfProjectInternalServerError) WithXRequestID(xRequestID string) *GetWebhookPolicyOfProjectInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the get webhook policy of project internal server error response +func (o *GetWebhookPolicyOfProjectInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the get webhook policy of project internal server error response +func (o *GetWebhookPolicyOfProjectInternalServerError) WithPayload(payload *models.Errors) *GetWebhookPolicyOfProjectInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get webhook policy of project internal server error response +func (o *GetWebhookPolicyOfProjectInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetWebhookPolicyOfProjectInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/webhook/get_webhook_policy_of_project_urlbuilder.go b/src/server/v2.0/restapi/operations/webhook/get_webhook_policy_of_project_urlbuilder.go new file mode 100644 index 000000000..27169194f --- /dev/null +++ b/src/server/v2.0/restapi/operations/webhook/get_webhook_policy_of_project_urlbuilder.go @@ -0,0 +1,109 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package webhook + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetWebhookPolicyOfProjectURL generates an URL for the get webhook policy of project operation +type GetWebhookPolicyOfProjectURL struct { + ProjectNameOrID string + WebhookPolicyID int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetWebhookPolicyOfProjectURL) WithBasePath(bp string) *GetWebhookPolicyOfProjectURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetWebhookPolicyOfProjectURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetWebhookPolicyOfProjectURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}" + + projectNameOrID := o.ProjectNameOrID + if projectNameOrID != "" { + _path = strings.Replace(_path, "{project_name_or_id}", projectNameOrID, -1) + } else { + return nil, errors.New("projectNameOrId is required on GetWebhookPolicyOfProjectURL") + } + + webhookPolicyID := swag.FormatInt64(o.WebhookPolicyID) + if webhookPolicyID != "" { + _path = strings.Replace(_path, "{webhook_policy_id}", webhookPolicyID, -1) + } else { + return nil, errors.New("webhookPolicyId is required on GetWebhookPolicyOfProjectURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetWebhookPolicyOfProjectURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetWebhookPolicyOfProjectURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetWebhookPolicyOfProjectURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetWebhookPolicyOfProjectURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetWebhookPolicyOfProjectURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetWebhookPolicyOfProjectURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/webhook/last_trigger.go b/src/server/v2.0/restapi/operations/webhook/last_trigger.go new file mode 100644 index 000000000..7b3ed41bf --- /dev/null +++ b/src/server/v2.0/restapi/operations/webhook/last_trigger.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package webhook + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// LastTriggerHandlerFunc turns a function with the right signature into a last trigger handler +type LastTriggerHandlerFunc func(LastTriggerParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn LastTriggerHandlerFunc) Handle(params LastTriggerParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// LastTriggerHandler interface for that can handle valid last trigger params +type LastTriggerHandler interface { + Handle(LastTriggerParams, interface{}) middleware.Responder +} + +// NewLastTrigger creates a new http.Handler for the last trigger operation +func NewLastTrigger(ctx *middleware.Context, handler LastTriggerHandler) *LastTrigger { + return &LastTrigger{Context: ctx, Handler: handler} +} + +/*LastTrigger swagger:route GET /projects/{project_name_or_id}/webhook/lasttrigger webhook lastTrigger + +Get project webhook policy last trigger info + +This endpoint returns last trigger information of project webhook policy. + + +*/ +type LastTrigger struct { + Context *middleware.Context + Handler LastTriggerHandler +} + +func (o *LastTrigger) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewLastTriggerParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/webhook/last_trigger_parameters.go b/src/server/v2.0/restapi/operations/webhook/last_trigger_parameters.go new file mode 100644 index 000000000..65abd6cf7 --- /dev/null +++ b/src/server/v2.0/restapi/operations/webhook/last_trigger_parameters.go @@ -0,0 +1,155 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package webhook + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewLastTriggerParams creates a new LastTriggerParams object +// with the default values initialized. +func NewLastTriggerParams() LastTriggerParams { + + var ( + // initialize parameters with default values + + xIsResourceNameDefault = bool(false) + ) + + return LastTriggerParams{ + XIsResourceName: &xIsResourceNameDefault, + } +} + +// LastTriggerParams contains all the bound params for the last trigger operation +// typically these are obtained from a http.Request +// +// swagger:parameters LastTrigger +type LastTriggerParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name. + In: header + Default: false + */ + XIsResourceName *bool + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The name or id of the project + Required: true + In: path + */ + ProjectNameOrID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewLastTriggerParams() beforehand. +func (o *LastTriggerParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXIsResourceName(r.Header[http.CanonicalHeaderKey("X-Is-Resource-Name")], true, route.Formats); err != nil { + res = append(res, err) + } + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + rProjectNameOrID, rhkProjectNameOrID, _ := route.Params.GetOK("project_name_or_id") + if err := o.bindProjectNameOrID(rProjectNameOrID, rhkProjectNameOrID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXIsResourceName binds and validates parameter XIsResourceName from header. +func (o *LastTriggerParams) bindXIsResourceName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewLastTriggerParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("X-Is-Resource-Name", "header", "bool", raw) + } + o.XIsResourceName = &value + + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *LastTriggerParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *LastTriggerParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindProjectNameOrID binds and validates parameter ProjectNameOrID from path. +func (o *LastTriggerParams) bindProjectNameOrID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectNameOrID = raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/webhook/last_trigger_responses.go b/src/server/v2.0/restapi/operations/webhook/last_trigger_responses.go new file mode 100644 index 000000000..d3cb388c3 --- /dev/null +++ b/src/server/v2.0/restapi/operations/webhook/last_trigger_responses.go @@ -0,0 +1,325 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package webhook + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// LastTriggerOKCode is the HTTP code returned for type LastTriggerOK +const LastTriggerOKCode int = 200 + +/*LastTriggerOK Test webhook connection successfully. + +swagger:response lastTriggerOK +*/ +type LastTriggerOK struct { + + /* + In: Body + */ + Payload []*models.WebhookLastTrigger `json:"body,omitempty"` +} + +// NewLastTriggerOK creates LastTriggerOK with default headers values +func NewLastTriggerOK() *LastTriggerOK { + + return &LastTriggerOK{} +} + +// WithPayload adds the payload to the last trigger o k response +func (o *LastTriggerOK) WithPayload(payload []*models.WebhookLastTrigger) *LastTriggerOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the last trigger o k response +func (o *LastTriggerOK) SetPayload(payload []*models.WebhookLastTrigger) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *LastTriggerOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = make([]*models.WebhookLastTrigger, 0, 50) + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// LastTriggerBadRequestCode is the HTTP code returned for type LastTriggerBadRequest +const LastTriggerBadRequestCode int = 400 + +/*LastTriggerBadRequest Bad request + +swagger:response lastTriggerBadRequest +*/ +type LastTriggerBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewLastTriggerBadRequest creates LastTriggerBadRequest with default headers values +func NewLastTriggerBadRequest() *LastTriggerBadRequest { + + return &LastTriggerBadRequest{} +} + +// WithXRequestID adds the xRequestId to the last trigger bad request response +func (o *LastTriggerBadRequest) WithXRequestID(xRequestID string) *LastTriggerBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the last trigger bad request response +func (o *LastTriggerBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the last trigger bad request response +func (o *LastTriggerBadRequest) WithPayload(payload *models.Errors) *LastTriggerBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the last trigger bad request response +func (o *LastTriggerBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *LastTriggerBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// LastTriggerUnauthorizedCode is the HTTP code returned for type LastTriggerUnauthorized +const LastTriggerUnauthorizedCode int = 401 + +/*LastTriggerUnauthorized Unauthorized + +swagger:response lastTriggerUnauthorized +*/ +type LastTriggerUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewLastTriggerUnauthorized creates LastTriggerUnauthorized with default headers values +func NewLastTriggerUnauthorized() *LastTriggerUnauthorized { + + return &LastTriggerUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the last trigger unauthorized response +func (o *LastTriggerUnauthorized) WithXRequestID(xRequestID string) *LastTriggerUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the last trigger unauthorized response +func (o *LastTriggerUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the last trigger unauthorized response +func (o *LastTriggerUnauthorized) WithPayload(payload *models.Errors) *LastTriggerUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the last trigger unauthorized response +func (o *LastTriggerUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *LastTriggerUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// LastTriggerForbiddenCode is the HTTP code returned for type LastTriggerForbidden +const LastTriggerForbiddenCode int = 403 + +/*LastTriggerForbidden Forbidden + +swagger:response lastTriggerForbidden +*/ +type LastTriggerForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewLastTriggerForbidden creates LastTriggerForbidden with default headers values +func NewLastTriggerForbidden() *LastTriggerForbidden { + + return &LastTriggerForbidden{} +} + +// WithXRequestID adds the xRequestId to the last trigger forbidden response +func (o *LastTriggerForbidden) WithXRequestID(xRequestID string) *LastTriggerForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the last trigger forbidden response +func (o *LastTriggerForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the last trigger forbidden response +func (o *LastTriggerForbidden) WithPayload(payload *models.Errors) *LastTriggerForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the last trigger forbidden response +func (o *LastTriggerForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *LastTriggerForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// LastTriggerInternalServerErrorCode is the HTTP code returned for type LastTriggerInternalServerError +const LastTriggerInternalServerErrorCode int = 500 + +/*LastTriggerInternalServerError Internal server error + +swagger:response lastTriggerInternalServerError +*/ +type LastTriggerInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewLastTriggerInternalServerError creates LastTriggerInternalServerError with default headers values +func NewLastTriggerInternalServerError() *LastTriggerInternalServerError { + + return &LastTriggerInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the last trigger internal server error response +func (o *LastTriggerInternalServerError) WithXRequestID(xRequestID string) *LastTriggerInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the last trigger internal server error response +func (o *LastTriggerInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the last trigger internal server error response +func (o *LastTriggerInternalServerError) WithPayload(payload *models.Errors) *LastTriggerInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the last trigger internal server error response +func (o *LastTriggerInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *LastTriggerInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/webhook/last_trigger_urlbuilder.go b/src/server/v2.0/restapi/operations/webhook/last_trigger_urlbuilder.go new file mode 100644 index 000000000..8d69cbf0d --- /dev/null +++ b/src/server/v2.0/restapi/operations/webhook/last_trigger_urlbuilder.go @@ -0,0 +1,99 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package webhook + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// LastTriggerURL generates an URL for the last trigger operation +type LastTriggerURL struct { + ProjectNameOrID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *LastTriggerURL) WithBasePath(bp string) *LastTriggerURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *LastTriggerURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *LastTriggerURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name_or_id}/webhook/lasttrigger" + + projectNameOrID := o.ProjectNameOrID + if projectNameOrID != "" { + _path = strings.Replace(_path, "{project_name_or_id}", projectNameOrID, -1) + } else { + return nil, errors.New("projectNameOrId is required on LastTriggerURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *LastTriggerURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *LastTriggerURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *LastTriggerURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on LastTriggerURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on LastTriggerURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *LastTriggerURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/webhook/list_webhook_policies_of_project.go b/src/server/v2.0/restapi/operations/webhook/list_webhook_policies_of_project.go new file mode 100644 index 000000000..1bda8559f --- /dev/null +++ b/src/server/v2.0/restapi/operations/webhook/list_webhook_policies_of_project.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package webhook + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ListWebhookPoliciesOfProjectHandlerFunc turns a function with the right signature into a list webhook policies of project handler +type ListWebhookPoliciesOfProjectHandlerFunc func(ListWebhookPoliciesOfProjectParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ListWebhookPoliciesOfProjectHandlerFunc) Handle(params ListWebhookPoliciesOfProjectParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ListWebhookPoliciesOfProjectHandler interface for that can handle valid list webhook policies of project params +type ListWebhookPoliciesOfProjectHandler interface { + Handle(ListWebhookPoliciesOfProjectParams, interface{}) middleware.Responder +} + +// NewListWebhookPoliciesOfProject creates a new http.Handler for the list webhook policies of project operation +func NewListWebhookPoliciesOfProject(ctx *middleware.Context, handler ListWebhookPoliciesOfProjectHandler) *ListWebhookPoliciesOfProject { + return &ListWebhookPoliciesOfProject{Context: ctx, Handler: handler} +} + +/*ListWebhookPoliciesOfProject swagger:route GET /projects/{project_name_or_id}/webhook/policies webhook listWebhookPoliciesOfProject + +List project webhook policies. + +This endpoint returns webhook policies of a project. + + +*/ +type ListWebhookPoliciesOfProject struct { + Context *middleware.Context + Handler ListWebhookPoliciesOfProjectHandler +} + +func (o *ListWebhookPoliciesOfProject) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewListWebhookPoliciesOfProjectParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/webhook/list_webhook_policies_of_project_parameters.go b/src/server/v2.0/restapi/operations/webhook/list_webhook_policies_of_project_parameters.go new file mode 100644 index 000000000..d56f53abe --- /dev/null +++ b/src/server/v2.0/restapi/operations/webhook/list_webhook_policies_of_project_parameters.go @@ -0,0 +1,300 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package webhook + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewListWebhookPoliciesOfProjectParams creates a new ListWebhookPoliciesOfProjectParams object +// with the default values initialized. +func NewListWebhookPoliciesOfProjectParams() ListWebhookPoliciesOfProjectParams { + + var ( + // initialize parameters with default values + + xIsResourceNameDefault = bool(false) + + pageDefault = int64(1) + pageSizeDefault = int64(10) + ) + + return ListWebhookPoliciesOfProjectParams{ + XIsResourceName: &xIsResourceNameDefault, + + Page: &pageDefault, + + PageSize: &pageSizeDefault, + } +} + +// ListWebhookPoliciesOfProjectParams contains all the bound params for the list webhook policies of project operation +// typically these are obtained from a http.Request +// +// swagger:parameters ListWebhookPoliciesOfProject +type ListWebhookPoliciesOfProjectParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name. + In: header + Default: false + */ + XIsResourceName *bool + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The page number + In: query + Default: 1 + */ + Page *int64 + /*The size of per page + Maximum: 100 + In: query + Default: 10 + */ + PageSize *int64 + /*The name or id of the project + Required: true + In: path + */ + ProjectNameOrID string + /*Query string to query resources. Supported query patterns are "exact match(k=v)", "fuzzy match(k=~v)", "range(k=[min~max])", "list with union releationship(k={v1 v2 v3})" and "list with intersetion relationship(k=(v1 v2 v3))". The value of range and list can be string(enclosed by " or '), integer or time(in format "2020-04-09 02:36:00"). All of these query patterns should be put in the query string "q=xxx" and splitted by ",". e.g. q=k1=v1,k2=~v2,k3=[min~max] + In: query + */ + Q *string + /*Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + In: query + */ + Sort *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewListWebhookPoliciesOfProjectParams() beforehand. +func (o *ListWebhookPoliciesOfProjectParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if err := o.bindXIsResourceName(r.Header[http.CanonicalHeaderKey("X-Is-Resource-Name")], true, route.Formats); err != nil { + res = append(res, err) + } + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + qPage, qhkPage, _ := qs.GetOK("page") + if err := o.bindPage(qPage, qhkPage, route.Formats); err != nil { + res = append(res, err) + } + + qPageSize, qhkPageSize, _ := qs.GetOK("page_size") + if err := o.bindPageSize(qPageSize, qhkPageSize, route.Formats); err != nil { + res = append(res, err) + } + + rProjectNameOrID, rhkProjectNameOrID, _ := route.Params.GetOK("project_name_or_id") + if err := o.bindProjectNameOrID(rProjectNameOrID, rhkProjectNameOrID, route.Formats); err != nil { + res = append(res, err) + } + + qQ, qhkQ, _ := qs.GetOK("q") + if err := o.bindQ(qQ, qhkQ, route.Formats); err != nil { + res = append(res, err) + } + + qSort, qhkSort, _ := qs.GetOK("sort") + if err := o.bindSort(qSort, qhkSort, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXIsResourceName binds and validates parameter XIsResourceName from header. +func (o *ListWebhookPoliciesOfProjectParams) bindXIsResourceName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListWebhookPoliciesOfProjectParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("X-Is-Resource-Name", "header", "bool", raw) + } + o.XIsResourceName = &value + + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *ListWebhookPoliciesOfProjectParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *ListWebhookPoliciesOfProjectParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindPage binds and validates parameter Page from query. +func (o *ListWebhookPoliciesOfProjectParams) bindPage(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListWebhookPoliciesOfProjectParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page", "query", "int64", raw) + } + o.Page = &value + + return nil +} + +// bindPageSize binds and validates parameter PageSize from query. +func (o *ListWebhookPoliciesOfProjectParams) bindPageSize(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListWebhookPoliciesOfProjectParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page_size", "query", "int64", raw) + } + o.PageSize = &value + + if err := o.validatePageSize(formats); err != nil { + return err + } + + return nil +} + +// validatePageSize carries on validations for parameter PageSize +func (o *ListWebhookPoliciesOfProjectParams) validatePageSize(formats strfmt.Registry) error { + + if err := validate.MaximumInt("page_size", "query", int64(*o.PageSize), 100, false); err != nil { + return err + } + + return nil +} + +// bindProjectNameOrID binds and validates parameter ProjectNameOrID from path. +func (o *ListWebhookPoliciesOfProjectParams) bindProjectNameOrID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectNameOrID = raw + + return nil +} + +// bindQ binds and validates parameter Q from query. +func (o *ListWebhookPoliciesOfProjectParams) bindQ(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Q = &raw + + return nil +} + +// bindSort binds and validates parameter Sort from query. +func (o *ListWebhookPoliciesOfProjectParams) bindSort(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Sort = &raw + + return nil +} diff --git a/src/server/v2.0/restapi/operations/webhook/list_webhook_policies_of_project_responses.go b/src/server/v2.0/restapi/operations/webhook/list_webhook_policies_of_project_responses.go new file mode 100644 index 000000000..c3c48e6ff --- /dev/null +++ b/src/server/v2.0/restapi/operations/webhook/list_webhook_policies_of_project_responses.go @@ -0,0 +1,370 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package webhook + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/swag" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// ListWebhookPoliciesOfProjectOKCode is the HTTP code returned for type ListWebhookPoliciesOfProjectOK +const ListWebhookPoliciesOfProjectOKCode int = 200 + +/*ListWebhookPoliciesOfProjectOK Success + +swagger:response listWebhookPoliciesOfProjectOK +*/ +type ListWebhookPoliciesOfProjectOK struct { + /*Link refers to the previous page and next page + + */ + Link string `json:"Link"` + /*The total count of webhook policies. + + */ + XTotalCount int64 `json:"X-Total-Count"` + + /* + In: Body + */ + Payload []*models.WebhookPolicy `json:"body,omitempty"` +} + +// NewListWebhookPoliciesOfProjectOK creates ListWebhookPoliciesOfProjectOK with default headers values +func NewListWebhookPoliciesOfProjectOK() *ListWebhookPoliciesOfProjectOK { + + return &ListWebhookPoliciesOfProjectOK{} +} + +// WithLink adds the link to the list webhook policies of project o k response +func (o *ListWebhookPoliciesOfProjectOK) WithLink(link string) *ListWebhookPoliciesOfProjectOK { + o.Link = link + return o +} + +// SetLink sets the link to the list webhook policies of project o k response +func (o *ListWebhookPoliciesOfProjectOK) SetLink(link string) { + o.Link = link +} + +// WithXTotalCount adds the xTotalCount to the list webhook policies of project o k response +func (o *ListWebhookPoliciesOfProjectOK) WithXTotalCount(xTotalCount int64) *ListWebhookPoliciesOfProjectOK { + o.XTotalCount = xTotalCount + return o +} + +// SetXTotalCount sets the xTotalCount to the list webhook policies of project o k response +func (o *ListWebhookPoliciesOfProjectOK) SetXTotalCount(xTotalCount int64) { + o.XTotalCount = xTotalCount +} + +// WithPayload adds the payload to the list webhook policies of project o k response +func (o *ListWebhookPoliciesOfProjectOK) WithPayload(payload []*models.WebhookPolicy) *ListWebhookPoliciesOfProjectOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list webhook policies of project o k response +func (o *ListWebhookPoliciesOfProjectOK) SetPayload(payload []*models.WebhookPolicy) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListWebhookPoliciesOfProjectOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Link + + link := o.Link + if link != "" { + rw.Header().Set("Link", link) + } + + // response header X-Total-Count + + xTotalCount := swag.FormatInt64(o.XTotalCount) + if xTotalCount != "" { + rw.Header().Set("X-Total-Count", xTotalCount) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = make([]*models.WebhookPolicy, 0, 50) + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ListWebhookPoliciesOfProjectBadRequestCode is the HTTP code returned for type ListWebhookPoliciesOfProjectBadRequest +const ListWebhookPoliciesOfProjectBadRequestCode int = 400 + +/*ListWebhookPoliciesOfProjectBadRequest Bad request + +swagger:response listWebhookPoliciesOfProjectBadRequest +*/ +type ListWebhookPoliciesOfProjectBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListWebhookPoliciesOfProjectBadRequest creates ListWebhookPoliciesOfProjectBadRequest with default headers values +func NewListWebhookPoliciesOfProjectBadRequest() *ListWebhookPoliciesOfProjectBadRequest { + + return &ListWebhookPoliciesOfProjectBadRequest{} +} + +// WithXRequestID adds the xRequestId to the list webhook policies of project bad request response +func (o *ListWebhookPoliciesOfProjectBadRequest) WithXRequestID(xRequestID string) *ListWebhookPoliciesOfProjectBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list webhook policies of project bad request response +func (o *ListWebhookPoliciesOfProjectBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list webhook policies of project bad request response +func (o *ListWebhookPoliciesOfProjectBadRequest) WithPayload(payload *models.Errors) *ListWebhookPoliciesOfProjectBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list webhook policies of project bad request response +func (o *ListWebhookPoliciesOfProjectBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListWebhookPoliciesOfProjectBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListWebhookPoliciesOfProjectUnauthorizedCode is the HTTP code returned for type ListWebhookPoliciesOfProjectUnauthorized +const ListWebhookPoliciesOfProjectUnauthorizedCode int = 401 + +/*ListWebhookPoliciesOfProjectUnauthorized Unauthorized + +swagger:response listWebhookPoliciesOfProjectUnauthorized +*/ +type ListWebhookPoliciesOfProjectUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListWebhookPoliciesOfProjectUnauthorized creates ListWebhookPoliciesOfProjectUnauthorized with default headers values +func NewListWebhookPoliciesOfProjectUnauthorized() *ListWebhookPoliciesOfProjectUnauthorized { + + return &ListWebhookPoliciesOfProjectUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the list webhook policies of project unauthorized response +func (o *ListWebhookPoliciesOfProjectUnauthorized) WithXRequestID(xRequestID string) *ListWebhookPoliciesOfProjectUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list webhook policies of project unauthorized response +func (o *ListWebhookPoliciesOfProjectUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list webhook policies of project unauthorized response +func (o *ListWebhookPoliciesOfProjectUnauthorized) WithPayload(payload *models.Errors) *ListWebhookPoliciesOfProjectUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list webhook policies of project unauthorized response +func (o *ListWebhookPoliciesOfProjectUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListWebhookPoliciesOfProjectUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListWebhookPoliciesOfProjectForbiddenCode is the HTTP code returned for type ListWebhookPoliciesOfProjectForbidden +const ListWebhookPoliciesOfProjectForbiddenCode int = 403 + +/*ListWebhookPoliciesOfProjectForbidden Forbidden + +swagger:response listWebhookPoliciesOfProjectForbidden +*/ +type ListWebhookPoliciesOfProjectForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListWebhookPoliciesOfProjectForbidden creates ListWebhookPoliciesOfProjectForbidden with default headers values +func NewListWebhookPoliciesOfProjectForbidden() *ListWebhookPoliciesOfProjectForbidden { + + return &ListWebhookPoliciesOfProjectForbidden{} +} + +// WithXRequestID adds the xRequestId to the list webhook policies of project forbidden response +func (o *ListWebhookPoliciesOfProjectForbidden) WithXRequestID(xRequestID string) *ListWebhookPoliciesOfProjectForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list webhook policies of project forbidden response +func (o *ListWebhookPoliciesOfProjectForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list webhook policies of project forbidden response +func (o *ListWebhookPoliciesOfProjectForbidden) WithPayload(payload *models.Errors) *ListWebhookPoliciesOfProjectForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list webhook policies of project forbidden response +func (o *ListWebhookPoliciesOfProjectForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListWebhookPoliciesOfProjectForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListWebhookPoliciesOfProjectInternalServerErrorCode is the HTTP code returned for type ListWebhookPoliciesOfProjectInternalServerError +const ListWebhookPoliciesOfProjectInternalServerErrorCode int = 500 + +/*ListWebhookPoliciesOfProjectInternalServerError Internal server error + +swagger:response listWebhookPoliciesOfProjectInternalServerError +*/ +type ListWebhookPoliciesOfProjectInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListWebhookPoliciesOfProjectInternalServerError creates ListWebhookPoliciesOfProjectInternalServerError with default headers values +func NewListWebhookPoliciesOfProjectInternalServerError() *ListWebhookPoliciesOfProjectInternalServerError { + + return &ListWebhookPoliciesOfProjectInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the list webhook policies of project internal server error response +func (o *ListWebhookPoliciesOfProjectInternalServerError) WithXRequestID(xRequestID string) *ListWebhookPoliciesOfProjectInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list webhook policies of project internal server error response +func (o *ListWebhookPoliciesOfProjectInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list webhook policies of project internal server error response +func (o *ListWebhookPoliciesOfProjectInternalServerError) WithPayload(payload *models.Errors) *ListWebhookPoliciesOfProjectInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list webhook policies of project internal server error response +func (o *ListWebhookPoliciesOfProjectInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListWebhookPoliciesOfProjectInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/webhook/list_webhook_policies_of_project_urlbuilder.go b/src/server/v2.0/restapi/operations/webhook/list_webhook_policies_of_project_urlbuilder.go new file mode 100644 index 000000000..7d204011a --- /dev/null +++ b/src/server/v2.0/restapi/operations/webhook/list_webhook_policies_of_project_urlbuilder.go @@ -0,0 +1,142 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package webhook + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ListWebhookPoliciesOfProjectURL generates an URL for the list webhook policies of project operation +type ListWebhookPoliciesOfProjectURL struct { + ProjectNameOrID string + + Page *int64 + PageSize *int64 + Q *string + Sort *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListWebhookPoliciesOfProjectURL) WithBasePath(bp string) *ListWebhookPoliciesOfProjectURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListWebhookPoliciesOfProjectURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ListWebhookPoliciesOfProjectURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name_or_id}/webhook/policies" + + projectNameOrID := o.ProjectNameOrID + if projectNameOrID != "" { + _path = strings.Replace(_path, "{project_name_or_id}", projectNameOrID, -1) + } else { + return nil, errors.New("projectNameOrId is required on ListWebhookPoliciesOfProjectURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var pageQ string + if o.Page != nil { + pageQ = swag.FormatInt64(*o.Page) + } + if pageQ != "" { + qs.Set("page", pageQ) + } + + var pageSizeQ string + if o.PageSize != nil { + pageSizeQ = swag.FormatInt64(*o.PageSize) + } + if pageSizeQ != "" { + qs.Set("page_size", pageSizeQ) + } + + var qQ string + if o.Q != nil { + qQ = *o.Q + } + if qQ != "" { + qs.Set("q", qQ) + } + + var sortQ string + if o.Sort != nil { + sortQ = *o.Sort + } + if sortQ != "" { + qs.Set("sort", sortQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ListWebhookPoliciesOfProjectURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ListWebhookPoliciesOfProjectURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ListWebhookPoliciesOfProjectURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ListWebhookPoliciesOfProjectURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ListWebhookPoliciesOfProjectURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ListWebhookPoliciesOfProjectURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/webhook/update_webhook_policy_of_project.go b/src/server/v2.0/restapi/operations/webhook/update_webhook_policy_of_project.go new file mode 100644 index 000000000..ad7b0789c --- /dev/null +++ b/src/server/v2.0/restapi/operations/webhook/update_webhook_policy_of_project.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package webhook + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// UpdateWebhookPolicyOfProjectHandlerFunc turns a function with the right signature into a update webhook policy of project handler +type UpdateWebhookPolicyOfProjectHandlerFunc func(UpdateWebhookPolicyOfProjectParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn UpdateWebhookPolicyOfProjectHandlerFunc) Handle(params UpdateWebhookPolicyOfProjectParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// UpdateWebhookPolicyOfProjectHandler interface for that can handle valid update webhook policy of project params +type UpdateWebhookPolicyOfProjectHandler interface { + Handle(UpdateWebhookPolicyOfProjectParams, interface{}) middleware.Responder +} + +// NewUpdateWebhookPolicyOfProject creates a new http.Handler for the update webhook policy of project operation +func NewUpdateWebhookPolicyOfProject(ctx *middleware.Context, handler UpdateWebhookPolicyOfProjectHandler) *UpdateWebhookPolicyOfProject { + return &UpdateWebhookPolicyOfProject{Context: ctx, Handler: handler} +} + +/*UpdateWebhookPolicyOfProject swagger:route PUT /projects/{project_name_or_id}/webhook/policies/{webhook_policy_id} webhook updateWebhookPolicyOfProject + +Update webhook policy of a project. + +This endpoint is aimed to update the webhook policy of a project. + + +*/ +type UpdateWebhookPolicyOfProject struct { + Context *middleware.Context + Handler UpdateWebhookPolicyOfProjectHandler +} + +func (o *UpdateWebhookPolicyOfProject) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewUpdateWebhookPolicyOfProjectParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/webhook/update_webhook_policy_of_project_parameters.go b/src/server/v2.0/restapi/operations/webhook/update_webhook_policy_of_project_parameters.go new file mode 100644 index 000000000..1c405cea7 --- /dev/null +++ b/src/server/v2.0/restapi/operations/webhook/update_webhook_policy_of_project_parameters.go @@ -0,0 +1,215 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package webhook + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// NewUpdateWebhookPolicyOfProjectParams creates a new UpdateWebhookPolicyOfProjectParams object +// with the default values initialized. +func NewUpdateWebhookPolicyOfProjectParams() UpdateWebhookPolicyOfProjectParams { + + var ( + // initialize parameters with default values + + xIsResourceNameDefault = bool(false) + ) + + return UpdateWebhookPolicyOfProjectParams{ + XIsResourceName: &xIsResourceNameDefault, + } +} + +// UpdateWebhookPolicyOfProjectParams contains all the bound params for the update webhook policy of project operation +// typically these are obtained from a http.Request +// +// swagger:parameters UpdateWebhookPolicyOfProject +type UpdateWebhookPolicyOfProjectParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name. + In: header + Default: false + */ + XIsResourceName *bool + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*All properties needed except "id", "project_id", "creation_time", "update_time". + Required: true + In: body + */ + Policy *models.WebhookPolicy + /*The name or id of the project + Required: true + In: path + */ + ProjectNameOrID string + /*The ID of the webhook policy + Required: true + In: path + */ + WebhookPolicyID int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewUpdateWebhookPolicyOfProjectParams() beforehand. +func (o *UpdateWebhookPolicyOfProjectParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := o.bindXIsResourceName(r.Header[http.CanonicalHeaderKey("X-Is-Resource-Name")], true, route.Formats); err != nil { + res = append(res, err) + } + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.WebhookPolicy + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("policy", "body", "")) + } else { + res = append(res, errors.NewParseError("policy", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Policy = &body + } + } + } else { + res = append(res, errors.Required("policy", "body", "")) + } + rProjectNameOrID, rhkProjectNameOrID, _ := route.Params.GetOK("project_name_or_id") + if err := o.bindProjectNameOrID(rProjectNameOrID, rhkProjectNameOrID, route.Formats); err != nil { + res = append(res, err) + } + + rWebhookPolicyID, rhkWebhookPolicyID, _ := route.Params.GetOK("webhook_policy_id") + if err := o.bindWebhookPolicyID(rWebhookPolicyID, rhkWebhookPolicyID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXIsResourceName binds and validates parameter XIsResourceName from header. +func (o *UpdateWebhookPolicyOfProjectParams) bindXIsResourceName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewUpdateWebhookPolicyOfProjectParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("X-Is-Resource-Name", "header", "bool", raw) + } + o.XIsResourceName = &value + + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *UpdateWebhookPolicyOfProjectParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *UpdateWebhookPolicyOfProjectParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindProjectNameOrID binds and validates parameter ProjectNameOrID from path. +func (o *UpdateWebhookPolicyOfProjectParams) bindProjectNameOrID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectNameOrID = raw + + return nil +} + +// bindWebhookPolicyID binds and validates parameter WebhookPolicyID from path. +func (o *UpdateWebhookPolicyOfProjectParams) bindWebhookPolicyID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("webhook_policy_id", "path", "int64", raw) + } + o.WebhookPolicyID = value + + return nil +} diff --git a/src/server/v2.0/restapi/operations/webhook/update_webhook_policy_of_project_responses.go b/src/server/v2.0/restapi/operations/webhook/update_webhook_policy_of_project_responses.go new file mode 100644 index 000000000..143e67a1c --- /dev/null +++ b/src/server/v2.0/restapi/operations/webhook/update_webhook_policy_of_project_responses.go @@ -0,0 +1,390 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package webhook + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// UpdateWebhookPolicyOfProjectOKCode is the HTTP code returned for type UpdateWebhookPolicyOfProjectOK +const UpdateWebhookPolicyOfProjectOKCode int = 200 + +/*UpdateWebhookPolicyOfProjectOK Success + +swagger:response updateWebhookPolicyOfProjectOK +*/ +type UpdateWebhookPolicyOfProjectOK struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` +} + +// NewUpdateWebhookPolicyOfProjectOK creates UpdateWebhookPolicyOfProjectOK with default headers values +func NewUpdateWebhookPolicyOfProjectOK() *UpdateWebhookPolicyOfProjectOK { + + return &UpdateWebhookPolicyOfProjectOK{} +} + +// WithXRequestID adds the xRequestId to the update webhook policy of project o k response +func (o *UpdateWebhookPolicyOfProjectOK) WithXRequestID(xRequestID string) *UpdateWebhookPolicyOfProjectOK { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update webhook policy of project o k response +func (o *UpdateWebhookPolicyOfProjectOK) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WriteResponse to the client +func (o *UpdateWebhookPolicyOfProjectOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.Header().Del(runtime.HeaderContentType) // Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// UpdateWebhookPolicyOfProjectBadRequestCode is the HTTP code returned for type UpdateWebhookPolicyOfProjectBadRequest +const UpdateWebhookPolicyOfProjectBadRequestCode int = 400 + +/*UpdateWebhookPolicyOfProjectBadRequest Bad request + +swagger:response updateWebhookPolicyOfProjectBadRequest +*/ +type UpdateWebhookPolicyOfProjectBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateWebhookPolicyOfProjectBadRequest creates UpdateWebhookPolicyOfProjectBadRequest with default headers values +func NewUpdateWebhookPolicyOfProjectBadRequest() *UpdateWebhookPolicyOfProjectBadRequest { + + return &UpdateWebhookPolicyOfProjectBadRequest{} +} + +// WithXRequestID adds the xRequestId to the update webhook policy of project bad request response +func (o *UpdateWebhookPolicyOfProjectBadRequest) WithXRequestID(xRequestID string) *UpdateWebhookPolicyOfProjectBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update webhook policy of project bad request response +func (o *UpdateWebhookPolicyOfProjectBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update webhook policy of project bad request response +func (o *UpdateWebhookPolicyOfProjectBadRequest) WithPayload(payload *models.Errors) *UpdateWebhookPolicyOfProjectBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update webhook policy of project bad request response +func (o *UpdateWebhookPolicyOfProjectBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateWebhookPolicyOfProjectBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateWebhookPolicyOfProjectUnauthorizedCode is the HTTP code returned for type UpdateWebhookPolicyOfProjectUnauthorized +const UpdateWebhookPolicyOfProjectUnauthorizedCode int = 401 + +/*UpdateWebhookPolicyOfProjectUnauthorized Unauthorized + +swagger:response updateWebhookPolicyOfProjectUnauthorized +*/ +type UpdateWebhookPolicyOfProjectUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateWebhookPolicyOfProjectUnauthorized creates UpdateWebhookPolicyOfProjectUnauthorized with default headers values +func NewUpdateWebhookPolicyOfProjectUnauthorized() *UpdateWebhookPolicyOfProjectUnauthorized { + + return &UpdateWebhookPolicyOfProjectUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the update webhook policy of project unauthorized response +func (o *UpdateWebhookPolicyOfProjectUnauthorized) WithXRequestID(xRequestID string) *UpdateWebhookPolicyOfProjectUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update webhook policy of project unauthorized response +func (o *UpdateWebhookPolicyOfProjectUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update webhook policy of project unauthorized response +func (o *UpdateWebhookPolicyOfProjectUnauthorized) WithPayload(payload *models.Errors) *UpdateWebhookPolicyOfProjectUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update webhook policy of project unauthorized response +func (o *UpdateWebhookPolicyOfProjectUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateWebhookPolicyOfProjectUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateWebhookPolicyOfProjectForbiddenCode is the HTTP code returned for type UpdateWebhookPolicyOfProjectForbidden +const UpdateWebhookPolicyOfProjectForbiddenCode int = 403 + +/*UpdateWebhookPolicyOfProjectForbidden Forbidden + +swagger:response updateWebhookPolicyOfProjectForbidden +*/ +type UpdateWebhookPolicyOfProjectForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateWebhookPolicyOfProjectForbidden creates UpdateWebhookPolicyOfProjectForbidden with default headers values +func NewUpdateWebhookPolicyOfProjectForbidden() *UpdateWebhookPolicyOfProjectForbidden { + + return &UpdateWebhookPolicyOfProjectForbidden{} +} + +// WithXRequestID adds the xRequestId to the update webhook policy of project forbidden response +func (o *UpdateWebhookPolicyOfProjectForbidden) WithXRequestID(xRequestID string) *UpdateWebhookPolicyOfProjectForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update webhook policy of project forbidden response +func (o *UpdateWebhookPolicyOfProjectForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update webhook policy of project forbidden response +func (o *UpdateWebhookPolicyOfProjectForbidden) WithPayload(payload *models.Errors) *UpdateWebhookPolicyOfProjectForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update webhook policy of project forbidden response +func (o *UpdateWebhookPolicyOfProjectForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateWebhookPolicyOfProjectForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateWebhookPolicyOfProjectNotFoundCode is the HTTP code returned for type UpdateWebhookPolicyOfProjectNotFound +const UpdateWebhookPolicyOfProjectNotFoundCode int = 404 + +/*UpdateWebhookPolicyOfProjectNotFound Not found + +swagger:response updateWebhookPolicyOfProjectNotFound +*/ +type UpdateWebhookPolicyOfProjectNotFound struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateWebhookPolicyOfProjectNotFound creates UpdateWebhookPolicyOfProjectNotFound with default headers values +func NewUpdateWebhookPolicyOfProjectNotFound() *UpdateWebhookPolicyOfProjectNotFound { + + return &UpdateWebhookPolicyOfProjectNotFound{} +} + +// WithXRequestID adds the xRequestId to the update webhook policy of project not found response +func (o *UpdateWebhookPolicyOfProjectNotFound) WithXRequestID(xRequestID string) *UpdateWebhookPolicyOfProjectNotFound { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update webhook policy of project not found response +func (o *UpdateWebhookPolicyOfProjectNotFound) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update webhook policy of project not found response +func (o *UpdateWebhookPolicyOfProjectNotFound) WithPayload(payload *models.Errors) *UpdateWebhookPolicyOfProjectNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update webhook policy of project not found response +func (o *UpdateWebhookPolicyOfProjectNotFound) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateWebhookPolicyOfProjectNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateWebhookPolicyOfProjectInternalServerErrorCode is the HTTP code returned for type UpdateWebhookPolicyOfProjectInternalServerError +const UpdateWebhookPolicyOfProjectInternalServerErrorCode int = 500 + +/*UpdateWebhookPolicyOfProjectInternalServerError Internal server error + +swagger:response updateWebhookPolicyOfProjectInternalServerError +*/ +type UpdateWebhookPolicyOfProjectInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewUpdateWebhookPolicyOfProjectInternalServerError creates UpdateWebhookPolicyOfProjectInternalServerError with default headers values +func NewUpdateWebhookPolicyOfProjectInternalServerError() *UpdateWebhookPolicyOfProjectInternalServerError { + + return &UpdateWebhookPolicyOfProjectInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the update webhook policy of project internal server error response +func (o *UpdateWebhookPolicyOfProjectInternalServerError) WithXRequestID(xRequestID string) *UpdateWebhookPolicyOfProjectInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the update webhook policy of project internal server error response +func (o *UpdateWebhookPolicyOfProjectInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the update webhook policy of project internal server error response +func (o *UpdateWebhookPolicyOfProjectInternalServerError) WithPayload(payload *models.Errors) *UpdateWebhookPolicyOfProjectInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update webhook policy of project internal server error response +func (o *UpdateWebhookPolicyOfProjectInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateWebhookPolicyOfProjectInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/webhook/update_webhook_policy_of_project_urlbuilder.go b/src/server/v2.0/restapi/operations/webhook/update_webhook_policy_of_project_urlbuilder.go new file mode 100644 index 000000000..b1c101769 --- /dev/null +++ b/src/server/v2.0/restapi/operations/webhook/update_webhook_policy_of_project_urlbuilder.go @@ -0,0 +1,109 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package webhook + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// UpdateWebhookPolicyOfProjectURL generates an URL for the update webhook policy of project operation +type UpdateWebhookPolicyOfProjectURL struct { + ProjectNameOrID string + WebhookPolicyID int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdateWebhookPolicyOfProjectURL) WithBasePath(bp string) *UpdateWebhookPolicyOfProjectURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdateWebhookPolicyOfProjectURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *UpdateWebhookPolicyOfProjectURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}" + + projectNameOrID := o.ProjectNameOrID + if projectNameOrID != "" { + _path = strings.Replace(_path, "{project_name_or_id}", projectNameOrID, -1) + } else { + return nil, errors.New("projectNameOrId is required on UpdateWebhookPolicyOfProjectURL") + } + + webhookPolicyID := swag.FormatInt64(o.WebhookPolicyID) + if webhookPolicyID != "" { + _path = strings.Replace(_path, "{webhook_policy_id}", webhookPolicyID, -1) + } else { + return nil, errors.New("webhookPolicyId is required on UpdateWebhookPolicyOfProjectURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *UpdateWebhookPolicyOfProjectURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *UpdateWebhookPolicyOfProjectURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *UpdateWebhookPolicyOfProjectURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on UpdateWebhookPolicyOfProjectURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on UpdateWebhookPolicyOfProjectURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *UpdateWebhookPolicyOfProjectURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/operations/webhookjob/list_webhook_jobs.go b/src/server/v2.0/restapi/operations/webhookjob/list_webhook_jobs.go new file mode 100644 index 000000000..1ce2d0dba --- /dev/null +++ b/src/server/v2.0/restapi/operations/webhookjob/list_webhook_jobs.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package webhookjob + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ListWebhookJobsHandlerFunc turns a function with the right signature into a list webhook jobs handler +type ListWebhookJobsHandlerFunc func(ListWebhookJobsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ListWebhookJobsHandlerFunc) Handle(params ListWebhookJobsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ListWebhookJobsHandler interface for that can handle valid list webhook jobs params +type ListWebhookJobsHandler interface { + Handle(ListWebhookJobsParams, interface{}) middleware.Responder +} + +// NewListWebhookJobs creates a new http.Handler for the list webhook jobs operation +func NewListWebhookJobs(ctx *middleware.Context, handler ListWebhookJobsHandler) *ListWebhookJobs { + return &ListWebhookJobs{Context: ctx, Handler: handler} +} + +/*ListWebhookJobs swagger:route GET /projects/{project_name_or_id}/webhook/jobs webhookjob listWebhookJobs + +List project webhook jobs + +This endpoint returns webhook jobs of a project. + + +*/ +type ListWebhookJobs struct { + Context *middleware.Context + Handler ListWebhookJobsHandler +} + +func (o *ListWebhookJobs) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewListWebhookJobsParams() + + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + r = aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/src/server/v2.0/restapi/operations/webhookjob/list_webhook_jobs_parameters.go b/src/server/v2.0/restapi/operations/webhookjob/list_webhook_jobs_parameters.go new file mode 100644 index 000000000..d01ce2e5d --- /dev/null +++ b/src/server/v2.0/restapi/operations/webhookjob/list_webhook_jobs_parameters.go @@ -0,0 +1,372 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package webhookjob + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewListWebhookJobsParams creates a new ListWebhookJobsParams object +// with the default values initialized. +func NewListWebhookJobsParams() ListWebhookJobsParams { + + var ( + // initialize parameters with default values + + xIsResourceNameDefault = bool(false) + + pageDefault = int64(1) + pageSizeDefault = int64(10) + ) + + return ListWebhookJobsParams{ + XIsResourceName: &xIsResourceNameDefault, + + Page: &pageDefault, + + PageSize: &pageSizeDefault, + } +} + +// ListWebhookJobsParams contains all the bound params for the list webhook jobs operation +// typically these are obtained from a http.Request +// +// swagger:parameters ListWebhookJobs +type ListWebhookJobsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name. + In: header + Default: false + */ + XIsResourceName *bool + /*An unique ID for the request + Min Length: 1 + In: header + */ + XRequestID *string + /*The page number + In: query + Default: 1 + */ + Page *int64 + /*The size of per page + Maximum: 100 + In: query + Default: 10 + */ + PageSize *int64 + /*The policy ID. + Required: true + In: query + */ + PolicyID int64 + /*The name or id of the project + Required: true + In: path + */ + ProjectNameOrID string + /*Query string to query resources. Supported query patterns are "exact match(k=v)", "fuzzy match(k=~v)", "range(k=[min~max])", "list with union releationship(k={v1 v2 v3})" and "list with intersetion relationship(k=(v1 v2 v3))". The value of range and list can be string(enclosed by " or '), integer or time(in format "2020-04-09 02:36:00"). All of these query patterns should be put in the query string "q=xxx" and splitted by ",". e.g. q=k1=v1,k2=~v2,k3=[min~max] + In: query + */ + Q *string + /*Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + In: query + */ + Sort *string + /*The status of webhook job. + In: query + */ + Status []string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewListWebhookJobsParams() beforehand. +func (o *ListWebhookJobsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if err := o.bindXIsResourceName(r.Header[http.CanonicalHeaderKey("X-Is-Resource-Name")], true, route.Formats); err != nil { + res = append(res, err) + } + + if err := o.bindXRequestID(r.Header[http.CanonicalHeaderKey("X-Request-Id")], true, route.Formats); err != nil { + res = append(res, err) + } + + qPage, qhkPage, _ := qs.GetOK("page") + if err := o.bindPage(qPage, qhkPage, route.Formats); err != nil { + res = append(res, err) + } + + qPageSize, qhkPageSize, _ := qs.GetOK("page_size") + if err := o.bindPageSize(qPageSize, qhkPageSize, route.Formats); err != nil { + res = append(res, err) + } + + qPolicyID, qhkPolicyID, _ := qs.GetOK("policy_id") + if err := o.bindPolicyID(qPolicyID, qhkPolicyID, route.Formats); err != nil { + res = append(res, err) + } + + rProjectNameOrID, rhkProjectNameOrID, _ := route.Params.GetOK("project_name_or_id") + if err := o.bindProjectNameOrID(rProjectNameOrID, rhkProjectNameOrID, route.Formats); err != nil { + res = append(res, err) + } + + qQ, qhkQ, _ := qs.GetOK("q") + if err := o.bindQ(qQ, qhkQ, route.Formats); err != nil { + res = append(res, err) + } + + qSort, qhkSort, _ := qs.GetOK("sort") + if err := o.bindSort(qSort, qhkSort, route.Formats); err != nil { + res = append(res, err) + } + + qStatus, qhkStatus, _ := qs.GetOK("status") + if err := o.bindStatus(qStatus, qhkStatus, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindXIsResourceName binds and validates parameter XIsResourceName from header. +func (o *ListWebhookJobsParams) bindXIsResourceName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListWebhookJobsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("X-Is-Resource-Name", "header", "bool", raw) + } + o.XIsResourceName = &value + + return nil +} + +// bindXRequestID binds and validates parameter XRequestID from header. +func (o *ListWebhookJobsParams) bindXRequestID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + + o.XRequestID = &raw + + if err := o.validateXRequestID(formats); err != nil { + return err + } + + return nil +} + +// validateXRequestID carries on validations for parameter XRequestID +func (o *ListWebhookJobsParams) validateXRequestID(formats strfmt.Registry) error { + + if err := validate.MinLength("X-Request-Id", "header", (*o.XRequestID), 1); err != nil { + return err + } + + return nil +} + +// bindPage binds and validates parameter Page from query. +func (o *ListWebhookJobsParams) bindPage(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListWebhookJobsParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page", "query", "int64", raw) + } + o.Page = &value + + return nil +} + +// bindPageSize binds and validates parameter PageSize from query. +func (o *ListWebhookJobsParams) bindPageSize(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewListWebhookJobsParams() + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("page_size", "query", "int64", raw) + } + o.PageSize = &value + + if err := o.validatePageSize(formats); err != nil { + return err + } + + return nil +} + +// validatePageSize carries on validations for parameter PageSize +func (o *ListWebhookJobsParams) validatePageSize(formats strfmt.Registry) error { + + if err := validate.MaximumInt("page_size", "query", int64(*o.PageSize), 100, false); err != nil { + return err + } + + return nil +} + +// bindPolicyID binds and validates parameter PolicyID from query. +func (o *ListWebhookJobsParams) bindPolicyID(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("policy_id", "query", rawData) + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // AllowEmptyValue: false + if err := validate.RequiredString("policy_id", "query", raw); err != nil { + return err + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("policy_id", "query", "int64", raw) + } + o.PolicyID = value + + return nil +} + +// bindProjectNameOrID binds and validates parameter ProjectNameOrID from path. +func (o *ListWebhookJobsParams) bindProjectNameOrID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ProjectNameOrID = raw + + return nil +} + +// bindQ binds and validates parameter Q from query. +func (o *ListWebhookJobsParams) bindQ(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Q = &raw + + return nil +} + +// bindSort binds and validates parameter Sort from query. +func (o *ListWebhookJobsParams) bindSort(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + o.Sort = &raw + + return nil +} + +// bindStatus binds and validates array parameter Status from query. +// +// Arrays are parsed according to CollectionFormat: "" (defaults to "csv" when empty). +func (o *ListWebhookJobsParams) bindStatus(rawData []string, hasKey bool, formats strfmt.Registry) error { + + var qvStatus string + if len(rawData) > 0 { + qvStatus = rawData[len(rawData)-1] + } + + // CollectionFormat: + statusIC := swag.SplitByFormat(qvStatus, "") + if len(statusIC) == 0 { + return nil + } + + var statusIR []string + for _, statusIV := range statusIC { + statusI := statusIV + + statusIR = append(statusIR, statusI) + } + + o.Status = statusIR + + return nil +} diff --git a/src/server/v2.0/restapi/operations/webhookjob/list_webhook_jobs_responses.go b/src/server/v2.0/restapi/operations/webhookjob/list_webhook_jobs_responses.go new file mode 100644 index 000000000..07181e2f1 --- /dev/null +++ b/src/server/v2.0/restapi/operations/webhookjob/list_webhook_jobs_responses.go @@ -0,0 +1,370 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package webhookjob + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/swag" + + "github.com/goharbor/harbor/src/server/v2.0/models" +) + +// ListWebhookJobsOKCode is the HTTP code returned for type ListWebhookJobsOK +const ListWebhookJobsOKCode int = 200 + +/*ListWebhookJobsOK List project webhook jobs successfully. + +swagger:response listWebhookJobsOK +*/ +type ListWebhookJobsOK struct { + /*Link to previous page and next page + + */ + Link string `json:"Link"` + /*The total count of available items + + */ + XTotalCount int64 `json:"X-Total-Count"` + + /* + In: Body + */ + Payload []*models.WebhookJob `json:"body,omitempty"` +} + +// NewListWebhookJobsOK creates ListWebhookJobsOK with default headers values +func NewListWebhookJobsOK() *ListWebhookJobsOK { + + return &ListWebhookJobsOK{} +} + +// WithLink adds the link to the list webhook jobs o k response +func (o *ListWebhookJobsOK) WithLink(link string) *ListWebhookJobsOK { + o.Link = link + return o +} + +// SetLink sets the link to the list webhook jobs o k response +func (o *ListWebhookJobsOK) SetLink(link string) { + o.Link = link +} + +// WithXTotalCount adds the xTotalCount to the list webhook jobs o k response +func (o *ListWebhookJobsOK) WithXTotalCount(xTotalCount int64) *ListWebhookJobsOK { + o.XTotalCount = xTotalCount + return o +} + +// SetXTotalCount sets the xTotalCount to the list webhook jobs o k response +func (o *ListWebhookJobsOK) SetXTotalCount(xTotalCount int64) { + o.XTotalCount = xTotalCount +} + +// WithPayload adds the payload to the list webhook jobs o k response +func (o *ListWebhookJobsOK) WithPayload(payload []*models.WebhookJob) *ListWebhookJobsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list webhook jobs o k response +func (o *ListWebhookJobsOK) SetPayload(payload []*models.WebhookJob) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListWebhookJobsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Link + + link := o.Link + if link != "" { + rw.Header().Set("Link", link) + } + + // response header X-Total-Count + + xTotalCount := swag.FormatInt64(o.XTotalCount) + if xTotalCount != "" { + rw.Header().Set("X-Total-Count", xTotalCount) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = make([]*models.WebhookJob, 0, 50) + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ListWebhookJobsBadRequestCode is the HTTP code returned for type ListWebhookJobsBadRequest +const ListWebhookJobsBadRequestCode int = 400 + +/*ListWebhookJobsBadRequest Bad request + +swagger:response listWebhookJobsBadRequest +*/ +type ListWebhookJobsBadRequest struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListWebhookJobsBadRequest creates ListWebhookJobsBadRequest with default headers values +func NewListWebhookJobsBadRequest() *ListWebhookJobsBadRequest { + + return &ListWebhookJobsBadRequest{} +} + +// WithXRequestID adds the xRequestId to the list webhook jobs bad request response +func (o *ListWebhookJobsBadRequest) WithXRequestID(xRequestID string) *ListWebhookJobsBadRequest { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list webhook jobs bad request response +func (o *ListWebhookJobsBadRequest) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list webhook jobs bad request response +func (o *ListWebhookJobsBadRequest) WithPayload(payload *models.Errors) *ListWebhookJobsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list webhook jobs bad request response +func (o *ListWebhookJobsBadRequest) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListWebhookJobsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListWebhookJobsUnauthorizedCode is the HTTP code returned for type ListWebhookJobsUnauthorized +const ListWebhookJobsUnauthorizedCode int = 401 + +/*ListWebhookJobsUnauthorized Unauthorized + +swagger:response listWebhookJobsUnauthorized +*/ +type ListWebhookJobsUnauthorized struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListWebhookJobsUnauthorized creates ListWebhookJobsUnauthorized with default headers values +func NewListWebhookJobsUnauthorized() *ListWebhookJobsUnauthorized { + + return &ListWebhookJobsUnauthorized{} +} + +// WithXRequestID adds the xRequestId to the list webhook jobs unauthorized response +func (o *ListWebhookJobsUnauthorized) WithXRequestID(xRequestID string) *ListWebhookJobsUnauthorized { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list webhook jobs unauthorized response +func (o *ListWebhookJobsUnauthorized) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list webhook jobs unauthorized response +func (o *ListWebhookJobsUnauthorized) WithPayload(payload *models.Errors) *ListWebhookJobsUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list webhook jobs unauthorized response +func (o *ListWebhookJobsUnauthorized) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListWebhookJobsUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListWebhookJobsForbiddenCode is the HTTP code returned for type ListWebhookJobsForbidden +const ListWebhookJobsForbiddenCode int = 403 + +/*ListWebhookJobsForbidden Forbidden + +swagger:response listWebhookJobsForbidden +*/ +type ListWebhookJobsForbidden struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListWebhookJobsForbidden creates ListWebhookJobsForbidden with default headers values +func NewListWebhookJobsForbidden() *ListWebhookJobsForbidden { + + return &ListWebhookJobsForbidden{} +} + +// WithXRequestID adds the xRequestId to the list webhook jobs forbidden response +func (o *ListWebhookJobsForbidden) WithXRequestID(xRequestID string) *ListWebhookJobsForbidden { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list webhook jobs forbidden response +func (o *ListWebhookJobsForbidden) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list webhook jobs forbidden response +func (o *ListWebhookJobsForbidden) WithPayload(payload *models.Errors) *ListWebhookJobsForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list webhook jobs forbidden response +func (o *ListWebhookJobsForbidden) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListWebhookJobsForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListWebhookJobsInternalServerErrorCode is the HTTP code returned for type ListWebhookJobsInternalServerError +const ListWebhookJobsInternalServerErrorCode int = 500 + +/*ListWebhookJobsInternalServerError Internal server error + +swagger:response listWebhookJobsInternalServerError +*/ +type ListWebhookJobsInternalServerError struct { + /*The ID of the corresponding request for the response + + */ + XRequestID string `json:"X-Request-Id"` + + /* + In: Body + */ + Payload *models.Errors `json:"body,omitempty"` +} + +// NewListWebhookJobsInternalServerError creates ListWebhookJobsInternalServerError with default headers values +func NewListWebhookJobsInternalServerError() *ListWebhookJobsInternalServerError { + + return &ListWebhookJobsInternalServerError{} +} + +// WithXRequestID adds the xRequestId to the list webhook jobs internal server error response +func (o *ListWebhookJobsInternalServerError) WithXRequestID(xRequestID string) *ListWebhookJobsInternalServerError { + o.XRequestID = xRequestID + return o +} + +// SetXRequestID sets the xRequestId to the list webhook jobs internal server error response +func (o *ListWebhookJobsInternalServerError) SetXRequestID(xRequestID string) { + o.XRequestID = xRequestID +} + +// WithPayload adds the payload to the list webhook jobs internal server error response +func (o *ListWebhookJobsInternalServerError) WithPayload(payload *models.Errors) *ListWebhookJobsInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list webhook jobs internal server error response +func (o *ListWebhookJobsInternalServerError) SetPayload(payload *models.Errors) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListWebhookJobsInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header X-Request-Id + + xRequestID := o.XRequestID + if xRequestID != "" { + rw.Header().Set("X-Request-Id", xRequestID) + } + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/src/server/v2.0/restapi/operations/webhookjob/list_webhook_jobs_urlbuilder.go b/src/server/v2.0/restapi/operations/webhookjob/list_webhook_jobs_urlbuilder.go new file mode 100644 index 000000000..453c54ee4 --- /dev/null +++ b/src/server/v2.0/restapi/operations/webhookjob/list_webhook_jobs_urlbuilder.go @@ -0,0 +1,166 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package webhookjob + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ListWebhookJobsURL generates an URL for the list webhook jobs operation +type ListWebhookJobsURL struct { + ProjectNameOrID string + + Page *int64 + PageSize *int64 + PolicyID int64 + Q *string + Sort *string + Status []string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListWebhookJobsURL) WithBasePath(bp string) *ListWebhookJobsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListWebhookJobsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ListWebhookJobsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/projects/{project_name_or_id}/webhook/jobs" + + projectNameOrID := o.ProjectNameOrID + if projectNameOrID != "" { + _path = strings.Replace(_path, "{project_name_or_id}", projectNameOrID, -1) + } else { + return nil, errors.New("projectNameOrId is required on ListWebhookJobsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v2.0" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var pageQ string + if o.Page != nil { + pageQ = swag.FormatInt64(*o.Page) + } + if pageQ != "" { + qs.Set("page", pageQ) + } + + var pageSizeQ string + if o.PageSize != nil { + pageSizeQ = swag.FormatInt64(*o.PageSize) + } + if pageSizeQ != "" { + qs.Set("page_size", pageSizeQ) + } + + policyIDQ := swag.FormatInt64(o.PolicyID) + if policyIDQ != "" { + qs.Set("policy_id", policyIDQ) + } + + var qQ string + if o.Q != nil { + qQ = *o.Q + } + if qQ != "" { + qs.Set("q", qQ) + } + + var sortQ string + if o.Sort != nil { + sortQ = *o.Sort + } + if sortQ != "" { + qs.Set("sort", sortQ) + } + + var statusIR []string + for _, statusI := range o.Status { + statusIS := statusI + if statusIS != "" { + statusIR = append(statusIR, statusIS) + } + } + + status := swag.JoinByFormat(statusIR, "") + + if len(status) > 0 { + qsv := status[0] + if qsv != "" { + qs.Set("status", qsv) + } + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ListWebhookJobsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ListWebhookJobsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ListWebhookJobsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ListWebhookJobsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ListWebhookJobsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ListWebhookJobsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/src/server/v2.0/restapi/server.go b/src/server/v2.0/restapi/server.go new file mode 100644 index 000000000..77b66a099 --- /dev/null +++ b/src/server/v2.0/restapi/server.go @@ -0,0 +1,5 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package restapi + +// this file is intentionally empty. Otherwise go-swagger will generate a server which we don't want -- 2.39.2 (Apple Git-143)