├── .gitignore ├── .rubocop.yml ├── CONTRIBUTORS ├── Dockerfile ├── Gemfile ├── Gemfile.lock ├── LICENSE ├── README.md ├── SECURITY.md ├── _VERSION ├── app ├── action_notification_export_api.rb ├── action_notification_export_result_api.rb ├── api_key_api.rb ├── api_request_log_api.rb ├── app_api.rb ├── as2_incoming_message_api.rb ├── as2_outgoing_message_api.rb ├── as2_partner_api.rb ├── as2_station_api.rb ├── automation_api.rb ├── automation_log_api.rb ├── automation_run_api.rb ├── bandwidth_snapshot_api.rb ├── behavior_api.rb ├── bundle_action_api.rb ├── bundle_api.rb ├── bundle_download_api.rb ├── bundle_notification_api.rb ├── bundle_recipient_api.rb ├── bundle_registration_api.rb ├── clickwrap_api.rb ├── dns_record_api.rb ├── email_incoming_message_api.rb ├── email_log_api.rb ├── exavault_api_request_log_api.rb ├── external_event_api.rb ├── file_api.rb ├── file_comment_api.rb ├── file_comment_reaction_api.rb ├── file_migration_api.rb ├── file_migration_log_api.rb ├── folder_api.rb ├── form_field_set_api.rb ├── ftp_action_log_api.rb ├── gpg_key_api.rb ├── group_api.rb ├── group_user_api.rb ├── history_api.rb ├── history_export_api.rb ├── history_export_result_api.rb ├── inbox_recipient_api.rb ├── inbox_registration_api.rb ├── inbox_upload_api.rb ├── invoice_api.rb ├── ip_address_api.rb ├── lock_api.rb ├── message_api.rb ├── message_comment_api.rb ├── message_comment_reaction_api.rb ├── message_reaction_api.rb ├── notification_api.rb ├── outbound_connection_log_api.rb ├── payment_api.rb ├── permission_api.rb ├── priority_api.rb ├── project_api.rb ├── public_hosting_request_log_api.rb ├── public_key_api.rb ├── remote_bandwidth_snapshot_api.rb ├── remote_server_api.rb ├── request_api.rb ├── restore_api.rb ├── session_api.rb ├── settings_change_api.rb ├── sftp_action_log_api.rb ├── sftp_host_key_api.rb ├── share_group_api.rb ├── siem_http_destination_api.rb ├── site_api.rb ├── snapshot_api.rb ├── sso_strategy_api.rb ├── style_api.rb ├── sync_log_api.rb ├── usage_daily_snapshot_api.rb ├── usage_snapshot_api.rb ├── user_api.rb ├── user_cipher_use_api.rb ├── user_lifecycle_rule_api.rb ├── user_request_api.rb ├── user_sftp_client_use_api.rb ├── web_dav_action_log_api.rb └── webhook_test_api.rb ├── build.sh ├── config.ru ├── config └── puma.rb ├── files-mock-server.rb ├── files.com-mock-server.gemspec ├── lib ├── base64_upload.rb └── grape_extensions.rb └── shared ├── header_test_data.json ├── normalization_for_comparison_test_data.json └── url_test_data.json /.gitignore: -------------------------------------------------------------------------------- 1 | setup.sh 2 | -------------------------------------------------------------------------------- /.rubocop.yml: -------------------------------------------------------------------------------- 1 | AllCops: 2 | TargetRubyVersion: 3.2 3 | NewCops: enable 4 | 5 | Layout/ArgumentAlignment: 6 | Enabled: false 7 | 8 | Layout/CaseIndentation: 9 | EnforcedStyle: end 10 | 11 | Layout/HashAlignment: 12 | Enabled: false 13 | 14 | Layout/FirstArrayElementIndentation: 15 | Enabled: false 16 | 17 | Layout/LeadingCommentSpace: 18 | Enabled: false 19 | 20 | Layout/LineLength: 21 | Enabled: false 22 | 23 | Layout/MultilineMethodCallBraceLayout: 24 | EnforcedStyle: new_line 25 | 26 | Layout/RescueEnsureAlignment: 27 | Enabled: false 28 | 29 | Layout/SpaceInsideArrayLiteralBrackets: 30 | EnforcedStyle: space 31 | 32 | Lint/AmbiguousRegexpLiteral: 33 | Enabled: false 34 | 35 | Lint/AmbiguousOperator: 36 | Enabled: false 37 | 38 | Lint/AssignmentInCondition: 39 | Enabled: false 40 | 41 | Lint/FormatParameterMismatch: 42 | Enabled: false 43 | 44 | Lint/IneffectiveAccessModifier: 45 | Enabled: false 46 | 47 | Lint/UriEscapeUnescape: 48 | Enabled: false 49 | 50 | Metrics/AbcSize: 51 | Enabled: false 52 | 53 | Metrics/BlockLength: 54 | Enabled: false 55 | 56 | Metrics/ClassLength: 57 | Enabled: false 58 | 59 | Metrics/CyclomaticComplexity: 60 | Enabled: false 61 | Metrics/MethodLength: 62 | Enabled: false 63 | 64 | Metrics/ModuleLength: 65 | Enabled: false 66 | 67 | Metrics/ParameterLists: 68 | Enabled: false 69 | 70 | Metrics/PerceivedComplexity: 71 | Enabled: false 72 | 73 | Naming/HeredocDelimiterCase: 74 | EnforcedStyle: lowercase 75 | 76 | Naming/MethodParameterName: 77 | Enabled: false 78 | 79 | Naming/PredicateName: 80 | Enabled: false 81 | 82 | Security/YAMLLoad: 83 | Enabled: false 84 | 85 | Style/AccessModifierDeclarations: 86 | Enabled: false 87 | 88 | Style/AndOr: 89 | Enabled: false 90 | 91 | Style/BlockDelimiters: 92 | Enabled: false 93 | 94 | Style/ClassAndModuleChildren: 95 | Enabled: false 96 | 97 | Style/ClassVars: 98 | Enabled: false 99 | 100 | Style/ConditionalAssignment: 101 | Enabled: false 102 | 103 | Style/Documentation: 104 | Enabled: false 105 | 106 | Style/DoubleNegation: 107 | Enabled: false 108 | 109 | Style/FormatString: 110 | Enabled: false 111 | 112 | Style/FormatStringToken: 113 | Enabled: false 114 | 115 | Style/FrozenStringLiteralComment: 116 | Enabled: false 117 | 118 | Style/GlobalVars: 119 | Enabled: false 120 | 121 | Style/GuardClause: 122 | Enabled: false 123 | 124 | Style/MultilineBlockChain: 125 | Enabled: false 126 | 127 | Style/NumericLiterals: 128 | MinDigits: 7 129 | 130 | Style/NumericPredicate: 131 | Enabled: false 132 | 133 | Style/ParallelAssignment: 134 | Enabled: false 135 | 136 | Style/PercentLiteralDelimiters: 137 | Enabled: false 138 | 139 | Style/PerlBackrefs: 140 | Enabled: false 141 | 142 | Style/RaiseArgs: 143 | Enabled: false 144 | 145 | Style/RegexpLiteral: 146 | AllowInnerSlashes: true 147 | 148 | Style/StringLiterals: 149 | Enabled: false 150 | 151 | Style/StringLiteralsInInterpolation: 152 | Enabled: false 153 | 154 | Style/SymbolArray: 155 | Enabled: false 156 | 157 | Style/TrailingCommaInArguments: 158 | Enabled: false 159 | 160 | Style/TrailingCommaInHashLiteral: 161 | Enabled: false 162 | 163 | Style/WordArray: 164 | Enabled: false 165 | 166 | # Added for option var_number 167 | Naming/VariableNumber: 168 | Enabled: false -------------------------------------------------------------------------------- /CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | Daniel Cowgill 2 | Dustin Zeisler 3 | Jesse Harris 4 | Kevin Bombino 5 | Kevin Killingsworth 6 | Martyn Garcia 7 | Rommel Santor 8 | Sam Harrison 9 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ruby:3.2.2 2 | MAINTAINER Action Verb, LLC "https://github.com/Files-com" 3 | 4 | ADD . /files-mock-server 5 | RUN gem update --system \ 6 | && cd files-mock-server \ 7 | && bundle install 8 | 9 | EXPOSE 4041 10 | WORKDIR files-mock-server 11 | ENTRYPOINT ["bundle", "exec", "puma"] 12 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem 'activesupport' 4 | gem 'grape', '1.8.0' 5 | gem 'puma' 6 | gem 'puma-daemon', require: false 7 | gem 'rubocop' 8 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | activesupport (7.1.2) 5 | base64 6 | bigdecimal 7 | concurrent-ruby (~> 1.0, >= 1.0.2) 8 | connection_pool (>= 2.2.5) 9 | drb 10 | i18n (>= 1.6, < 2) 11 | minitest (>= 5.1) 12 | mutex_m 13 | tzinfo (~> 2.0) 14 | ast (2.4.2) 15 | base64 (0.2.0) 16 | bigdecimal (3.1.4) 17 | builder (3.2.4) 18 | concurrent-ruby (1.2.2) 19 | connection_pool (2.4.1) 20 | drb (2.2.0) 21 | ruby2_keywords 22 | dry-core (1.0.1) 23 | concurrent-ruby (~> 1.0) 24 | zeitwerk (~> 2.6) 25 | dry-inflector (1.0.0) 26 | dry-logic (1.5.0) 27 | concurrent-ruby (~> 1.0) 28 | dry-core (~> 1.0, < 2) 29 | zeitwerk (~> 2.6) 30 | dry-types (1.7.1) 31 | concurrent-ruby (~> 1.0) 32 | dry-core (~> 1.0) 33 | dry-inflector (~> 1.0) 34 | dry-logic (~> 1.4) 35 | zeitwerk (~> 2.6) 36 | grape (1.8.0) 37 | activesupport (>= 5) 38 | builder 39 | dry-types (>= 1.1) 40 | mustermann-grape (~> 1.0.0) 41 | rack (>= 1.3.0) 42 | rack-accept 43 | i18n (1.14.1) 44 | concurrent-ruby (~> 1.0) 45 | json (2.6.3) 46 | language_server-protocol (3.17.0.3) 47 | minitest (5.20.0) 48 | mustermann (3.0.0) 49 | ruby2_keywords (~> 0.0.1) 50 | mustermann-grape (1.0.2) 51 | mustermann (>= 1.0.0) 52 | mutex_m (0.2.0) 53 | nio4r (2.7.0) 54 | parallel (1.23.0) 55 | parser (3.2.2.4) 56 | ast (~> 2.4.1) 57 | racc 58 | puma (6.4.2) 59 | nio4r (~> 2.0) 60 | puma-daemon (0.3.2) 61 | puma (>= 5.0) 62 | rack 63 | racc (1.7.3) 64 | rack (3.0.8) 65 | rack-accept (0.4.5) 66 | rack (>= 0.4) 67 | rainbow (3.1.1) 68 | regexp_parser (2.8.2) 69 | rexml (3.2.6) 70 | rubocop (1.57.2) 71 | json (~> 2.3) 72 | language_server-protocol (>= 3.17.0) 73 | parallel (~> 1.10) 74 | parser (>= 3.2.2.4) 75 | rainbow (>= 2.2.2, < 4.0) 76 | regexp_parser (>= 1.8, < 3.0) 77 | rexml (>= 3.2.5, < 4.0) 78 | rubocop-ast (>= 1.28.1, < 2.0) 79 | ruby-progressbar (~> 1.7) 80 | unicode-display_width (>= 2.4.0, < 3.0) 81 | rubocop-ast (1.30.0) 82 | parser (>= 3.2.1.0) 83 | ruby-progressbar (1.13.0) 84 | ruby2_keywords (0.0.5) 85 | tzinfo (2.0.6) 86 | concurrent-ruby (~> 1.0) 87 | unicode-display_width (2.5.0) 88 | zeitwerk (2.6.12) 89 | 90 | PLATFORMS 91 | ruby 92 | 93 | DEPENDENCIES 94 | activesupport 95 | grape (= 1.8.0) 96 | puma 97 | puma-daemon 98 | rubocop 99 | 100 | BUNDLED WITH 101 | 2.4.21 102 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2019- Action Verb, LLC (https://www.files.com) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Files.com Mock API Server (in Ruby) 2 | 3 | This serves a mock Files.com API server, which is useful for testing 4 | things like the Files.com SDKs and other direct integrations 5 | against the Files.com API. 6 | 7 | It is built as a simple Grape app with generated definitions for each 8 | API endpoint. 9 | 10 | This is meant as a minimal server for the purpose of testing basic 11 | network operations and JSON encoding for your SDK or API client. It 12 | does not maintain state and it does not deeply inspect your submissions 13 | for correctness. 14 | 15 | Eventually we will add features intended for integration testing, such as 16 | the ability to intentionally provoke errors. 17 | 18 | ## Requirements 19 | 20 | * Ruby 3+ 21 | 22 | ## Local Ruby Usage 23 | 24 | ```bash 25 | bundle install 26 | bundle exec puma 27 | ``` 28 | 29 | ## Docker Image Usage 30 | 31 | We also supply a docker image for easier accessibility. First install docker; then, execute the following: 32 | 33 | ```bash 34 | docker run -p 40410:4041 -it filescom/files-mock-server:latest 35 | ``` 36 | 37 | The image will be pulled from docker-hub, and the mock server can be accessed via the open port bound on the host machine. 38 | 39 | Example: 40 | 41 | ```bash 42 | curl 127.0.0.1:40410/api/rest/v1/users 43 | ``` 44 | 45 | ## Getting Support 46 | 47 | The Files.com team is happy to help with any issues you may have running the Files.com mock server. 48 | 49 | Just email and we'll get the process started. 50 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | Thank you for your interest in Files.com security. We recognize that your data is very personal and sensitive and we work hard to keep it protected. 4 | 5 | 6 | ## Supported Versions 7 | 8 | Only the latest version will be supported with security updates. 9 | 10 | 11 | ## Reporting a Vulnerability 12 | 13 | Here at Files.com, we celebrate security and we encourage independent security researchers to help us keep our products secure. 14 | 15 | We offer a Security Bug Bounty Program to create an incentive and reward structure so that researchers are able to devote resources to working on Files.com. 16 | 17 | We offer our Bug Bounty Program on HackerOne at https://hackerone.com/files 18 | 19 | We prefer to receive reports of vulnerabilities there. 20 | 21 | If you do not wish to use HackerOne, alternate submission instructions are available at: 22 | https://www.files.com/legal/security-bounty/ 23 | 24 | Thank you for helping keep the Files.com community secure! 25 | -------------------------------------------------------------------------------- /_VERSION: -------------------------------------------------------------------------------- 1 | 1.0.437 2 | -------------------------------------------------------------------------------- /app/action_notification_export_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class ActionNotificationExportAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | requires :id, type: Integer 7 | end 8 | get "/api/rest/v1/action_notification_exports/:id" do 9 | status 200 10 | { "id" => 1, "export_version" => "20201213.2", "start_at" => "2000-01-01T01:00:00Z", "end_at" => "2000-01-01T01:00:00Z", "status" => "ready", "query_path" => "MyFile.txt", "query_folder" => "MyFolder", "query_message" => "Connection Refused", "query_request_method" => "GET", "query_request_url" => "http://example.com/webhook", "query_status" => "200", "query_success" => true, "results_url" => "https://files.com/action_notification_results.csv" } 11 | end 12 | 13 | params do 14 | optional :user_id, type: Integer 15 | optional :start_at, type: String 16 | optional :end_at, type: String 17 | optional :query_message, type: String 18 | optional :query_request_method, type: String 19 | optional :query_request_url, type: String 20 | optional :query_status, type: String 21 | optional :query_success, type: Boolean 22 | optional :query_path, type: String 23 | optional :query_folder, type: String 24 | end 25 | post "/api/rest/v1/action_notification_exports" do 26 | status 201 27 | { "id" => 1, "export_version" => "20201213.2", "start_at" => "2000-01-01T01:00:00Z", "end_at" => "2000-01-01T01:00:00Z", "status" => "ready", "query_path" => "MyFile.txt", "query_folder" => "MyFolder", "query_message" => "Connection Refused", "query_request_method" => "GET", "query_request_url" => "http://example.com/webhook", "query_status" => "200", "query_success" => true, "results_url" => "https://files.com/action_notification_results.csv" } 28 | end 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /app/action_notification_export_result_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class ActionNotificationExportResultAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :user_id, type: Integer 7 | optional :cursor, type: String 8 | optional :per_page, type: Integer 9 | requires :action_notification_export_id, type: Integer 10 | end 11 | get "/api/rest/v1/action_notification_export_results" do 12 | status 200 13 | [ { "id" => 1, "created_at" => 1, "status" => 200, "message" => "Success", "success" => true, "request_headers" => "{\"User-Agent\":\"Files.com Webhook\"}", "request_method" => "GET", "request_url" => "www.example.com/webhook_receiver", "path" => "MyFolder/MyFile.txt", "folder" => "MyFolder" } ] 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /app/api_key_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class ApiKeyAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :user_id, type: Integer 7 | optional :cursor, type: String 8 | optional :per_page, type: Integer 9 | optional :sort_by, type: Hash 10 | optional :filter, type: Hash 11 | optional :filter_gt, type: Hash 12 | optional :filter_gteq, type: Hash 13 | optional :filter_lt, type: Hash 14 | optional :filter_lteq, type: Hash 15 | end 16 | get "/api/rest/v1/api_keys" do 17 | status 200 18 | [ { "id" => 1, "descriptive_label" => "Site-wide API key for https://site.files.com/ (key ID #1)", "description" => "example", "created_at" => "2000-01-01T01:00:00Z", "expires_at" => "2000-01-01T01:00:00Z", "key" => "[key]", "last_use_at" => "2000-01-01T01:00:00Z", "name" => "My Main API Key", "permission_set" => "full", "platform" => "win32", "url" => "example", "user_id" => 1 } ] 19 | end 20 | 21 | get "/api/rest/v1/api_key" do 22 | status 200 23 | { "id" => 1, "descriptive_label" => "Site-wide API key for https://site.files.com/ (key ID #1)", "description" => "example", "created_at" => "2000-01-01T01:00:00Z", "expires_at" => "2000-01-01T01:00:00Z", "key" => "[key]", "last_use_at" => "2000-01-01T01:00:00Z", "name" => "My Main API Key", "permission_set" => "full", "platform" => "win32", "url" => "example", "user_id" => 1 } 24 | end 25 | 26 | params do 27 | requires :id, type: Integer 28 | end 29 | get "/api/rest/v1/api_keys/:id" do 30 | status 200 31 | { "id" => 1, "descriptive_label" => "Site-wide API key for https://site.files.com/ (key ID #1)", "description" => "example", "created_at" => "2000-01-01T01:00:00Z", "expires_at" => "2000-01-01T01:00:00Z", "key" => "[key]", "last_use_at" => "2000-01-01T01:00:00Z", "name" => "My Main API Key", "permission_set" => "full", "platform" => "win32", "url" => "example", "user_id" => 1 } 32 | end 33 | 34 | params do 35 | optional :user_id, type: Integer 36 | optional :description, type: String 37 | optional :expires_at, type: String 38 | optional :permission_set, type: String 39 | requires :name, type: String 40 | optional :path, type: String 41 | end 42 | post "/api/rest/v1/api_keys" do 43 | status 201 44 | { "id" => 1, "descriptive_label" => "Site-wide API key for https://site.files.com/ (key ID #1)", "description" => "example", "created_at" => "2000-01-01T01:00:00Z", "expires_at" => "2000-01-01T01:00:00Z", "key" => "[key]", "last_use_at" => "2000-01-01T01:00:00Z", "name" => "My Main API Key", "permission_set" => "full", "platform" => "win32", "url" => "example", "user_id" => 1 } 45 | end 46 | 47 | params do 48 | optional :expires_at, type: String 49 | optional :name, type: String 50 | optional :permission_set, type: String 51 | end 52 | patch "/api/rest/v1/api_key" do 53 | status 200 54 | { "id" => 1, "descriptive_label" => "Site-wide API key for https://site.files.com/ (key ID #1)", "description" => "example", "created_at" => "2000-01-01T01:00:00Z", "expires_at" => "2000-01-01T01:00:00Z", "key" => "[key]", "last_use_at" => "2000-01-01T01:00:00Z", "name" => "My Main API Key", "permission_set" => "full", "platform" => "win32", "url" => "example", "user_id" => 1 } 55 | end 56 | 57 | params do 58 | requires :id, type: Integer 59 | optional :description, type: String 60 | optional :expires_at, type: String 61 | optional :permission_set, type: String 62 | optional :name, type: String 63 | end 64 | patch "/api/rest/v1/api_keys/:id" do 65 | status 200 66 | { "id" => 1, "descriptive_label" => "Site-wide API key for https://site.files.com/ (key ID #1)", "description" => "example", "created_at" => "2000-01-01T01:00:00Z", "expires_at" => "2000-01-01T01:00:00Z", "key" => "[key]", "last_use_at" => "2000-01-01T01:00:00Z", "name" => "My Main API Key", "permission_set" => "full", "platform" => "win32", "url" => "example", "user_id" => 1 } 67 | end 68 | 69 | delete "/api/rest/v1/api_key" do 70 | status 204 71 | body false 72 | end 73 | 74 | params do 75 | requires :id, type: Integer 76 | end 77 | delete "/api/rest/v1/api_keys/:id" do 78 | status 204 79 | body false 80 | end 81 | end 82 | end 83 | -------------------------------------------------------------------------------- /app/api_request_log_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class ApiRequestLogAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :cursor, type: String 7 | optional :per_page, type: Integer 8 | optional :filter, type: Hash 9 | optional :filter_prefix, type: Hash 10 | end 11 | get "/api/rest/v1/api_request_logs" do 12 | status 200 13 | [ { "timestamp" => "2000-01-01T01:00:00Z", "api_key_id" => 1, "api_key_prefix" => "example", "user_id" => 1, "username" => "example", "user_is_from_parent_site" => true, "interface" => "example", "request_method" => "example", "request_path" => "example", "request_ip" => "example", "request_host" => "example", "request_id" => "example", "api_name" => "example", "user_agent" => "example", "error_type" => "example", "error_message" => "example", "response_code" => 1, "success" => true, "duration_ms" => 1, "impersonator_user_id" => 1 } ] 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /app/app_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class AppAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :cursor, type: String 7 | optional :per_page, type: Integer 8 | optional :sort_by, type: Hash 9 | optional :filter, type: Hash 10 | optional :filter_prefix, type: Hash 11 | end 12 | get "/api/rest/v1/apps" do 13 | status 200 14 | [ { "app_type" => "example", "documentation_links" => { "Important Info" => "http://files.test/learn-more" }, "extended_description" => "example", "extended_description_for_marketing_site" => "example", "external_homepage_url" => "example", "featured" => true, "folder_behavior_type" => "example", "icon_url" => "example", "logo_thumbnail_url" => "example", "logo_url" => "example", "marketing_intro" => "example", "marketing_youtube_url" => "example", "name" => "example", "package_manager_install_command" => "example", "remote_server_type" => "example", "screenshot_list_urls" => [ "example" ], "sdk_installation_instructions_link" => "example", "short_description" => "example", "sso_strategy_type" => "example", "siem_type" => "example", "tutorial_youtube_url" => "example" } ] 15 | end 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /app/as2_incoming_message_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class As2IncomingMessageAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :cursor, type: String 7 | optional :per_page, type: Integer 8 | optional :sort_by, type: Hash 9 | optional :filter, type: Hash 10 | optional :filter_gt, type: Hash 11 | optional :filter_gteq, type: Hash 12 | optional :filter_lt, type: Hash 13 | optional :filter_lteq, type: Hash 14 | optional :as2_partner_id, type: Integer 15 | end 16 | get "/api/rest/v1/as2_incoming_messages" do 17 | status 200 18 | [ { "id" => 1, "as2_partner_id" => 1, "as2_station_id" => 1, "uuid" => "example", "content_type" => "example", "http_headers" => { "key" => "example value" }, "processing_result" => "example", "processing_result_description" => "example", "mic" => "example", "mic_algo" => "example", "as2_to" => "example", "as2_from" => "example", "message_id" => "example", "subject" => "example", "date" => "example", "body_size" => "example", "attachment_filename" => "example", "ip" => "example", "created_at" => "2000-01-01T01:00:00Z", "http_response_code" => "example", "http_response_headers" => { "key" => "example value" }, "recipient_serial" => "example", "hex_recipient_serial" => "A5:EB:C1:95:DC:D8:2B:E7", "recipient_issuer" => "example", "message_received" => true, "message_decrypted" => true, "message_signature_verified" => true, "message_processing_success" => true, "message_mdn_returned" => true, "encrypted_uri" => "example", "smime_signed_uri" => "example", "smime_uri" => "example", "raw_uri" => "example", "mdn_response_uri" => "example" } ] 19 | end 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /app/as2_outgoing_message_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class As2OutgoingMessageAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :cursor, type: String 7 | optional :per_page, type: Integer 8 | optional :sort_by, type: Hash 9 | optional :filter, type: Hash 10 | optional :filter_gt, type: Hash 11 | optional :filter_gteq, type: Hash 12 | optional :filter_lt, type: Hash 13 | optional :filter_lteq, type: Hash 14 | optional :as2_partner_id, type: Integer 15 | end 16 | get "/api/rest/v1/as2_outgoing_messages" do 17 | status 200 18 | [ { "id" => 1, "as2_partner_id" => 1, "as2_station_id" => 1, "uuid" => "example", "http_headers" => { "key" => "example value" }, "processing_result" => "example", "processing_result_description" => "example", "mic" => "example", "mic_sha_256" => "example", "as2_to" => "example", "as2_from" => "example", "date" => "example", "message_id" => "example", "body_size" => "example", "attachment_filename" => "example", "created_at" => "2000-01-01T01:00:00Z", "http_response_code" => "example", "http_response_headers" => { "key" => "example value" }, "http_transmission_duration" => 1.0, "mdn_received" => true, "mdn_valid" => true, "mdn_signature_verified" => true, "mdn_message_id_matched" => true, "mdn_mic_matched" => true, "mdn_processing_success" => true, "raw_uri" => "example", "smime_uri" => "example", "smime_signed_uri" => "example", "encrypted_uri" => "example", "mdn_response_uri" => "example" } ] 19 | end 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /app/as2_partner_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class As2PartnerAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :cursor, type: String 7 | optional :per_page, type: Integer 8 | end 9 | get "/api/rest/v1/as2_partners" do 10 | status 200 11 | [ { "id" => 1, "as2_station_id" => 1, "name" => "AS2 Partner Name", "uri" => "example", "server_certificate" => "require_match", "http_auth_username" => "username", "additional_http_headers" => { "key" => "example value" }, "default_mime_type" => "application/octet-stream", "mdn_validation_level" => "none", "enable_dedicated_ips" => true, "hex_public_certificate_serial" => "A5:EB:C1:95:DC:D8:2B:E7", "public_certificate_md5" => "example", "public_certificate_subject" => "example", "public_certificate_issuer" => "example", "public_certificate_serial" => "example", "public_certificate_not_before" => "example", "public_certificate_not_after" => "example" } ] 12 | end 13 | 14 | params do 15 | requires :id, type: Integer 16 | end 17 | get "/api/rest/v1/as2_partners/:id" do 18 | status 200 19 | { "id" => 1, "as2_station_id" => 1, "name" => "AS2 Partner Name", "uri" => "example", "server_certificate" => "require_match", "http_auth_username" => "username", "additional_http_headers" => { "key" => "example value" }, "default_mime_type" => "application/octet-stream", "mdn_validation_level" => "none", "enable_dedicated_ips" => true, "hex_public_certificate_serial" => "A5:EB:C1:95:DC:D8:2B:E7", "public_certificate_md5" => "example", "public_certificate_subject" => "example", "public_certificate_issuer" => "example", "public_certificate_serial" => "example", "public_certificate_not_before" => "example", "public_certificate_not_after" => "example" } 20 | end 21 | 22 | params do 23 | optional :enable_dedicated_ips, type: Boolean 24 | optional :http_auth_username, type: String 25 | optional :http_auth_password, type: String 26 | optional :mdn_validation_level, type: String 27 | optional :server_certificate, type: String 28 | optional :default_mime_type, type: String 29 | optional :additional_http_headers, type: Hash 30 | requires :as2_station_id, type: Integer 31 | requires :name, type: String 32 | requires :uri, type: String 33 | requires :public_certificate, type: String 34 | end 35 | post "/api/rest/v1/as2_partners" do 36 | status 201 37 | { "id" => 1, "as2_station_id" => 1, "name" => "AS2 Partner Name", "uri" => "example", "server_certificate" => "require_match", "http_auth_username" => "username", "additional_http_headers" => { "key" => "example value" }, "default_mime_type" => "application/octet-stream", "mdn_validation_level" => "none", "enable_dedicated_ips" => true, "hex_public_certificate_serial" => "A5:EB:C1:95:DC:D8:2B:E7", "public_certificate_md5" => "example", "public_certificate_subject" => "example", "public_certificate_issuer" => "example", "public_certificate_serial" => "example", "public_certificate_not_before" => "example", "public_certificate_not_after" => "example" } 38 | end 39 | 40 | params do 41 | requires :id, type: Integer 42 | optional :enable_dedicated_ips, type: Boolean 43 | optional :http_auth_username, type: String 44 | optional :http_auth_password, type: String 45 | optional :mdn_validation_level, type: String 46 | optional :server_certificate, type: String 47 | optional :default_mime_type, type: String 48 | optional :additional_http_headers, type: Hash 49 | optional :name, type: String 50 | optional :uri, type: String 51 | optional :public_certificate, type: String 52 | end 53 | patch "/api/rest/v1/as2_partners/:id" do 54 | status 200 55 | { "id" => 1, "as2_station_id" => 1, "name" => "AS2 Partner Name", "uri" => "example", "server_certificate" => "require_match", "http_auth_username" => "username", "additional_http_headers" => { "key" => "example value" }, "default_mime_type" => "application/octet-stream", "mdn_validation_level" => "none", "enable_dedicated_ips" => true, "hex_public_certificate_serial" => "A5:EB:C1:95:DC:D8:2B:E7", "public_certificate_md5" => "example", "public_certificate_subject" => "example", "public_certificate_issuer" => "example", "public_certificate_serial" => "example", "public_certificate_not_before" => "example", "public_certificate_not_after" => "example" } 56 | end 57 | 58 | params do 59 | requires :id, type: Integer 60 | end 61 | delete "/api/rest/v1/as2_partners/:id" do 62 | status 204 63 | body false 64 | end 65 | end 66 | end 67 | -------------------------------------------------------------------------------- /app/as2_station_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class As2StationAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :cursor, type: String 7 | optional :per_page, type: Integer 8 | optional :sort_by, type: Hash 9 | end 10 | get "/api/rest/v1/as2_stations" do 11 | status 200 12 | [ { "id" => 1, "name" => "AS2 Station Name", "uri" => "example", "domain" => "domain.test", "hex_public_certificate_serial" => "A5:EB:C1:95:DC:D8:2B:E7", "public_certificate_md5" => "example", "private_key_md5" => "example", "public_certificate_subject" => "example", "public_certificate_issuer" => "example", "public_certificate_serial" => "example", "public_certificate_not_before" => "example", "public_certificate_not_after" => "example", "private_key_password_md5" => "example" } ] 13 | end 14 | 15 | params do 16 | requires :id, type: Integer 17 | end 18 | get "/api/rest/v1/as2_stations/:id" do 19 | status 200 20 | { "id" => 1, "name" => "AS2 Station Name", "uri" => "example", "domain" => "domain.test", "hex_public_certificate_serial" => "A5:EB:C1:95:DC:D8:2B:E7", "public_certificate_md5" => "example", "private_key_md5" => "example", "public_certificate_subject" => "example", "public_certificate_issuer" => "example", "public_certificate_serial" => "example", "public_certificate_not_before" => "example", "public_certificate_not_after" => "example", "private_key_password_md5" => "example" } 21 | end 22 | 23 | params do 24 | requires :name, type: String 25 | requires :public_certificate, type: String 26 | requires :private_key, type: String 27 | optional :private_key_password, type: String 28 | end 29 | post "/api/rest/v1/as2_stations" do 30 | status 201 31 | { "id" => 1, "name" => "AS2 Station Name", "uri" => "example", "domain" => "domain.test", "hex_public_certificate_serial" => "A5:EB:C1:95:DC:D8:2B:E7", "public_certificate_md5" => "example", "private_key_md5" => "example", "public_certificate_subject" => "example", "public_certificate_issuer" => "example", "public_certificate_serial" => "example", "public_certificate_not_before" => "example", "public_certificate_not_after" => "example", "private_key_password_md5" => "example" } 32 | end 33 | 34 | params do 35 | requires :id, type: Integer 36 | optional :name, type: String 37 | optional :public_certificate, type: String 38 | optional :private_key, type: String 39 | optional :private_key_password, type: String 40 | end 41 | patch "/api/rest/v1/as2_stations/:id" do 42 | status 200 43 | { "id" => 1, "name" => "AS2 Station Name", "uri" => "example", "domain" => "domain.test", "hex_public_certificate_serial" => "A5:EB:C1:95:DC:D8:2B:E7", "public_certificate_md5" => "example", "private_key_md5" => "example", "public_certificate_subject" => "example", "public_certificate_issuer" => "example", "public_certificate_serial" => "example", "public_certificate_not_before" => "example", "public_certificate_not_after" => "example", "private_key_password_md5" => "example" } 44 | end 45 | 46 | params do 47 | requires :id, type: Integer 48 | end 49 | delete "/api/rest/v1/as2_stations/:id" do 50 | status 204 51 | body false 52 | end 53 | end 54 | end 55 | -------------------------------------------------------------------------------- /app/automation_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class AutomationAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :cursor, type: String 7 | optional :per_page, type: Integer 8 | optional :sort_by, type: Hash 9 | optional :filter, type: Hash 10 | optional :filter_gt, type: Hash 11 | optional :filter_gteq, type: Hash 12 | optional :filter_lt, type: Hash 13 | optional :filter_lteq, type: Hash 14 | end 15 | get "/api/rest/v1/automations" do 16 | status 200 17 | [ { "id" => 1, "always_serialize_jobs" => true, "always_overwrite_size_matching_files" => true, "automation" => "create_folder", "deleted" => true, "description" => "example", "destination_replace_from" => "example", "destination_replace_to" => "example", "destinations" => [ "destination" ], "disabled" => true, "exclude_pattern" => "path/to/exclude/*", "import_urls" => [ { "name" => "users.json", "url" => "http://example.com/users", "method" => "POST", "headers" => { "Content-Type" => "application/json" }, "content" => { "group" => "support" } } ], "flatten_destination_structure" => true, "group_ids" => [ 1, 2 ], "ignore_locked_folders" => true, "interval" => "week", "last_modified_at" => "2000-01-01T01:00:00Z", "legacy_folder_matching" => true, "name" => "example", "overwrite_files" => true, "path" => "example", "path_time_zone" => "Eastern Time (US & Canada)", "recurring_day" => 25, "retry_on_failure_interval_in_minutes" => 60, "retry_on_failure_number_of_attempts" => 10, "schedule" => { "days_of_week" => [ 0, 2, 4 ], "times_of_day" => [ "06:30", "14:30" ], "time_zone" => "Eastern Time (US & Canada)" }, "human_readable_schedule" => "Triggered every Monday, Wednesday at 6:30 AM,\n 2:30 PM Eastern Time (US & Canada) TZ", "schedule_days_of_week" => [ 0, 2, 4 ], "schedule_times_of_day" => [ "06:30", "14:30" ], "schedule_time_zone" => "Eastern Time (US & Canada)", "source" => "example", "sync_ids" => [ 1, 2 ], "trigger_actions" => [ "create" ], "trigger" => "daily", "user_id" => 1, "user_ids" => [ 1, 2 ], "value" => { "limit" => "1" }, "webhook_url" => "https://app.files.com/api/webhooks/abc123" } ] 18 | end 19 | 20 | params do 21 | requires :id, type: Integer 22 | end 23 | get "/api/rest/v1/automations/:id" do 24 | status 200 25 | { "id" => 1, "always_serialize_jobs" => true, "always_overwrite_size_matching_files" => true, "automation" => "create_folder", "deleted" => true, "description" => "example", "destination_replace_from" => "example", "destination_replace_to" => "example", "destinations" => [ "destination" ], "disabled" => true, "exclude_pattern" => "path/to/exclude/*", "import_urls" => [ { "name" => "users.json", "url" => "http://example.com/users", "method" => "POST", "headers" => { "Content-Type" => "application/json" }, "content" => { "group" => "support" } } ], "flatten_destination_structure" => true, "group_ids" => [ 1, 2 ], "ignore_locked_folders" => true, "interval" => "week", "last_modified_at" => "2000-01-01T01:00:00Z", "legacy_folder_matching" => true, "name" => "example", "overwrite_files" => true, "path" => "example", "path_time_zone" => "Eastern Time (US & Canada)", "recurring_day" => 25, "retry_on_failure_interval_in_minutes" => 60, "retry_on_failure_number_of_attempts" => 10, "schedule" => { "days_of_week" => [ 0, 2, 4 ], "times_of_day" => [ "06:30", "14:30" ], "time_zone" => "Eastern Time (US & Canada)" }, "human_readable_schedule" => "Triggered every Monday, Wednesday at 6:30 AM,\n 2:30 PM Eastern Time (US & Canada) TZ", "schedule_days_of_week" => [ 0, 2, 4 ], "schedule_times_of_day" => [ "06:30", "14:30" ], "schedule_time_zone" => "Eastern Time (US & Canada)", "source" => "example", "sync_ids" => [ 1, 2 ], "trigger_actions" => [ "create" ], "trigger" => "daily", "user_id" => 1, "user_ids" => [ 1, 2 ], "value" => { "limit" => "1" }, "webhook_url" => "https://app.files.com/api/webhooks/abc123" } 26 | end 27 | 28 | params do 29 | optional :source, type: String 30 | optional :destinations, type: [ String ] 31 | optional :destination_replace_from, type: String 32 | optional :destination_replace_to, type: String 33 | optional :interval, type: String 34 | optional :path, type: String 35 | optional :sync_ids, type: String 36 | optional :user_ids, type: String 37 | optional :group_ids, type: String 38 | optional :schedule_days_of_week, type: [ Integer ] 39 | optional :schedule_times_of_day, type: [ String ] 40 | optional :schedule_time_zone, type: String 41 | optional :always_overwrite_size_matching_files, type: Boolean 42 | optional :always_serialize_jobs, type: Boolean 43 | optional :description, type: String 44 | optional :disabled, type: Boolean 45 | optional :exclude_pattern, type: String 46 | optional :import_urls, type: [ Hash ] 47 | optional :flatten_destination_structure, type: Boolean 48 | optional :ignore_locked_folders, type: Boolean 49 | optional :legacy_folder_matching, type: Boolean 50 | optional :name, type: String 51 | optional :overwrite_files, type: Boolean 52 | optional :path_time_zone, type: String 53 | optional :retry_on_failure_interval_in_minutes, type: Integer 54 | optional :retry_on_failure_number_of_attempts, type: Integer 55 | optional :trigger, type: String 56 | optional :trigger_actions, type: [ String ] 57 | optional :value, type: Hash 58 | optional :recurring_day, type: Integer 59 | requires :automation, type: String 60 | end 61 | post "/api/rest/v1/automations" do 62 | status 201 63 | { "id" => 1, "always_serialize_jobs" => true, "always_overwrite_size_matching_files" => true, "automation" => "create_folder", "deleted" => true, "description" => "example", "destination_replace_from" => "example", "destination_replace_to" => "example", "destinations" => [ "destination" ], "disabled" => true, "exclude_pattern" => "path/to/exclude/*", "import_urls" => [ { "name" => "users.json", "url" => "http://example.com/users", "method" => "POST", "headers" => { "Content-Type" => "application/json" }, "content" => { "group" => "support" } } ], "flatten_destination_structure" => true, "group_ids" => [ 1, 2 ], "ignore_locked_folders" => true, "interval" => "week", "last_modified_at" => "2000-01-01T01:00:00Z", "legacy_folder_matching" => true, "name" => "example", "overwrite_files" => true, "path" => "example", "path_time_zone" => "Eastern Time (US & Canada)", "recurring_day" => 25, "retry_on_failure_interval_in_minutes" => 60, "retry_on_failure_number_of_attempts" => 10, "schedule" => { "days_of_week" => [ 0, 2, 4 ], "times_of_day" => [ "06:30", "14:30" ], "time_zone" => "Eastern Time (US & Canada)" }, "human_readable_schedule" => "Triggered every Monday, Wednesday at 6:30 AM,\n 2:30 PM Eastern Time (US & Canada) TZ", "schedule_days_of_week" => [ 0, 2, 4 ], "schedule_times_of_day" => [ "06:30", "14:30" ], "schedule_time_zone" => "Eastern Time (US & Canada)", "source" => "example", "sync_ids" => [ 1, 2 ], "trigger_actions" => [ "create" ], "trigger" => "daily", "user_id" => 1, "user_ids" => [ 1, 2 ], "value" => { "limit" => "1" }, "webhook_url" => "https://app.files.com/api/webhooks/abc123" } 64 | end 65 | 66 | params do 67 | requires :id, type: Integer 68 | end 69 | post "/api/rest/v1/automations/:id/manual_run" do 70 | status 204 71 | body false 72 | end 73 | 74 | params do 75 | requires :id, type: Integer 76 | optional :source, type: String 77 | optional :destinations, type: [ String ] 78 | optional :destination_replace_from, type: String 79 | optional :destination_replace_to, type: String 80 | optional :interval, type: String 81 | optional :path, type: String 82 | optional :sync_ids, type: String 83 | optional :user_ids, type: String 84 | optional :group_ids, type: String 85 | optional :schedule_days_of_week, type: [ Integer ] 86 | optional :schedule_times_of_day, type: [ String ] 87 | optional :schedule_time_zone, type: String 88 | optional :always_overwrite_size_matching_files, type: Boolean 89 | optional :always_serialize_jobs, type: Boolean 90 | optional :description, type: String 91 | optional :disabled, type: Boolean 92 | optional :exclude_pattern, type: String 93 | optional :import_urls, type: [ Hash ] 94 | optional :flatten_destination_structure, type: Boolean 95 | optional :ignore_locked_folders, type: Boolean 96 | optional :legacy_folder_matching, type: Boolean 97 | optional :name, type: String 98 | optional :overwrite_files, type: Boolean 99 | optional :path_time_zone, type: String 100 | optional :retry_on_failure_interval_in_minutes, type: Integer 101 | optional :retry_on_failure_number_of_attempts, type: Integer 102 | optional :trigger, type: String 103 | optional :trigger_actions, type: [ String ] 104 | optional :value, type: Hash 105 | optional :recurring_day, type: Integer 106 | optional :automation, type: String 107 | end 108 | patch "/api/rest/v1/automations/:id" do 109 | status 200 110 | { "id" => 1, "always_serialize_jobs" => true, "always_overwrite_size_matching_files" => true, "automation" => "create_folder", "deleted" => true, "description" => "example", "destination_replace_from" => "example", "destination_replace_to" => "example", "destinations" => [ "destination" ], "disabled" => true, "exclude_pattern" => "path/to/exclude/*", "import_urls" => [ { "name" => "users.json", "url" => "http://example.com/users", "method" => "POST", "headers" => { "Content-Type" => "application/json" }, "content" => { "group" => "support" } } ], "flatten_destination_structure" => true, "group_ids" => [ 1, 2 ], "ignore_locked_folders" => true, "interval" => "week", "last_modified_at" => "2000-01-01T01:00:00Z", "legacy_folder_matching" => true, "name" => "example", "overwrite_files" => true, "path" => "example", "path_time_zone" => "Eastern Time (US & Canada)", "recurring_day" => 25, "retry_on_failure_interval_in_minutes" => 60, "retry_on_failure_number_of_attempts" => 10, "schedule" => { "days_of_week" => [ 0, 2, 4 ], "times_of_day" => [ "06:30", "14:30" ], "time_zone" => "Eastern Time (US & Canada)" }, "human_readable_schedule" => "Triggered every Monday, Wednesday at 6:30 AM,\n 2:30 PM Eastern Time (US & Canada) TZ", "schedule_days_of_week" => [ 0, 2, 4 ], "schedule_times_of_day" => [ "06:30", "14:30" ], "schedule_time_zone" => "Eastern Time (US & Canada)", "source" => "example", "sync_ids" => [ 1, 2 ], "trigger_actions" => [ "create" ], "trigger" => "daily", "user_id" => 1, "user_ids" => [ 1, 2 ], "value" => { "limit" => "1" }, "webhook_url" => "https://app.files.com/api/webhooks/abc123" } 111 | end 112 | 113 | params do 114 | requires :id, type: Integer 115 | end 116 | delete "/api/rest/v1/automations/:id" do 117 | status 204 118 | body false 119 | end 120 | end 121 | end 122 | -------------------------------------------------------------------------------- /app/automation_log_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class AutomationLogAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :cursor, type: String 7 | optional :per_page, type: Integer 8 | optional :filter, type: Hash 9 | optional :filter_prefix, type: Hash 10 | end 11 | get "/api/rest/v1/automation_logs" do 12 | status 200 13 | [ { "timestamp" => "2000-01-01T01:00:00Z", "automation_id" => 1, "automation_run_id" => 1, "dest_path" => "example", "error_type" => "example", "message" => "example", "operation" => "example", "path" => "example", "status" => "example" } ] 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /app/automation_run_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class AutomationRunAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :user_id, type: Integer 7 | optional :cursor, type: String 8 | optional :per_page, type: Integer 9 | optional :sort_by, type: Hash 10 | optional :filter, type: Hash 11 | requires :automation_id, type: Integer 12 | end 13 | get "/api/rest/v1/automation_runs" do 14 | status 200 15 | [ { "id" => 1, "automation_id" => 1, "completed_at" => "2000-01-01T01:00:00Z", "created_at" => "2000-01-01T01:00:00Z", "retry_at" => "2000-01-01T01:00:00Z", "retried_at" => "2000-01-01T01:00:00Z", "retried_in_run_id" => 1, "retry_of_run_id" => 1, "runtime" => 1.0, "status" => "success", "successful_operations" => 1, "failed_operations" => 1, "status_messages_url" => "https://www.example.com/log_file.txt" } ] 16 | end 17 | 18 | params do 19 | requires :id, type: Integer 20 | end 21 | get "/api/rest/v1/automation_runs/:id" do 22 | status 200 23 | { "id" => 1, "automation_id" => 1, "completed_at" => "2000-01-01T01:00:00Z", "created_at" => "2000-01-01T01:00:00Z", "retry_at" => "2000-01-01T01:00:00Z", "retried_at" => "2000-01-01T01:00:00Z", "retried_in_run_id" => 1, "retry_of_run_id" => 1, "runtime" => 1.0, "status" => "success", "successful_operations" => 1, "failed_operations" => 1, "status_messages_url" => "https://www.example.com/log_file.txt" } 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /app/bandwidth_snapshot_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class BandwidthSnapshotAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :cursor, type: String 7 | optional :per_page, type: Integer 8 | optional :sort_by, type: Hash 9 | optional :filter, type: Hash 10 | optional :filter_gt, type: Hash 11 | optional :filter_gteq, type: Hash 12 | optional :filter_lt, type: Hash 13 | optional :filter_lteq, type: Hash 14 | end 15 | get "/api/rest/v1/bandwidth_snapshots" do 16 | status 200 17 | [ { "id" => 1, "bytes_received" => 1.0, "bytes_sent" => 1.0, "sync_bytes_received" => 1.0, "sync_bytes_sent" => 1.0, "requests_get" => 1.0, "requests_put" => 1.0, "requests_other" => 1.0, "logged_at" => "2000-01-01T01:00:00Z" } ] 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /app/behavior_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class BehaviorAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :cursor, type: String 7 | optional :per_page, type: Integer 8 | optional :sort_by, type: Hash 9 | optional :filter, type: Hash 10 | optional :filter_prefix, type: Hash 11 | end 12 | get "/api/rest/v1/behaviors" do 13 | status 200 14 | [ { "id" => 1, "path" => "example", "attachment_url" => "example", "behavior" => "webhook", "name" => "example", "description" => "example", "value" => { "method" => "GET" }, "disable_parent_folder_behavior" => true, "recursive" => true } ] 15 | end 16 | 17 | params do 18 | requires :id, type: Integer 19 | end 20 | get "/api/rest/v1/behaviors/:id" do 21 | status 200 22 | { "id" => 1, "path" => "example", "attachment_url" => "example", "behavior" => "webhook", "name" => "example", "description" => "example", "value" => { "method" => "GET" }, "disable_parent_folder_behavior" => true, "recursive" => true } 23 | end 24 | 25 | params do 26 | optional :cursor, type: String 27 | optional :per_page, type: Integer 28 | optional :sort_by, type: Hash 29 | optional :filter, type: Hash 30 | optional :filter_prefix, type: Hash 31 | requires :path, type: String 32 | optional :ancestor_behaviors, type: Boolean 33 | end 34 | get "/api/rest/v1/behaviors/folders/:path" do 35 | status 200 36 | [ { "id" => 1, "path" => "example", "attachment_url" => "example", "behavior" => "webhook", "name" => "example", "description" => "example", "value" => { "method" => "GET" }, "disable_parent_folder_behavior" => true, "recursive" => true } ] 37 | end 38 | 39 | params do 40 | optional :value, type: String 41 | optional :attachment_file, type: File 42 | optional :disable_parent_folder_behavior, type: Boolean 43 | optional :recursive, type: Boolean 44 | optional :name, type: String 45 | optional :description, type: String 46 | requires :path, type: String 47 | requires :behavior, type: String 48 | end 49 | post "/api/rest/v1/behaviors" do 50 | status 201 51 | { "id" => 1, "path" => "example", "attachment_url" => "example", "behavior" => "webhook", "name" => "example", "description" => "example", "value" => { "method" => "GET" }, "disable_parent_folder_behavior" => true, "recursive" => true } 52 | end 53 | 54 | params do 55 | requires :url, type: String 56 | optional :method, type: String 57 | optional :encoding, type: String 58 | optional :headers, type: Hash 59 | optional :body, type: Hash 60 | optional :action, type: String 61 | end 62 | post "/api/rest/v1/behaviors/webhook/test" do 63 | status 200 64 | body false 65 | end 66 | 67 | params do 68 | requires :id, type: [ String, Integer, Hash ] 69 | optional :value, type: String 70 | optional :attachment_file, type: File 71 | optional :disable_parent_folder_behavior, type: Boolean 72 | optional :recursive, type: Boolean 73 | optional :name, type: String 74 | optional :description, type: String 75 | optional :attachment_delete, type: [ String, Integer, Hash ] 76 | end 77 | patch "/api/rest/v1/behaviors/:id" do 78 | status 200 79 | { "id" => 1, "path" => "example", "attachment_url" => "example", "behavior" => "webhook", "name" => "example", "description" => "example", "value" => { "method" => "GET" }, "disable_parent_folder_behavior" => true, "recursive" => true } 80 | end 81 | 82 | params do 83 | requires :id, type: Integer 84 | end 85 | delete "/api/rest/v1/behaviors/:id" do 86 | status 204 87 | body false 88 | end 89 | end 90 | end 91 | -------------------------------------------------------------------------------- /app/bundle_action_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class BundleActionAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :user_id, type: Integer 7 | optional :cursor, type: String 8 | optional :per_page, type: Integer 9 | optional :sort_by, type: Hash 10 | optional :filter, type: Hash 11 | optional :filter_gt, type: Hash 12 | optional :filter_gteq, type: Hash 13 | optional :filter_lt, type: Hash 14 | optional :filter_lteq, type: Hash 15 | end 16 | get "/api/rest/v1/bundle_actions" do 17 | status 200 18 | [ { "action" => "create", "bundle_registration" => { "code" => "abc123", "name" => "account", "company" => "Action Verb", "email" => "john.doe@files.com", "ip" => "10.1.1.1", "inbox_code" => "abc123", "clickwrap_body" => "example", "form_field_set_id" => 1, "form_field_data" => { "key" => "example value" }, "bundle_code" => "example", "bundle_id" => 1, "bundle_recipient_id" => 1, "created_at" => "2000-01-01T01:00:00Z" }, "created_at" => "2000-01-01T01:00:00Z", "destination" => "/to_path", "path" => "", "source" => "/from_path" } ] 19 | end 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /app/bundle_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class BundleAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :user_id, type: Integer 7 | optional :cursor, type: String 8 | optional :per_page, type: Integer 9 | optional :sort_by, type: Hash 10 | optional :filter, type: Hash 11 | optional :filter_gt, type: Hash 12 | optional :filter_gteq, type: Hash 13 | optional :filter_prefix, type: Hash 14 | optional :filter_lt, type: Hash 15 | optional :filter_lteq, type: Hash 16 | end 17 | get "/api/rest/v1/bundles" do 18 | status 200 19 | [ { "code" => "abc123", "color_left" => "#0066a7", "color_link" => "#d34f5d", "color_text" => "#0066a7", "color_top" => "#000000", "color_top_text" => "#ffffff", "url" => "https://subdomain.files.com/f/12345678", "description" => "The public description of the bundle.", "expires_at" => "2000-01-01T01:00:00Z", "password_protected" => true, "permissions" => "read", "preview_only" => true, "require_registration" => true, "require_share_recipient" => true, "require_logout" => true, "clickwrap_body" => "[Legal text]", "form_field_set" => { "id" => 1, "title" => "Sample Form Title", "form_layout" => [ 1, 2, 3, 4 ], "form_fields" => [ { "id" => 1, "label" => "Sample Label", "required" => true, "help_text" => "Help Text", "field_type" => "text", "options_for_select" => [ "red", "green", "blue" ], "default_option" => "red", "form_field_set_id" => 1 } ], "skip_name" => true, "skip_email" => true, "skip_company" => true, "in_use" => true }, "skip_name" => true, "skip_email" => true, "start_access_on_date" => "2000-01-01T01:00:00Z", "skip_company" => true, "id" => 1, "created_at" => "2000-01-01T01:00:00Z", "dont_separate_submissions_by_folder" => true, "max_uses" => 1, "note" => "The internal note on the bundle.", "path_template" => "{{name}}_{{ip}}", "path_template_time_zone" => "Eastern Time (US & Canada)", "send_email_receipt_to_uploader" => true, "snapshot_id" => 1, "user_id" => 1, "username" => "user", "clickwrap_id" => 1, "inbox_id" => 1, "watermark_attachment" => { "name" => "My logo", "uri" => "https://mysite.files.com/.../my_image.png" }, "watermark_value" => { "key" => "example value" }, "has_inbox" => true, "dont_allow_folders_in_uploads" => true, "paths" => [ "file.txt" ], "bundlepaths" => [ { "recursive" => true, "path" => "example" } ] } ] 20 | end 21 | 22 | params do 23 | requires :id, type: Integer 24 | end 25 | get "/api/rest/v1/bundles/:id" do 26 | status 200 27 | { "code" => "abc123", "color_left" => "#0066a7", "color_link" => "#d34f5d", "color_text" => "#0066a7", "color_top" => "#000000", "color_top_text" => "#ffffff", "url" => "https://subdomain.files.com/f/12345678", "description" => "The public description of the bundle.", "expires_at" => "2000-01-01T01:00:00Z", "password_protected" => true, "permissions" => "read", "preview_only" => true, "require_registration" => true, "require_share_recipient" => true, "require_logout" => true, "clickwrap_body" => "[Legal text]", "form_field_set" => { "id" => 1, "title" => "Sample Form Title", "form_layout" => [ 1, 2, 3, 4 ], "form_fields" => [ { "id" => 1, "label" => "Sample Label", "required" => true, "help_text" => "Help Text", "field_type" => "text", "options_for_select" => [ "red", "green", "blue" ], "default_option" => "red", "form_field_set_id" => 1 } ], "skip_name" => true, "skip_email" => true, "skip_company" => true, "in_use" => true }, "skip_name" => true, "skip_email" => true, "start_access_on_date" => "2000-01-01T01:00:00Z", "skip_company" => true, "id" => 1, "created_at" => "2000-01-01T01:00:00Z", "dont_separate_submissions_by_folder" => true, "max_uses" => 1, "note" => "The internal note on the bundle.", "path_template" => "{{name}}_{{ip}}", "path_template_time_zone" => "Eastern Time (US & Canada)", "send_email_receipt_to_uploader" => true, "snapshot_id" => 1, "user_id" => 1, "username" => "user", "clickwrap_id" => 1, "inbox_id" => 1, "watermark_attachment" => { "name" => "My logo", "uri" => "https://mysite.files.com/.../my_image.png" }, "watermark_value" => { "key" => "example value" }, "has_inbox" => true, "dont_allow_folders_in_uploads" => true, "paths" => [ "file.txt" ], "bundlepaths" => [ { "recursive" => true, "path" => "example" } ] } 28 | end 29 | 30 | params do 31 | optional :user_id, type: Integer 32 | requires :paths, type: [ String ] 33 | optional :password, type: String 34 | optional :form_field_set_id, type: Integer 35 | optional :create_snapshot, type: Boolean 36 | optional :dont_separate_submissions_by_folder, type: Boolean 37 | optional :expires_at, type: String 38 | optional :finalize_snapshot, type: Boolean 39 | optional :max_uses, type: Integer 40 | optional :description, type: String 41 | optional :note, type: String 42 | optional :code, type: String 43 | optional :path_template, type: String 44 | optional :path_template_time_zone, type: String 45 | optional :permissions, type: String 46 | optional :require_registration, type: Boolean 47 | optional :clickwrap_id, type: Integer 48 | optional :inbox_id, type: Integer 49 | optional :require_share_recipient, type: Boolean 50 | optional :send_email_receipt_to_uploader, type: Boolean 51 | optional :skip_email, type: Boolean 52 | optional :skip_name, type: Boolean 53 | optional :skip_company, type: Boolean 54 | optional :start_access_on_date, type: String 55 | optional :snapshot_id, type: Integer 56 | optional :watermark_attachment_file, type: File 57 | end 58 | post "/api/rest/v1/bundles" do 59 | status 201 60 | { "code" => "abc123", "color_left" => "#0066a7", "color_link" => "#d34f5d", "color_text" => "#0066a7", "color_top" => "#000000", "color_top_text" => "#ffffff", "url" => "https://subdomain.files.com/f/12345678", "description" => "The public description of the bundle.", "expires_at" => "2000-01-01T01:00:00Z", "password_protected" => true, "permissions" => "read", "preview_only" => true, "require_registration" => true, "require_share_recipient" => true, "require_logout" => true, "clickwrap_body" => "[Legal text]", "form_field_set" => { "id" => 1, "title" => "Sample Form Title", "form_layout" => [ 1, 2, 3, 4 ], "form_fields" => [ { "id" => 1, "label" => "Sample Label", "required" => true, "help_text" => "Help Text", "field_type" => "text", "options_for_select" => [ "red", "green", "blue" ], "default_option" => "red", "form_field_set_id" => 1 } ], "skip_name" => true, "skip_email" => true, "skip_company" => true, "in_use" => true }, "skip_name" => true, "skip_email" => true, "start_access_on_date" => "2000-01-01T01:00:00Z", "skip_company" => true, "id" => 1, "created_at" => "2000-01-01T01:00:00Z", "dont_separate_submissions_by_folder" => true, "max_uses" => 1, "note" => "The internal note on the bundle.", "path_template" => "{{name}}_{{ip}}", "path_template_time_zone" => "Eastern Time (US & Canada)", "send_email_receipt_to_uploader" => true, "snapshot_id" => 1, "user_id" => 1, "username" => "user", "clickwrap_id" => 1, "inbox_id" => 1, "watermark_attachment" => { "name" => "My logo", "uri" => "https://mysite.files.com/.../my_image.png" }, "watermark_value" => { "key" => "example value" }, "has_inbox" => true, "dont_allow_folders_in_uploads" => true, "paths" => [ "file.txt" ], "bundlepaths" => [ { "recursive" => true, "path" => "example" } ] } 61 | end 62 | 63 | params do 64 | requires :id, type: Integer 65 | optional :to, type: [ String ] 66 | optional :note, type: String 67 | optional :recipients, type: [ Hash ] 68 | end 69 | post "/api/rest/v1/bundles/:id/share" do 70 | status 204 71 | body false 72 | end 73 | 74 | params do 75 | requires :id, type: Integer 76 | optional :paths, type: [ String ] 77 | optional :password, type: String 78 | optional :form_field_set_id, type: Integer 79 | optional :clickwrap_id, type: Integer 80 | optional :code, type: String 81 | optional :create_snapshot, type: Boolean 82 | optional :description, type: String 83 | optional :dont_separate_submissions_by_folder, type: Boolean 84 | optional :expires_at, type: String 85 | optional :finalize_snapshot, type: Boolean 86 | optional :inbox_id, type: Integer 87 | optional :max_uses, type: Integer 88 | optional :note, type: String 89 | optional :path_template, type: String 90 | optional :path_template_time_zone, type: String 91 | optional :permissions, type: String 92 | optional :require_registration, type: Boolean 93 | optional :require_share_recipient, type: Boolean 94 | optional :send_email_receipt_to_uploader, type: Boolean 95 | optional :skip_company, type: Boolean 96 | optional :start_access_on_date, type: String 97 | optional :skip_email, type: Boolean 98 | optional :skip_name, type: Boolean 99 | optional :watermark_attachment_delete, type: Boolean 100 | optional :watermark_attachment_file, type: File 101 | end 102 | patch "/api/rest/v1/bundles/:id" do 103 | status 200 104 | { "code" => "abc123", "color_left" => "#0066a7", "color_link" => "#d34f5d", "color_text" => "#0066a7", "color_top" => "#000000", "color_top_text" => "#ffffff", "url" => "https://subdomain.files.com/f/12345678", "description" => "The public description of the bundle.", "expires_at" => "2000-01-01T01:00:00Z", "password_protected" => true, "permissions" => "read", "preview_only" => true, "require_registration" => true, "require_share_recipient" => true, "require_logout" => true, "clickwrap_body" => "[Legal text]", "form_field_set" => { "id" => 1, "title" => "Sample Form Title", "form_layout" => [ 1, 2, 3, 4 ], "form_fields" => [ { "id" => 1, "label" => "Sample Label", "required" => true, "help_text" => "Help Text", "field_type" => "text", "options_for_select" => [ "red", "green", "blue" ], "default_option" => "red", "form_field_set_id" => 1 } ], "skip_name" => true, "skip_email" => true, "skip_company" => true, "in_use" => true }, "skip_name" => true, "skip_email" => true, "start_access_on_date" => "2000-01-01T01:00:00Z", "skip_company" => true, "id" => 1, "created_at" => "2000-01-01T01:00:00Z", "dont_separate_submissions_by_folder" => true, "max_uses" => 1, "note" => "The internal note on the bundle.", "path_template" => "{{name}}_{{ip}}", "path_template_time_zone" => "Eastern Time (US & Canada)", "send_email_receipt_to_uploader" => true, "snapshot_id" => 1, "user_id" => 1, "username" => "user", "clickwrap_id" => 1, "inbox_id" => 1, "watermark_attachment" => { "name" => "My logo", "uri" => "https://mysite.files.com/.../my_image.png" }, "watermark_value" => { "key" => "example value" }, "has_inbox" => true, "dont_allow_folders_in_uploads" => true, "paths" => [ "file.txt" ], "bundlepaths" => [ { "recursive" => true, "path" => "example" } ] } 105 | end 106 | 107 | params do 108 | requires :id, type: Integer 109 | end 110 | delete "/api/rest/v1/bundles/:id" do 111 | status 204 112 | body false 113 | end 114 | end 115 | end 116 | -------------------------------------------------------------------------------- /app/bundle_download_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class BundleDownloadAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :cursor, type: String 7 | optional :per_page, type: Integer 8 | optional :sort_by, type: Hash 9 | optional :filter, type: Hash 10 | optional :filter_gt, type: Hash 11 | optional :filter_gteq, type: Hash 12 | optional :filter_lt, type: Hash 13 | optional :filter_lteq, type: Hash 14 | optional :bundle_id, type: Integer 15 | optional :bundle_registration_id, type: Integer 16 | end 17 | get "/api/rest/v1/bundle_downloads" do 18 | status 200 19 | [ { "bundle_registration" => { "code" => "abc123", "name" => "account", "company" => "Action Verb", "email" => "john.doe@files.com", "ip" => "10.1.1.1", "inbox_code" => "abc123", "clickwrap_body" => "example", "form_field_set_id" => 1, "form_field_data" => { "key" => "example value" }, "bundle_code" => "example", "bundle_id" => 1, "bundle_recipient_id" => 1, "created_at" => "2000-01-01T01:00:00Z" }, "download_method" => "file", "path" => "a/b/test.txt", "created_at" => "2000-01-01T01:00:00Z" } ] 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /app/bundle_notification_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class BundleNotificationAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :user_id, type: Integer 7 | optional :cursor, type: String 8 | optional :per_page, type: Integer 9 | optional :sort_by, type: Hash 10 | optional :filter, type: Hash 11 | end 12 | get "/api/rest/v1/bundle_notifications" do 13 | status 200 14 | [ { "bundle_id" => 1, "id" => 1, "notify_on_registration" => true, "notify_on_upload" => true, "notify_user_id" => 1 } ] 15 | end 16 | 17 | params do 18 | requires :id, type: Integer 19 | end 20 | get "/api/rest/v1/bundle_notifications/:id" do 21 | status 200 22 | { "bundle_id" => 1, "id" => 1, "notify_on_registration" => true, "notify_on_upload" => true, "notify_user_id" => 1 } 23 | end 24 | 25 | params do 26 | optional :user_id, type: Integer 27 | requires :bundle_id, type: Integer 28 | optional :notify_user_id, type: Integer 29 | optional :notify_on_registration, type: Boolean 30 | optional :notify_on_upload, type: Boolean 31 | end 32 | post "/api/rest/v1/bundle_notifications" do 33 | status 201 34 | { "bundle_id" => 1, "id" => 1, "notify_on_registration" => true, "notify_on_upload" => true, "notify_user_id" => 1 } 35 | end 36 | 37 | params do 38 | requires :id, type: Integer 39 | optional :notify_on_registration, type: Boolean 40 | optional :notify_on_upload, type: Boolean 41 | end 42 | patch "/api/rest/v1/bundle_notifications/:id" do 43 | status 200 44 | { "bundle_id" => 1, "id" => 1, "notify_on_registration" => true, "notify_on_upload" => true, "notify_user_id" => 1 } 45 | end 46 | 47 | params do 48 | requires :id, type: Integer 49 | end 50 | delete "/api/rest/v1/bundle_notifications/:id" do 51 | status 204 52 | body false 53 | end 54 | end 55 | end 56 | -------------------------------------------------------------------------------- /app/bundle_recipient_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class BundleRecipientAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :user_id, type: Integer 7 | optional :cursor, type: String 8 | optional :per_page, type: Integer 9 | optional :sort_by, type: Hash 10 | optional :filter, type: Hash 11 | requires :bundle_id, type: Integer 12 | end 13 | get "/api/rest/v1/bundle_recipients" do 14 | status 200 15 | [ { "company" => "Acme Inc.", "name" => "John Doe", "note" => "Some note.", "recipient" => "john.doe@example.com", "sent_at" => "2000-01-01T01:00:00Z" } ] 16 | end 17 | 18 | params do 19 | optional :user_id, type: Integer 20 | requires :bundle_id, type: Integer 21 | requires :recipient, type: String 22 | optional :name, type: String 23 | optional :company, type: String 24 | optional :note, type: String 25 | optional :share_after_create, type: Boolean 26 | end 27 | post "/api/rest/v1/bundle_recipients" do 28 | status 201 29 | { "company" => "Acme Inc.", "name" => "John Doe", "note" => "Some note.", "recipient" => "john.doe@example.com", "sent_at" => "2000-01-01T01:00:00Z" } 30 | end 31 | end 32 | end 33 | -------------------------------------------------------------------------------- /app/bundle_registration_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class BundleRegistrationAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :user_id, type: Integer 7 | optional :cursor, type: String 8 | optional :per_page, type: Integer 9 | optional :sort_by, type: Hash 10 | optional :bundle_id, type: Integer 11 | end 12 | get "/api/rest/v1/bundle_registrations" do 13 | status 200 14 | [ { "code" => "abc123", "name" => "account", "company" => "Action Verb", "email" => "john.doe@files.com", "ip" => "10.1.1.1", "inbox_code" => "abc123", "clickwrap_body" => "example", "form_field_set_id" => 1, "form_field_data" => { "key" => "example value" }, "bundle_code" => "example", "bundle_id" => 1, "bundle_recipient_id" => 1, "created_at" => "2000-01-01T01:00:00Z" } ] 15 | end 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /app/clickwrap_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class ClickwrapAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :cursor, type: String 7 | optional :per_page, type: Integer 8 | optional :sort_by, type: Hash 9 | end 10 | get "/api/rest/v1/clickwraps" do 11 | status 200 12 | [ { "id" => 1, "name" => "Example Site NDA for Files.com Use", "body" => "[Legal body text]", "use_with_users" => "example", "use_with_bundles" => "example", "use_with_inboxes" => "example" } ] 13 | end 14 | 15 | params do 16 | requires :id, type: Integer 17 | end 18 | get "/api/rest/v1/clickwraps/:id" do 19 | status 200 20 | { "id" => 1, "name" => "Example Site NDA for Files.com Use", "body" => "[Legal body text]", "use_with_users" => "example", "use_with_bundles" => "example", "use_with_inboxes" => "example" } 21 | end 22 | 23 | params do 24 | optional :name, type: String 25 | optional :body, type: String 26 | optional :use_with_bundles, type: String 27 | optional :use_with_inboxes, type: String 28 | optional :use_with_users, type: String 29 | end 30 | post "/api/rest/v1/clickwraps" do 31 | status 201 32 | { "id" => 1, "name" => "Example Site NDA for Files.com Use", "body" => "[Legal body text]", "use_with_users" => "example", "use_with_bundles" => "example", "use_with_inboxes" => "example" } 33 | end 34 | 35 | params do 36 | requires :id, type: Integer 37 | optional :name, type: String 38 | optional :body, type: String 39 | optional :use_with_bundles, type: String 40 | optional :use_with_inboxes, type: String 41 | optional :use_with_users, type: String 42 | end 43 | patch "/api/rest/v1/clickwraps/:id" do 44 | status 200 45 | { "id" => 1, "name" => "Example Site NDA for Files.com Use", "body" => "[Legal body text]", "use_with_users" => "example", "use_with_bundles" => "example", "use_with_inboxes" => "example" } 46 | end 47 | 48 | params do 49 | requires :id, type: Integer 50 | end 51 | delete "/api/rest/v1/clickwraps/:id" do 52 | status 204 53 | body false 54 | end 55 | end 56 | end 57 | -------------------------------------------------------------------------------- /app/dns_record_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class DnsRecordAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :cursor, type: String 7 | optional :per_page, type: Integer 8 | end 9 | get "/api/rest/v1/dns_records" do 10 | status 200 11 | [ { "id" => "customdomain.com-CNAME-site.files.com", "domain" => "my-custom-domain.com", "rrtype" => "CNAME", "value" => "mysite.files.com" } ] 12 | end 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /app/email_incoming_message_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class EmailIncomingMessageAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :cursor, type: String 7 | optional :per_page, type: Integer 8 | optional :sort_by, type: Hash 9 | optional :filter, type: Hash 10 | optional :filter_gt, type: Hash 11 | optional :filter_gteq, type: Hash 12 | optional :filter_prefix, type: Hash 13 | optional :filter_lt, type: Hash 14 | optional :filter_lteq, type: Hash 15 | end 16 | get "/api/rest/v1/email_incoming_messages" do 17 | status 200 18 | [ { "id" => 1, "inbox_id" => 1, "sender" => "example", "sender_name" => "example", "status" => "success", "body" => "example", "message" => "example", "created_at" => "2000-01-01T01:00:00Z", "inbox_title" => "Inbox Title" } ] 19 | end 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /app/email_log_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class EmailLogAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :cursor, type: String 7 | optional :per_page, type: Integer 8 | optional :filter, type: Hash 9 | optional :filter_prefix, type: Hash 10 | end 11 | get "/api/rest/v1/email_logs" do 12 | status 200 13 | [ { "timestamp" => "2000-01-01T01:00:00Z", "message" => "example", "status" => "example", "subject" => "example", "to" => "example", "cc" => "example", "delivery_method" => "example", "smtp_hostname" => "example", "smtp_ip" => "example" } ] 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /app/exavault_api_request_log_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class ExavaultApiRequestLogAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :cursor, type: String 7 | optional :per_page, type: Integer 8 | optional :filter, type: Hash 9 | optional :filter_prefix, type: Hash 10 | end 11 | get "/api/rest/v1/exavault_api_request_logs" do 12 | status 200 13 | [ { "timestamp" => "2000-01-01T01:00:00Z", "endpoint" => "example", "version" => 1, "request_ip" => "example", "request_method" => "example", "error_type" => "example", "error_message" => "example", "user_agent" => "example", "response_code" => 1, "success" => true, "duration_ms" => 1 } ] 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /app/external_event_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class ExternalEventAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :cursor, type: String 7 | optional :per_page, type: Integer 8 | optional :sort_by, type: Hash 9 | optional :filter, type: Hash 10 | optional :filter_gt, type: Hash 11 | optional :filter_gteq, type: Hash 12 | optional :filter_lt, type: Hash 13 | optional :filter_lteq, type: Hash 14 | end 15 | get "/api/rest/v1/external_events" do 16 | status 200 17 | [ { "id" => 1, "event_type" => "example", "status" => "example", "body" => "example", "created_at" => "2000-01-01T01:00:00Z", "body_url" => "example", "folder_behavior_id" => 1, "siem_http_destination_id" => 1, "successful_files" => 1, "errored_files" => 1, "bytes_synced" => 1, "compared_files" => 1, "compared_folders" => 1, "remote_server_type" => "example" } ] 18 | end 19 | 20 | params do 21 | requires :id, type: Integer 22 | end 23 | get "/api/rest/v1/external_events/:id" do 24 | status 200 25 | { "id" => 1, "event_type" => "example", "status" => "example", "body" => "example", "created_at" => "2000-01-01T01:00:00Z", "body_url" => "example", "folder_behavior_id" => 1, "siem_http_destination_id" => 1, "successful_files" => 1, "errored_files" => 1, "bytes_synced" => 1, "compared_files" => 1, "compared_folders" => 1, "remote_server_type" => "example" } 26 | end 27 | 28 | params do 29 | requires :status, type: String 30 | requires :body, type: String 31 | end 32 | post "/api/rest/v1/external_events" do 33 | status 201 34 | { "id" => 1, "event_type" => "example", "status" => "example", "body" => "example", "created_at" => "2000-01-01T01:00:00Z", "body_url" => "example", "folder_behavior_id" => 1, "siem_http_destination_id" => 1, "successful_files" => 1, "errored_files" => 1, "bytes_synced" => 1, "compared_files" => 1, "compared_folders" => 1, "remote_server_type" => "example" } 35 | end 36 | end 37 | end 38 | -------------------------------------------------------------------------------- /app/file_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class FileAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | requires :path, type: String 7 | optional :action, type: String 8 | optional :preview_size, type: String 9 | optional :with_previews, type: Boolean 10 | optional :with_priority_color, type: Boolean 11 | end 12 | get "/api/rest/v1/files/:path" do 13 | status 200 14 | { "path" => "path/file.txt", "created_by_id" => 1, "created_by_api_key_id" => 1, "created_by_as2_incoming_message_id" => 1, "created_by_automation_id" => 1, "created_by_bundle_registration_id" => 1, "created_by_inbox_id" => 1, "created_by_remote_server_id" => 1, "created_by_remote_server_sync_id" => 1, "custom_metadata" => { "key" => "value" }, "display_name" => "file.txt", "type" => "file", "size" => 1024, "created_at" => "2000-01-01T01:00:00Z", "last_modified_by_id" => 1, "last_modified_by_api_key_id" => 1, "last_modified_by_automation_id" => 1, "last_modified_by_bundle_registration_id" => 1, "last_modified_by_remote_server_id" => 1, "last_modified_by_remote_server_sync_id" => 1, "mtime" => "2000-01-01T01:00:00Z", "provided_mtime" => "2000-01-01T01:00:00Z", "crc32" => "70976923", "md5" => "17c54824e9931a4688ca032d03f6663c", "sha1" => "a94a8fe5ccb19ba61c4c0873d391e987982fbbd3", "sha256" => "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08", "mime_type" => "application/octet-stream", "region" => "us-east-1", "permissions" => "rwd", "subfolders_locked?" => true, "is_locked" => true, "download_uri" => "https://mysite.files.com/...", "priority_color" => "red", "preview_id" => 1, "preview" => { "id" => 1, "status" => "complete", "download_uri" => "https://mysite.files.com/...", "type" => "image", "size" => "large" } } 15 | end 16 | 17 | params do 18 | requires :path, type: String 19 | optional :action, type: String 20 | optional "etags[etag]", type: [ String ] 21 | optional "etags[part]", type: [ Integer ] 22 | optional :length, type: Integer 23 | optional :mkdir_parents, type: Boolean 24 | optional :part, type: Integer 25 | optional :parts, type: Integer 26 | optional :provided_mtime, type: String 27 | optional :ref, type: String 28 | optional :restart, type: Integer 29 | optional :size, type: Integer 30 | optional :structure, type: String 31 | optional :with_rename, type: Boolean 32 | end 33 | post "/api/rest/v1/files/:path" do 34 | status 201 35 | { "path" => "path/file.txt", "created_by_id" => 1, "created_by_api_key_id" => 1, "created_by_as2_incoming_message_id" => 1, "created_by_automation_id" => 1, "created_by_bundle_registration_id" => 1, "created_by_inbox_id" => 1, "created_by_remote_server_id" => 1, "created_by_remote_server_sync_id" => 1, "custom_metadata" => { "key" => "value" }, "display_name" => "file.txt", "type" => "file", "size" => 1024, "created_at" => "2000-01-01T01:00:00Z", "last_modified_by_id" => 1, "last_modified_by_api_key_id" => 1, "last_modified_by_automation_id" => 1, "last_modified_by_bundle_registration_id" => 1, "last_modified_by_remote_server_id" => 1, "last_modified_by_remote_server_sync_id" => 1, "mtime" => "2000-01-01T01:00:00Z", "provided_mtime" => "2000-01-01T01:00:00Z", "crc32" => "70976923", "md5" => "17c54824e9931a4688ca032d03f6663c", "sha1" => "a94a8fe5ccb19ba61c4c0873d391e987982fbbd3", "sha256" => "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08", "mime_type" => "application/octet-stream", "region" => "us-east-1", "permissions" => "rwd", "subfolders_locked?" => true, "is_locked" => true, "download_uri" => "https://mysite.files.com/...", "priority_color" => "red", "preview_id" => 1, "preview" => { "id" => 1, "status" => "complete", "download_uri" => "https://mysite.files.com/...", "type" => "image", "size" => "large" } } 36 | end 37 | 38 | params do 39 | requires :path, type: String 40 | optional :custom_metadata, type: Hash 41 | optional :provided_mtime, type: String 42 | optional :priority_color, type: String 43 | end 44 | patch "/api/rest/v1/files/:path" do 45 | status 200 46 | { "path" => "path/file.txt", "created_by_id" => 1, "created_by_api_key_id" => 1, "created_by_as2_incoming_message_id" => 1, "created_by_automation_id" => 1, "created_by_bundle_registration_id" => 1, "created_by_inbox_id" => 1, "created_by_remote_server_id" => 1, "created_by_remote_server_sync_id" => 1, "custom_metadata" => { "key" => "value" }, "display_name" => "file.txt", "type" => "file", "size" => 1024, "created_at" => "2000-01-01T01:00:00Z", "last_modified_by_id" => 1, "last_modified_by_api_key_id" => 1, "last_modified_by_automation_id" => 1, "last_modified_by_bundle_registration_id" => 1, "last_modified_by_remote_server_id" => 1, "last_modified_by_remote_server_sync_id" => 1, "mtime" => "2000-01-01T01:00:00Z", "provided_mtime" => "2000-01-01T01:00:00Z", "crc32" => "70976923", "md5" => "17c54824e9931a4688ca032d03f6663c", "sha1" => "a94a8fe5ccb19ba61c4c0873d391e987982fbbd3", "sha256" => "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08", "mime_type" => "application/octet-stream", "region" => "us-east-1", "permissions" => "rwd", "subfolders_locked?" => true, "is_locked" => true, "download_uri" => "https://mysite.files.com/...", "priority_color" => "red", "preview_id" => 1, "preview" => { "id" => 1, "status" => "complete", "download_uri" => "https://mysite.files.com/...", "type" => "image", "size" => "large" } } 47 | end 48 | 49 | params do 50 | requires :path, type: String 51 | optional :recursive, type: Boolean 52 | end 53 | delete "/api/rest/v1/files/:path" do 54 | status 204 55 | body false 56 | end 57 | 58 | params do 59 | requires :path, type: String 60 | optional :preview_size, type: String 61 | optional :with_previews, type: Boolean 62 | optional :with_priority_color, type: Boolean 63 | end 64 | get "/api/rest/v1/file_actions/metadata/:path" do 65 | status 200 66 | { "path" => "path/file.txt", "created_by_id" => 1, "created_by_api_key_id" => 1, "created_by_as2_incoming_message_id" => 1, "created_by_automation_id" => 1, "created_by_bundle_registration_id" => 1, "created_by_inbox_id" => 1, "created_by_remote_server_id" => 1, "created_by_remote_server_sync_id" => 1, "custom_metadata" => { "key" => "value" }, "display_name" => "file.txt", "type" => "file", "size" => 1024, "created_at" => "2000-01-01T01:00:00Z", "last_modified_by_id" => 1, "last_modified_by_api_key_id" => 1, "last_modified_by_automation_id" => 1, "last_modified_by_bundle_registration_id" => 1, "last_modified_by_remote_server_id" => 1, "last_modified_by_remote_server_sync_id" => 1, "mtime" => "2000-01-01T01:00:00Z", "provided_mtime" => "2000-01-01T01:00:00Z", "crc32" => "70976923", "md5" => "17c54824e9931a4688ca032d03f6663c", "sha1" => "a94a8fe5ccb19ba61c4c0873d391e987982fbbd3", "sha256" => "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08", "mime_type" => "application/octet-stream", "region" => "us-east-1", "permissions" => "rwd", "subfolders_locked?" => true, "is_locked" => true, "download_uri" => "https://mysite.files.com/...", "priority_color" => "red", "preview_id" => 1, "preview" => { "id" => 1, "status" => "complete", "download_uri" => "https://mysite.files.com/...", "type" => "image", "size" => "large" } } 67 | end 68 | 69 | params do 70 | requires :path, type: String 71 | requires :destination, type: String 72 | optional :structure, type: Boolean 73 | optional :overwrite, type: Boolean 74 | end 75 | post "/api/rest/v1/file_actions/copy/:path" do 76 | status 201 77 | { "status" => "pending", "file_migration_id" => 1 } 78 | end 79 | 80 | params do 81 | requires :path, type: String 82 | requires :destination, type: String 83 | optional :overwrite, type: Boolean 84 | end 85 | post "/api/rest/v1/file_actions/move/:path" do 86 | status 201 87 | { "status" => "pending", "file_migration_id" => 1 } 88 | end 89 | 90 | params do 91 | requires :path, type: String 92 | optional :mkdir_parents, type: Boolean 93 | optional :part, type: Integer 94 | optional :parts, type: Integer 95 | optional :ref, type: String 96 | optional :restart, type: Integer 97 | optional :size, type: Integer 98 | optional :with_rename, type: Boolean 99 | end 100 | post "/api/rest/v1/file_actions/begin_upload/:path" do 101 | status 200 102 | [ { "send" => { "key" => "example value" }, "action" => "multipart", "ask_about_overwrites" => true, "available_parts" => 1, "expires" => "example", "headers" => { "key" => "example value" }, "http_method" => "PUT", "next_partsize" => 1, "parallel_parts" => true, "retry_parts" => true, "parameters" => { "key" => "example value" }, "part_number" => 1, "partsize" => 1, "path" => "", "ref" => "upload-1", "upload_uri" => "example" } ] 103 | end 104 | end 105 | end 106 | -------------------------------------------------------------------------------- /app/file_comment_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class FileCommentAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :cursor, type: String 7 | optional :per_page, type: Integer 8 | requires :path, type: String 9 | end 10 | get "/api/rest/v1/file_comments/files/:path" do 11 | status 200 12 | [ { "id" => 1, "body" => "What a great file!", "reactions" => [ { "id" => 1, "emoji" => "👍" } ] } ] 13 | end 14 | 15 | params do 16 | requires :body, type: String 17 | requires :path, type: String 18 | end 19 | post "/api/rest/v1/file_comments" do 20 | status 201 21 | { "id" => 1, "body" => "What a great file!", "reactions" => [ { "id" => 1, "emoji" => "👍" } ] } 22 | end 23 | 24 | params do 25 | requires :id, type: Integer 26 | requires :body, type: String 27 | end 28 | patch "/api/rest/v1/file_comments/:id" do 29 | status 200 30 | { "id" => 1, "body" => "What a great file!", "reactions" => [ { "id" => 1, "emoji" => "👍" } ] } 31 | end 32 | 33 | params do 34 | requires :id, type: Integer 35 | end 36 | delete "/api/rest/v1/file_comments/:id" do 37 | status 204 38 | body false 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /app/file_comment_reaction_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class FileCommentReactionAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :user_id, type: Integer 7 | requires :file_comment_id, type: Integer 8 | requires :emoji, type: String 9 | end 10 | post "/api/rest/v1/file_comment_reactions" do 11 | status 201 12 | { "id" => 1, "emoji" => "👍" } 13 | end 14 | 15 | params do 16 | requires :id, type: Integer 17 | end 18 | delete "/api/rest/v1/file_comment_reactions/:id" do 19 | status 204 20 | body false 21 | end 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /app/file_migration_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class FileMigrationAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | requires :id, type: Integer 7 | end 8 | get "/api/rest/v1/file_migrations/:id" do 9 | status 200 10 | { "id" => 1, "path" => "MyFolder", "dest_path" => "MyFolder", "files_moved" => 1, "files_total" => 1, "operation" => "move", "region" => "USA", "status" => "complete", "log_url" => "https://www.example.com/log_file" } 11 | end 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /app/file_migration_log_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class FileMigrationLogAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :cursor, type: String 7 | optional :per_page, type: Integer 8 | optional :filter, type: Hash 9 | optional :filter_prefix, type: Hash 10 | end 11 | get "/api/rest/v1/file_migration_logs" do 12 | status 200 13 | [ { "timestamp" => "2000-01-01T01:00:00Z", "file_migration_id" => 1, "dest_path" => "example", "error_type" => "example", "message" => "example", "operation" => "example", "path" => "example", "status" => "example" } ] 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /app/folder_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class FolderAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :cursor, type: String 7 | optional :per_page, type: Integer 8 | requires :path, type: String 9 | optional :preview_size, type: String 10 | optional :sort_by, type: Hash 11 | optional :search, type: String 12 | optional :search_custom_metadata_key, type: String 13 | optional :search_all, type: Boolean 14 | optional :with_previews, type: Boolean 15 | optional :with_priority_color, type: Boolean 16 | end 17 | get "/api/rest/v1/folders/:path" do 18 | status 200 19 | [ { "path" => "path/file.txt", "created_by_id" => 1, "created_by_api_key_id" => 1, "created_by_as2_incoming_message_id" => 1, "created_by_automation_id" => 1, "created_by_bundle_registration_id" => 1, "created_by_inbox_id" => 1, "created_by_remote_server_id" => 1, "created_by_remote_server_sync_id" => 1, "custom_metadata" => { "key" => "value" }, "display_name" => "file.txt", "type" => "file", "size" => 1024, "created_at" => "2000-01-01T01:00:00Z", "last_modified_by_id" => 1, "last_modified_by_api_key_id" => 1, "last_modified_by_automation_id" => 1, "last_modified_by_bundle_registration_id" => 1, "last_modified_by_remote_server_id" => 1, "last_modified_by_remote_server_sync_id" => 1, "mtime" => "2000-01-01T01:00:00Z", "provided_mtime" => "2000-01-01T01:00:00Z", "crc32" => "70976923", "md5" => "17c54824e9931a4688ca032d03f6663c", "sha1" => "a94a8fe5ccb19ba61c4c0873d391e987982fbbd3", "sha256" => "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08", "mime_type" => "application/octet-stream", "region" => "us-east-1", "permissions" => "rwd", "subfolders_locked?" => true, "is_locked" => true, "download_uri" => "https://mysite.files.com/...", "priority_color" => "red", "preview_id" => 1, "preview" => { "id" => 1, "status" => "complete", "download_uri" => "https://mysite.files.com/...", "type" => "image", "size" => "large" } } ] 20 | end 21 | 22 | params do 23 | requires :path, type: String 24 | optional :mkdir_parents, type: Boolean 25 | optional :provided_mtime, type: String 26 | end 27 | post "/api/rest/v1/folders/:path" do 28 | status 201 29 | { "path" => "path/file.txt", "created_by_id" => 1, "created_by_api_key_id" => 1, "created_by_as2_incoming_message_id" => 1, "created_by_automation_id" => 1, "created_by_bundle_registration_id" => 1, "created_by_inbox_id" => 1, "created_by_remote_server_id" => 1, "created_by_remote_server_sync_id" => 1, "custom_metadata" => { "key" => "value" }, "display_name" => "file.txt", "type" => "file", "size" => 1024, "created_at" => "2000-01-01T01:00:00Z", "last_modified_by_id" => 1, "last_modified_by_api_key_id" => 1, "last_modified_by_automation_id" => 1, "last_modified_by_bundle_registration_id" => 1, "last_modified_by_remote_server_id" => 1, "last_modified_by_remote_server_sync_id" => 1, "mtime" => "2000-01-01T01:00:00Z", "provided_mtime" => "2000-01-01T01:00:00Z", "crc32" => "70976923", "md5" => "17c54824e9931a4688ca032d03f6663c", "sha1" => "a94a8fe5ccb19ba61c4c0873d391e987982fbbd3", "sha256" => "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08", "mime_type" => "application/octet-stream", "region" => "us-east-1", "permissions" => "rwd", "subfolders_locked?" => true, "is_locked" => true, "download_uri" => "https://mysite.files.com/...", "priority_color" => "red", "preview_id" => 1, "preview" => { "id" => 1, "status" => "complete", "download_uri" => "https://mysite.files.com/...", "type" => "image", "size" => "large" } } 30 | end 31 | end 32 | end 33 | -------------------------------------------------------------------------------- /app/form_field_set_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class FormFieldSetAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :user_id, type: Integer 7 | optional :cursor, type: String 8 | optional :per_page, type: Integer 9 | end 10 | get "/api/rest/v1/form_field_sets" do 11 | status 200 12 | [ { "id" => 1, "title" => "Sample Form Title", "form_layout" => [ 1, 2, 3, 4 ], "form_fields" => [ { "id" => 1, "label" => "Sample Label", "required" => true, "help_text" => "Help Text", "field_type" => "text", "options_for_select" => [ "red", "green", "blue" ], "default_option" => "red", "form_field_set_id" => 1 } ], "skip_name" => true, "skip_email" => true, "skip_company" => true, "in_use" => true } ] 13 | end 14 | 15 | params do 16 | requires :id, type: Integer 17 | end 18 | get "/api/rest/v1/form_field_sets/:id" do 19 | status 200 20 | { "id" => 1, "title" => "Sample Form Title", "form_layout" => [ 1, 2, 3, 4 ], "form_fields" => [ { "id" => 1, "label" => "Sample Label", "required" => true, "help_text" => "Help Text", "field_type" => "text", "options_for_select" => [ "red", "green", "blue" ], "default_option" => "red", "form_field_set_id" => 1 } ], "skip_name" => true, "skip_email" => true, "skip_company" => true, "in_use" => true } 21 | end 22 | 23 | params do 24 | optional :user_id, type: Integer 25 | optional :title, type: String 26 | optional :skip_email, type: Boolean 27 | optional :skip_name, type: Boolean 28 | optional :skip_company, type: Boolean 29 | optional :form_fields, type: [ Hash ] 30 | end 31 | post "/api/rest/v1/form_field_sets" do 32 | status 201 33 | { "id" => 1, "title" => "Sample Form Title", "form_layout" => [ 1, 2, 3, 4 ], "form_fields" => [ { "id" => 1, "label" => "Sample Label", "required" => true, "help_text" => "Help Text", "field_type" => "text", "options_for_select" => [ "red", "green", "blue" ], "default_option" => "red", "form_field_set_id" => 1 } ], "skip_name" => true, "skip_email" => true, "skip_company" => true, "in_use" => true } 34 | end 35 | 36 | params do 37 | requires :id, type: Integer 38 | optional :title, type: String 39 | optional :skip_email, type: Boolean 40 | optional :skip_name, type: Boolean 41 | optional :skip_company, type: Boolean 42 | optional :form_fields, type: [ Hash ] 43 | end 44 | patch "/api/rest/v1/form_field_sets/:id" do 45 | status 200 46 | { "id" => 1, "title" => "Sample Form Title", "form_layout" => [ 1, 2, 3, 4 ], "form_fields" => [ { "id" => 1, "label" => "Sample Label", "required" => true, "help_text" => "Help Text", "field_type" => "text", "options_for_select" => [ "red", "green", "blue" ], "default_option" => "red", "form_field_set_id" => 1 } ], "skip_name" => true, "skip_email" => true, "skip_company" => true, "in_use" => true } 47 | end 48 | 49 | params do 50 | requires :id, type: Integer 51 | end 52 | delete "/api/rest/v1/form_field_sets/:id" do 53 | status 204 54 | body false 55 | end 56 | end 57 | end 58 | -------------------------------------------------------------------------------- /app/ftp_action_log_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class FtpActionLogAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :cursor, type: String 7 | optional :per_page, type: Integer 8 | optional :filter, type: Hash 9 | optional :filter_prefix, type: Hash 10 | end 11 | get "/api/rest/v1/ftp_action_logs" do 12 | status 200 13 | [ { "timestamp" => "2000-01-01T01:00:00Z", "remote_ip" => "example", "server_ip" => "example", "username" => "example", "session_uuid" => "example", "seq_id" => 1, "auth_ciphers" => "example", "action_type" => "example", "path" => "example", "true_path" => "example", "name" => "example", "cmd" => "example", "param" => "example", "responseCode" => 1, "responseMessage" => "example", "entries_returned" => 1, "success" => true, "status" => "example", "duration_ms" => 1 } ] 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /app/gpg_key_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class GpgKeyAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :user_id, type: Integer 7 | optional :cursor, type: String 8 | optional :per_page, type: Integer 9 | optional :sort_by, type: Hash 10 | end 11 | get "/api/rest/v1/gpg_keys" do 12 | status 200 13 | [ { "id" => 1, "expires_at" => "2000-01-01T01:00:00Z", "name" => "key name", "user_id" => 1, "public_key" => "7f8bc1210b09b9ddf469e6b6b8920e76", "private_key" => "ab236cfe4a195f0226bc2e674afdd6b0", "private_key_password" => "[your GPG private key password]" } ] 14 | end 15 | 16 | params do 17 | requires :id, type: Integer 18 | end 19 | get "/api/rest/v1/gpg_keys/:id" do 20 | status 200 21 | { "id" => 1, "expires_at" => "2000-01-01T01:00:00Z", "name" => "key name", "user_id" => 1, "public_key" => "7f8bc1210b09b9ddf469e6b6b8920e76", "private_key" => "ab236cfe4a195f0226bc2e674afdd6b0", "private_key_password" => "[your GPG private key password]" } 22 | end 23 | 24 | params do 25 | optional :user_id, type: Integer 26 | optional :public_key, type: String 27 | optional :private_key, type: String 28 | optional :private_key_password, type: String 29 | requires :name, type: String 30 | end 31 | post "/api/rest/v1/gpg_keys" do 32 | status 201 33 | { "id" => 1, "expires_at" => "2000-01-01T01:00:00Z", "name" => "key name", "user_id" => 1, "public_key" => "7f8bc1210b09b9ddf469e6b6b8920e76", "private_key" => "ab236cfe4a195f0226bc2e674afdd6b0", "private_key_password" => "[your GPG private key password]" } 34 | end 35 | 36 | params do 37 | requires :id, type: Integer 38 | optional :public_key, type: String 39 | optional :private_key, type: String 40 | optional :private_key_password, type: String 41 | optional :name, type: String 42 | end 43 | patch "/api/rest/v1/gpg_keys/:id" do 44 | status 200 45 | { "id" => 1, "expires_at" => "2000-01-01T01:00:00Z", "name" => "key name", "user_id" => 1, "public_key" => "7f8bc1210b09b9ddf469e6b6b8920e76", "private_key" => "ab236cfe4a195f0226bc2e674afdd6b0", "private_key_password" => "[your GPG private key password]" } 46 | end 47 | 48 | params do 49 | requires :id, type: Integer 50 | end 51 | delete "/api/rest/v1/gpg_keys/:id" do 52 | status 204 53 | body false 54 | end 55 | end 56 | end 57 | -------------------------------------------------------------------------------- /app/group_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class GroupAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :cursor, type: String 7 | optional :per_page, type: Integer 8 | optional :sort_by, type: Hash 9 | optional :filter, type: Hash 10 | optional :filter_prefix, type: Hash 11 | optional :ids, type: String 12 | optional :include_parent_site_groups, type: Boolean 13 | end 14 | get "/api/rest/v1/groups" do 15 | status 200 16 | [ { "id" => 1, "name" => "owners", "allowed_ips" => "10.0.0.0/8\n127.0.0.1", "admin_ids" => "1", "notes" => "example", "user_ids" => "1", "usernames" => "user", "ftp_permission" => true, "sftp_permission" => true, "dav_permission" => true, "restapi_permission" => true, "site_id" => 1 } ] 17 | end 18 | 19 | params do 20 | requires :id, type: Integer 21 | end 22 | get "/api/rest/v1/groups/:id" do 23 | status 200 24 | { "id" => 1, "name" => "owners", "allowed_ips" => "10.0.0.0/8\n127.0.0.1", "admin_ids" => "1", "notes" => "example", "user_ids" => "1", "usernames" => "user", "ftp_permission" => true, "sftp_permission" => true, "dav_permission" => true, "restapi_permission" => true, "site_id" => 1 } 25 | end 26 | 27 | params do 28 | optional :notes, type: String 29 | optional :user_ids, type: String 30 | optional :admin_ids, type: String 31 | optional :ftp_permission, type: Boolean 32 | optional :sftp_permission, type: Boolean 33 | optional :dav_permission, type: Boolean 34 | optional :restapi_permission, type: Boolean 35 | optional :allowed_ips, type: String 36 | requires :name, type: String 37 | end 38 | post "/api/rest/v1/groups" do 39 | status 201 40 | { "id" => 1, "name" => "owners", "allowed_ips" => "10.0.0.0/8\n127.0.0.1", "admin_ids" => "1", "notes" => "example", "user_ids" => "1", "usernames" => "user", "ftp_permission" => true, "sftp_permission" => true, "dav_permission" => true, "restapi_permission" => true, "site_id" => 1 } 41 | end 42 | 43 | params do 44 | requires :id, type: Integer 45 | optional :notes, type: String 46 | optional :user_ids, type: String 47 | optional :admin_ids, type: String 48 | optional :ftp_permission, type: Boolean 49 | optional :sftp_permission, type: Boolean 50 | optional :dav_permission, type: Boolean 51 | optional :restapi_permission, type: Boolean 52 | optional :allowed_ips, type: String 53 | optional :name, type: String 54 | end 55 | patch "/api/rest/v1/groups/:id" do 56 | status 200 57 | { "id" => 1, "name" => "owners", "allowed_ips" => "10.0.0.0/8\n127.0.0.1", "admin_ids" => "1", "notes" => "example", "user_ids" => "1", "usernames" => "user", "ftp_permission" => true, "sftp_permission" => true, "dav_permission" => true, "restapi_permission" => true, "site_id" => 1 } 58 | end 59 | 60 | params do 61 | requires :id, type: Integer 62 | end 63 | delete "/api/rest/v1/groups/:id" do 64 | status 204 65 | body false 66 | end 67 | end 68 | end 69 | -------------------------------------------------------------------------------- /app/group_user_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class GroupUserAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :user_id, type: Integer 7 | optional :cursor, type: String 8 | optional :per_page, type: Integer 9 | optional :group_id, type: Integer 10 | end 11 | get "/api/rest/v1/group_users" do 12 | status 200 13 | [ { "group_name" => "My Group", "group_id" => 1, "user_id" => 1, "admin" => true, "usernames" => "user" } ] 14 | end 15 | 16 | params do 17 | requires :group_id, type: Integer 18 | requires :user_id, type: Integer 19 | optional :admin, type: Boolean 20 | end 21 | post "/api/rest/v1/group_users" do 22 | status 201 23 | { "group_name" => "My Group", "group_id" => 1, "user_id" => 1, "admin" => true, "usernames" => "user" } 24 | end 25 | 26 | params do 27 | requires :id, type: Integer 28 | requires :group_id, type: Integer 29 | requires :user_id, type: Integer 30 | optional :admin, type: Boolean 31 | end 32 | patch "/api/rest/v1/group_users/:id" do 33 | status 200 34 | { "group_name" => "My Group", "group_id" => 1, "user_id" => 1, "admin" => true, "usernames" => "user" } 35 | end 36 | 37 | params do 38 | requires :id, type: Integer 39 | requires :group_id, type: Integer 40 | requires :user_id, type: Integer 41 | end 42 | delete "/api/rest/v1/group_users/:id" do 43 | status 204 44 | body false 45 | end 46 | end 47 | end 48 | -------------------------------------------------------------------------------- /app/history_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class HistoryAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :start_at, type: String 7 | optional :end_at, type: String 8 | optional :display, type: String 9 | optional :cursor, type: String 10 | optional :per_page, type: Integer 11 | optional :sort_by, type: Hash 12 | requires :path, type: String 13 | end 14 | get "/api/rest/v1/history/files/:path" do 15 | status 200 16 | [ { "id" => 1, "path" => "", "when" => "2000-01-01T01:00:00Z", "destination" => "/to_path", "display" => "Actual text of the action here.", "ip" => "192.283.128.182", "source" => "/from_path", "targets" => nil, "user_id" => 1, "username" => "user", "user_is_from_parent_site" => true, "action" => "create", "failure_type" => "none", "interface" => "web" } ] 17 | end 18 | 19 | params do 20 | optional :start_at, type: String 21 | optional :end_at, type: String 22 | optional :display, type: String 23 | optional :cursor, type: String 24 | optional :per_page, type: Integer 25 | optional :sort_by, type: Hash 26 | requires :path, type: String 27 | end 28 | get "/api/rest/v1/history/folders/:path" do 29 | status 200 30 | [ { "id" => 1, "path" => "", "when" => "2000-01-01T01:00:00Z", "destination" => "/to_path", "display" => "Actual text of the action here.", "ip" => "192.283.128.182", "source" => "/from_path", "targets" => nil, "user_id" => 1, "username" => "user", "user_is_from_parent_site" => true, "action" => "create", "failure_type" => "none", "interface" => "web" } ] 31 | end 32 | 33 | params do 34 | optional :start_at, type: String 35 | optional :end_at, type: String 36 | optional :display, type: String 37 | optional :cursor, type: String 38 | optional :per_page, type: Integer 39 | optional :sort_by, type: Hash 40 | requires :user_id, type: Integer 41 | end 42 | get "/api/rest/v1/history/users/:user_id" do 43 | status 200 44 | [ { "id" => 1, "path" => "", "when" => "2000-01-01T01:00:00Z", "destination" => "/to_path", "display" => "Actual text of the action here.", "ip" => "192.283.128.182", "source" => "/from_path", "targets" => nil, "user_id" => 1, "username" => "user", "user_is_from_parent_site" => true, "action" => "create", "failure_type" => "none", "interface" => "web" } ] 45 | end 46 | 47 | params do 48 | optional :start_at, type: String 49 | optional :end_at, type: String 50 | optional :display, type: String 51 | optional :cursor, type: String 52 | optional :per_page, type: Integer 53 | optional :sort_by, type: Hash 54 | end 55 | get "/api/rest/v1/history/login" do 56 | status 200 57 | [ { "id" => 1, "path" => "", "when" => "2000-01-01T01:00:00Z", "destination" => "/to_path", "display" => "Actual text of the action here.", "ip" => "192.283.128.182", "source" => "/from_path", "targets" => nil, "user_id" => 1, "username" => "user", "user_is_from_parent_site" => true, "action" => "create", "failure_type" => "none", "interface" => "web" } ] 58 | end 59 | 60 | params do 61 | optional :start_at, type: String 62 | optional :end_at, type: String 63 | optional :display, type: String 64 | optional :cursor, type: String 65 | optional :per_page, type: Integer 66 | optional :sort_by, type: Hash 67 | optional :filter, type: Hash 68 | optional :filter_prefix, type: Hash 69 | end 70 | get "/api/rest/v1/history" do 71 | status 200 72 | [ { "id" => 1, "path" => "", "when" => "2000-01-01T01:00:00Z", "destination" => "/to_path", "display" => "Actual text of the action here.", "ip" => "192.283.128.182", "source" => "/from_path", "targets" => nil, "user_id" => 1, "username" => "user", "user_is_from_parent_site" => true, "action" => "create", "failure_type" => "none", "interface" => "web" } ] 73 | end 74 | end 75 | end 76 | -------------------------------------------------------------------------------- /app/history_export_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class HistoryExportAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | requires :id, type: Integer 7 | end 8 | get "/api/rest/v1/history_exports/:id" do 9 | status 200 10 | { "id" => 1, "history_version" => "20201213.2", "start_at" => "2000-01-01T01:00:00Z", "end_at" => "2000-01-01T01:00:00Z", "status" => "ready", "query_action" => "read", "query_interface" => "ftp", "query_user_id" => "1", "query_file_id" => "1", "query_parent_id" => "1", "query_path" => "MyFile.txt", "query_folder" => "Folder", "query_src" => "SrcFolder", "query_destination" => "DestFolder", "query_ip" => "127.0.0.1", "query_username" => "jerry", "query_failure_type" => "bad_password", "query_target_id" => "1", "query_target_name" => "full", "query_target_permission" => "full", "query_target_user_id" => "1", "query_target_username" => "jerry", "query_target_platform" => "windows", "query_target_permission_set" => "desktop_app", "results_url" => "https://files.com/history_results.csv" } 11 | end 12 | 13 | params do 14 | optional :user_id, type: Integer 15 | optional :start_at, type: String 16 | optional :end_at, type: String 17 | optional :query_action, type: String 18 | optional :query_interface, type: String 19 | optional :query_user_id, type: String 20 | optional :query_file_id, type: String 21 | optional :query_parent_id, type: String 22 | optional :query_path, type: String 23 | optional :query_folder, type: String 24 | optional :query_src, type: String 25 | optional :query_destination, type: String 26 | optional :query_ip, type: String 27 | optional :query_username, type: String 28 | optional :query_failure_type, type: String 29 | optional :query_target_id, type: String 30 | optional :query_target_name, type: String 31 | optional :query_target_permission, type: String 32 | optional :query_target_user_id, type: String 33 | optional :query_target_username, type: String 34 | optional :query_target_platform, type: String 35 | optional :query_target_permission_set, type: String 36 | end 37 | post "/api/rest/v1/history_exports" do 38 | status 201 39 | { "id" => 1, "history_version" => "20201213.2", "start_at" => "2000-01-01T01:00:00Z", "end_at" => "2000-01-01T01:00:00Z", "status" => "ready", "query_action" => "read", "query_interface" => "ftp", "query_user_id" => "1", "query_file_id" => "1", "query_parent_id" => "1", "query_path" => "MyFile.txt", "query_folder" => "Folder", "query_src" => "SrcFolder", "query_destination" => "DestFolder", "query_ip" => "127.0.0.1", "query_username" => "jerry", "query_failure_type" => "bad_password", "query_target_id" => "1", "query_target_name" => "full", "query_target_permission" => "full", "query_target_user_id" => "1", "query_target_username" => "jerry", "query_target_platform" => "windows", "query_target_permission_set" => "desktop_app", "results_url" => "https://files.com/history_results.csv" } 40 | end 41 | end 42 | end 43 | -------------------------------------------------------------------------------- /app/history_export_result_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class HistoryExportResultAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :user_id, type: Integer 7 | optional :cursor, type: String 8 | optional :per_page, type: Integer 9 | requires :history_export_id, type: Integer 10 | end 11 | get "/api/rest/v1/history_export_results" do 12 | status 200 13 | [ { "id" => 1, "created_at" => 1, "created_at_iso8601" => "example", "user_id" => 1, "file_id" => 1, "parent_id" => 1, "path" => "MyFile.txt", "folder" => "Folder", "src" => "SrcFolder", "destination" => "DestFolder", "ip" => "127.0.0.1", "username" => "jerry", "user_is_from_parent_site" => true, "action" => "read", "failure_type" => "bad_password", "interface" => "ftp", "target_id" => 1, "target_name" => "full", "target_permission" => "full", "target_recursive" => true, "target_expires_at" => 1, "target_expires_at_iso8601" => "example", "target_permission_set" => "desktop_app", "target_platform" => "windows", "target_username" => "jerry", "target_user_id" => 1 } ] 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /app/inbox_recipient_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class InboxRecipientAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :cursor, type: String 7 | optional :per_page, type: Integer 8 | optional :sort_by, type: Hash 9 | optional :filter, type: Hash 10 | requires :inbox_id, type: Integer 11 | end 12 | get "/api/rest/v1/inbox_recipients" do 13 | status 200 14 | [ { "company" => "Acme Inc.", "name" => "John Doe", "note" => "Some note.", "recipient" => "john.doe@example.com", "sent_at" => "2000-01-01T01:00:00Z" } ] 15 | end 16 | 17 | params do 18 | requires :inbox_id, type: Integer 19 | requires :recipient, type: String 20 | optional :name, type: String 21 | optional :company, type: String 22 | optional :note, type: String 23 | optional :share_after_create, type: Boolean 24 | end 25 | post "/api/rest/v1/inbox_recipients" do 26 | status 201 27 | { "company" => "Acme Inc.", "name" => "John Doe", "note" => "Some note.", "recipient" => "john.doe@example.com", "sent_at" => "2000-01-01T01:00:00Z" } 28 | end 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /app/inbox_registration_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class InboxRegistrationAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :cursor, type: String 7 | optional :per_page, type: Integer 8 | optional :folder_behavior_id, type: Integer 9 | end 10 | get "/api/rest/v1/inbox_registrations" do 11 | status 200 12 | [ { "code" => "abc123", "name" => "account", "company" => "Action Verb", "email" => "john.doe@files.com", "ip" => "10.1.1.1", "clickwrap_body" => "example", "form_field_set_id" => 1, "form_field_data" => { "key" => "example value" }, "inbox_id" => 1, "inbox_recipient_id" => 1, "inbox_title" => "example", "created_at" => "2000-01-01T01:00:00Z" } ] 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /app/inbox_upload_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class InboxUploadAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :cursor, type: String 7 | optional :per_page, type: Integer 8 | optional :sort_by, type: Hash 9 | optional :filter, type: Hash 10 | optional :filter_gt, type: Hash 11 | optional :filter_gteq, type: Hash 12 | optional :filter_lt, type: Hash 13 | optional :filter_lteq, type: Hash 14 | end 15 | get "/api/rest/v1/inbox_uploads" do 16 | status 200 17 | [ { "inbox_registration" => { "code" => "abc123", "name" => "account", "company" => "Action Verb", "email" => "john.doe@files.com", "ip" => "10.1.1.1", "clickwrap_body" => "example", "form_field_set_id" => 1, "form_field_data" => { "key" => "example value" }, "inbox_id" => 1, "inbox_recipient_id" => 1, "inbox_title" => "example", "created_at" => "2000-01-01T01:00:00Z" }, "path" => "a/b/test.txt", "created_at" => "2000-01-01T01:00:00Z" } ] 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /app/invoice_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class InvoiceAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :cursor, type: String 7 | optional :per_page, type: Integer 8 | end 9 | get "/api/rest/v1/invoices" do 10 | status 200 11 | [ { "id" => 1, "amount" => 1.0, "balance" => 1.0, "created_at" => "2000-01-01T01:00:00Z", "currency" => "USD", "download_uri" => "https://url...", "invoice_line_items" => [ { "amount" => 1.0, "created_at" => "2000-01-01T01:00:00Z", "description" => "Service from 2019-01-01 through 2019-12-31", "type" => "invoice", "service_end_at" => "2000-01-01T01:00:00Z", "service_start_at" => "2000-01-01T01:00:00Z", "plan" => "Premier", "site" => "My site" } ], "method" => "paypal", "payment_line_items" => [ { "amount" => 1.0, "created_at" => "2000-01-01T01:00:00Z", "invoice_id" => 1, "payment_id" => 1 } ], "payment_reversed_at" => "2000-01-01T01:00:00Z", "payment_type" => "example", "site_name" => "My Site", "type" => "invoice" } ] 12 | end 13 | 14 | params do 15 | requires :id, type: Integer 16 | end 17 | get "/api/rest/v1/invoices/:id" do 18 | status 200 19 | { "id" => 1, "amount" => 1.0, "balance" => 1.0, "created_at" => "2000-01-01T01:00:00Z", "currency" => "USD", "download_uri" => "https://url...", "invoice_line_items" => [ { "amount" => 1.0, "created_at" => "2000-01-01T01:00:00Z", "description" => "Service from 2019-01-01 through 2019-12-31", "type" => "invoice", "service_end_at" => "2000-01-01T01:00:00Z", "service_start_at" => "2000-01-01T01:00:00Z", "plan" => "Premier", "site" => "My site" } ], "method" => "paypal", "payment_line_items" => [ { "amount" => 1.0, "created_at" => "2000-01-01T01:00:00Z", "invoice_id" => 1, "payment_id" => 1 } ], "payment_reversed_at" => "2000-01-01T01:00:00Z", "payment_type" => "example", "site_name" => "My Site", "type" => "invoice" } 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /app/ip_address_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class IpAddressAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :cursor, type: String 7 | optional :per_page, type: Integer 8 | end 9 | get "/api/rest/v1/ip_addresses" do 10 | status 200 11 | [ { "id" => "Site", "associated_with" => "Site", "group_id" => 1, "ip_addresses" => [ "127.0.0.1" ] } ] 12 | end 13 | 14 | params do 15 | optional :cursor, type: String 16 | optional :per_page, type: Integer 17 | end 18 | get "/api/rest/v1/ip_addresses/smartfile-reserved" do 19 | status 200 20 | [ { "ip_address" => "1.1.1.1", "server_name" => "server-1", "ftp_enabled" => true, "sftp_enabled" => true } ] 21 | end 22 | 23 | params do 24 | optional :cursor, type: String 25 | optional :per_page, type: Integer 26 | end 27 | get "/api/rest/v1/ip_addresses/exavault-reserved" do 28 | status 200 29 | [ { "ip_address" => "1.1.1.1", "server_name" => "server-1", "ftp_enabled" => true, "sftp_enabled" => true } ] 30 | end 31 | 32 | params do 33 | optional :cursor, type: String 34 | optional :per_page, type: Integer 35 | end 36 | get "/api/rest/v1/ip_addresses/reserved" do 37 | status 200 38 | [ { "ip_address" => "1.1.1.1", "server_name" => "server-1", "ftp_enabled" => true, "sftp_enabled" => true } ] 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /app/lock_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class LockAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :cursor, type: String 7 | optional :per_page, type: Integer 8 | requires :path, type: String 9 | optional :include_children, type: Boolean 10 | end 11 | get "/api/rest/v1/locks/:path" do 12 | status 200 13 | [ { "path" => "locked_file", "timeout" => 1, "depth" => "infinity", "recursive" => true, "owner" => "user", "scope" => "shared", "exclusive" => true, "token" => "17c54824e9931a4688ca032d03f6663c", "type" => "write", "allow_access_by_any_user" => true, "user_id" => 1, "username" => "" } ] 14 | end 15 | 16 | params do 17 | requires :path, type: String 18 | optional :allow_access_by_any_user, type: Boolean 19 | optional :exclusive, type: Boolean 20 | optional :recursive, type: Boolean 21 | optional :timeout, type: Integer 22 | end 23 | post "/api/rest/v1/locks/:path" do 24 | status 201 25 | { "path" => "locked_file", "timeout" => 1, "depth" => "infinity", "recursive" => true, "owner" => "user", "scope" => "shared", "exclusive" => true, "token" => "17c54824e9931a4688ca032d03f6663c", "type" => "write", "allow_access_by_any_user" => true, "user_id" => 1, "username" => "" } 26 | end 27 | 28 | params do 29 | requires :path, type: String 30 | requires :token, type: String 31 | end 32 | delete "/api/rest/v1/locks/:path" do 33 | status 204 34 | body false 35 | end 36 | end 37 | end 38 | -------------------------------------------------------------------------------- /app/message_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class MessageAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :user_id, type: Integer 7 | optional :cursor, type: String 8 | optional :per_page, type: Integer 9 | requires :project_id, type: Integer 10 | end 11 | get "/api/rest/v1/messages" do 12 | status 200 13 | [ { "id" => 1, "subject" => "Files.com Account Upgrade", "body" => "We should upgrade our Files.com account!", "comments" => [ { "id" => 1, "body" => "What a great idea, thank you!", "reactions" => [ { "id" => 1, "emoji" => "👍" } ] } ] } ] 14 | end 15 | 16 | params do 17 | requires :id, type: Integer 18 | end 19 | get "/api/rest/v1/messages/:id" do 20 | status 200 21 | { "id" => 1, "subject" => "Files.com Account Upgrade", "body" => "We should upgrade our Files.com account!", "comments" => [ { "id" => 1, "body" => "What a great idea, thank you!", "reactions" => [ { "id" => 1, "emoji" => "👍" } ] } ] } 22 | end 23 | 24 | params do 25 | optional :user_id, type: Integer 26 | requires :project_id, type: Integer 27 | requires :subject, type: String 28 | requires :body, type: String 29 | end 30 | post "/api/rest/v1/messages" do 31 | status 201 32 | { "id" => 1, "subject" => "Files.com Account Upgrade", "body" => "We should upgrade our Files.com account!", "comments" => [ { "id" => 1, "body" => "What a great idea, thank you!", "reactions" => [ { "id" => 1, "emoji" => "👍" } ] } ] } 33 | end 34 | 35 | params do 36 | requires :id, type: Integer 37 | requires :project_id, type: Integer 38 | requires :subject, type: String 39 | requires :body, type: String 40 | end 41 | patch "/api/rest/v1/messages/:id" do 42 | status 200 43 | { "id" => 1, "subject" => "Files.com Account Upgrade", "body" => "We should upgrade our Files.com account!", "comments" => [ { "id" => 1, "body" => "What a great idea, thank you!", "reactions" => [ { "id" => 1, "emoji" => "👍" } ] } ] } 44 | end 45 | 46 | params do 47 | requires :id, type: Integer 48 | end 49 | delete "/api/rest/v1/messages/:id" do 50 | status 204 51 | body false 52 | end 53 | end 54 | end 55 | -------------------------------------------------------------------------------- /app/message_comment_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class MessageCommentAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :user_id, type: Integer 7 | optional :cursor, type: String 8 | optional :per_page, type: Integer 9 | optional :sort_by, type: Hash 10 | requires :message_id, type: Integer 11 | end 12 | get "/api/rest/v1/message_comments" do 13 | status 200 14 | [ { "id" => 1, "body" => "What a great idea, thank you!", "reactions" => [ { "id" => 1, "emoji" => "👍" } ] } ] 15 | end 16 | 17 | params do 18 | requires :id, type: Integer 19 | end 20 | get "/api/rest/v1/message_comments/:id" do 21 | status 200 22 | { "id" => 1, "body" => "What a great idea, thank you!", "reactions" => [ { "id" => 1, "emoji" => "👍" } ] } 23 | end 24 | 25 | params do 26 | optional :user_id, type: Integer 27 | requires :body, type: String 28 | end 29 | post "/api/rest/v1/message_comments" do 30 | status 201 31 | { "id" => 1, "body" => "What a great idea, thank you!", "reactions" => [ { "id" => 1, "emoji" => "👍" } ] } 32 | end 33 | 34 | params do 35 | requires :id, type: Integer 36 | requires :body, type: String 37 | end 38 | patch "/api/rest/v1/message_comments/:id" do 39 | status 200 40 | { "id" => 1, "body" => "What a great idea, thank you!", "reactions" => [ { "id" => 1, "emoji" => "👍" } ] } 41 | end 42 | 43 | params do 44 | requires :id, type: Integer 45 | end 46 | delete "/api/rest/v1/message_comments/:id" do 47 | status 204 48 | body false 49 | end 50 | end 51 | end 52 | -------------------------------------------------------------------------------- /app/message_comment_reaction_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class MessageCommentReactionAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :user_id, type: Integer 7 | optional :cursor, type: String 8 | optional :per_page, type: Integer 9 | optional :sort_by, type: Hash 10 | requires :message_comment_id, type: Integer 11 | end 12 | get "/api/rest/v1/message_comment_reactions" do 13 | status 200 14 | [ { "id" => 1, "emoji" => "👍" } ] 15 | end 16 | 17 | params do 18 | requires :id, type: Integer 19 | end 20 | get "/api/rest/v1/message_comment_reactions/:id" do 21 | status 200 22 | { "id" => 1, "emoji" => "👍" } 23 | end 24 | 25 | params do 26 | optional :user_id, type: Integer 27 | requires :emoji, type: String 28 | end 29 | post "/api/rest/v1/message_comment_reactions" do 30 | status 201 31 | { "id" => 1, "emoji" => "👍" } 32 | end 33 | 34 | params do 35 | requires :id, type: Integer 36 | end 37 | delete "/api/rest/v1/message_comment_reactions/:id" do 38 | status 204 39 | body false 40 | end 41 | end 42 | end 43 | -------------------------------------------------------------------------------- /app/message_reaction_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class MessageReactionAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :user_id, type: Integer 7 | optional :cursor, type: String 8 | optional :per_page, type: Integer 9 | requires :message_id, type: Integer 10 | end 11 | get "/api/rest/v1/message_reactions" do 12 | status 200 13 | [ { "id" => 1, "emoji" => "👍" } ] 14 | end 15 | 16 | params do 17 | requires :id, type: Integer 18 | end 19 | get "/api/rest/v1/message_reactions/:id" do 20 | status 200 21 | { "id" => 1, "emoji" => "👍" } 22 | end 23 | 24 | params do 25 | optional :user_id, type: Integer 26 | requires :emoji, type: String 27 | end 28 | post "/api/rest/v1/message_reactions" do 29 | status 201 30 | { "id" => 1, "emoji" => "👍" } 31 | end 32 | 33 | params do 34 | requires :id, type: Integer 35 | end 36 | delete "/api/rest/v1/message_reactions/:id" do 37 | status 204 38 | body false 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /app/notification_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class NotificationAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :cursor, type: String 7 | optional :per_page, type: Integer 8 | optional :sort_by, type: Hash 9 | optional :filter, type: Hash 10 | optional :filter_prefix, type: Hash 11 | optional :path, type: String 12 | optional :include_ancestors, type: Boolean 13 | optional :group_id, type: String 14 | end 15 | get "/api/rest/v1/notifications" do 16 | status 200 17 | [ { "id" => 1, "path" => "", "group_id" => 1, "group_name" => "example", "triggering_group_ids" => [ 1 ], "triggering_user_ids" => [ 1 ], "trigger_by_share_recipients" => true, "notify_user_actions" => true, "notify_on_copy" => true, "notify_on_delete" => true, "notify_on_download" => true, "notify_on_move" => true, "notify_on_upload" => true, "recursive" => true, "send_interval" => "fifteen_minutes", "message" => "custom notification email message", "triggering_filenames" => [ "*.jpg", "notify_file.txt" ], "unsubscribed" => true, "unsubscribed_reason" => "example", "user_id" => 1, "username" => "User", "suppressed_email" => true } ] 18 | end 19 | 20 | params do 21 | requires :id, type: Integer 22 | end 23 | get "/api/rest/v1/notifications/:id" do 24 | status 200 25 | { "id" => 1, "path" => "", "group_id" => 1, "group_name" => "example", "triggering_group_ids" => [ 1 ], "triggering_user_ids" => [ 1 ], "trigger_by_share_recipients" => true, "notify_user_actions" => true, "notify_on_copy" => true, "notify_on_delete" => true, "notify_on_download" => true, "notify_on_move" => true, "notify_on_upload" => true, "recursive" => true, "send_interval" => "fifteen_minutes", "message" => "custom notification email message", "triggering_filenames" => [ "*.jpg", "notify_file.txt" ], "unsubscribed" => true, "unsubscribed_reason" => "example", "user_id" => 1, "username" => "User", "suppressed_email" => true } 26 | end 27 | 28 | params do 29 | optional :user_id, type: Integer 30 | optional :notify_on_copy, type: Boolean 31 | optional :notify_on_delete, type: Boolean 32 | optional :notify_on_download, type: Boolean 33 | optional :notify_on_move, type: Boolean 34 | optional :notify_on_upload, type: Boolean 35 | optional :notify_user_actions, type: Boolean 36 | optional :recursive, type: Boolean 37 | optional :send_interval, type: String 38 | optional :message, type: String 39 | optional :triggering_filenames, type: [ String ] 40 | optional :triggering_group_ids, type: [ Integer ] 41 | optional :triggering_user_ids, type: [ Integer ] 42 | optional :trigger_by_share_recipients, type: Boolean 43 | optional :group_id, type: Integer 44 | optional :path, type: String 45 | optional :username, type: String 46 | end 47 | post "/api/rest/v1/notifications" do 48 | status 201 49 | { "id" => 1, "path" => "", "group_id" => 1, "group_name" => "example", "triggering_group_ids" => [ 1 ], "triggering_user_ids" => [ 1 ], "trigger_by_share_recipients" => true, "notify_user_actions" => true, "notify_on_copy" => true, "notify_on_delete" => true, "notify_on_download" => true, "notify_on_move" => true, "notify_on_upload" => true, "recursive" => true, "send_interval" => "fifteen_minutes", "message" => "custom notification email message", "triggering_filenames" => [ "*.jpg", "notify_file.txt" ], "unsubscribed" => true, "unsubscribed_reason" => "example", "user_id" => 1, "username" => "User", "suppressed_email" => true } 50 | end 51 | 52 | params do 53 | requires :id, type: Integer 54 | optional :notify_on_copy, type: Boolean 55 | optional :notify_on_delete, type: Boolean 56 | optional :notify_on_download, type: Boolean 57 | optional :notify_on_move, type: Boolean 58 | optional :notify_on_upload, type: Boolean 59 | optional :notify_user_actions, type: Boolean 60 | optional :recursive, type: Boolean 61 | optional :send_interval, type: String 62 | optional :message, type: String 63 | optional :triggering_filenames, type: [ String ] 64 | optional :triggering_group_ids, type: [ Integer ] 65 | optional :triggering_user_ids, type: [ Integer ] 66 | optional :trigger_by_share_recipients, type: Boolean 67 | end 68 | patch "/api/rest/v1/notifications/:id" do 69 | status 200 70 | { "id" => 1, "path" => "", "group_id" => 1, "group_name" => "example", "triggering_group_ids" => [ 1 ], "triggering_user_ids" => [ 1 ], "trigger_by_share_recipients" => true, "notify_user_actions" => true, "notify_on_copy" => true, "notify_on_delete" => true, "notify_on_download" => true, "notify_on_move" => true, "notify_on_upload" => true, "recursive" => true, "send_interval" => "fifteen_minutes", "message" => "custom notification email message", "triggering_filenames" => [ "*.jpg", "notify_file.txt" ], "unsubscribed" => true, "unsubscribed_reason" => "example", "user_id" => 1, "username" => "User", "suppressed_email" => true } 71 | end 72 | 73 | params do 74 | requires :id, type: Integer 75 | end 76 | delete "/api/rest/v1/notifications/:id" do 77 | status 204 78 | body false 79 | end 80 | end 81 | end 82 | -------------------------------------------------------------------------------- /app/outbound_connection_log_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class OutboundConnectionLogAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :cursor, type: String 7 | optional :per_page, type: Integer 8 | optional :filter, type: Hash 9 | optional :filter_prefix, type: Hash 10 | end 11 | get "/api/rest/v1/outbound_connection_logs" do 12 | status 200 13 | [ { "timestamp" => "2000-01-01T01:00:00Z", "path" => "example", "client_ip" => "example", "src_remote_server_id" => 1, "dest_remote_server_id" => 1, "operation" => "example", "error_message" => "example", "error_operation" => "example", "error_type" => "example", "status" => "example", "duration_ms" => 1, "bytes_uploaded" => 1, "bytes_downloaded" => 1, "list_count" => 1 } ] 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /app/payment_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class PaymentAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :cursor, type: String 7 | optional :per_page, type: Integer 8 | end 9 | get "/api/rest/v1/payments" do 10 | status 200 11 | [ { "id" => 1, "amount" => 1.0, "balance" => 1.0, "created_at" => "2000-01-01T01:00:00Z", "currency" => "USD", "download_uri" => "https://url...", "invoice_line_items" => [ { "amount" => 1.0, "created_at" => "2000-01-01T01:00:00Z", "description" => "Service from 2019-01-01 through 2019-12-31", "type" => "invoice", "service_end_at" => "2000-01-01T01:00:00Z", "service_start_at" => "2000-01-01T01:00:00Z", "plan" => "Premier", "site" => "My site" } ], "method" => "paypal", "payment_line_items" => [ { "amount" => 1.0, "created_at" => "2000-01-01T01:00:00Z", "invoice_id" => 1, "payment_id" => 1 } ], "payment_reversed_at" => "2000-01-01T01:00:00Z", "payment_type" => "example", "site_name" => "My Site", "type" => "invoice" } ] 12 | end 13 | 14 | params do 15 | requires :id, type: Integer 16 | end 17 | get "/api/rest/v1/payments/:id" do 18 | status 200 19 | { "id" => 1, "amount" => 1.0, "balance" => 1.0, "created_at" => "2000-01-01T01:00:00Z", "currency" => "USD", "download_uri" => "https://url...", "invoice_line_items" => [ { "amount" => 1.0, "created_at" => "2000-01-01T01:00:00Z", "description" => "Service from 2019-01-01 through 2019-12-31", "type" => "invoice", "service_end_at" => "2000-01-01T01:00:00Z", "service_start_at" => "2000-01-01T01:00:00Z", "plan" => "Premier", "site" => "My site" } ], "method" => "paypal", "payment_line_items" => [ { "amount" => 1.0, "created_at" => "2000-01-01T01:00:00Z", "invoice_id" => 1, "payment_id" => 1 } ], "payment_reversed_at" => "2000-01-01T01:00:00Z", "payment_type" => "example", "site_name" => "My Site", "type" => "invoice" } 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /app/permission_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class PermissionAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :cursor, type: String 7 | optional :per_page, type: Integer 8 | optional :sort_by, type: Hash 9 | optional :filter, type: Hash 10 | optional :filter_prefix, type: Hash 11 | optional :path, type: String 12 | optional :include_groups, type: Boolean 13 | optional :group_id, type: String 14 | optional :user_id, type: String 15 | end 16 | get "/api/rest/v1/permissions" do 17 | status 200 18 | [ { "id" => 1, "path" => "example", "user_id" => 1, "username" => "user", "group_id" => 1, "group_name" => "example", "permission" => "full", "recursive" => true, "site_id" => 1 } ] 19 | end 20 | 21 | params do 22 | requires :path, type: String 23 | optional :group_id, type: Integer 24 | optional :permission, type: String 25 | optional :recursive, type: Boolean 26 | optional :user_id, type: Integer 27 | optional :username, type: String 28 | optional :group_name, type: String 29 | optional :site_id, type: Integer 30 | end 31 | post "/api/rest/v1/permissions" do 32 | status 201 33 | { "id" => 1, "path" => "example", "user_id" => 1, "username" => "user", "group_id" => 1, "group_name" => "example", "permission" => "full", "recursive" => true, "site_id" => 1 } 34 | end 35 | 36 | params do 37 | requires :id, type: Integer 38 | end 39 | delete "/api/rest/v1/permissions/:id" do 40 | status 204 41 | body false 42 | end 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /app/priority_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class PriorityAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :cursor, type: String 7 | optional :per_page, type: Integer 8 | requires :path, type: String 9 | end 10 | get "/api/rest/v1/priorities" do 11 | status 200 12 | [ { "path" => "foo/bar", "color" => "pink" } ] 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /app/project_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class ProjectAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :cursor, type: String 7 | optional :per_page, type: Integer 8 | end 9 | get "/api/rest/v1/projects" do 10 | status 200 11 | [ { "id" => 1, "global_access" => "none" } ] 12 | end 13 | 14 | params do 15 | requires :id, type: Integer 16 | end 17 | get "/api/rest/v1/projects/:id" do 18 | status 200 19 | { "id" => 1, "global_access" => "none" } 20 | end 21 | 22 | params do 23 | requires :global_access, type: String 24 | end 25 | post "/api/rest/v1/projects" do 26 | status 201 27 | { "id" => 1, "global_access" => "none" } 28 | end 29 | 30 | params do 31 | requires :id, type: Integer 32 | requires :global_access, type: String 33 | end 34 | patch "/api/rest/v1/projects/:id" do 35 | status 200 36 | { "id" => 1, "global_access" => "none" } 37 | end 38 | 39 | params do 40 | requires :id, type: Integer 41 | end 42 | delete "/api/rest/v1/projects/:id" do 43 | status 204 44 | body false 45 | end 46 | end 47 | end 48 | -------------------------------------------------------------------------------- /app/public_hosting_request_log_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class PublicHostingRequestLogAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :cursor, type: String 7 | optional :per_page, type: Integer 8 | optional :filter, type: Hash 9 | optional :filter_prefix, type: Hash 10 | end 11 | get "/api/rest/v1/public_hosting_request_logs" do 12 | status 200 13 | [ { "timestamp" => "2000-01-01T01:00:00Z", "remote_ip" => "example", "server_ip" => "example", "hostname" => "example", "path" => "example", "responseCode" => 1, "success" => true, "duration_ms" => 1 } ] 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /app/public_key_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class PublicKeyAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :user_id, type: Integer 7 | optional :cursor, type: String 8 | optional :per_page, type: Integer 9 | optional :filter, type: Hash 10 | optional :filter_gt, type: Hash 11 | optional :filter_gteq, type: Hash 12 | optional :filter_lt, type: Hash 13 | optional :filter_lteq, type: Hash 14 | end 15 | get "/api/rest/v1/public_keys" do 16 | status 200 17 | [ { "id" => 1, "title" => "My public key", "created_at" => "2000-01-01T01:00:00Z", "fingerprint" => "43:51:43:a1:b5:fc:8b:b7:0a:3a:a9:b1:0f:66:73:a8", "fingerprint_sha256" => "V5Q5t/ghT3R8Tol5GX9385bzmpygWVRnLuI9EXNrjCX", "last_login_at" => "2000-01-01T01:00:00Z", "username" => "User", "user_id" => 1 } ] 18 | end 19 | 20 | params do 21 | requires :id, type: Integer 22 | end 23 | get "/api/rest/v1/public_keys/:id" do 24 | status 200 25 | { "id" => 1, "title" => "My public key", "created_at" => "2000-01-01T01:00:00Z", "fingerprint" => "43:51:43:a1:b5:fc:8b:b7:0a:3a:a9:b1:0f:66:73:a8", "fingerprint_sha256" => "V5Q5t/ghT3R8Tol5GX9385bzmpygWVRnLuI9EXNrjCX", "last_login_at" => "2000-01-01T01:00:00Z", "username" => "User", "user_id" => 1 } 26 | end 27 | 28 | params do 29 | optional :user_id, type: Integer 30 | requires :title, type: String 31 | requires :public_key, type: String 32 | end 33 | post "/api/rest/v1/public_keys" do 34 | status 201 35 | { "id" => 1, "title" => "My public key", "created_at" => "2000-01-01T01:00:00Z", "fingerprint" => "43:51:43:a1:b5:fc:8b:b7:0a:3a:a9:b1:0f:66:73:a8", "fingerprint_sha256" => "V5Q5t/ghT3R8Tol5GX9385bzmpygWVRnLuI9EXNrjCX", "last_login_at" => "2000-01-01T01:00:00Z", "username" => "User", "user_id" => 1 } 36 | end 37 | 38 | params do 39 | requires :id, type: Integer 40 | requires :title, type: String 41 | end 42 | patch "/api/rest/v1/public_keys/:id" do 43 | status 200 44 | { "id" => 1, "title" => "My public key", "created_at" => "2000-01-01T01:00:00Z", "fingerprint" => "43:51:43:a1:b5:fc:8b:b7:0a:3a:a9:b1:0f:66:73:a8", "fingerprint_sha256" => "V5Q5t/ghT3R8Tol5GX9385bzmpygWVRnLuI9EXNrjCX", "last_login_at" => "2000-01-01T01:00:00Z", "username" => "User", "user_id" => 1 } 45 | end 46 | 47 | params do 48 | requires :id, type: Integer 49 | end 50 | delete "/api/rest/v1/public_keys/:id" do 51 | status 204 52 | body false 53 | end 54 | end 55 | end 56 | -------------------------------------------------------------------------------- /app/remote_bandwidth_snapshot_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class RemoteBandwidthSnapshotAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :cursor, type: String 7 | optional :per_page, type: Integer 8 | optional :sort_by, type: Hash 9 | optional :filter, type: Hash 10 | optional :filter_gt, type: Hash 11 | optional :filter_gteq, type: Hash 12 | optional :filter_lt, type: Hash 13 | optional :filter_lteq, type: Hash 14 | end 15 | get "/api/rest/v1/remote_bandwidth_snapshots" do 16 | status 200 17 | [ { "id" => 1, "sync_bytes_received" => 1.0, "sync_bytes_sent" => 1.0, "logged_at" => "2000-01-01T01:00:00Z", "remote_server_id" => 1 } ] 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /app/request_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class RequestAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :cursor, type: String 7 | optional :per_page, type: Integer 8 | optional :sort_by, type: Hash 9 | optional :mine, type: Boolean 10 | optional :path, type: String 11 | end 12 | get "/api/rest/v1/requests" do 13 | status 200 14 | [ { "id" => 1, "path" => "example", "source" => "example", "destination" => "example", "automation_id" => 1, "user_display_name" => "example" } ] 15 | end 16 | 17 | params do 18 | optional :cursor, type: String 19 | optional :per_page, type: Integer 20 | optional :sort_by, type: Hash 21 | optional :mine, type: Boolean 22 | requires :path, type: String 23 | end 24 | get "/api/rest/v1/requests/folders/:path" do 25 | status 200 26 | [ { "id" => 1, "path" => "example", "source" => "example", "destination" => "example", "automation_id" => 1, "user_display_name" => "example" } ] 27 | end 28 | 29 | params do 30 | requires :path, type: String 31 | requires :destination, type: String 32 | optional :user_ids, type: String 33 | optional :group_ids, type: String 34 | end 35 | post "/api/rest/v1/requests" do 36 | status 201 37 | { "id" => 1, "path" => "example", "source" => "example", "destination" => "example", "automation_id" => 1, "user_display_name" => "example" } 38 | end 39 | 40 | params do 41 | requires :id, type: Integer 42 | end 43 | delete "/api/rest/v1/requests/:id" do 44 | status 204 45 | body false 46 | end 47 | end 48 | end 49 | -------------------------------------------------------------------------------- /app/restore_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class RestoreAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :cursor, type: String 7 | optional :per_page, type: Integer 8 | end 9 | get "/api/rest/v1/restores" do 10 | status 200 11 | [ { "earliest_date" => "2000-01-01T01:00:00Z", "id" => 1, "dirs_restored" => 1, "dirs_errored" => 1, "dirs_total" => 1, "files_restored" => 1, "files_errored" => 1, "files_total" => 1, "prefix" => "foo/bar/baz.txt", "restore_in_place" => true, "restore_deleted_permissions" => true, "status" => "pending", "update_timestamps" => true, "error_messages" => [ "example" ] } ] 12 | end 13 | 14 | params do 15 | requires :earliest_date, type: String 16 | optional :prefix, type: String 17 | optional :restore_deleted_permissions, type: Boolean 18 | optional :restore_in_place, type: Boolean 19 | optional :update_timestamps, type: Boolean 20 | end 21 | post "/api/rest/v1/restores" do 22 | status 201 23 | { "earliest_date" => "2000-01-01T01:00:00Z", "id" => 1, "dirs_restored" => 1, "dirs_errored" => 1, "dirs_total" => 1, "files_restored" => 1, "files_errored" => 1, "files_total" => 1, "prefix" => "foo/bar/baz.txt", "restore_in_place" => true, "restore_deleted_permissions" => true, "status" => "pending", "update_timestamps" => true, "error_messages" => [ "example" ] } 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /app/session_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class SessionAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :username, type: String 7 | optional :password, type: String 8 | optional :otp, type: String 9 | optional :partial_session_id, type: String 10 | end 11 | post "/api/rest/v1/sessions" do 12 | status 201 13 | { "id" => "60525f92e859c4c3d74cb02fd176b1525901b525", "language" => "en", "read_only" => true, "sftp_insecure_ciphers" => true } 14 | end 15 | 16 | delete "/api/rest/v1/sessions" do 17 | status 204 18 | body false 19 | end 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /app/settings_change_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class SettingsChangeAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :cursor, type: String 7 | optional :per_page, type: Integer 8 | optional :sort_by, type: Hash 9 | optional :filter, type: Hash 10 | end 11 | get "/api/rest/v1/settings_changes" do 12 | status 200 13 | [ { "api_key_id" => 1, "changes" => [ "example" ], "created_at" => "2000-01-01T01:00:00Z", "user_id" => 1, "user_is_files_support" => true, "user_is_from_parent_site" => true, "username" => "some_user" } ] 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /app/sftp_action_log_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class SftpActionLogAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :cursor, type: String 7 | optional :per_page, type: Integer 8 | optional :filter, type: Hash 9 | optional :filter_prefix, type: Hash 10 | end 11 | get "/api/rest/v1/sftp_action_logs" do 12 | status 200 13 | [ { "timestamp" => "2000-01-01T01:00:00Z", "remote_ip" => "example", "server_ip" => "example", "username" => "example", "ssh_client_identification" => "example", "session_uuid" => "example", "seq_id" => 1, "auth_method" => "example", "auth_ciphers" => "example", "action_type" => "example", "path" => "example", "true_path" => "example", "name" => "example", "sftp_response_code" => "example", "sftp_response_message" => "example", "md5" => "example", "size" => 1, "data_length" => 1, "bytes_transferred" => 1, "entries_returned" => 1, "success" => true, "status" => "example", "duration_ms" => 1 } ] 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /app/sftp_host_key_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class SftpHostKeyAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :cursor, type: String 7 | optional :per_page, type: Integer 8 | end 9 | get "/api/rest/v1/sftp_host_keys" do 10 | status 200 11 | [ { "id" => 1, "name" => "My Key", "fingerprint_md5" => "12:7e:f8:61:78:a4:b2:c2:ee:12:51:92:25:a7:42:cc", "fingerprint_sha256" => "SHA256:5ANRkDpXWA+PgOquzZAG9RtQ1Bt8KXYAH2hecr7LQk8" } ] 12 | end 13 | 14 | params do 15 | requires :id, type: Integer 16 | end 17 | get "/api/rest/v1/sftp_host_keys/:id" do 18 | status 200 19 | { "id" => 1, "name" => "My Key", "fingerprint_md5" => "12:7e:f8:61:78:a4:b2:c2:ee:12:51:92:25:a7:42:cc", "fingerprint_sha256" => "SHA256:5ANRkDpXWA+PgOquzZAG9RtQ1Bt8KXYAH2hecr7LQk8" } 20 | end 21 | 22 | params do 23 | optional :name, type: String 24 | optional :private_key, type: String 25 | end 26 | post "/api/rest/v1/sftp_host_keys" do 27 | status 201 28 | { "id" => 1, "name" => "My Key", "fingerprint_md5" => "12:7e:f8:61:78:a4:b2:c2:ee:12:51:92:25:a7:42:cc", "fingerprint_sha256" => "SHA256:5ANRkDpXWA+PgOquzZAG9RtQ1Bt8KXYAH2hecr7LQk8" } 29 | end 30 | 31 | params do 32 | requires :id, type: Integer 33 | optional :name, type: String 34 | optional :private_key, type: String 35 | end 36 | patch "/api/rest/v1/sftp_host_keys/:id" do 37 | status 200 38 | { "id" => 1, "name" => "My Key", "fingerprint_md5" => "12:7e:f8:61:78:a4:b2:c2:ee:12:51:92:25:a7:42:cc", "fingerprint_sha256" => "SHA256:5ANRkDpXWA+PgOquzZAG9RtQ1Bt8KXYAH2hecr7LQk8" } 39 | end 40 | 41 | params do 42 | requires :id, type: Integer 43 | end 44 | delete "/api/rest/v1/sftp_host_keys/:id" do 45 | status 204 46 | body false 47 | end 48 | end 49 | end 50 | -------------------------------------------------------------------------------- /app/share_group_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class ShareGroupAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :user_id, type: Integer 7 | optional :cursor, type: String 8 | optional :per_page, type: Integer 9 | end 10 | get "/api/rest/v1/share_groups" do 11 | status 200 12 | [ { "id" => 1, "name" => "Test group 1", "notes" => "This group is defined for testing purposes", "user_id" => 1, "members" => [ { "name" => "John Doe", "company" => "Acme Ltd", "email" => "johndoe@gmail.com" } ] } ] 13 | end 14 | 15 | params do 16 | requires :id, type: Integer 17 | end 18 | get "/api/rest/v1/share_groups/:id" do 19 | status 200 20 | { "id" => 1, "name" => "Test group 1", "notes" => "This group is defined for testing purposes", "user_id" => 1, "members" => [ { "name" => "John Doe", "company" => "Acme Ltd", "email" => "johndoe@gmail.com" } ] } 21 | end 22 | 23 | params do 24 | optional :user_id, type: Integer 25 | optional :notes, type: String 26 | requires :name, type: String 27 | requires :members, type: [ Hash ] 28 | end 29 | post "/api/rest/v1/share_groups" do 30 | status 201 31 | { "id" => 1, "name" => "Test group 1", "notes" => "This group is defined for testing purposes", "user_id" => 1, "members" => [ { "name" => "John Doe", "company" => "Acme Ltd", "email" => "johndoe@gmail.com" } ] } 32 | end 33 | 34 | params do 35 | requires :id, type: Integer 36 | optional :notes, type: String 37 | optional :name, type: String 38 | optional :members, type: [ Hash ] 39 | end 40 | patch "/api/rest/v1/share_groups/:id" do 41 | status 200 42 | { "id" => 1, "name" => "Test group 1", "notes" => "This group is defined for testing purposes", "user_id" => 1, "members" => [ { "name" => "John Doe", "company" => "Acme Ltd", "email" => "johndoe@gmail.com" } ] } 43 | end 44 | 45 | params do 46 | requires :id, type: Integer 47 | end 48 | delete "/api/rest/v1/share_groups/:id" do 49 | status 204 50 | body false 51 | end 52 | end 53 | end 54 | -------------------------------------------------------------------------------- /app/siem_http_destination_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class SiemHttpDestinationAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :cursor, type: String 7 | optional :per_page, type: Integer 8 | end 9 | get "/api/rest/v1/siem_http_destinations" do 10 | status 200 11 | [ { "id" => 1, "name" => "example", "destination_type" => "example", "destination_url" => "example", "additional_headers" => { "key" => "example value" }, "sending_active" => true, "generic_payload_type" => "example", "splunk_token_masked" => "example", "azure_dcr_immutable_id" => "example", "azure_stream_name" => "example", "azure_oauth_client_credentials_tenant_id" => "example", "azure_oauth_client_credentials_client_id" => "example", "azure_oauth_client_credentials_client_secret_masked" => "example", "qradar_username" => "example", "qradar_password_masked" => "example", "solar_winds_token_masked" => "example", "new_relic_api_key_masked" => "example", "datadog_api_key_masked" => "example", "sftp_action_send_enabled" => true, "sftp_action_entries_sent" => 1, "ftp_action_send_enabled" => true, "ftp_action_entries_sent" => 1, "web_dav_action_send_enabled" => true, "web_dav_action_entries_sent" => 1, "sync_send_enabled" => true, "sync_entries_sent" => 1, "outbound_connection_send_enabled" => true, "outbound_connection_entries_sent" => 1, "automation_send_enabled" => true, "automation_entries_sent" => 1, "api_request_send_enabled" => true, "api_request_entries_sent" => 1, "public_hosting_request_send_enabled" => true, "public_hosting_request_entries_sent" => 1, "email_send_enabled" => true, "email_entries_sent" => 1, "exavault_api_request_send_enabled" => true, "exavault_api_request_entries_sent" => 1, "settings_change_send_enabled" => true, "settings_change_entries_sent" => 1, "last_http_call_target_type" => "destination_url", "last_http_call_success" => true, "last_http_call_response_code" => 1, "last_http_call_response_body" => "example", "last_http_call_error_message" => "example", "last_http_call_time" => "example", "last_http_call_duration_ms" => 1, "most_recent_http_call_success_time" => "example", "connection_test_entry" => "example" } ] 12 | end 13 | 14 | params do 15 | requires :id, type: Integer 16 | end 17 | get "/api/rest/v1/siem_http_destinations/:id" do 18 | status 200 19 | { "id" => 1, "name" => "example", "destination_type" => "example", "destination_url" => "example", "additional_headers" => { "key" => "example value" }, "sending_active" => true, "generic_payload_type" => "example", "splunk_token_masked" => "example", "azure_dcr_immutable_id" => "example", "azure_stream_name" => "example", "azure_oauth_client_credentials_tenant_id" => "example", "azure_oauth_client_credentials_client_id" => "example", "azure_oauth_client_credentials_client_secret_masked" => "example", "qradar_username" => "example", "qradar_password_masked" => "example", "solar_winds_token_masked" => "example", "new_relic_api_key_masked" => "example", "datadog_api_key_masked" => "example", "sftp_action_send_enabled" => true, "sftp_action_entries_sent" => 1, "ftp_action_send_enabled" => true, "ftp_action_entries_sent" => 1, "web_dav_action_send_enabled" => true, "web_dav_action_entries_sent" => 1, "sync_send_enabled" => true, "sync_entries_sent" => 1, "outbound_connection_send_enabled" => true, "outbound_connection_entries_sent" => 1, "automation_send_enabled" => true, "automation_entries_sent" => 1, "api_request_send_enabled" => true, "api_request_entries_sent" => 1, "public_hosting_request_send_enabled" => true, "public_hosting_request_entries_sent" => 1, "email_send_enabled" => true, "email_entries_sent" => 1, "exavault_api_request_send_enabled" => true, "exavault_api_request_entries_sent" => 1, "settings_change_send_enabled" => true, "settings_change_entries_sent" => 1, "last_http_call_target_type" => "destination_url", "last_http_call_success" => true, "last_http_call_response_code" => 1, "last_http_call_response_body" => "example", "last_http_call_error_message" => "example", "last_http_call_time" => "example", "last_http_call_duration_ms" => 1, "most_recent_http_call_success_time" => "example", "connection_test_entry" => "example" } 20 | end 21 | 22 | params do 23 | optional :name, type: String 24 | optional :additional_headers, type: Hash 25 | optional :sending_active, type: Boolean 26 | optional :generic_payload_type, type: String 27 | optional :splunk_token, type: String 28 | optional :azure_dcr_immutable_id, type: String 29 | optional :azure_stream_name, type: String 30 | optional :azure_oauth_client_credentials_tenant_id, type: String 31 | optional :azure_oauth_client_credentials_client_id, type: String 32 | optional :azure_oauth_client_credentials_client_secret, type: String 33 | optional :qradar_username, type: String 34 | optional :qradar_password, type: String 35 | optional :solar_winds_token, type: String 36 | optional :new_relic_api_key, type: String 37 | optional :datadog_api_key, type: String 38 | optional :sftp_action_send_enabled, type: Boolean 39 | optional :ftp_action_send_enabled, type: Boolean 40 | optional :web_dav_action_send_enabled, type: Boolean 41 | optional :sync_send_enabled, type: Boolean 42 | optional :outbound_connection_send_enabled, type: Boolean 43 | optional :automation_send_enabled, type: Boolean 44 | optional :api_request_send_enabled, type: Boolean 45 | optional :public_hosting_request_send_enabled, type: Boolean 46 | optional :email_send_enabled, type: Boolean 47 | optional :exavault_api_request_send_enabled, type: Boolean 48 | optional :settings_change_send_enabled, type: Boolean 49 | requires :destination_type, type: String 50 | requires :destination_url, type: String 51 | end 52 | post "/api/rest/v1/siem_http_destinations" do 53 | status 201 54 | { "id" => 1, "name" => "example", "destination_type" => "example", "destination_url" => "example", "additional_headers" => { "key" => "example value" }, "sending_active" => true, "generic_payload_type" => "example", "splunk_token_masked" => "example", "azure_dcr_immutable_id" => "example", "azure_stream_name" => "example", "azure_oauth_client_credentials_tenant_id" => "example", "azure_oauth_client_credentials_client_id" => "example", "azure_oauth_client_credentials_client_secret_masked" => "example", "qradar_username" => "example", "qradar_password_masked" => "example", "solar_winds_token_masked" => "example", "new_relic_api_key_masked" => "example", "datadog_api_key_masked" => "example", "sftp_action_send_enabled" => true, "sftp_action_entries_sent" => 1, "ftp_action_send_enabled" => true, "ftp_action_entries_sent" => 1, "web_dav_action_send_enabled" => true, "web_dav_action_entries_sent" => 1, "sync_send_enabled" => true, "sync_entries_sent" => 1, "outbound_connection_send_enabled" => true, "outbound_connection_entries_sent" => 1, "automation_send_enabled" => true, "automation_entries_sent" => 1, "api_request_send_enabled" => true, "api_request_entries_sent" => 1, "public_hosting_request_send_enabled" => true, "public_hosting_request_entries_sent" => 1, "email_send_enabled" => true, "email_entries_sent" => 1, "exavault_api_request_send_enabled" => true, "exavault_api_request_entries_sent" => 1, "settings_change_send_enabled" => true, "settings_change_entries_sent" => 1, "last_http_call_target_type" => "destination_url", "last_http_call_success" => true, "last_http_call_response_code" => 1, "last_http_call_response_body" => "example", "last_http_call_error_message" => "example", "last_http_call_time" => "example", "last_http_call_duration_ms" => 1, "most_recent_http_call_success_time" => "example", "connection_test_entry" => "example" } 55 | end 56 | 57 | params do 58 | optional :siem_http_destination_id, type: Integer 59 | optional :destination_type, type: String 60 | optional :destination_url, type: String 61 | optional :name, type: String 62 | optional :additional_headers, type: Hash 63 | optional :sending_active, type: Boolean 64 | optional :generic_payload_type, type: String 65 | optional :splunk_token, type: String 66 | optional :azure_dcr_immutable_id, type: String 67 | optional :azure_stream_name, type: String 68 | optional :azure_oauth_client_credentials_tenant_id, type: String 69 | optional :azure_oauth_client_credentials_client_id, type: String 70 | optional :azure_oauth_client_credentials_client_secret, type: String 71 | optional :qradar_username, type: String 72 | optional :qradar_password, type: String 73 | optional :solar_winds_token, type: String 74 | optional :new_relic_api_key, type: String 75 | optional :datadog_api_key, type: String 76 | optional :sftp_action_send_enabled, type: Boolean 77 | optional :ftp_action_send_enabled, type: Boolean 78 | optional :web_dav_action_send_enabled, type: Boolean 79 | optional :sync_send_enabled, type: Boolean 80 | optional :outbound_connection_send_enabled, type: Boolean 81 | optional :automation_send_enabled, type: Boolean 82 | optional :api_request_send_enabled, type: Boolean 83 | optional :public_hosting_request_send_enabled, type: Boolean 84 | optional :email_send_enabled, type: Boolean 85 | optional :exavault_api_request_send_enabled, type: Boolean 86 | optional :settings_change_send_enabled, type: Boolean 87 | end 88 | post "/api/rest/v1/siem_http_destinations/send_test_entry" do 89 | status 204 90 | body false 91 | end 92 | 93 | params do 94 | requires :id, type: Integer 95 | optional :name, type: String 96 | optional :additional_headers, type: Hash 97 | optional :sending_active, type: Boolean 98 | optional :generic_payload_type, type: String 99 | optional :splunk_token, type: String 100 | optional :azure_dcr_immutable_id, type: String 101 | optional :azure_stream_name, type: String 102 | optional :azure_oauth_client_credentials_tenant_id, type: String 103 | optional :azure_oauth_client_credentials_client_id, type: String 104 | optional :azure_oauth_client_credentials_client_secret, type: String 105 | optional :qradar_username, type: String 106 | optional :qradar_password, type: String 107 | optional :solar_winds_token, type: String 108 | optional :new_relic_api_key, type: String 109 | optional :datadog_api_key, type: String 110 | optional :sftp_action_send_enabled, type: Boolean 111 | optional :ftp_action_send_enabled, type: Boolean 112 | optional :web_dav_action_send_enabled, type: Boolean 113 | optional :sync_send_enabled, type: Boolean 114 | optional :outbound_connection_send_enabled, type: Boolean 115 | optional :automation_send_enabled, type: Boolean 116 | optional :api_request_send_enabled, type: Boolean 117 | optional :public_hosting_request_send_enabled, type: Boolean 118 | optional :email_send_enabled, type: Boolean 119 | optional :exavault_api_request_send_enabled, type: Boolean 120 | optional :settings_change_send_enabled, type: Boolean 121 | optional :destination_type, type: String 122 | optional :destination_url, type: String 123 | end 124 | patch "/api/rest/v1/siem_http_destinations/:id" do 125 | status 200 126 | { "id" => 1, "name" => "example", "destination_type" => "example", "destination_url" => "example", "additional_headers" => { "key" => "example value" }, "sending_active" => true, "generic_payload_type" => "example", "splunk_token_masked" => "example", "azure_dcr_immutable_id" => "example", "azure_stream_name" => "example", "azure_oauth_client_credentials_tenant_id" => "example", "azure_oauth_client_credentials_client_id" => "example", "azure_oauth_client_credentials_client_secret_masked" => "example", "qradar_username" => "example", "qradar_password_masked" => "example", "solar_winds_token_masked" => "example", "new_relic_api_key_masked" => "example", "datadog_api_key_masked" => "example", "sftp_action_send_enabled" => true, "sftp_action_entries_sent" => 1, "ftp_action_send_enabled" => true, "ftp_action_entries_sent" => 1, "web_dav_action_send_enabled" => true, "web_dav_action_entries_sent" => 1, "sync_send_enabled" => true, "sync_entries_sent" => 1, "outbound_connection_send_enabled" => true, "outbound_connection_entries_sent" => 1, "automation_send_enabled" => true, "automation_entries_sent" => 1, "api_request_send_enabled" => true, "api_request_entries_sent" => 1, "public_hosting_request_send_enabled" => true, "public_hosting_request_entries_sent" => 1, "email_send_enabled" => true, "email_entries_sent" => 1, "exavault_api_request_send_enabled" => true, "exavault_api_request_entries_sent" => 1, "settings_change_send_enabled" => true, "settings_change_entries_sent" => 1, "last_http_call_target_type" => "destination_url", "last_http_call_success" => true, "last_http_call_response_code" => 1, "last_http_call_response_body" => "example", "last_http_call_error_message" => "example", "last_http_call_time" => "example", "last_http_call_duration_ms" => 1, "most_recent_http_call_success_time" => "example", "connection_test_entry" => "example" } 127 | end 128 | 129 | params do 130 | requires :id, type: Integer 131 | end 132 | delete "/api/rest/v1/siem_http_destinations/:id" do 133 | status 204 134 | body false 135 | end 136 | end 137 | end 138 | -------------------------------------------------------------------------------- /app/snapshot_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class SnapshotAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :cursor, type: String 7 | optional :per_page, type: Integer 8 | end 9 | get "/api/rest/v1/snapshots" do 10 | status 200 11 | [ { "id" => 1, "expires_at" => "2000-01-01T01:00:00Z", "finalized_at" => "2000-01-01T01:00:00Z", "name" => "My Snapshot", "user_id" => 1, "bundle_id" => 1 } ] 12 | end 13 | 14 | params do 15 | requires :id, type: Integer 16 | end 17 | get "/api/rest/v1/snapshots/:id" do 18 | status 200 19 | { "id" => 1, "expires_at" => "2000-01-01T01:00:00Z", "finalized_at" => "2000-01-01T01:00:00Z", "name" => "My Snapshot", "user_id" => 1, "bundle_id" => 1 } 20 | end 21 | 22 | params do 23 | optional :expires_at, type: String 24 | optional :name, type: String 25 | optional :paths, type: [ String ] 26 | end 27 | post "/api/rest/v1/snapshots" do 28 | status 201 29 | { "id" => 1, "expires_at" => "2000-01-01T01:00:00Z", "finalized_at" => "2000-01-01T01:00:00Z", "name" => "My Snapshot", "user_id" => 1, "bundle_id" => 1 } 30 | end 31 | 32 | params do 33 | requires :id, type: Integer 34 | end 35 | post "/api/rest/v1/snapshots/:id/finalize" do 36 | status 204 37 | body false 38 | end 39 | 40 | params do 41 | requires :id, type: Integer 42 | optional :expires_at, type: String 43 | optional :name, type: String 44 | optional :paths, type: [ String ] 45 | end 46 | patch "/api/rest/v1/snapshots/:id" do 47 | status 200 48 | { "id" => 1, "expires_at" => "2000-01-01T01:00:00Z", "finalized_at" => "2000-01-01T01:00:00Z", "name" => "My Snapshot", "user_id" => 1, "bundle_id" => 1 } 49 | end 50 | 51 | params do 52 | requires :id, type: Integer 53 | end 54 | delete "/api/rest/v1/snapshots/:id" do 55 | status 204 56 | body false 57 | end 58 | end 59 | end 60 | -------------------------------------------------------------------------------- /app/sso_strategy_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class SsoStrategyAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :cursor, type: String 7 | optional :per_page, type: Integer 8 | optional :sort_by, type: Hash 9 | end 10 | get "/api/rest/v1/sso_strategies" do 11 | status 200 12 | [ { "protocol" => "oauth2", "provider" => "okta", "label" => "My Corporate SSO Provider", "logo_url" => "https://mysite.files.com/.../logo.png", "id" => 1, "user_count" => 1, "saml_provider_cert_fingerprint" => "example", "saml_provider_issuer_url" => "example", "saml_provider_metadata_content" => "example", "saml_provider_metadata_url" => "example", "saml_provider_slo_target_url" => "example", "saml_provider_sso_target_url" => "example", "scim_authentication_method" => "example", "scim_username" => "example", "scim_oauth_access_token" => "example", "scim_oauth_access_token_expires_at" => "example", "subdomain" => "my-site", "provision_users" => true, "provision_groups" => true, "deprovision_users" => true, "deprovision_groups" => true, "deprovision_behavior" => "disable", "provision_group_default" => "Employees", "provision_group_exclusion" => "Employees", "provision_group_inclusion" => "Employees", "provision_group_required" => "example", "provision_email_signup_groups" => "Employees", "provision_readonly_site_admin_groups" => "Employees", "provision_site_admin_groups" => "Employees", "provision_group_admin_groups" => "Employees", "provision_attachments_permission" => true, "provision_dav_permission" => true, "provision_ftp_permission" => true, "provision_sftp_permission" => true, "provision_time_zone" => "Eastern Time (US & Canada)", "provision_company" => "ACME Corp.", "provision_require_2fa" => "always_require", "provider_identifier" => "", "ldap_base_dn" => "example", "ldap_domain" => "mysite.com", "enabled" => true, "ldap_host" => "ldap.site.com", "ldap_host_2" => "ldap2.site.com", "ldap_host_3" => "ldap3.site.com", "ldap_port" => 1, "ldap_secure" => true, "ldap_username" => "[ldap username]", "ldap_username_field" => "sAMAccountName" } ] 13 | end 14 | 15 | params do 16 | requires :id, type: Integer 17 | end 18 | get "/api/rest/v1/sso_strategies/:id" do 19 | status 200 20 | { "protocol" => "oauth2", "provider" => "okta", "label" => "My Corporate SSO Provider", "logo_url" => "https://mysite.files.com/.../logo.png", "id" => 1, "user_count" => 1, "saml_provider_cert_fingerprint" => "example", "saml_provider_issuer_url" => "example", "saml_provider_metadata_content" => "example", "saml_provider_metadata_url" => "example", "saml_provider_slo_target_url" => "example", "saml_provider_sso_target_url" => "example", "scim_authentication_method" => "example", "scim_username" => "example", "scim_oauth_access_token" => "example", "scim_oauth_access_token_expires_at" => "example", "subdomain" => "my-site", "provision_users" => true, "provision_groups" => true, "deprovision_users" => true, "deprovision_groups" => true, "deprovision_behavior" => "disable", "provision_group_default" => "Employees", "provision_group_exclusion" => "Employees", "provision_group_inclusion" => "Employees", "provision_group_required" => "example", "provision_email_signup_groups" => "Employees", "provision_readonly_site_admin_groups" => "Employees", "provision_site_admin_groups" => "Employees", "provision_group_admin_groups" => "Employees", "provision_attachments_permission" => true, "provision_dav_permission" => true, "provision_ftp_permission" => true, "provision_sftp_permission" => true, "provision_time_zone" => "Eastern Time (US & Canada)", "provision_company" => "ACME Corp.", "provision_require_2fa" => "always_require", "provider_identifier" => "", "ldap_base_dn" => "example", "ldap_domain" => "mysite.com", "enabled" => true, "ldap_host" => "ldap.site.com", "ldap_host_2" => "ldap2.site.com", "ldap_host_3" => "ldap3.site.com", "ldap_port" => 1, "ldap_secure" => true, "ldap_username" => "[ldap username]", "ldap_username_field" => "sAMAccountName" } 21 | end 22 | 23 | params do 24 | requires :id, type: Integer 25 | end 26 | post "/api/rest/v1/sso_strategies/:id/sync" do 27 | status 204 28 | body false 29 | end 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /app/style_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class StyleAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | requires :path, type: String 7 | end 8 | get "/api/rest/v1/styles/:path" do 9 | status 200 10 | { "id" => 1, "path" => "example", "logo" => "https://mysite.files.com/...", "thumbnail" => { "name" => "My logo", "uri" => "https://mysite.files.com/.../my_image.png" } } 11 | end 12 | 13 | params do 14 | requires :path, type: String 15 | requires :file, type: File 16 | end 17 | patch "/api/rest/v1/styles/:path" do 18 | status 200 19 | { "id" => 1, "path" => "example", "logo" => "https://mysite.files.com/...", "thumbnail" => { "name" => "My logo", "uri" => "https://mysite.files.com/.../my_image.png" } } 20 | end 21 | 22 | params do 23 | requires :path, type: String 24 | end 25 | delete "/api/rest/v1/styles/:path" do 26 | status 204 27 | body false 28 | end 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /app/sync_log_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class SyncLogAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :cursor, type: String 7 | optional :per_page, type: Integer 8 | optional :filter, type: Hash 9 | optional :filter_prefix, type: Hash 10 | end 11 | get "/api/rest/v1/sync_logs" do 12 | status 200 13 | [ { "timestamp" => "2000-01-01T01:00:00Z", "sync_id" => 1, "external_event_id" => 1, "error_type" => "example", "message" => "example", "operation" => "example", "path" => "example", "size" => 1, "file_type" => "example", "status" => "example" } ] 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /app/usage_daily_snapshot_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class UsageDailySnapshotAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :cursor, type: String 7 | optional :per_page, type: Integer 8 | optional :sort_by, type: Hash 9 | optional :filter, type: Hash 10 | optional :filter_gt, type: Hash 11 | optional :filter_gteq, type: Hash 12 | optional :filter_lt, type: Hash 13 | optional :filter_lteq, type: Hash 14 | end 15 | get "/api/rest/v1/usage_daily_snapshots" do 16 | status 200 17 | [ { "id" => 1, "date" => "2000-01-01T01:00:00Z", "api_usage_available" => true, "read_api_usage" => 1, "write_api_usage" => 1, "user_count" => 1, "current_storage" => 1.0, "deleted_files_storage" => 1.0, "deleted_files_counted_in_minimum" => 1.0, "root_storage" => 1.0, "usage_by_top_level_dir" => [ { "dir" => "dir", "size" => 100, "count" => 10 } ] } ] 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /app/usage_snapshot_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class UsageSnapshotAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :cursor, type: String 7 | optional :per_page, type: Integer 8 | end 9 | get "/api/rest/v1/usage_snapshots" do 10 | status 200 11 | [ { "id" => 1, "start_at" => "2000-01-01T01:00:00Z", "end_at" => "2000-01-01T01:00:00Z", "high_water_user_count" => 1, "current_storage" => 1.0, "high_water_storage" => 1.0, "root_storage" => 1.0, "deleted_files_counted_in_minimum" => 1.0, "deleted_files_storage" => 1.0, "total_billable_usage" => 1.0, "total_billable_transfer_usage" => 1.0, "bytes_sent" => 1.0, "sync_bytes_received" => 1.0, "sync_bytes_sent" => 1.0, "usage_by_top_level_dir" => [ { "dir" => "dir", "size" => 100, "count" => 10 } ] } ] 12 | end 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /app/user_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class UserAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :cursor, type: String 7 | optional :per_page, type: Integer 8 | optional :sort_by, type: Hash 9 | optional :filter, type: Hash 10 | optional :filter_gt, type: Hash 11 | optional :filter_gteq, type: Hash 12 | optional :filter_prefix, type: Hash 13 | optional :filter_lt, type: Hash 14 | optional :filter_lteq, type: Hash 15 | optional :ids, type: String 16 | optional :include_parent_site_users, type: Boolean 17 | optional :search, type: String 18 | end 19 | get "/api/rest/v1/users" do 20 | status 200 21 | [ { "id" => 1, "username" => "user", "admin_group_ids" => [ 1 ], "allowed_ips" => "10.0.0.0/8\n127.0.0.1", "attachments_permission" => true, "api_keys_count" => 1, "authenticate_until" => "2000-01-01T01:00:00Z", "authentication_method" => "password", "avatar_url" => "example", "billable" => true, "billing_permission" => true, "bypass_site_allowed_ips" => true, "bypass_user_lifecycle_rules" => true, "created_at" => "2000-01-01T01:00:00Z", "dav_permission" => true, "disabled" => true, "disabled_expired_or_inactive" => true, "email" => "john.doe@files.com", "first_login_at" => "2000-01-01T01:00:00Z", "ftp_permission" => true, "group_ids" => "example", "header_text" => "User-specific message.", "language" => "en", "last_login_at" => "2000-01-01T01:00:00Z", "last_web_login_at" => "2000-01-01T01:00:00Z", "last_ftp_login_at" => "2000-01-01T01:00:00Z", "last_sftp_login_at" => "2000-01-01T01:00:00Z", "last_dav_login_at" => "2000-01-01T01:00:00Z", "last_desktop_login_at" => "2000-01-01T01:00:00Z", "last_restapi_login_at" => "2000-01-01T01:00:00Z", "last_api_use_at" => "2000-01-01T01:00:00Z", "last_active_at" => "2000-01-01T01:00:00Z", "last_protocol_cipher" => "example", "lockout_expires" => "2000-01-01T01:00:00Z", "name" => "John Doe", "company" => "ACME Corp.", "notes" => "Internal notes on this user.", "notification_daily_send_time" => 18, "office_integration_enabled" => true, "password_set_at" => "2000-01-01T01:00:00Z", "password_validity_days" => 1, "public_keys_count" => 1, "receive_admin_alerts" => true, "require_2fa" => "always_require", "require_login_by" => "2000-01-01T01:00:00Z", "active_2fa" => true, "require_password_change" => true, "password_expired" => true, "readonly_site_admin" => true, "restapi_permission" => true, "self_managed" => true, "sftp_permission" => true, "site_admin" => true, "site_id" => 1, "skip_welcome_screen" => true, "ssl_required" => "always_require", "sso_strategy_id" => 1, "subscribe_to_newsletter" => true, "externally_managed" => true, "time_zone" => "Pacific Time (US & Canada)", "type_of_2fa" => "yubi", "type_of_2fa_for_display" => "yubi", "user_root" => "example", "user_home" => "example", "days_remaining_until_password_expire" => 1, "password_expire_at" => "2000-01-01T01:00:00Z" } ] 22 | end 23 | 24 | params do 25 | requires :id, type: Integer 26 | end 27 | get "/api/rest/v1/users/:id" do 28 | status 200 29 | { "id" => 1, "username" => "user", "admin_group_ids" => [ 1 ], "allowed_ips" => "10.0.0.0/8\n127.0.0.1", "attachments_permission" => true, "api_keys_count" => 1, "authenticate_until" => "2000-01-01T01:00:00Z", "authentication_method" => "password", "avatar_url" => "example", "billable" => true, "billing_permission" => true, "bypass_site_allowed_ips" => true, "bypass_user_lifecycle_rules" => true, "created_at" => "2000-01-01T01:00:00Z", "dav_permission" => true, "disabled" => true, "disabled_expired_or_inactive" => true, "email" => "john.doe@files.com", "first_login_at" => "2000-01-01T01:00:00Z", "ftp_permission" => true, "group_ids" => "example", "header_text" => "User-specific message.", "language" => "en", "last_login_at" => "2000-01-01T01:00:00Z", "last_web_login_at" => "2000-01-01T01:00:00Z", "last_ftp_login_at" => "2000-01-01T01:00:00Z", "last_sftp_login_at" => "2000-01-01T01:00:00Z", "last_dav_login_at" => "2000-01-01T01:00:00Z", "last_desktop_login_at" => "2000-01-01T01:00:00Z", "last_restapi_login_at" => "2000-01-01T01:00:00Z", "last_api_use_at" => "2000-01-01T01:00:00Z", "last_active_at" => "2000-01-01T01:00:00Z", "last_protocol_cipher" => "example", "lockout_expires" => "2000-01-01T01:00:00Z", "name" => "John Doe", "company" => "ACME Corp.", "notes" => "Internal notes on this user.", "notification_daily_send_time" => 18, "office_integration_enabled" => true, "password_set_at" => "2000-01-01T01:00:00Z", "password_validity_days" => 1, "public_keys_count" => 1, "receive_admin_alerts" => true, "require_2fa" => "always_require", "require_login_by" => "2000-01-01T01:00:00Z", "active_2fa" => true, "require_password_change" => true, "password_expired" => true, "readonly_site_admin" => true, "restapi_permission" => true, "self_managed" => true, "sftp_permission" => true, "site_admin" => true, "site_id" => 1, "skip_welcome_screen" => true, "ssl_required" => "always_require", "sso_strategy_id" => 1, "subscribe_to_newsletter" => true, "externally_managed" => true, "time_zone" => "Pacific Time (US & Canada)", "type_of_2fa" => "yubi", "type_of_2fa_for_display" => "yubi", "user_root" => "example", "user_home" => "example", "days_remaining_until_password_expire" => 1, "password_expire_at" => "2000-01-01T01:00:00Z" } 30 | end 31 | 32 | params do 33 | optional :avatar_file, type: File 34 | optional :avatar_delete, type: Boolean 35 | optional :change_password, type: String 36 | optional :change_password_confirmation, type: String 37 | optional :email, type: String 38 | optional :grant_permission, type: String 39 | optional :group_id, type: Integer 40 | optional :group_ids, type: String 41 | optional :imported_password_hash, type: String 42 | optional :password, type: String 43 | optional :password_confirmation, type: String 44 | optional :announcements_read, type: Boolean 45 | optional :allowed_ips, type: String 46 | optional :attachments_permission, type: Boolean 47 | optional :authenticate_until, type: String 48 | optional :authentication_method, type: String 49 | optional :billing_permission, type: Boolean 50 | optional :bypass_user_lifecycle_rules, type: Boolean 51 | optional :bypass_site_allowed_ips, type: Boolean 52 | optional :dav_permission, type: Boolean 53 | optional :disabled, type: Boolean 54 | optional :ftp_permission, type: Boolean 55 | optional :header_text, type: String 56 | optional :language, type: String 57 | optional :notification_daily_send_time, type: Integer 58 | optional :name, type: String 59 | optional :company, type: String 60 | optional :notes, type: String 61 | optional :office_integration_enabled, type: Boolean 62 | optional :password_validity_days, type: Integer 63 | optional :readonly_site_admin, type: Boolean 64 | optional :receive_admin_alerts, type: Boolean 65 | optional :require_login_by, type: String 66 | optional :require_password_change, type: Boolean 67 | optional :restapi_permission, type: Boolean 68 | optional :self_managed, type: Boolean 69 | optional :sftp_permission, type: Boolean 70 | optional :site_admin, type: Boolean 71 | optional :skip_welcome_screen, type: Boolean 72 | optional :ssl_required, type: String 73 | optional :sso_strategy_id, type: Integer 74 | optional :subscribe_to_newsletter, type: Boolean 75 | optional :require_2fa, type: String 76 | optional :time_zone, type: String 77 | optional :user_root, type: String 78 | optional :user_home, type: String 79 | requires :username, type: String 80 | end 81 | post "/api/rest/v1/users" do 82 | status 201 83 | { "id" => 1, "username" => "user", "admin_group_ids" => [ 1 ], "allowed_ips" => "10.0.0.0/8\n127.0.0.1", "attachments_permission" => true, "api_keys_count" => 1, "authenticate_until" => "2000-01-01T01:00:00Z", "authentication_method" => "password", "avatar_url" => "example", "billable" => true, "billing_permission" => true, "bypass_site_allowed_ips" => true, "bypass_user_lifecycle_rules" => true, "created_at" => "2000-01-01T01:00:00Z", "dav_permission" => true, "disabled" => true, "disabled_expired_or_inactive" => true, "email" => "john.doe@files.com", "first_login_at" => "2000-01-01T01:00:00Z", "ftp_permission" => true, "group_ids" => "example", "header_text" => "User-specific message.", "language" => "en", "last_login_at" => "2000-01-01T01:00:00Z", "last_web_login_at" => "2000-01-01T01:00:00Z", "last_ftp_login_at" => "2000-01-01T01:00:00Z", "last_sftp_login_at" => "2000-01-01T01:00:00Z", "last_dav_login_at" => "2000-01-01T01:00:00Z", "last_desktop_login_at" => "2000-01-01T01:00:00Z", "last_restapi_login_at" => "2000-01-01T01:00:00Z", "last_api_use_at" => "2000-01-01T01:00:00Z", "last_active_at" => "2000-01-01T01:00:00Z", "last_protocol_cipher" => "example", "lockout_expires" => "2000-01-01T01:00:00Z", "name" => "John Doe", "company" => "ACME Corp.", "notes" => "Internal notes on this user.", "notification_daily_send_time" => 18, "office_integration_enabled" => true, "password_set_at" => "2000-01-01T01:00:00Z", "password_validity_days" => 1, "public_keys_count" => 1, "receive_admin_alerts" => true, "require_2fa" => "always_require", "require_login_by" => "2000-01-01T01:00:00Z", "active_2fa" => true, "require_password_change" => true, "password_expired" => true, "readonly_site_admin" => true, "restapi_permission" => true, "self_managed" => true, "sftp_permission" => true, "site_admin" => true, "site_id" => 1, "skip_welcome_screen" => true, "ssl_required" => "always_require", "sso_strategy_id" => 1, "subscribe_to_newsletter" => true, "externally_managed" => true, "time_zone" => "Pacific Time (US & Canada)", "type_of_2fa" => "yubi", "type_of_2fa_for_display" => "yubi", "user_root" => "example", "user_home" => "example", "days_remaining_until_password_expire" => 1, "password_expire_at" => "2000-01-01T01:00:00Z" } 84 | end 85 | 86 | params do 87 | requires :id, type: Integer 88 | end 89 | post "/api/rest/v1/users/:id/unlock" do 90 | status 204 91 | body false 92 | end 93 | 94 | params do 95 | requires :id, type: Integer 96 | end 97 | post "/api/rest/v1/users/:id/resend_welcome_email" do 98 | status 204 99 | body false 100 | end 101 | 102 | params do 103 | requires :id, type: Integer 104 | end 105 | post "/api/rest/v1/users/:id/2fa/reset" do 106 | status 204 107 | body false 108 | end 109 | 110 | params do 111 | requires :id, type: Integer 112 | optional :avatar_file, type: File 113 | optional :avatar_delete, type: Boolean 114 | optional :change_password, type: String 115 | optional :change_password_confirmation, type: String 116 | optional :email, type: String 117 | optional :grant_permission, type: String 118 | optional :group_id, type: Integer 119 | optional :group_ids, type: String 120 | optional :imported_password_hash, type: String 121 | optional :password, type: String 122 | optional :password_confirmation, type: String 123 | optional :announcements_read, type: Boolean 124 | optional :allowed_ips, type: String 125 | optional :attachments_permission, type: Boolean 126 | optional :authenticate_until, type: String 127 | optional :authentication_method, type: String 128 | optional :billing_permission, type: Boolean 129 | optional :bypass_user_lifecycle_rules, type: Boolean 130 | optional :bypass_site_allowed_ips, type: Boolean 131 | optional :dav_permission, type: Boolean 132 | optional :disabled, type: Boolean 133 | optional :ftp_permission, type: Boolean 134 | optional :header_text, type: String 135 | optional :language, type: String 136 | optional :notification_daily_send_time, type: Integer 137 | optional :name, type: String 138 | optional :company, type: String 139 | optional :notes, type: String 140 | optional :office_integration_enabled, type: Boolean 141 | optional :password_validity_days, type: Integer 142 | optional :readonly_site_admin, type: Boolean 143 | optional :receive_admin_alerts, type: Boolean 144 | optional :require_login_by, type: String 145 | optional :require_password_change, type: Boolean 146 | optional :restapi_permission, type: Boolean 147 | optional :self_managed, type: Boolean 148 | optional :sftp_permission, type: Boolean 149 | optional :site_admin, type: Boolean 150 | optional :skip_welcome_screen, type: Boolean 151 | optional :ssl_required, type: String 152 | optional :sso_strategy_id, type: Integer 153 | optional :subscribe_to_newsletter, type: Boolean 154 | optional :require_2fa, type: String 155 | optional :time_zone, type: String 156 | optional :user_root, type: String 157 | optional :user_home, type: String 158 | optional :username, type: String 159 | end 160 | patch "/api/rest/v1/users/:id" do 161 | status 200 162 | { "id" => 1, "username" => "user", "admin_group_ids" => [ 1 ], "allowed_ips" => "10.0.0.0/8\n127.0.0.1", "attachments_permission" => true, "api_keys_count" => 1, "authenticate_until" => "2000-01-01T01:00:00Z", "authentication_method" => "password", "avatar_url" => "example", "billable" => true, "billing_permission" => true, "bypass_site_allowed_ips" => true, "bypass_user_lifecycle_rules" => true, "created_at" => "2000-01-01T01:00:00Z", "dav_permission" => true, "disabled" => true, "disabled_expired_or_inactive" => true, "email" => "john.doe@files.com", "first_login_at" => "2000-01-01T01:00:00Z", "ftp_permission" => true, "group_ids" => "example", "header_text" => "User-specific message.", "language" => "en", "last_login_at" => "2000-01-01T01:00:00Z", "last_web_login_at" => "2000-01-01T01:00:00Z", "last_ftp_login_at" => "2000-01-01T01:00:00Z", "last_sftp_login_at" => "2000-01-01T01:00:00Z", "last_dav_login_at" => "2000-01-01T01:00:00Z", "last_desktop_login_at" => "2000-01-01T01:00:00Z", "last_restapi_login_at" => "2000-01-01T01:00:00Z", "last_api_use_at" => "2000-01-01T01:00:00Z", "last_active_at" => "2000-01-01T01:00:00Z", "last_protocol_cipher" => "example", "lockout_expires" => "2000-01-01T01:00:00Z", "name" => "John Doe", "company" => "ACME Corp.", "notes" => "Internal notes on this user.", "notification_daily_send_time" => 18, "office_integration_enabled" => true, "password_set_at" => "2000-01-01T01:00:00Z", "password_validity_days" => 1, "public_keys_count" => 1, "receive_admin_alerts" => true, "require_2fa" => "always_require", "require_login_by" => "2000-01-01T01:00:00Z", "active_2fa" => true, "require_password_change" => true, "password_expired" => true, "readonly_site_admin" => true, "restapi_permission" => true, "self_managed" => true, "sftp_permission" => true, "site_admin" => true, "site_id" => 1, "skip_welcome_screen" => true, "ssl_required" => "always_require", "sso_strategy_id" => 1, "subscribe_to_newsletter" => true, "externally_managed" => true, "time_zone" => "Pacific Time (US & Canada)", "type_of_2fa" => "yubi", "type_of_2fa_for_display" => "yubi", "user_root" => "example", "user_home" => "example", "days_remaining_until_password_expire" => 1, "password_expire_at" => "2000-01-01T01:00:00Z" } 163 | end 164 | 165 | params do 166 | requires :id, type: Integer 167 | optional :new_owner_id, type: Integer 168 | end 169 | delete "/api/rest/v1/users/:id" do 170 | status 204 171 | body false 172 | end 173 | end 174 | end 175 | -------------------------------------------------------------------------------- /app/user_cipher_use_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class UserCipherUseAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :user_id, type: Integer 7 | optional :cursor, type: String 8 | optional :per_page, type: Integer 9 | end 10 | get "/api/rest/v1/user_cipher_uses" do 11 | status 200 12 | [ { "id" => 1, "protocol_cipher" => "TLSv1.2; ECDHE-RSA-AES256-GCM-SHA384", "created_at" => "2000-01-01T01:00:00Z", "insecure" => true, "interface" => "restapi", "updated_at" => "2000-01-01T01:00:00Z", "user_id" => 1 } ] 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /app/user_lifecycle_rule_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class UserLifecycleRuleAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :cursor, type: String 7 | optional :per_page, type: Integer 8 | end 9 | get "/api/rest/v1/user_lifecycle_rules" do 10 | status 200 11 | [ { "id" => 1, "authentication_method" => "password", "inactivity_days" => 12, "include_folder_admins" => true, "include_site_admins" => true, "action" => "disable", "site_id" => 1 } ] 12 | end 13 | 14 | params do 15 | requires :id, type: Integer 16 | end 17 | get "/api/rest/v1/user_lifecycle_rules/:id" do 18 | status 200 19 | { "id" => 1, "authentication_method" => "password", "inactivity_days" => 12, "include_folder_admins" => true, "include_site_admins" => true, "action" => "disable", "site_id" => 1 } 20 | end 21 | 22 | params do 23 | requires :action, type: String 24 | requires :authentication_method, type: String 25 | requires :inactivity_days, type: Integer 26 | optional :include_site_admins, type: Boolean 27 | optional :include_folder_admins, type: Boolean 28 | end 29 | post "/api/rest/v1/user_lifecycle_rules" do 30 | status 201 31 | { "id" => 1, "authentication_method" => "password", "inactivity_days" => 12, "include_folder_admins" => true, "include_site_admins" => true, "action" => "disable", "site_id" => 1 } 32 | end 33 | 34 | params do 35 | requires :id, type: Integer 36 | requires :action, type: String 37 | requires :authentication_method, type: String 38 | requires :inactivity_days, type: Integer 39 | optional :include_site_admins, type: Boolean 40 | optional :include_folder_admins, type: Boolean 41 | end 42 | patch "/api/rest/v1/user_lifecycle_rules/:id" do 43 | status 200 44 | { "id" => 1, "authentication_method" => "password", "inactivity_days" => 12, "include_folder_admins" => true, "include_site_admins" => true, "action" => "disable", "site_id" => 1 } 45 | end 46 | 47 | params do 48 | requires :id, type: Integer 49 | end 50 | delete "/api/rest/v1/user_lifecycle_rules/:id" do 51 | status 204 52 | body false 53 | end 54 | end 55 | end 56 | -------------------------------------------------------------------------------- /app/user_request_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class UserRequestAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :cursor, type: String 7 | optional :per_page, type: Integer 8 | end 9 | get "/api/rest/v1/user_requests" do 10 | status 200 11 | [ { "id" => 1, "name" => "John Doe", "email" => "john.doe@files.com", "details" => "Changed Departments", "company" => "Acme Inc." } ] 12 | end 13 | 14 | params do 15 | requires :id, type: Integer 16 | end 17 | get "/api/rest/v1/user_requests/:id" do 18 | status 200 19 | { "id" => 1, "name" => "John Doe", "email" => "john.doe@files.com", "details" => "Changed Departments", "company" => "Acme Inc." } 20 | end 21 | 22 | params do 23 | requires :name, type: String 24 | requires :email, type: String 25 | requires :details, type: String 26 | optional :company, type: String 27 | end 28 | post "/api/rest/v1/user_requests" do 29 | status 201 30 | { "id" => 1, "name" => "John Doe", "email" => "john.doe@files.com", "details" => "Changed Departments", "company" => "Acme Inc." } 31 | end 32 | 33 | params do 34 | requires :id, type: Integer 35 | end 36 | delete "/api/rest/v1/user_requests/:id" do 37 | status 204 38 | body false 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /app/user_sftp_client_use_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class UserSftpClientUseAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :user_id, type: Integer 7 | optional :cursor, type: String 8 | optional :per_page, type: Integer 9 | end 10 | get "/api/rest/v1/user_sftp_client_uses" do 11 | status 200 12 | [ { "id" => 1, "sftp_client" => "example", "created_at" => "2000-01-01T01:00:00Z", "updated_at" => "2000-01-01T01:00:00Z", "user_id" => 1 } ] 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /app/web_dav_action_log_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class WebDavActionLogAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | optional :cursor, type: String 7 | optional :per_page, type: Integer 8 | optional :filter, type: Hash 9 | optional :filter_prefix, type: Hash 10 | end 11 | get "/api/rest/v1/web_dav_action_logs" do 12 | status 200 13 | [ { "timestamp" => "2000-01-01T01:00:00Z", "remote_ip" => "example", "server_ip" => "example", "username" => "example", "auth_ciphers" => "example", "action_type" => "example", "path" => "example", "true_path" => "example", "name" => "example", "http_method" => "example", "http_path" => "example", "http_response_code" => 1, "size" => 1, "entries_returned" => 1, "success" => true, "status" => "example", "duration_ms" => 1 } ] 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /app/webhook_test_api.rb: -------------------------------------------------------------------------------- 1 | module FilesMockServer 2 | class WebhookTestAPI < Grape::API 3 | format :json 4 | 5 | params do 6 | requires :url, type: String 7 | optional :method, type: String 8 | optional :encoding, type: String 9 | optional :headers, type: Hash 10 | optional :body, type: Hash 11 | optional :raw_body, type: String 12 | optional :file_as_body, type: Boolean 13 | optional :file_form_field, type: String 14 | optional :action, type: String 15 | optional :use_dedicated_ips, type: Boolean 16 | end 17 | post "/api/rest/v1/webhook_tests" do 18 | status 201 19 | { "code" => 200, "message" => "", "status" => "", "data" => "example", "success" => true } 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | bundle install && bundle exec rubocop --format simple -a --ignore-parent-exclusion 4 | -------------------------------------------------------------------------------- /config.ru: -------------------------------------------------------------------------------- 1 | $LOAD_PATH.push __dir__ 2 | 3 | require 'files-mock-server' 4 | 5 | run FilesMockServer::API 6 | -------------------------------------------------------------------------------- /config/puma.rb: -------------------------------------------------------------------------------- 1 | port 4041 2 | -------------------------------------------------------------------------------- /files-mock-server.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | $stderr.reopen $stdout 4 | 5 | require 'rubygems' 6 | require 'bundler' 7 | require 'fileutils' 8 | require 'socket' 9 | require 'timeout' 10 | 11 | Bundler.require(:default) 12 | 13 | require 'active_support' 14 | require 'active_support/core_ext' 15 | 16 | $LOAD_PATH.push __dir__ 17 | 18 | require 'lib/base64_upload' 19 | require 'lib/grape_extensions' 20 | 21 | require "app/action_notification_export_api" 22 | require "app/action_notification_export_result_api" 23 | require "app/api_key_api" 24 | require "app/api_request_log_api" 25 | require "app/app_api" 26 | require "app/as2_incoming_message_api" 27 | require "app/as2_outgoing_message_api" 28 | require "app/as2_partner_api" 29 | require "app/as2_station_api" 30 | require "app/automation_api" 31 | require "app/automation_log_api" 32 | require "app/automation_run_api" 33 | require "app/bandwidth_snapshot_api" 34 | require "app/behavior_api" 35 | require "app/bundle_api" 36 | require "app/bundle_action_api" 37 | require "app/bundle_download_api" 38 | require "app/bundle_notification_api" 39 | require "app/bundle_recipient_api" 40 | require "app/bundle_registration_api" 41 | require "app/clickwrap_api" 42 | require "app/dns_record_api" 43 | require "app/email_incoming_message_api" 44 | require "app/email_log_api" 45 | require "app/exavault_api_request_log_api" 46 | require "app/external_event_api" 47 | require "app/file_api" 48 | require "app/file_comment_api" 49 | require "app/file_comment_reaction_api" 50 | require "app/file_migration_api" 51 | require "app/file_migration_log_api" 52 | require "app/folder_api" 53 | require "app/form_field_set_api" 54 | require "app/ftp_action_log_api" 55 | require "app/gpg_key_api" 56 | require "app/group_api" 57 | require "app/group_user_api" 58 | require "app/history_api" 59 | require "app/history_export_api" 60 | require "app/history_export_result_api" 61 | require "app/inbox_recipient_api" 62 | require "app/inbox_registration_api" 63 | require "app/inbox_upload_api" 64 | require "app/invoice_api" 65 | require "app/ip_address_api" 66 | require "app/lock_api" 67 | require "app/message_api" 68 | require "app/message_comment_api" 69 | require "app/message_comment_reaction_api" 70 | require "app/message_reaction_api" 71 | require "app/notification_api" 72 | require "app/outbound_connection_log_api" 73 | require "app/payment_api" 74 | require "app/permission_api" 75 | require "app/priority_api" 76 | require "app/project_api" 77 | require "app/public_hosting_request_log_api" 78 | require "app/public_key_api" 79 | require "app/remote_bandwidth_snapshot_api" 80 | require "app/remote_server_api" 81 | require "app/request_api" 82 | require "app/restore_api" 83 | require "app/session_api" 84 | require "app/settings_change_api" 85 | require "app/sftp_action_log_api" 86 | require "app/sftp_host_key_api" 87 | require "app/share_group_api" 88 | require "app/siem_http_destination_api" 89 | require "app/site_api" 90 | require "app/snapshot_api" 91 | require "app/sso_strategy_api" 92 | require "app/style_api" 93 | require "app/sync_log_api" 94 | require "app/usage_daily_snapshot_api" 95 | require "app/usage_snapshot_api" 96 | require "app/user_api" 97 | require "app/user_cipher_use_api" 98 | require "app/user_lifecycle_rule_api" 99 | require "app/user_request_api" 100 | require "app/user_sftp_client_use_api" 101 | require "app/web_dav_action_log_api" 102 | require "app/webhook_test_api" 103 | 104 | class FilesMockServer::API < Grape::API 105 | mount FilesMockServer::ActionNotificationExportAPI 106 | mount FilesMockServer::ActionNotificationExportResultAPI 107 | mount FilesMockServer::ApiKeyAPI 108 | mount FilesMockServer::ApiRequestLogAPI 109 | mount FilesMockServer::AppAPI 110 | mount FilesMockServer::As2IncomingMessageAPI 111 | mount FilesMockServer::As2OutgoingMessageAPI 112 | mount FilesMockServer::As2PartnerAPI 113 | mount FilesMockServer::As2StationAPI 114 | mount FilesMockServer::AutomationAPI 115 | mount FilesMockServer::AutomationLogAPI 116 | mount FilesMockServer::AutomationRunAPI 117 | mount FilesMockServer::BandwidthSnapshotAPI 118 | mount FilesMockServer::BehaviorAPI 119 | mount FilesMockServer::BundleAPI 120 | mount FilesMockServer::BundleActionAPI 121 | mount FilesMockServer::BundleDownloadAPI 122 | mount FilesMockServer::BundleNotificationAPI 123 | mount FilesMockServer::BundleRecipientAPI 124 | mount FilesMockServer::BundleRegistrationAPI 125 | mount FilesMockServer::ClickwrapAPI 126 | mount FilesMockServer::DnsRecordAPI 127 | mount FilesMockServer::EmailIncomingMessageAPI 128 | mount FilesMockServer::EmailLogAPI 129 | mount FilesMockServer::ExavaultApiRequestLogAPI 130 | mount FilesMockServer::ExternalEventAPI 131 | mount FilesMockServer::FileAPI 132 | mount FilesMockServer::FileCommentAPI 133 | mount FilesMockServer::FileCommentReactionAPI 134 | mount FilesMockServer::FileMigrationAPI 135 | mount FilesMockServer::FileMigrationLogAPI 136 | mount FilesMockServer::FolderAPI 137 | mount FilesMockServer::FormFieldSetAPI 138 | mount FilesMockServer::FtpActionLogAPI 139 | mount FilesMockServer::GpgKeyAPI 140 | mount FilesMockServer::GroupAPI 141 | mount FilesMockServer::GroupUserAPI 142 | mount FilesMockServer::HistoryAPI 143 | mount FilesMockServer::HistoryExportAPI 144 | mount FilesMockServer::HistoryExportResultAPI 145 | mount FilesMockServer::InboxRecipientAPI 146 | mount FilesMockServer::InboxRegistrationAPI 147 | mount FilesMockServer::InboxUploadAPI 148 | mount FilesMockServer::InvoiceAPI 149 | mount FilesMockServer::IpAddressAPI 150 | mount FilesMockServer::LockAPI 151 | mount FilesMockServer::MessageAPI 152 | mount FilesMockServer::MessageCommentAPI 153 | mount FilesMockServer::MessageCommentReactionAPI 154 | mount FilesMockServer::MessageReactionAPI 155 | mount FilesMockServer::NotificationAPI 156 | mount FilesMockServer::OutboundConnectionLogAPI 157 | mount FilesMockServer::PaymentAPI 158 | mount FilesMockServer::PermissionAPI 159 | mount FilesMockServer::PriorityAPI 160 | mount FilesMockServer::ProjectAPI 161 | mount FilesMockServer::PublicHostingRequestLogAPI 162 | mount FilesMockServer::PublicKeyAPI 163 | mount FilesMockServer::RemoteBandwidthSnapshotAPI 164 | mount FilesMockServer::RemoteServerAPI 165 | mount FilesMockServer::RequestAPI 166 | mount FilesMockServer::RestoreAPI 167 | mount FilesMockServer::SessionAPI 168 | mount FilesMockServer::SettingsChangeAPI 169 | mount FilesMockServer::SftpActionLogAPI 170 | mount FilesMockServer::SftpHostKeyAPI 171 | mount FilesMockServer::ShareGroupAPI 172 | mount FilesMockServer::SiemHttpDestinationAPI 173 | mount FilesMockServer::SiteAPI 174 | mount FilesMockServer::SnapshotAPI 175 | mount FilesMockServer::SsoStrategyAPI 176 | mount FilesMockServer::StyleAPI 177 | mount FilesMockServer::SyncLogAPI 178 | mount FilesMockServer::UsageDailySnapshotAPI 179 | mount FilesMockServer::UsageSnapshotAPI 180 | mount FilesMockServer::UserAPI 181 | mount FilesMockServer::UserCipherUseAPI 182 | mount FilesMockServer::UserLifecycleRuleAPI 183 | mount FilesMockServer::UserRequestAPI 184 | mount FilesMockServer::UserSftpClientUseAPI 185 | mount FilesMockServer::WebDavActionLogAPI 186 | mount FilesMockServer::WebhookTestAPI 187 | end 188 | -------------------------------------------------------------------------------- /files.com-mock-server.gemspec: -------------------------------------------------------------------------------- 1 | $LOAD_PATH.push File.expand_path('lib', __dir__) 2 | 3 | Gem::Specification.new do |s| 4 | s.name = "files.com-mock-server" 5 | s.version = File.read(File.expand_path('_VERSION', __dir__)) 6 | s.platform = Gem::Platform::RUBY 7 | s.authors = [ "files.com" ] 8 | s.email = [ "support@files.com" ] 9 | s.homepage = "https://www.files.com" 10 | s.summary = "Files.com Mock API Server." 11 | s.description = "Mock Files.com Server API for your own Integration Testing." 12 | s.license = "MIT" 13 | s.required_ruby_version = ">= 3.2.2" 14 | s.add_dependency 'activesupport', ">= 6.0.3.2" 15 | s.add_dependency 'grape', ">= 1.3.3" 16 | s.add_dependency 'puma', ">= 4.3.5" 17 | s.add_dependency 'rubocop' 18 | 19 | s.files = `find *`.split("\n").uniq.sort.reject(&:empty?) 20 | s.metadata['rubygems_mfa_required'] = 'true' 21 | end 22 | -------------------------------------------------------------------------------- /lib/base64_upload.rb: -------------------------------------------------------------------------------- 1 | class Base64Upload 2 | attr_reader :tempfile, :filename 3 | 4 | def initialize(file_content, filename, _filetype) 5 | @tempfile = StringIO.new(file_content) 6 | @filename = filename.present? ? filename : "file.ext" 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/grape_extensions.rb: -------------------------------------------------------------------------------- 1 | module Grape 2 | module Validations 3 | module Types 4 | # Accept Base64Uploads as a File and coerce them to work like a normal File 5 | class File 6 | def self.parse(input) 7 | if input.is_a?(ActiveSupport::HashWithIndifferentAccess) and input.key?(:encoded_content) 8 | Base64Upload.new(Base64.decode64(input[:encoded_content]), input[:filename], input[:type]) 9 | else 10 | input 11 | end 12 | end 13 | 14 | def self.parsed?(value) 15 | return true if value == "" # the frontend passes an empty string when creating a user for this value, and master accepts it as a valid file 16 | 17 | value.is_a?(Base64Upload) || 18 | (value.is_a?(::Hash) && value.key?(:tempfile) && value[:tempfile].is_a?(Tempfile)) || 19 | (value.is_a?(ActionDispatch::Http::UploadedFile) && value.tempfile.is_a?(Tempfile)) 20 | end 21 | end 22 | end 23 | 24 | module Validators 25 | # Handle Array params, e.g. `type: Array[File]`. Normal Grape validation behavior enforces the outer type (Array) but not the inner type (File). We want to coerce the inner type. 26 | class CoerceValidator < Base 27 | alias orig_coerce_value coerce_value 28 | alias orig_type type 29 | 30 | def coerce_value(val) 31 | return nil if val.nil? 32 | 33 | if type == DateTime and val.to_s =~ /\A[0-9]+\Z/ 34 | Time.at(val.to_i).to_datetime 35 | elsif type.is_a?(Array) and converter.instance_variable_get(:@coercer)&.primitive == Array 36 | # virtus wouldn't even get to this point. both type and coercer were # so I don't think it was doing any checking at all 37 | # unfortunately, DRY types will choke on this and we have at least specs and probably behavior that actually depends on this - JimBob 11/13/2023 38 | return [ "" ] if val == [ "" ] 39 | 40 | o = orig_coerce_value([ *val ]) # virtus automatically turned "string" into ["string"] for these but dry doesn't 41 | return o if o.is_a?(Grape::Validations::Types::InvalidValue) 42 | 43 | inner_converter = Grape::Validations::Types.build_coercer(type.first) 44 | o.each_with_object([]) do |item, collection| 45 | if item.is_a? type.first 46 | collection << item 47 | else 48 | collection << inner_converter.call(item) 49 | end 50 | end 51 | else 52 | orig_coerce_value(val) 53 | end 54 | end 55 | 56 | # Override to account for Hash[String=>String] which has no `value` 57 | def type 58 | orig_result = orig_type 59 | if orig_result.nil? and @option[:type].is_a?(Hash) 60 | @option[:type] 61 | else 62 | orig_result 63 | end 64 | end 65 | end 66 | end 67 | end 68 | end 69 | -------------------------------------------------------------------------------- /shared/header_test_data.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "headers": {}, 4 | "result": null 5 | }, 6 | { 7 | "headers": { 8 | "Retry-After": ["aaaaaa"] 9 | }, 10 | "result": null 11 | }, 12 | { 13 | "headers": { 14 | "Retry-After": ["5"] 15 | }, 16 | "result": 5 17 | }, 18 | { 19 | "headers": { 20 | "Retry-After": ["60"] 21 | }, 22 | "result": null 23 | }, 24 | { 25 | "headers": { 26 | "Retry-After": ["5", "10"] 27 | }, 28 | "result": 5 29 | }, 30 | { 31 | "headers": { 32 | "Retry-After": ["5", "aaaaaa"] 33 | }, 34 | "result": 5 35 | }, 36 | { 37 | "headers": { 38 | "Retry-After": ["%s"] 39 | }, 40 | "result": 8 41 | } 42 | ] -------------------------------------------------------------------------------- /shared/normalization_for_comparison_test_data.json: -------------------------------------------------------------------------------- 1 | [ 2 | [ "filename.txt", "filename.txt" ], 3 | [ "FiLeNaMe.TxT", "filename.txt" ], 4 | [ "FILENAME.TXT", "filename.txt" ], 5 | [ "FÎŁĘÑÂMÉ.TXT", "filename.txt" ], 6 | [ "Fïłèńämê.Txt", "filename.txt" ], 7 | [ "a/b/c.txt", "a/b/c.txt" ], 8 | [ "A\\B\\C.TXT", "a/b/c.txt" ], 9 | [ "A/B\\C.TXT", "a/b/c.txt" ], 10 | [ "//a/b//c.txt", "a/b/c.txt" ], 11 | [ "a/b/c.txt ", "a/b/c.txt" ], 12 | [ "a/b/c.txt\t", "a/b/c.txt" ], 13 | [ "a/b/c.txt\n", "a/b/c.txt" ], 14 | [ "a/b/c.txt\r", "a/b/c.txt" ], 15 | [ " space_at_beginning", " space_at_beginning"], 16 | [ "space_at_end ", "space_at_end"], 17 | [ "tab\tseparated", "tab\tseparated"], 18 | [ "hello</hello>", "<title>hello</hello>"], 19 | [ "안녕하세요", "안녕하세요" ], 20 | [ "こんにちは", "こんにちは" ], 21 | [ "今日は", "今日は" ], 22 | [ "longest_unicode_character_﷽", "longest_unicode_character_﷽"], 23 | [ "invalid_null_byte_before\u0000after", "invalid_null_byte_beforeafter" ], 24 | [ "a/b/c/../../hello", "a/b/c/hello" ], 25 | [ "a/b/c/././hello", "a/b/c/hello" ], 26 | [ "one_code_point_ą", "one_code_point_a" ], 27 | [ "two_code_points_ą", "two_code_points_a" ], 28 | [ "one_code_point_훯", "one_code_point_훯"], 29 | [ "three_code_points_훯", "three_code_points_훯" ], 30 | [ "ÞþŊŋŦŧ", "þþŋŋŧŧ" ], 31 | [ "ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿ", "aaaaaaaeceeeeiiiidnoooooouuuuyssaaaaaaaeceeeeiiiidnoooooouuuuyy" ], 32 | [ "ĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİIJij", "aaaaaaccccccccddddeeeeeeeeeegggggggghhhhiiiiiiiiiijij" ], 33 | [ "ĴĵĶķĹĺĻļĽľŁłŃńŅņŇňʼnŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤť", "jjkkllllllllnnnnnnʼnoooooooeoerrrrrrsssssssstttt" ], 34 | [ "ŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽž", "uuuuuuuuuuuuwwyyyzzzzzz" ], 35 | [ "😂❤️😍🤣😊🙏💕😭😘👍😅👏😁♥️🔥💔💖💙😢🤔😆🙄💪😉☺️👌🤗", "😂❤️😍🤣😊🙏💕😭😘👍😅👏😁♥️🔥💔💖💙😢🤔😆🙄💪😉☺️👌🤗" ], 36 | [ "💜😔😎😇🌹🤦🎉💞✌️✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣️", "💜😔😎😇🌹🤦🎉💞✌️✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣️" ], 37 | [ "emoji_‼️", "emoji_!!️" ], 38 | [ "<title>hello<:hello>.txt", "<title>hello<:hello>.txt" ], 39 | [ "twodotfile..txt", "twodotfile..txt" ], 40 | [ "three/.../dots_path", "three/.../dots_path" ], 41 | [ ".", "" ], 42 | [ "..", ""], 43 | [ "./..", "" ], 44 | [ "../..", ""], 45 | [ "./.", "" ], 46 | [ "../.", ""], 47 | [ "./../.", "" ], 48 | [ ".././..", ""] 49 | ] -------------------------------------------------------------------------------- /shared/url_test_data.json: -------------------------------------------------------------------------------- 1 | { 2 | "substitute_urls": [ 3 | "https://storage.googleapis.com/example-bucket/cat.jpeg?X-Goog-Date=%s&X-Goog-Expires=%s&X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-SignedHeaders=host", 4 | "https://s3.amazonaws.com/test.example.com/metadata/1234/00000000-0000-0000-0001-00000000?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=%s&X-Amz-Expires=%s", 5 | "https://filescomtests.blob.core.windows.net/testazureremote/ntie3buw/file-to-download.txt?sp=se=%s" 6 | ], 7 | "error_urls": [ 8 | "https://storage.googleapis.com/example-bucket/cat.jpeg?X-Goog-Date=20220101T120000Z", 9 | "https://storage.googleapis.com/example-bucket/cat.jpeg?X-Goog-Date=20220101T120000Z&X-Goog-Date=20220202T120000Z", 10 | "https://storage.googleapis.com/example-bucket/cat.jpeg?X-Goog-Expires=900&X-Goog-Expires=600", 11 | "https://filescomtests.blob.core.windows.net/testazureremote/ntie3buw/file-to-download.txt?sp=se=20220101T120000Z&sp=se=20220202T120000Z", 12 | "https://filescomtests.blob.core.windows.net/testazureremote/ntie3buw/file-to-download.txt?sp=20220101T120000Z", 13 | "https://storage.googleapis.com/example-bucket/cat.jpeg?X-Goog-Date=20220101&X-Goog-Expires=900", 14 | "https://storage.googleapis.com/example-bucket/cat.jpeg?X-Goog-Date=asdf&X-Goog-Expires=900", 15 | "https://storage.googleapis.com/example-bucket/cat.jpeg?X-Goog-Date=20220101T120000Z&&X-Goog-Expires=900", 16 | "https://s3.amazonaws.com/test.example.com/metadata/1234/00000000-0000-0000-0001-00000000?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=asdf&X-Amz-Expires=900" 17 | ] 18 | } --------------------------------------------------------------------------------