From 42d73fb7da872eee94325ae8412a66b1f6e5adf9 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Thu, 10 Jan 2019 21:36:41 -0800 Subject: rust codegen --- rust/fatcat-api-spec/README.md | 9 +- rust/fatcat-api-spec/api.yaml | 241 ++++++- rust/fatcat-api-spec/api/swagger.yaml | 606 +++++++++++++++++- rust/fatcat-api-spec/examples/client.rs | 60 +- rust/fatcat-api-spec/examples/server_lib/server.rs | 117 +++- rust/fatcat-api-spec/src/client.rs | 521 ++++++++++++++- rust/fatcat-api-spec/src/lib.rs | 190 +++++- rust/fatcat-api-spec/src/mimetypes.rs | 136 +++- rust/fatcat-api-spec/src/models.rs | 53 ++ rust/fatcat-api-spec/src/server.rs | 711 +++++++++++++++++++-- 10 files changed, 2527 insertions(+), 117 deletions(-) (limited to 'rust/fatcat-api-spec') diff --git a/rust/fatcat-api-spec/README.md b/rust/fatcat-api-spec/README.md index 300cba5f..cb7815d2 100644 --- a/rust/fatcat-api-spec/README.md +++ b/rust/fatcat-api-spec/README.md @@ -13,7 +13,7 @@ To see how to make this your own, look here: [README](https://github.com/swagger-api/swagger-codegen/blob/master/README.md) - API version: 0.1.0 -- Build date: 2019-01-10T07:48:01.403Z +- Build date: 2019-01-11T05:35:09.223Z This autogenerated project defines an API crate `fatcat` which contains: * An `Api` trait defining the API in Rust. @@ -81,14 +81,19 @@ cargo run --example client LookupCreator cargo run --example client UpdateCreator cargo run --example client AuthCheck cargo run --example client AuthOidc +cargo run --example client GetEditgroupsReviewable cargo run --example client GetEditor -cargo run --example client GetEditorChangelog +cargo run --example client GetEditorEditgroups +cargo run --example client UpdateEditgroup cargo run --example client UpdateEditor cargo run --example client AcceptEditgroup cargo run --example client CreateEditgroup +cargo run --example client CreateEditgroupAnnotation cargo run --example client GetChangelog cargo run --example client GetChangelogEntry cargo run --example client GetEditgroup +cargo run --example client GetEditgroupAnnotations +cargo run --example client GetEditorAnnotations cargo run --example client CreateFile cargo run --example client CreateFileBatch cargo run --example client DeleteFile diff --git a/rust/fatcat-api-spec/api.yaml b/rust/fatcat-api-spec/api.yaml index 70e8e540..61f895fa 100644 --- a/rust/fatcat-api-spec/api.yaml +++ b/rust/fatcat-api-spec/api.yaml @@ -465,11 +465,18 @@ definitions: <<: *FATCATIDENT editor_id: <<: *FATCATIDENT + submitted: + type: string + format: date-time description: type: string extra: type: object additionalProperties: {} + annotations: + type: array + items: + $ref: "#/definitions/editgroup_annotation" edits: type: object properties: @@ -501,6 +508,23 @@ definitions: type: array items: $ref: "#/definitions/entity_edit" + editgroup_annotation: + type: object + properties: + annotation_id: + <<: *FATCATUUID + editgroup_id: + <<: *FATCATIDENT + editor_id: + <<: *FATCATIDENT + created: + type: string + format: date-time + comment_markdown: + type: string + extra: + type: object + additionalProperties: {} changelog_entry: type: object required: @@ -2524,21 +2548,37 @@ paths: schema: $ref: "#/definitions/error_response" <<: *AUTHRESPONSES - /editor/{editor_id}/changelog: + /editor/{editor_id}/editgroups: parameters: - name: editor_id in: path type: string required: true get: - operationId: "get_editor_changelog" + operationId: "get_editor_editgroups" + parameters: + - name: limit + in: query + type: integer + format: int64 + required: false + - name: before + in: query + type: string + format: date-time + required: false + - name: since + in: query + type: string + format: date-time + required: false responses: 200: description: Found schema: type: array items: - $ref: "#/definitions/changelog_entry" + $ref: "#/definitions/editgroup" 400: description: Bad Request schema: @@ -2551,6 +2591,52 @@ paths: description: Generic Error schema: $ref: "#/definitions/error_response" + /editor/{editor_id}/annotations: + parameters: + - name: editor_id + in: path + required: true + <<: *FATCATIDENT + get: + operationId: "get_editor_annotations" + tags: # TAGLINE + - edit-lifecycle # TAGLINE + parameters: + - name: limit + in: query + type: integer + format: int64 + required: false + - name: before + in: query + type: string + format: date-time + required: false + - name: since + in: query + type: string + format: date-time + required: false + responses: + 200: + description: Success + schema: + type: array + items: + $ref: "#/definitions/editgroup_annotation" + 400: + description: Bad Request + schema: + $ref: "#/definitions/error_response" + 404: + description: Not Found + schema: + $ref: "#/definitions/error_response" + 500: + description: Generic Error + schema: + $ref: "#/definitions/error_response" + <<: *AUTHRESPONSES /editgroup: post: operationId: "create_editgroup" @@ -2609,6 +2695,38 @@ paths: description: Generic Error schema: $ref: "#/definitions/error_response" + put: + operationId: "update_editgroup" + security: + - Bearer: [] + parameters: + - name: editgroup + in: body + required: true + schema: + $ref: "#/definitions/editgroup" + - name: submit + in: query + type: boolean + required: false + responses: + 200: + description: Updated Editgroup + schema: + $ref: "#/definitions/editgroup" + 400: + description: Bad Request + schema: + $ref: "#/definitions/error_response" + 404: + description: Not Found + schema: + $ref: "#/definitions/error_response" + 500: + description: Generic Error + schema: + $ref: "#/definitions/error_response" + <<: *AUTHRESPONSES /editgroup/{editgroup_id}/accept: parameters: - name: editgroup_id @@ -2643,6 +2761,123 @@ paths: schema: $ref: "#/definitions/error_response" <<: *AUTHRESPONSES + /editgroup/{editgroup_id}/annotations: + parameters: + - name: editgroup_id + in: path + required: true + <<: *FATCATIDENT + get: + operationId: "get_editgroup_annotations" + tags: # TAGLINE + - edit-lifecycle # TAGLINE + security: + - Bearer: [] + parameters: + - name: expand + in: query + type: string + required: false + description: "List of sub-entities to expand in response. For editgroups: 'editors'" + responses: + 200: + description: Success + schema: + type: array + items: + $ref: "#/definitions/editgroup_annotation" + 400: + description: Bad Request + schema: + $ref: "#/definitions/error_response" + 404: + description: Not Found + schema: + $ref: "#/definitions/error_response" + 500: + description: Generic Error + schema: + $ref: "#/definitions/error_response" + <<: *AUTHRESPONSES + /editgroup/{editgroup_id}/annotation: + parameters: + - name: editgroup_id + in: path + required: true + <<: *FATCATIDENT + post: + operationId: "create_editgroup_annotation" + tags: # TAGLINE + - edit-lifecycle # TAGLINE + security: + - Bearer: [] + parameters: + - name: annotation + in: body + required: true + schema: + $ref: "#/definitions/editgroup_annotation" + responses: + 201: + description: Created + schema: + $ref: "#/definitions/editgroup_annotation" + 400: + description: Bad Request + schema: + $ref: "#/definitions/error_response" + 404: + description: Not Found + schema: + $ref: "#/definitions/error_response" + 500: + description: Generic Error + schema: + $ref: "#/definitions/error_response" + <<: *AUTHRESPONSES + /editgroup/reviewable: + get: + operationId: "get_editgroups_reviewable" + parameters: + - name: expand + in: query + type: string + required: false + description: "List of sub-entities to expand in response. For editgroups: 'editors'" + - name: limit + in: query + type: integer + format: int64 + required: false + - name: before + in: query + type: string + format: date-time + required: false + - name: since + in: query + type: string + format: date-time + required: false + responses: + 200: + description: Found + schema: + type: array + items: + $ref: "#/definitions/editgroup" + 400: + description: Bad Request + schema: + $ref: "#/definitions/error_response" + 404: + description: Not Found + schema: + $ref: "#/definitions/error_response" + 500: + description: Generic Error + schema: + $ref: "#/definitions/error_response" /changelog: parameters: - name: limit diff --git a/rust/fatcat-api-spec/api/swagger.yaml b/rust/fatcat-api-spec/api/swagger.yaml index 0b18add8..bf6d32dc 100644 --- a/rust/fatcat-api-spec/api/swagger.yaml +++ b/rust/fatcat-api-spec/api/swagger.yaml @@ -6206,9 +6206,9 @@ paths: HttpMethod: "Put" httpmethod: "put" noClientExample: true - /editor/{editor_id}/changelog: + /editor/{editor_id}/editgroups: get: - operationId: "get_editor_changelog" + operationId: "get_editor_editgroups" parameters: - name: "editor_id" in: "path" @@ -6216,17 +6216,119 @@ paths: type: "string" formatString: "\\\"{}\\\"" example: "\"editor_id_example\".to_string()" + - name: "limit" + in: "query" + required: false + type: "integer" + format: "int64" + formatString: "{:?}" + example: "Some(789)" + - name: "before" + in: "query" + required: false + type: "string" + format: "date-time" + formatString: "{:?}" + example: "None" + - name: "since" + in: "query" + required: false + type: "string" + format: "date-time" + formatString: "{:?}" + example: "None" responses: 200: description: "Found" schema: type: "array" items: - $ref: "#/definitions/changelog_entry" + $ref: "#/definitions/editgroup" x-responseId: "Found" x-uppercaseResponseId: "FOUND" - uppercase_operation_id: "GET_EDITOR_CHANGELOG" - uppercase_data_type: "VEC" + uppercase_operation_id: "GET_EDITOR_EDITGROUPS" + uppercase_data_type: "VEC" + producesJson: true + 400: + description: "Bad Request" + schema: + $ref: "#/definitions/error_response" + x-responseId: "BadRequest" + x-uppercaseResponseId: "BAD_REQUEST" + uppercase_operation_id: "GET_EDITOR_EDITGROUPS" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 404: + description: "Not Found" + schema: + $ref: "#/definitions/error_response" + x-responseId: "NotFound" + x-uppercaseResponseId: "NOT_FOUND" + uppercase_operation_id: "GET_EDITOR_EDITGROUPS" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 500: + description: "Generic Error" + schema: + $ref: "#/definitions/error_response" + x-responseId: "GenericError" + x-uppercaseResponseId: "GENERIC_ERROR" + uppercase_operation_id: "GET_EDITOR_EDITGROUPS" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + operation_id: "get_editor_editgroups" + uppercase_operation_id: "GET_EDITOR_EDITGROUPS" + path: "/editor/:editor_id/editgroups" + HttpMethod: "Get" + httpmethod: "get" + /editor/{editor_id}/annotations: + get: + tags: + - "edit-lifecycle" + operationId: "get_editor_annotations" + parameters: + - name: "editor_id" + in: "path" + description: "base32-encoded unique identifier" + required: true + type: "string" + maxLength: 26 + minLength: 26 + pattern: "[a-zA-Z2-7]{26}" + formatString: "\\\"{}\\\"" + example: "\"editor_id_example\".to_string()" + - name: "limit" + in: "query" + required: false + type: "integer" + format: "int64" + formatString: "{:?}" + example: "Some(789)" + - name: "before" + in: "query" + required: false + type: "string" + format: "date-time" + formatString: "{:?}" + example: "None" + - name: "since" + in: "query" + required: false + type: "string" + format: "date-time" + formatString: "{:?}" + example: "None" + responses: + 200: + description: "Success" + schema: + type: "array" + items: + $ref: "#/definitions/editgroup_annotation" + x-responseId: "Success" + x-uppercaseResponseId: "SUCCESS" + uppercase_operation_id: "GET_EDITOR_ANNOTATIONS" + uppercase_data_type: "VEC" producesJson: true 400: description: "Bad Request" @@ -6234,7 +6336,28 @@ paths: $ref: "#/definitions/error_response" x-responseId: "BadRequest" x-uppercaseResponseId: "BAD_REQUEST" - uppercase_operation_id: "GET_EDITOR_CHANGELOG" + uppercase_operation_id: "GET_EDITOR_ANNOTATIONS" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 401: + description: "Not Authorized" + schema: + $ref: "#/definitions/error_response" + headers: + WWW_Authenticate: + type: "string" + x-responseId: "NotAuthorized" + x-uppercaseResponseId: "NOT_AUTHORIZED" + uppercase_operation_id: "GET_EDITOR_ANNOTATIONS" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 403: + description: "Forbidden" + schema: + $ref: "#/definitions/error_response" + x-responseId: "Forbidden" + x-uppercaseResponseId: "FORBIDDEN" + uppercase_operation_id: "GET_EDITOR_ANNOTATIONS" uppercase_data_type: "ERRORRESPONSE" producesJson: true 404: @@ -6243,7 +6366,7 @@ paths: $ref: "#/definitions/error_response" x-responseId: "NotFound" x-uppercaseResponseId: "NOT_FOUND" - uppercase_operation_id: "GET_EDITOR_CHANGELOG" + uppercase_operation_id: "GET_EDITOR_ANNOTATIONS" uppercase_data_type: "ERRORRESPONSE" producesJson: true 500: @@ -6252,12 +6375,12 @@ paths: $ref: "#/definitions/error_response" x-responseId: "GenericError" x-uppercaseResponseId: "GENERIC_ERROR" - uppercase_operation_id: "GET_EDITOR_CHANGELOG" + uppercase_operation_id: "GET_EDITOR_ANNOTATIONS" uppercase_data_type: "ERRORRESPONSE" producesJson: true - operation_id: "get_editor_changelog" - uppercase_operation_id: "GET_EDITOR_CHANGELOG" - path: "/editor/:editor_id/changelog" + operation_id: "get_editor_annotations" + uppercase_operation_id: "GET_EDITOR_ANNOTATIONS" + path: "/editor/:editor_id/annotations" HttpMethod: "Get" httpmethod: "get" /editgroup: @@ -6402,6 +6525,103 @@ paths: path: "/editgroup/:editgroup_id" HttpMethod: "Get" httpmethod: "get" + put: + operationId: "update_editgroup" + parameters: + - name: "editgroup_id" + in: "path" + description: "base32-encoded unique identifier" + required: true + type: "string" + maxLength: 26 + minLength: 26 + pattern: "[a-zA-Z2-7]{26}" + formatString: "\\\"{}\\\"" + example: "\"editgroup_id_example\".to_string()" + - in: "body" + name: "editgroup" + required: true + schema: + $ref: "#/definitions/editgroup" + uppercase_data_type: "EDITGROUP" + refName: "editgroup" + formatString: "{:?}" + example: "???" + model_key: "editgroup_edits" + uppercase_operation_id: "UPDATE_EDITGROUP" + consumesJson: true + - name: "submit" + in: "query" + required: false + type: "boolean" + formatString: "{:?}" + example: "Some(true)" + responses: + 200: + description: "Updated Editgroup" + schema: + $ref: "#/definitions/editgroup" + x-responseId: "UpdatedEditgroup" + x-uppercaseResponseId: "UPDATED_EDITGROUP" + uppercase_operation_id: "UPDATE_EDITGROUP" + uppercase_data_type: "EDITGROUP" + producesJson: true + 400: + description: "Bad Request" + schema: + $ref: "#/definitions/error_response" + x-responseId: "BadRequest" + x-uppercaseResponseId: "BAD_REQUEST" + uppercase_operation_id: "UPDATE_EDITGROUP" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 401: + description: "Not Authorized" + schema: + $ref: "#/definitions/error_response" + headers: + WWW_Authenticate: + type: "string" + x-responseId: "NotAuthorized" + x-uppercaseResponseId: "NOT_AUTHORIZED" + uppercase_operation_id: "UPDATE_EDITGROUP" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 403: + description: "Forbidden" + schema: + $ref: "#/definitions/error_response" + x-responseId: "Forbidden" + x-uppercaseResponseId: "FORBIDDEN" + uppercase_operation_id: "UPDATE_EDITGROUP" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 404: + description: "Not Found" + schema: + $ref: "#/definitions/error_response" + x-responseId: "NotFound" + x-uppercaseResponseId: "NOT_FOUND" + uppercase_operation_id: "UPDATE_EDITGROUP" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 500: + description: "Generic Error" + schema: + $ref: "#/definitions/error_response" + x-responseId: "GenericError" + x-uppercaseResponseId: "GENERIC_ERROR" + uppercase_operation_id: "UPDATE_EDITGROUP" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + security: + - Bearer: [] + operation_id: "update_editgroup" + uppercase_operation_id: "UPDATE_EDITGROUP" + path: "/editgroup/:editgroup_id" + HttpMethod: "Put" + httpmethod: "put" + noClientExample: true /editgroup/{editgroup_id}/accept: post: tags: @@ -6492,6 +6712,268 @@ paths: path: "/editgroup/:editgroup_id/accept" HttpMethod: "Post" httpmethod: "post" + /editgroup/{editgroup_id}/annotations: + get: + tags: + - "edit-lifecycle" + operationId: "get_editgroup_annotations" + parameters: + - name: "editgroup_id" + in: "path" + description: "base32-encoded unique identifier" + required: true + type: "string" + maxLength: 26 + minLength: 26 + pattern: "[a-zA-Z2-7]{26}" + formatString: "\\\"{}\\\"" + example: "\"editgroup_id_example\".to_string()" + - name: "expand" + in: "query" + description: "List of sub-entities to expand in response. For editgroups:\ + \ 'editors'" + required: false + type: "string" + formatString: "{:?}" + example: "Some(\"expand_example\".to_string())" + responses: + 200: + description: "Success" + schema: + type: "array" + items: + $ref: "#/definitions/editgroup_annotation" + x-responseId: "Success" + x-uppercaseResponseId: "SUCCESS" + uppercase_operation_id: "GET_EDITGROUP_ANNOTATIONS" + uppercase_data_type: "VEC" + producesJson: true + 400: + description: "Bad Request" + schema: + $ref: "#/definitions/error_response" + x-responseId: "BadRequest" + x-uppercaseResponseId: "BAD_REQUEST" + uppercase_operation_id: "GET_EDITGROUP_ANNOTATIONS" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 401: + description: "Not Authorized" + schema: + $ref: "#/definitions/error_response" + headers: + WWW_Authenticate: + type: "string" + x-responseId: "NotAuthorized" + x-uppercaseResponseId: "NOT_AUTHORIZED" + uppercase_operation_id: "GET_EDITGROUP_ANNOTATIONS" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 403: + description: "Forbidden" + schema: + $ref: "#/definitions/error_response" + x-responseId: "Forbidden" + x-uppercaseResponseId: "FORBIDDEN" + uppercase_operation_id: "GET_EDITGROUP_ANNOTATIONS" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 404: + description: "Not Found" + schema: + $ref: "#/definitions/error_response" + x-responseId: "NotFound" + x-uppercaseResponseId: "NOT_FOUND" + uppercase_operation_id: "GET_EDITGROUP_ANNOTATIONS" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 500: + description: "Generic Error" + schema: + $ref: "#/definitions/error_response" + x-responseId: "GenericError" + x-uppercaseResponseId: "GENERIC_ERROR" + uppercase_operation_id: "GET_EDITGROUP_ANNOTATIONS" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + security: + - Bearer: [] + operation_id: "get_editgroup_annotations" + uppercase_operation_id: "GET_EDITGROUP_ANNOTATIONS" + path: "/editgroup/:editgroup_id/annotations" + HttpMethod: "Get" + httpmethod: "get" + /editgroup/{editgroup_id}/annotation: + post: + tags: + - "edit-lifecycle" + operationId: "create_editgroup_annotation" + parameters: + - name: "editgroup_id" + in: "path" + description: "base32-encoded unique identifier" + required: true + type: "string" + maxLength: 26 + minLength: 26 + pattern: "[a-zA-Z2-7]{26}" + formatString: "\\\"{}\\\"" + example: "\"editgroup_id_example\".to_string()" + - in: "body" + name: "annotation" + required: true + schema: + $ref: "#/definitions/editgroup_annotation" + uppercase_data_type: "EDITGROUPANNOTATION" + refName: "editgroup_annotation" + formatString: "{:?}" + example: "???" + model_key: "editgroup_edits" + uppercase_operation_id: "CREATE_EDITGROUP_ANNOTATION" + consumesJson: true + responses: + 201: + description: "Created" + schema: + $ref: "#/definitions/editgroup_annotation" + x-responseId: "Created" + x-uppercaseResponseId: "CREATED" + uppercase_operation_id: "CREATE_EDITGROUP_ANNOTATION" + uppercase_data_type: "EDITGROUPANNOTATION" + producesJson: true + 400: + description: "Bad Request" + schema: + $ref: "#/definitions/error_response" + x-responseId: "BadRequest" + x-uppercaseResponseId: "BAD_REQUEST" + uppercase_operation_id: "CREATE_EDITGROUP_ANNOTATION" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 401: + description: "Not Authorized" + schema: + $ref: "#/definitions/error_response" + headers: + WWW_Authenticate: + type: "string" + x-responseId: "NotAuthorized" + x-uppercaseResponseId: "NOT_AUTHORIZED" + uppercase_operation_id: "CREATE_EDITGROUP_ANNOTATION" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 403: + description: "Forbidden" + schema: + $ref: "#/definitions/error_response" + x-responseId: "Forbidden" + x-uppercaseResponseId: "FORBIDDEN" + uppercase_operation_id: "CREATE_EDITGROUP_ANNOTATION" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 404: + description: "Not Found" + schema: + $ref: "#/definitions/error_response" + x-responseId: "NotFound" + x-uppercaseResponseId: "NOT_FOUND" + uppercase_operation_id: "CREATE_EDITGROUP_ANNOTATION" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 500: + description: "Generic Error" + schema: + $ref: "#/definitions/error_response" + x-responseId: "GenericError" + x-uppercaseResponseId: "GENERIC_ERROR" + uppercase_operation_id: "CREATE_EDITGROUP_ANNOTATION" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + security: + - Bearer: [] + operation_id: "create_editgroup_annotation" + uppercase_operation_id: "CREATE_EDITGROUP_ANNOTATION" + path: "/editgroup/:editgroup_id/annotation" + HttpMethod: "Post" + httpmethod: "post" + noClientExample: true + /editgroup/reviewable: + get: + operationId: "get_editgroups_reviewable" + parameters: + - name: "expand" + in: "query" + description: "List of sub-entities to expand in response. For editgroups:\ + \ 'editors'" + required: false + type: "string" + formatString: "{:?}" + example: "Some(\"expand_example\".to_string())" + - name: "limit" + in: "query" + required: false + type: "integer" + format: "int64" + formatString: "{:?}" + example: "Some(789)" + - name: "before" + in: "query" + required: false + type: "string" + format: "date-time" + formatString: "{:?}" + example: "None" + - name: "since" + in: "query" + required: false + type: "string" + format: "date-time" + formatString: "{:?}" + example: "None" + responses: + 200: + description: "Found" + schema: + type: "array" + items: + $ref: "#/definitions/editgroup" + x-responseId: "Found" + x-uppercaseResponseId: "FOUND" + uppercase_operation_id: "GET_EDITGROUPS_REVIEWABLE" + uppercase_data_type: "VEC" + producesJson: true + 400: + description: "Bad Request" + schema: + $ref: "#/definitions/error_response" + x-responseId: "BadRequest" + x-uppercaseResponseId: "BAD_REQUEST" + uppercase_operation_id: "GET_EDITGROUPS_REVIEWABLE" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 404: + description: "Not Found" + schema: + $ref: "#/definitions/error_response" + x-responseId: "NotFound" + x-uppercaseResponseId: "NOT_FOUND" + uppercase_operation_id: "GET_EDITGROUPS_REVIEWABLE" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + 500: + description: "Generic Error" + schema: + $ref: "#/definitions/error_response" + x-responseId: "GenericError" + x-uppercaseResponseId: "GENERIC_ERROR" + uppercase_operation_id: "GET_EDITGROUPS_REVIEWABLE" + uppercase_data_type: "ERRORRESPONSE" + producesJson: true + operation_id: "get_editgroups_reviewable" + uppercase_operation_id: "GET_EDITGROUPS_REVIEWABLE" + path: "/editgroup/reviewable" + HttpMethod: "Get" + httpmethod: "get" /changelog: get: tags: @@ -7614,6 +8096,7 @@ definitions: $ref: "#/definitions/changelog_entry" example: editgroup: + submitted: "2000-01-23T04:56:07.000+00:00" extra: "{}" edits: works: @@ -7723,6 +8206,19 @@ definitions: revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" description: "description" + annotations: + - annotation_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" + created: "2000-01-23T04:56:07.000+00:00" + extra: "{}" + editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" + editor_id: "q3nouwy3nnbsvo3h5klxsx4a7y" + comment_markdown: "comment_markdown" + - annotation_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" + created: "2000-01-23T04:56:07.000+00:00" + extra: "{}" + editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" + editor_id: "q3nouwy3nnbsvo3h5klxsx4a7y" + comment_markdown: "comment_markdown" editor_id: "q3nouwy3nnbsvo3h5klxsx4a7y" edit: ident: "q3nouwy3nnbsvo3h5klxsx4a7y" @@ -7734,6 +8230,7 @@ definitions: revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" changelog_entry: editgroup: + submitted: "2000-01-23T04:56:07.000+00:00" extra: "{}" edits: works: @@ -7843,6 +8340,19 @@ definitions: revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" description: "description" + annotations: + - annotation_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" + created: "2000-01-23T04:56:07.000+00:00" + extra: "{}" + editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" + editor_id: "q3nouwy3nnbsvo3h5klxsx4a7y" + comment_markdown: "comment_markdown" + - annotation_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" + created: "2000-01-23T04:56:07.000+00:00" + extra: "{}" + editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" + editor_id: "q3nouwy3nnbsvo3h5klxsx4a7y" + comment_markdown: "comment_markdown" editor_id: "q3nouwy3nnbsvo3h5klxsx4a7y" index: 0 editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" @@ -7953,13 +8463,21 @@ definitions: minLength: 26 maxLength: 26 pattern: "[a-zA-Z2-7]{26}" + submitted: + type: "string" + format: "date-time" description: type: "string" extra: type: "object" + annotations: + type: "array" + items: + $ref: "#/definitions/editgroup_annotation" edits: $ref: "#/definitions/editgroup_edits" example: + submitted: "2000-01-23T04:56:07.000+00:00" extra: "{}" edits: works: @@ -8069,8 +8587,60 @@ definitions: revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" description: "description" + annotations: + - annotation_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" + created: "2000-01-23T04:56:07.000+00:00" + extra: "{}" + editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" + editor_id: "q3nouwy3nnbsvo3h5klxsx4a7y" + comment_markdown: "comment_markdown" + - annotation_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" + created: "2000-01-23T04:56:07.000+00:00" + extra: "{}" + editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" + editor_id: "q3nouwy3nnbsvo3h5klxsx4a7y" + comment_markdown: "comment_markdown" editor_id: "q3nouwy3nnbsvo3h5klxsx4a7y" upperCaseName: "EDITGROUP" + editgroup_annotation: + type: "object" + properties: + annotation_id: + type: "string" + example: "86daea5b-1b6b-432a-bb67-ea97795f80fe" + description: "UUID (lower-case, dash-separated, hex-encoded 128-bit)" + minLength: 36 + maxLength: 36 + pattern: "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}" + editgroup_id: + type: "string" + example: "q3nouwy3nnbsvo3h5klxsx4a7y" + description: "base32-encoded unique identifier" + minLength: 26 + maxLength: 26 + pattern: "[a-zA-Z2-7]{26}" + editor_id: + type: "string" + example: "q3nouwy3nnbsvo3h5klxsx4a7y" + description: "base32-encoded unique identifier" + minLength: 26 + maxLength: 26 + pattern: "[a-zA-Z2-7]{26}" + created: + type: "string" + format: "date-time" + comment_markdown: + type: "string" + extra: + type: "object" + example: + annotation_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" + created: "2000-01-23T04:56:07.000+00:00" + extra: "{}" + editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" + editor_id: "q3nouwy3nnbsvo3h5klxsx4a7y" + comment_markdown: "comment_markdown" + upperCaseName: "EDITGROUP_ANNOTATION" changelog_entry: type: "object" required: @@ -8091,6 +8661,7 @@ definitions: $ref: "#/definitions/editgroup" example: editgroup: + submitted: "2000-01-23T04:56:07.000+00:00" extra: "{}" edits: works: @@ -8200,6 +8771,19 @@ definitions: revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" description: "description" + annotations: + - annotation_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" + created: "2000-01-23T04:56:07.000+00:00" + extra: "{}" + editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" + editor_id: "q3nouwy3nnbsvo3h5klxsx4a7y" + comment_markdown: "comment_markdown" + - annotation_id: "86daea5b-1b6b-432a-bb67-ea97795f80fe" + created: "2000-01-23T04:56:07.000+00:00" + extra: "{}" + editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" + editor_id: "q3nouwy3nnbsvo3h5klxsx4a7y" + comment_markdown: "comment_markdown" editor_id: "q3nouwy3nnbsvo3h5klxsx4a7y" index: 0 editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" diff --git a/rust/fatcat-api-spec/examples/client.rs b/rust/fatcat-api-spec/examples/client.rs index f5f336b0..b4d90719 100644 --- a/rust/fatcat-api-spec/examples/client.rs +++ b/rust/fatcat-api-spec/examples/client.rs @@ -13,18 +13,18 @@ use clap::{App, Arg}; #[allow(unused_imports)] use fatcat::{ AcceptEditgroupResponse, ApiError, ApiNoContext, AuthCheckResponse, AuthOidcResponse, ContextWrapperExt, CreateContainerBatchResponse, CreateContainerResponse, CreateCreatorBatchResponse, - CreateCreatorResponse, CreateEditgroupResponse, CreateFileBatchResponse, CreateFileResponse, CreateFilesetBatchResponse, CreateFilesetResponse, CreateReleaseBatchResponse, CreateReleaseResponse, - CreateWebcaptureBatchResponse, CreateWebcaptureResponse, CreateWorkBatchResponse, CreateWorkResponse, DeleteContainerEditResponse, DeleteContainerResponse, DeleteCreatorEditResponse, - DeleteCreatorResponse, DeleteFileEditResponse, DeleteFileResponse, DeleteFilesetEditResponse, DeleteFilesetResponse, DeleteReleaseEditResponse, DeleteReleaseResponse, - DeleteWebcaptureEditResponse, DeleteWebcaptureResponse, DeleteWorkEditResponse, DeleteWorkResponse, GetChangelogEntryResponse, GetChangelogResponse, GetContainerEditResponse, - GetContainerHistoryResponse, GetContainerRedirectsResponse, GetContainerResponse, GetContainerRevisionResponse, GetCreatorEditResponse, GetCreatorHistoryResponse, GetCreatorRedirectsResponse, - GetCreatorReleasesResponse, GetCreatorResponse, GetCreatorRevisionResponse, GetEditgroupResponse, GetEditorChangelogResponse, GetEditorResponse, GetFileEditResponse, GetFileHistoryResponse, - GetFileRedirectsResponse, GetFileResponse, GetFileRevisionResponse, GetFilesetEditResponse, GetFilesetHistoryResponse, GetFilesetRedirectsResponse, GetFilesetResponse, GetFilesetRevisionResponse, - GetReleaseEditResponse, GetReleaseFilesResponse, GetReleaseFilesetsResponse, GetReleaseHistoryResponse, GetReleaseRedirectsResponse, GetReleaseResponse, GetReleaseRevisionResponse, - GetReleaseWebcapturesResponse, GetWebcaptureEditResponse, GetWebcaptureHistoryResponse, GetWebcaptureRedirectsResponse, GetWebcaptureResponse, GetWebcaptureRevisionResponse, GetWorkEditResponse, - GetWorkHistoryResponse, GetWorkRedirectsResponse, GetWorkReleasesResponse, GetWorkResponse, GetWorkRevisionResponse, LookupContainerResponse, LookupCreatorResponse, LookupFileResponse, - LookupReleaseResponse, UpdateContainerResponse, UpdateCreatorResponse, UpdateEditorResponse, UpdateFileResponse, UpdateFilesetResponse, UpdateReleaseResponse, UpdateWebcaptureResponse, - UpdateWorkResponse, + CreateCreatorResponse, CreateEditgroupAnnotationResponse, CreateEditgroupResponse, CreateFileBatchResponse, CreateFileResponse, CreateFilesetBatchResponse, CreateFilesetResponse, + CreateReleaseBatchResponse, CreateReleaseResponse, CreateWebcaptureBatchResponse, CreateWebcaptureResponse, CreateWorkBatchResponse, CreateWorkResponse, DeleteContainerEditResponse, + DeleteContainerResponse, DeleteCreatorEditResponse, DeleteCreatorResponse, DeleteFileEditResponse, DeleteFileResponse, DeleteFilesetEditResponse, DeleteFilesetResponse, DeleteReleaseEditResponse, + DeleteReleaseResponse, DeleteWebcaptureEditResponse, DeleteWebcaptureResponse, DeleteWorkEditResponse, DeleteWorkResponse, GetChangelogEntryResponse, GetChangelogResponse, + GetContainerEditResponse, GetContainerHistoryResponse, GetContainerRedirectsResponse, GetContainerResponse, GetContainerRevisionResponse, GetCreatorEditResponse, GetCreatorHistoryResponse, + GetCreatorRedirectsResponse, GetCreatorReleasesResponse, GetCreatorResponse, GetCreatorRevisionResponse, GetEditgroupAnnotationsResponse, GetEditgroupResponse, GetEditgroupsReviewableResponse, + GetEditorAnnotationsResponse, GetEditorEditgroupsResponse, GetEditorResponse, GetFileEditResponse, GetFileHistoryResponse, GetFileRedirectsResponse, GetFileResponse, GetFileRevisionResponse, + GetFilesetEditResponse, GetFilesetHistoryResponse, GetFilesetRedirectsResponse, GetFilesetResponse, GetFilesetRevisionResponse, GetReleaseEditResponse, GetReleaseFilesResponse, + GetReleaseFilesetsResponse, GetReleaseHistoryResponse, GetReleaseRedirectsResponse, GetReleaseResponse, GetReleaseRevisionResponse, GetReleaseWebcapturesResponse, GetWebcaptureEditResponse, + GetWebcaptureHistoryResponse, GetWebcaptureRedirectsResponse, GetWebcaptureResponse, GetWebcaptureRevisionResponse, GetWorkEditResponse, GetWorkHistoryResponse, GetWorkRedirectsResponse, + GetWorkReleasesResponse, GetWorkResponse, GetWorkRevisionResponse, LookupContainerResponse, LookupCreatorResponse, LookupFileResponse, LookupReleaseResponse, UpdateContainerResponse, + UpdateCreatorResponse, UpdateEditgroupResponse, UpdateEditorResponse, UpdateFileResponse, UpdateFilesetResponse, UpdateReleaseResponse, UpdateWebcaptureResponse, UpdateWorkResponse, }; #[allow(unused_imports)] use futures::{future, stream, Future, Stream}; @@ -55,12 +55,15 @@ fn main() { "GetCreatorRevision", "LookupCreator", "AuthCheck", + "GetEditgroupsReviewable", "GetEditor", - "GetEditorChangelog", + "GetEditorEditgroups", "AcceptEditgroup", "GetChangelog", "GetChangelogEntry", "GetEditgroup", + "GetEditgroupAnnotations", + "GetEditorAnnotations", "CreateFileBatch", "DeleteFile", "DeleteFileEdit", @@ -283,16 +286,27 @@ fn main() { // let result = client.auth_oidc(???).wait(); // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); // }, + Some("GetEditgroupsReviewable") => { + let result = client.get_editgroups_reviewable(Some("expand_example".to_string()), Some(789), None, None).wait(); + println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); + } + Some("GetEditor") => { let result = client.get_editor("editor_id_example".to_string()).wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } - Some("GetEditorChangelog") => { - let result = client.get_editor_changelog("editor_id_example".to_string()).wait(); + Some("GetEditorEditgroups") => { + let result = client.get_editor_editgroups("editor_id_example".to_string(), Some(789), None, None).wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } + // Disabled because there's no example. + // Some("UpdateEditgroup") => { + // let result = client.update_editgroup("editgroup_id_example".to_string(), ???, Some(true)).wait(); + // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); + // }, + // Disabled because there's no example. // Some("UpdateEditor") => { // let result = client.update_editor("editor_id_example".to_string(), ???).wait(); @@ -308,6 +322,12 @@ fn main() { // let result = client.create_editgroup(???).wait(); // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); // }, + + // Disabled because there's no example. + // Some("CreateEditgroupAnnotation") => { + // let result = client.create_editgroup_annotation("editgroup_id_example".to_string(), ???).wait(); + // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); + // }, Some("GetChangelog") => { let result = client.get_changelog(Some(789)).wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); @@ -323,6 +343,16 @@ fn main() { println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } + Some("GetEditgroupAnnotations") => { + let result = client.get_editgroup_annotations("editgroup_id_example".to_string(), Some("expand_example".to_string())).wait(); + println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); + } + + Some("GetEditorAnnotations") => { + let result = client.get_editor_annotations("editor_id_example".to_string(), Some(789), None, None).wait(); + println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); + } + // Disabled because there's no example. // Some("CreateFile") => { // let result = client.create_file(???, "editgroup_id_example".to_string()).wait(); diff --git a/rust/fatcat-api-spec/examples/server_lib/server.rs b/rust/fatcat-api-spec/examples/server_lib/server.rs index febd61de..3c37106a 100644 --- a/rust/fatcat-api-spec/examples/server_lib/server.rs +++ b/rust/fatcat-api-spec/examples/server_lib/server.rs @@ -12,18 +12,18 @@ use swagger; use fatcat::models; use fatcat::{ AcceptEditgroupResponse, Api, ApiError, AuthCheckResponse, AuthOidcResponse, Context, CreateContainerBatchResponse, CreateContainerResponse, CreateCreatorBatchResponse, CreateCreatorResponse, - CreateEditgroupResponse, CreateFileBatchResponse, CreateFileResponse, CreateFilesetBatchResponse, CreateFilesetResponse, CreateReleaseBatchResponse, CreateReleaseResponse, - CreateWebcaptureBatchResponse, CreateWebcaptureResponse, CreateWorkBatchResponse, CreateWorkResponse, DeleteContainerEditResponse, DeleteContainerResponse, DeleteCreatorEditResponse, - DeleteCreatorResponse, DeleteFileEditResponse, DeleteFileResponse, DeleteFilesetEditResponse, DeleteFilesetResponse, DeleteReleaseEditResponse, DeleteReleaseResponse, + CreateEditgroupAnnotationResponse, CreateEditgroupResponse, CreateFileBatchResponse, CreateFileResponse, CreateFilesetBatchResponse, CreateFilesetResponse, CreateReleaseBatchResponse, + CreateReleaseResponse, CreateWebcaptureBatchResponse, CreateWebcaptureResponse, CreateWorkBatchResponse, CreateWorkResponse, DeleteContainerEditResponse, DeleteContainerResponse, + DeleteCreatorEditResponse, DeleteCreatorResponse, DeleteFileEditResponse, DeleteFileResponse, DeleteFilesetEditResponse, DeleteFilesetResponse, DeleteReleaseEditResponse, DeleteReleaseResponse, DeleteWebcaptureEditResponse, DeleteWebcaptureResponse, DeleteWorkEditResponse, DeleteWorkResponse, GetChangelogEntryResponse, GetChangelogResponse, GetContainerEditResponse, GetContainerHistoryResponse, GetContainerRedirectsResponse, GetContainerResponse, GetContainerRevisionResponse, GetCreatorEditResponse, GetCreatorHistoryResponse, GetCreatorRedirectsResponse, - GetCreatorReleasesResponse, GetCreatorResponse, GetCreatorRevisionResponse, GetEditgroupResponse, GetEditorChangelogResponse, GetEditorResponse, GetFileEditResponse, GetFileHistoryResponse, - GetFileRedirectsResponse, GetFileResponse, GetFileRevisionResponse, GetFilesetEditResponse, GetFilesetHistoryResponse, GetFilesetRedirectsResponse, GetFilesetResponse, GetFilesetRevisionResponse, - GetReleaseEditResponse, GetReleaseFilesResponse, GetReleaseFilesetsResponse, GetReleaseHistoryResponse, GetReleaseRedirectsResponse, GetReleaseResponse, GetReleaseRevisionResponse, - GetReleaseWebcapturesResponse, GetWebcaptureEditResponse, GetWebcaptureHistoryResponse, GetWebcaptureRedirectsResponse, GetWebcaptureResponse, GetWebcaptureRevisionResponse, GetWorkEditResponse, - GetWorkHistoryResponse, GetWorkRedirectsResponse, GetWorkReleasesResponse, GetWorkResponse, GetWorkRevisionResponse, LookupContainerResponse, LookupCreatorResponse, LookupFileResponse, - LookupReleaseResponse, UpdateContainerResponse, UpdateCreatorResponse, UpdateEditorResponse, UpdateFileResponse, UpdateFilesetResponse, UpdateReleaseResponse, UpdateWebcaptureResponse, - UpdateWorkResponse, + GetCreatorReleasesResponse, GetCreatorResponse, GetCreatorRevisionResponse, GetEditgroupAnnotationsResponse, GetEditgroupResponse, GetEditgroupsReviewableResponse, GetEditorAnnotationsResponse, + GetEditorEditgroupsResponse, GetEditorResponse, GetFileEditResponse, GetFileHistoryResponse, GetFileRedirectsResponse, GetFileResponse, GetFileRevisionResponse, GetFilesetEditResponse, + GetFilesetHistoryResponse, GetFilesetRedirectsResponse, GetFilesetResponse, GetFilesetRevisionResponse, GetReleaseEditResponse, GetReleaseFilesResponse, GetReleaseFilesetsResponse, + GetReleaseHistoryResponse, GetReleaseRedirectsResponse, GetReleaseResponse, GetReleaseRevisionResponse, GetReleaseWebcapturesResponse, GetWebcaptureEditResponse, GetWebcaptureHistoryResponse, + GetWebcaptureRedirectsResponse, GetWebcaptureResponse, GetWebcaptureRevisionResponse, GetWorkEditResponse, GetWorkHistoryResponse, GetWorkRedirectsResponse, GetWorkReleasesResponse, + GetWorkResponse, GetWorkRevisionResponse, LookupContainerResponse, LookupCreatorResponse, LookupFileResponse, LookupReleaseResponse, UpdateContainerResponse, UpdateCreatorResponse, + UpdateEditgroupResponse, UpdateEditorResponse, UpdateFileResponse, UpdateFilesetResponse, UpdateReleaseResponse, UpdateWebcaptureResponse, UpdateWorkResponse, }; #[derive(Copy, Clone)] @@ -303,15 +303,61 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } + fn get_editgroups_reviewable( + &self, + expand: Option, + limit: Option, + before: Option>, + since: Option>, + context: &Context, + ) -> Box + Send> { + let context = context.clone(); + println!( + "get_editgroups_reviewable({:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", + expand, + limit, + before, + since, + context.x_span_id.unwrap_or(String::from("")).clone() + ); + Box::new(futures::failed("Generic failure".into())) + } + fn get_editor(&self, editor_id: String, context: &Context) -> Box + Send> { let context = context.clone(); println!("get_editor(\"{}\") - X-Span-ID: {:?}", editor_id, context.x_span_id.unwrap_or(String::from("")).clone()); Box::new(futures::failed("Generic failure".into())) } - fn get_editor_changelog(&self, editor_id: String, context: &Context) -> Box + Send> { + fn get_editor_editgroups( + &self, + editor_id: String, + limit: Option, + before: Option>, + since: Option>, + context: &Context, + ) -> Box + Send> { let context = context.clone(); - println!("get_editor_changelog(\"{}\") - X-Span-ID: {:?}", editor_id, context.x_span_id.unwrap_or(String::from("")).clone()); + println!( + "get_editor_editgroups(\"{}\", {:?}, {:?}, {:?}) - X-Span-ID: {:?}", + editor_id, + limit, + before, + since, + context.x_span_id.unwrap_or(String::from("")).clone() + ); + Box::new(futures::failed("Generic failure".into())) + } + + fn update_editgroup(&self, editgroup_id: String, editgroup: models::Editgroup, submit: Option, context: &Context) -> Box + Send> { + let context = context.clone(); + println!( + "update_editgroup(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", + editgroup_id, + editgroup, + submit, + context.x_span_id.unwrap_or(String::from("")).clone() + ); Box::new(futures::failed("Generic failure".into())) } @@ -338,6 +384,22 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } + fn create_editgroup_annotation( + &self, + editgroup_id: String, + annotation: models::EditgroupAnnotation, + context: &Context, + ) -> Box + Send> { + let context = context.clone(); + println!( + "create_editgroup_annotation(\"{}\", {:?}) - X-Span-ID: {:?}", + editgroup_id, + annotation, + context.x_span_id.unwrap_or(String::from("")).clone() + ); + Box::new(futures::failed("Generic failure".into())) + } + fn get_changelog(&self, limit: Option, context: &Context) -> Box + Send> { let context = context.clone(); println!("get_changelog({:?}) - X-Span-ID: {:?}", limit, context.x_span_id.unwrap_or(String::from("")).clone()); @@ -356,6 +418,37 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } + fn get_editgroup_annotations(&self, editgroup_id: String, expand: Option, context: &Context) -> Box + Send> { + let context = context.clone(); + println!( + "get_editgroup_annotations(\"{}\", {:?}) - X-Span-ID: {:?}", + editgroup_id, + expand, + context.x_span_id.unwrap_or(String::from("")).clone() + ); + Box::new(futures::failed("Generic failure".into())) + } + + fn get_editor_annotations( + &self, + editor_id: String, + limit: Option, + before: Option>, + since: Option>, + context: &Context, + ) -> Box + Send> { + let context = context.clone(); + println!( + "get_editor_annotations(\"{}\", {:?}, {:?}, {:?}) - X-Span-ID: {:?}", + editor_id, + limit, + before, + since, + context.x_span_id.unwrap_or(String::from("")).clone() + ); + Box::new(futures::failed("Generic failure".into())) + } + fn create_file(&self, entity: models::FileEntity, editgroup_id: String, context: &Context) -> Box + Send> { let context = context.clone(); println!( diff --git a/rust/fatcat-api-spec/src/client.rs b/rust/fatcat-api-spec/src/client.rs index c5cf4297..a3e97fb3 100644 --- a/rust/fatcat-api-spec/src/client.rs +++ b/rust/fatcat-api-spec/src/client.rs @@ -36,18 +36,18 @@ use swagger::{ApiError, Context, XSpanId}; use models; use { AcceptEditgroupResponse, Api, AuthCheckResponse, AuthOidcResponse, CreateContainerBatchResponse, CreateContainerResponse, CreateCreatorBatchResponse, CreateCreatorResponse, - CreateEditgroupResponse, CreateFileBatchResponse, CreateFileResponse, CreateFilesetBatchResponse, CreateFilesetResponse, CreateReleaseBatchResponse, CreateReleaseResponse, - CreateWebcaptureBatchResponse, CreateWebcaptureResponse, CreateWorkBatchResponse, CreateWorkResponse, DeleteContainerEditResponse, DeleteContainerResponse, DeleteCreatorEditResponse, - DeleteCreatorResponse, DeleteFileEditResponse, DeleteFileResponse, DeleteFilesetEditResponse, DeleteFilesetResponse, DeleteReleaseEditResponse, DeleteReleaseResponse, + CreateEditgroupAnnotationResponse, CreateEditgroupResponse, CreateFileBatchResponse, CreateFileResponse, CreateFilesetBatchResponse, CreateFilesetResponse, CreateReleaseBatchResponse, + CreateReleaseResponse, CreateWebcaptureBatchResponse, CreateWebcaptureResponse, CreateWorkBatchResponse, CreateWorkResponse, DeleteContainerEditResponse, DeleteContainerResponse, + DeleteCreatorEditResponse, DeleteCreatorResponse, DeleteFileEditResponse, DeleteFileResponse, DeleteFilesetEditResponse, DeleteFilesetResponse, DeleteReleaseEditResponse, DeleteReleaseResponse, DeleteWebcaptureEditResponse, DeleteWebcaptureResponse, DeleteWorkEditResponse, DeleteWorkResponse, GetChangelogEntryResponse, GetChangelogResponse, GetContainerEditResponse, GetContainerHistoryResponse, GetContainerRedirectsResponse, GetContainerResponse, GetContainerRevisionResponse, GetCreatorEditResponse, GetCreatorHistoryResponse, GetCreatorRedirectsResponse, - GetCreatorReleasesResponse, GetCreatorResponse, GetCreatorRevisionResponse, GetEditgroupResponse, GetEditorChangelogResponse, GetEditorResponse, GetFileEditResponse, GetFileHistoryResponse, - GetFileRedirectsResponse, GetFileResponse, GetFileRevisionResponse, GetFilesetEditResponse, GetFilesetHistoryResponse, GetFilesetRedirectsResponse, GetFilesetResponse, GetFilesetRevisionResponse, - GetReleaseEditResponse, GetReleaseFilesResponse, GetReleaseFilesetsResponse, GetReleaseHistoryResponse, GetReleaseRedirectsResponse, GetReleaseResponse, GetReleaseRevisionResponse, - GetReleaseWebcapturesResponse, GetWebcaptureEditResponse, GetWebcaptureHistoryResponse, GetWebcaptureRedirectsResponse, GetWebcaptureResponse, GetWebcaptureRevisionResponse, GetWorkEditResponse, - GetWorkHistoryResponse, GetWorkRedirectsResponse, GetWorkReleasesResponse, GetWorkResponse, GetWorkRevisionResponse, LookupContainerResponse, LookupCreatorResponse, LookupFileResponse, - LookupReleaseResponse, UpdateContainerResponse, UpdateCreatorResponse, UpdateEditorResponse, UpdateFileResponse, UpdateFilesetResponse, UpdateReleaseResponse, UpdateWebcaptureResponse, - UpdateWorkResponse, + GetCreatorReleasesResponse, GetCreatorResponse, GetCreatorRevisionResponse, GetEditgroupAnnotationsResponse, GetEditgroupResponse, GetEditgroupsReviewableResponse, GetEditorAnnotationsResponse, + GetEditorEditgroupsResponse, GetEditorResponse, GetFileEditResponse, GetFileHistoryResponse, GetFileRedirectsResponse, GetFileResponse, GetFileRevisionResponse, GetFilesetEditResponse, + GetFilesetHistoryResponse, GetFilesetRedirectsResponse, GetFilesetResponse, GetFilesetRevisionResponse, GetReleaseEditResponse, GetReleaseFilesResponse, GetReleaseFilesetsResponse, + GetReleaseHistoryResponse, GetReleaseRedirectsResponse, GetReleaseResponse, GetReleaseRevisionResponse, GetReleaseWebcapturesResponse, GetWebcaptureEditResponse, GetWebcaptureHistoryResponse, + GetWebcaptureRedirectsResponse, GetWebcaptureResponse, GetWebcaptureRevisionResponse, GetWorkEditResponse, GetWorkHistoryResponse, GetWorkRedirectsResponse, GetWorkReleasesResponse, + GetWorkResponse, GetWorkRevisionResponse, LookupContainerResponse, LookupCreatorResponse, LookupFileResponse, LookupReleaseResponse, UpdateContainerResponse, UpdateCreatorResponse, + UpdateEditgroupResponse, UpdateEditorResponse, UpdateFileResponse, UpdateFilesetResponse, UpdateReleaseResponse, UpdateWebcaptureResponse, UpdateWorkResponse, }; /// Convert input into a base path, e.g. "http://example:123". Also checks the scheme as it goes. @@ -2203,6 +2203,86 @@ impl Api for Client { Box::new(futures::done(result)) } + fn get_editgroups_reviewable( + &self, + param_expand: Option, + param_limit: Option, + param_before: Option>, + param_since: Option>, + context: &Context, + ) -> Box + Send> { + // Query parameters + let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string())); + let query_limit = param_limit.map_or_else(String::new, |query| format!("limit={limit}&", limit = query.to_string())); + let query_before = param_before.map_or_else(String::new, |query| format!("before={before}&", before = query.to_string())); + let query_since = param_since.map_or_else(String::new, |query| format!("since={since}&", since = query.to_string())); + + let url = format!( + "{}/v0/editgroup/reviewable?{expand}{limit}{before}{since}", + self.base_path, + expand = utf8_percent_encode(&query_expand, QUERY_ENCODE_SET), + limit = utf8_percent_encode(&query_limit, QUERY_ENCODE_SET), + before = utf8_percent_encode(&query_before, QUERY_ENCODE_SET), + since = utf8_percent_encode(&query_since, QUERY_ENCODE_SET) + ); + + let hyper_client = (self.hyper_client)(); + let request = hyper_client.request(hyper::method::Method::Get, &url); + let mut custom_headers = hyper::header::Headers::new(); + + context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); + + let request = request.headers(custom_headers); + + // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). + fn parse_response(mut response: hyper::client::response::Response) -> Result { + match response.status.to_u16() { + 200 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::>(&buf)?; + + Ok(GetEditgroupsReviewableResponse::Found(body)) + } + 400 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetEditgroupsReviewableResponse::BadRequest(body)) + } + 404 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetEditgroupsReviewableResponse::NotFound(body)) + } + 500 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetEditgroupsReviewableResponse::GenericError(body)) + } + code => { + let mut buf = [0; 100]; + let debug_body = match response.read(&mut buf) { + Ok(len) => match str::from_utf8(&buf[..len]) { + Ok(body) => Cow::from(body), + Err(_) => Cow::from(format!("", &buf[..len].to_vec())), + }, + Err(e) => Cow::from(format!("", e)), + }; + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) + } + } + } + + let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); + Box::new(futures::done(result)) + } + fn get_editor(&self, param_editor_id: String, context: &Context) -> Box + Send> { let url = format!( "{}/v0/editor/{editor_id}", @@ -2267,11 +2347,26 @@ impl Api for Client { Box::new(futures::done(result)) } - fn get_editor_changelog(&self, param_editor_id: String, context: &Context) -> Box + Send> { + fn get_editor_editgroups( + &self, + param_editor_id: String, + param_limit: Option, + param_before: Option>, + param_since: Option>, + context: &Context, + ) -> Box + Send> { + // Query parameters + let query_limit = param_limit.map_or_else(String::new, |query| format!("limit={limit}&", limit = query.to_string())); + let query_before = param_before.map_or_else(String::new, |query| format!("before={before}&", before = query.to_string())); + let query_since = param_since.map_or_else(String::new, |query| format!("since={since}&", since = query.to_string())); + let url = format!( - "{}/v0/editor/{editor_id}/changelog", + "{}/v0/editor/{editor_id}/editgroups?{limit}{before}{since}", self.base_path, - editor_id = utf8_percent_encode(¶m_editor_id.to_string(), PATH_SEGMENT_ENCODE_SET) + editor_id = utf8_percent_encode(¶m_editor_id.to_string(), PATH_SEGMENT_ENCODE_SET), + limit = utf8_percent_encode(&query_limit, QUERY_ENCODE_SET), + before = utf8_percent_encode(&query_before, QUERY_ENCODE_SET), + since = utf8_percent_encode(&query_since, QUERY_ENCODE_SET) ); let hyper_client = (self.hyper_client)(); @@ -2283,35 +2378,136 @@ impl Api for Client { let request = request.headers(custom_headers); // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response(mut response: hyper::client::response::Response) -> Result { + fn parse_response(mut response: hyper::client::response::Response) -> Result { match response.status.to_u16() { 200 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; - let body = serde_json::from_str::>(&buf)?; + let body = serde_json::from_str::>(&buf)?; + + Ok(GetEditorEditgroupsResponse::Found(body)) + } + 400 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetEditorEditgroupsResponse::BadRequest(body)) + } + 404 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetEditorEditgroupsResponse::NotFound(body)) + } + 500 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetEditorEditgroupsResponse::GenericError(body)) + } + code => { + let mut buf = [0; 100]; + let debug_body = match response.read(&mut buf) { + Ok(len) => match str::from_utf8(&buf[..len]) { + Ok(body) => Cow::from(body), + Err(_) => Cow::from(format!("", &buf[..len].to_vec())), + }, + Err(e) => Cow::from(format!("", e)), + }; + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) + } + } + } + + let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); + Box::new(futures::done(result)) + } + + fn update_editgroup( + &self, + param_editgroup_id: String, + param_editgroup: models::Editgroup, + param_submit: Option, + context: &Context, + ) -> Box + Send> { + // Query parameters + let query_submit = param_submit.map_or_else(String::new, |query| format!("submit={submit}&", submit = query.to_string())); + + let url = format!( + "{}/v0/editgroup/{editgroup_id}?{submit}", + self.base_path, + editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET), + submit = utf8_percent_encode(&query_submit, QUERY_ENCODE_SET) + ); + + let body = serde_json::to_string(¶m_editgroup).expect("impossible to fail to serialize"); + + let hyper_client = (self.hyper_client)(); + let request = hyper_client.request(hyper::method::Method::Put, &url); + let mut custom_headers = hyper::header::Headers::new(); + + let request = request.body(&body); - Ok(GetEditorChangelogResponse::Found(body)) + custom_headers.set(ContentType(mimetypes::requests::UPDATE_EDITGROUP.clone())); + context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); + + let request = request.headers(custom_headers); + + // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). + fn parse_response(mut response: hyper::client::response::Response) -> Result { + match response.status.to_u16() { + 200 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(UpdateEditgroupResponse::UpdatedEditgroup(body)) } 400 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; - Ok(GetEditorChangelogResponse::BadRequest(body)) + Ok(UpdateEditgroupResponse::BadRequest(body)) + } + 401 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } + let response_www_authenticate = response + .headers + .get::() + .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?; + + Ok(UpdateEditgroupResponse::NotAuthorized { + body: body, + www_authenticate: response_www_authenticate.0.clone(), + }) + } + 403 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(UpdateEditgroupResponse::Forbidden(body)) } 404 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; - Ok(GetEditorChangelogResponse::NotFound(body)) + Ok(UpdateEditgroupResponse::NotFound(body)) } 500 => { let mut buf = String::new(); response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; - Ok(GetEditorChangelogResponse::GenericError(body)) + Ok(UpdateEditgroupResponse::GenericError(body)) } code => { let mut buf = [0; 100]; @@ -2602,6 +2798,102 @@ impl Api for Client { Box::new(futures::done(result)) } + fn create_editgroup_annotation( + &self, + param_editgroup_id: String, + param_annotation: models::EditgroupAnnotation, + context: &Context, + ) -> Box + Send> { + let url = format!( + "{}/v0/editgroup/{editgroup_id}/annotation", + self.base_path, + editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET) + ); + + let body = serde_json::to_string(¶m_annotation).expect("impossible to fail to serialize"); + + let hyper_client = (self.hyper_client)(); + let request = hyper_client.request(hyper::method::Method::Post, &url); + let mut custom_headers = hyper::header::Headers::new(); + + let request = request.body(&body); + + custom_headers.set(ContentType(mimetypes::requests::CREATE_EDITGROUP_ANNOTATION.clone())); + context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); + + let request = request.headers(custom_headers); + + // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). + fn parse_response(mut response: hyper::client::response::Response) -> Result { + match response.status.to_u16() { + 201 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(CreateEditgroupAnnotationResponse::Created(body)) + } + 400 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(CreateEditgroupAnnotationResponse::BadRequest(body)) + } + 401 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } + let response_www_authenticate = response + .headers + .get::() + .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?; + + Ok(CreateEditgroupAnnotationResponse::NotAuthorized { + body: body, + www_authenticate: response_www_authenticate.0.clone(), + }) + } + 403 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(CreateEditgroupAnnotationResponse::Forbidden(body)) + } + 404 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(CreateEditgroupAnnotationResponse::NotFound(body)) + } + 500 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(CreateEditgroupAnnotationResponse::GenericError(body)) + } + code => { + let mut buf = [0; 100]; + let debug_body = match response.read(&mut buf) { + Ok(len) => match str::from_utf8(&buf[..len]) { + Ok(body) => Cow::from(body), + Err(_) => Cow::from(format!("", &buf[..len].to_vec())), + }, + Err(e) => Cow::from(format!("", e)), + }; + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) + } + } + } + + let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); + Box::new(futures::done(result)) + } + fn get_changelog(&self, param_limit: Option, context: &Context) -> Box + Send> { // Query parameters let query_limit = param_limit.map_or_else(String::new, |query| format!("limit={limit}&", limit = query.to_string())); @@ -2786,6 +3078,197 @@ impl Api for Client { Box::new(futures::done(result)) } + fn get_editgroup_annotations(&self, param_editgroup_id: String, param_expand: Option, context: &Context) -> Box + Send> { + // Query parameters + let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string())); + + let url = format!( + "{}/v0/editgroup/{editgroup_id}/annotations?{expand}", + self.base_path, + editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET), + expand = utf8_percent_encode(&query_expand, QUERY_ENCODE_SET) + ); + + let hyper_client = (self.hyper_client)(); + let request = hyper_client.request(hyper::method::Method::Get, &url); + let mut custom_headers = hyper::header::Headers::new(); + + context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); + + let request = request.headers(custom_headers); + + // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). + fn parse_response(mut response: hyper::client::response::Response) -> Result { + match response.status.to_u16() { + 200 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::>(&buf)?; + + Ok(GetEditgroupAnnotationsResponse::Success(body)) + } + 400 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetEditgroupAnnotationsResponse::BadRequest(body)) + } + 401 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } + let response_www_authenticate = response + .headers + .get::() + .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?; + + Ok(GetEditgroupAnnotationsResponse::NotAuthorized { + body: body, + www_authenticate: response_www_authenticate.0.clone(), + }) + } + 403 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetEditgroupAnnotationsResponse::Forbidden(body)) + } + 404 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetEditgroupAnnotationsResponse::NotFound(body)) + } + 500 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetEditgroupAnnotationsResponse::GenericError(body)) + } + code => { + let mut buf = [0; 100]; + let debug_body = match response.read(&mut buf) { + Ok(len) => match str::from_utf8(&buf[..len]) { + Ok(body) => Cow::from(body), + Err(_) => Cow::from(format!("", &buf[..len].to_vec())), + }, + Err(e) => Cow::from(format!("", e)), + }; + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) + } + } + } + + let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); + Box::new(futures::done(result)) + } + + fn get_editor_annotations( + &self, + param_editor_id: String, + param_limit: Option, + param_before: Option>, + param_since: Option>, + context: &Context, + ) -> Box + Send> { + // Query parameters + let query_limit = param_limit.map_or_else(String::new, |query| format!("limit={limit}&", limit = query.to_string())); + let query_before = param_before.map_or_else(String::new, |query| format!("before={before}&", before = query.to_string())); + let query_since = param_since.map_or_else(String::new, |query| format!("since={since}&", since = query.to_string())); + + let url = format!( + "{}/v0/editor/{editor_id}/annotations?{limit}{before}{since}", + self.base_path, + editor_id = utf8_percent_encode(¶m_editor_id.to_string(), PATH_SEGMENT_ENCODE_SET), + limit = utf8_percent_encode(&query_limit, QUERY_ENCODE_SET), + before = utf8_percent_encode(&query_before, QUERY_ENCODE_SET), + since = utf8_percent_encode(&query_since, QUERY_ENCODE_SET) + ); + + let hyper_client = (self.hyper_client)(); + let request = hyper_client.request(hyper::method::Method::Get, &url); + let mut custom_headers = hyper::header::Headers::new(); + + context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); + + let request = request.headers(custom_headers); + + // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). + fn parse_response(mut response: hyper::client::response::Response) -> Result { + match response.status.to_u16() { + 200 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::>(&buf)?; + + Ok(GetEditorAnnotationsResponse::Success(body)) + } + 400 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetEditorAnnotationsResponse::BadRequest(body)) + } + 401 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } + let response_www_authenticate = response + .headers + .get::() + .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?; + + Ok(GetEditorAnnotationsResponse::NotAuthorized { + body: body, + www_authenticate: response_www_authenticate.0.clone(), + }) + } + 403 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetEditorAnnotationsResponse::Forbidden(body)) + } + 404 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetEditorAnnotationsResponse::NotFound(body)) + } + 500 => { + let mut buf = String::new(); + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + let body = serde_json::from_str::(&buf)?; + + Ok(GetEditorAnnotationsResponse::GenericError(body)) + } + code => { + let mut buf = [0; 100]; + let debug_body = match response.read(&mut buf) { + Ok(len) => match str::from_utf8(&buf[..len]) { + Ok(body) => Cow::from(body), + Err(_) => Cow::from(format!("", &buf[..len].to_vec())), + }, + Err(e) => Cow::from(format!("", e)), + }; + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) + } + } + } + + let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); + Box::new(futures::done(result)) + } + fn create_file(&self, param_entity: models::FileEntity, param_editgroup_id: String, context: &Context) -> Box + Send> { // Query parameters let query_editgroup_id = format!("editgroup_id={editgroup_id}&", editgroup_id = param_editgroup_id.to_string()); diff --git a/rust/fatcat-api-spec/src/lib.rs b/rust/fatcat-api-spec/src/lib.rs index 3f1afa67..9585f1c0 100644 --- a/rust/fatcat-api-spec/src/lib.rs +++ b/rust/fatcat-api-spec/src/lib.rs @@ -380,6 +380,18 @@ pub enum AuthOidcResponse { GenericError(models::ErrorResponse), } +#[derive(Debug, PartialEq)] +pub enum GetEditgroupsReviewableResponse { + /// Found + Found(Vec), + /// Bad Request + BadRequest(models::ErrorResponse), + /// Not Found + NotFound(models::ErrorResponse), + /// Generic Error + GenericError(models::ErrorResponse), +} + #[derive(Debug, PartialEq)] pub enum GetEditorResponse { /// Found @@ -393,11 +405,27 @@ pub enum GetEditorResponse { } #[derive(Debug, PartialEq)] -pub enum GetEditorChangelogResponse { +pub enum GetEditorEditgroupsResponse { /// Found - Found(Vec), + Found(Vec), + /// Bad Request + BadRequest(models::ErrorResponse), + /// Not Found + NotFound(models::ErrorResponse), + /// Generic Error + GenericError(models::ErrorResponse), +} + +#[derive(Debug, PartialEq)] +pub enum UpdateEditgroupResponse { + /// Updated Editgroup + UpdatedEditgroup(models::Editgroup), /// Bad Request BadRequest(models::ErrorResponse), + /// Not Authorized + NotAuthorized { body: models::ErrorResponse, www_authenticate: String }, + /// Forbidden + Forbidden(models::ErrorResponse), /// Not Found NotFound(models::ErrorResponse), /// Generic Error @@ -454,6 +482,22 @@ pub enum CreateEditgroupResponse { GenericError(models::ErrorResponse), } +#[derive(Debug, PartialEq)] +pub enum CreateEditgroupAnnotationResponse { + /// Created + Created(models::EditgroupAnnotation), + /// Bad Request + BadRequest(models::ErrorResponse), + /// Not Authorized + NotAuthorized { body: models::ErrorResponse, www_authenticate: String }, + /// Forbidden + Forbidden(models::ErrorResponse), + /// Not Found + NotFound(models::ErrorResponse), + /// Generic Error + GenericError(models::ErrorResponse), +} + #[derive(Debug, PartialEq)] pub enum GetChangelogResponse { /// Success @@ -488,6 +532,38 @@ pub enum GetEditgroupResponse { GenericError(models::ErrorResponse), } +#[derive(Debug, PartialEq)] +pub enum GetEditgroupAnnotationsResponse { + /// Success + Success(Vec), + /// Bad Request + BadRequest(models::ErrorResponse), + /// Not Authorized + NotAuthorized { body: models::ErrorResponse, www_authenticate: String }, + /// Forbidden + Forbidden(models::ErrorResponse), + /// Not Found + NotFound(models::ErrorResponse), + /// Generic Error + GenericError(models::ErrorResponse), +} + +#[derive(Debug, PartialEq)] +pub enum GetEditorAnnotationsResponse { + /// Success + Success(Vec), + /// Bad Request + BadRequest(models::ErrorResponse), + /// Not Authorized + NotAuthorized { body: models::ErrorResponse, www_authenticate: String }, + /// Forbidden + Forbidden(models::ErrorResponse), + /// Not Found + NotFound(models::ErrorResponse), + /// Generic Error + GenericError(models::ErrorResponse), +} + #[derive(Debug, PartialEq)] pub enum CreateFileResponse { /// Created Entity @@ -1338,9 +1414,27 @@ pub trait Api { fn auth_oidc(&self, oidc_params: models::AuthOidc, context: &Context) -> Box + Send>; + fn get_editgroups_reviewable( + &self, + expand: Option, + limit: Option, + before: Option>, + since: Option>, + context: &Context, + ) -> Box + Send>; + fn get_editor(&self, editor_id: String, context: &Context) -> Box + Send>; - fn get_editor_changelog(&self, editor_id: String, context: &Context) -> Box + Send>; + fn get_editor_editgroups( + &self, + editor_id: String, + limit: Option, + before: Option>, + since: Option>, + context: &Context, + ) -> Box + Send>; + + fn update_editgroup(&self, editgroup_id: String, editgroup: models::Editgroup, submit: Option, context: &Context) -> Box + Send>; fn update_editor(&self, editor_id: String, editor: models::Editor, context: &Context) -> Box + Send>; @@ -1348,12 +1442,30 @@ pub trait Api { fn create_editgroup(&self, editgroup: models::Editgroup, context: &Context) -> Box + Send>; + fn create_editgroup_annotation( + &self, + editgroup_id: String, + annotation: models::EditgroupAnnotation, + context: &Context, + ) -> Box + Send>; + fn get_changelog(&self, limit: Option, context: &Context) -> Box + Send>; fn get_changelog_entry(&self, index: i64, context: &Context) -> Box + Send>; fn get_editgroup(&self, editgroup_id: String, context: &Context) -> Box + Send>; + fn get_editgroup_annotations(&self, editgroup_id: String, expand: Option, context: &Context) -> Box + Send>; + + fn get_editor_annotations( + &self, + editor_id: String, + limit: Option, + before: Option>, + since: Option>, + context: &Context, + ) -> Box + Send>; + fn create_file(&self, entity: models::FileEntity, editgroup_id: String, context: &Context) -> Box + Send>; fn create_file_batch( @@ -1584,9 +1696,25 @@ pub trait ApiNoContext { fn auth_oidc(&self, oidc_params: models::AuthOidc) -> Box + Send>; + fn get_editgroups_reviewable( + &self, + expand: Option, + limit: Option, + before: Option>, + since: Option>, + ) -> Box + Send>; + fn get_editor(&self, editor_id: String) -> Box + Send>; - fn get_editor_changelog(&self, editor_id: String) -> Box + Send>; + fn get_editor_editgroups( + &self, + editor_id: String, + limit: Option, + before: Option>, + since: Option>, + ) -> Box + Send>; + + fn update_editgroup(&self, editgroup_id: String, editgroup: models::Editgroup, submit: Option) -> Box + Send>; fn update_editor(&self, editor_id: String, editor: models::Editor) -> Box + Send>; @@ -1594,12 +1722,24 @@ pub trait ApiNoContext { fn create_editgroup(&self, editgroup: models::Editgroup) -> Box + Send>; + fn create_editgroup_annotation(&self, editgroup_id: String, annotation: models::EditgroupAnnotation) -> Box + Send>; + fn get_changelog(&self, limit: Option) -> Box + Send>; fn get_changelog_entry(&self, index: i64) -> Box + Send>; fn get_editgroup(&self, editgroup_id: String) -> Box + Send>; + fn get_editgroup_annotations(&self, editgroup_id: String, expand: Option) -> Box + Send>; + + fn get_editor_annotations( + &self, + editor_id: String, + limit: Option, + before: Option>, + since: Option>, + ) -> Box + Send>; + fn create_file(&self, entity: models::FileEntity, editgroup_id: String) -> Box + Send>; fn create_file_batch(&self, entity_list: &Vec, autoaccept: Option, editgroup_id: Option) -> Box + Send>; @@ -1877,12 +2017,32 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { self.api().auth_oidc(oidc_params, &self.context()) } + fn get_editgroups_reviewable( + &self, + expand: Option, + limit: Option, + before: Option>, + since: Option>, + ) -> Box + Send> { + self.api().get_editgroups_reviewable(expand, limit, before, since, &self.context()) + } + fn get_editor(&self, editor_id: String) -> Box + Send> { self.api().get_editor(editor_id, &self.context()) } - fn get_editor_changelog(&self, editor_id: String) -> Box + Send> { - self.api().get_editor_changelog(editor_id, &self.context()) + fn get_editor_editgroups( + &self, + editor_id: String, + limit: Option, + before: Option>, + since: Option>, + ) -> Box + Send> { + self.api().get_editor_editgroups(editor_id, limit, before, since, &self.context()) + } + + fn update_editgroup(&self, editgroup_id: String, editgroup: models::Editgroup, submit: Option) -> Box + Send> { + self.api().update_editgroup(editgroup_id, editgroup, submit, &self.context()) } fn update_editor(&self, editor_id: String, editor: models::Editor) -> Box + Send> { @@ -1897,6 +2057,10 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { self.api().create_editgroup(editgroup, &self.context()) } + fn create_editgroup_annotation(&self, editgroup_id: String, annotation: models::EditgroupAnnotation) -> Box + Send> { + self.api().create_editgroup_annotation(editgroup_id, annotation, &self.context()) + } + fn get_changelog(&self, limit: Option) -> Box + Send> { self.api().get_changelog(limit, &self.context()) } @@ -1909,6 +2073,20 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { self.api().get_editgroup(editgroup_id, &self.context()) } + fn get_editgroup_annotations(&self, editgroup_id: String, expand: Option) -> Box + Send> { + self.api().get_editgroup_annotations(editgroup_id, expand, &self.context()) + } + + fn get_editor_annotations( + &self, + editor_id: String, + limit: Option, + before: Option>, + since: Option>, + ) -> Box + Send> { + self.api().get_editor_annotations(editor_id, limit, before, since, &self.context()) + } + fn create_file(&self, entity: models::FileEntity, editgroup_id: String) -> Box + Send> { self.api().create_file(entity, editgroup_id, &self.context()) } diff --git a/rust/fatcat-api-spec/src/mimetypes.rs b/rust/fatcat-api-spec/src/mimetypes.rs index 11159610..5c916e47 100644 --- a/rust/fatcat-api-spec/src/mimetypes.rs +++ b/rust/fatcat-api-spec/src/mimetypes.rs @@ -500,6 +500,22 @@ pub mod responses { lazy_static! { pub static ref AUTH_OIDC_GENERIC_ERROR: Mime = mime!(Application / Json); } + /// Create Mime objects for the response content types for GetEditgroupsReviewable + lazy_static! { + pub static ref GET_EDITGROUPS_REVIEWABLE_FOUND: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetEditgroupsReviewable + lazy_static! { + pub static ref GET_EDITGROUPS_REVIEWABLE_BAD_REQUEST: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetEditgroupsReviewable + lazy_static! { + pub static ref GET_EDITGROUPS_REVIEWABLE_NOT_FOUND: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetEditgroupsReviewable + lazy_static! { + pub static ref GET_EDITGROUPS_REVIEWABLE_GENERIC_ERROR: Mime = mime!(Application / Json); + } /// Create Mime objects for the response content types for GetEditor lazy_static! { pub static ref GET_EDITOR_FOUND: Mime = mime!(Application / Json); @@ -516,21 +532,45 @@ pub mod responses { lazy_static! { pub static ref GET_EDITOR_GENERIC_ERROR: Mime = mime!(Application / Json); } - /// Create Mime objects for the response content types for GetEditorChangelog + /// Create Mime objects for the response content types for GetEditorEditgroups + lazy_static! { + pub static ref GET_EDITOR_EDITGROUPS_FOUND: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetEditorEditgroups + lazy_static! { + pub static ref GET_EDITOR_EDITGROUPS_BAD_REQUEST: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetEditorEditgroups + lazy_static! { + pub static ref GET_EDITOR_EDITGROUPS_NOT_FOUND: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetEditorEditgroups + lazy_static! { + pub static ref GET_EDITOR_EDITGROUPS_GENERIC_ERROR: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for UpdateEditgroup + lazy_static! { + pub static ref UPDATE_EDITGROUP_UPDATED_EDITGROUP: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for UpdateEditgroup + lazy_static! { + pub static ref UPDATE_EDITGROUP_BAD_REQUEST: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for UpdateEditgroup lazy_static! { - pub static ref GET_EDITOR_CHANGELOG_FOUND: Mime = mime!(Application / Json); + pub static ref UPDATE_EDITGROUP_NOT_AUTHORIZED: Mime = mime!(Application / Json); } - /// Create Mime objects for the response content types for GetEditorChangelog + /// Create Mime objects for the response content types for UpdateEditgroup lazy_static! { - pub static ref GET_EDITOR_CHANGELOG_BAD_REQUEST: Mime = mime!(Application / Json); + pub static ref UPDATE_EDITGROUP_FORBIDDEN: Mime = mime!(Application / Json); } - /// Create Mime objects for the response content types for GetEditorChangelog + /// Create Mime objects for the response content types for UpdateEditgroup lazy_static! { - pub static ref GET_EDITOR_CHANGELOG_NOT_FOUND: Mime = mime!(Application / Json); + pub static ref UPDATE_EDITGROUP_NOT_FOUND: Mime = mime!(Application / Json); } - /// Create Mime objects for the response content types for GetEditorChangelog + /// Create Mime objects for the response content types for UpdateEditgroup lazy_static! { - pub static ref GET_EDITOR_CHANGELOG_GENERIC_ERROR: Mime = mime!(Application / Json); + pub static ref UPDATE_EDITGROUP_GENERIC_ERROR: Mime = mime!(Application / Json); } /// Create Mime objects for the response content types for UpdateEditor lazy_static! { @@ -608,6 +648,30 @@ pub mod responses { lazy_static! { pub static ref CREATE_EDITGROUP_GENERIC_ERROR: Mime = mime!(Application / Json); } + /// Create Mime objects for the response content types for CreateEditgroupAnnotation + lazy_static! { + pub static ref CREATE_EDITGROUP_ANNOTATION_CREATED: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for CreateEditgroupAnnotation + lazy_static! { + pub static ref CREATE_EDITGROUP_ANNOTATION_BAD_REQUEST: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for CreateEditgroupAnnotation + lazy_static! { + pub static ref CREATE_EDITGROUP_ANNOTATION_NOT_AUTHORIZED: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for CreateEditgroupAnnotation + lazy_static! { + pub static ref CREATE_EDITGROUP_ANNOTATION_FORBIDDEN: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for CreateEditgroupAnnotation + lazy_static! { + pub static ref CREATE_EDITGROUP_ANNOTATION_NOT_FOUND: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for CreateEditgroupAnnotation + lazy_static! { + pub static ref CREATE_EDITGROUP_ANNOTATION_GENERIC_ERROR: Mime = mime!(Application / Json); + } /// Create Mime objects for the response content types for GetChangelog lazy_static! { pub static ref GET_CHANGELOG_SUCCESS: Mime = mime!(Application / Json); @@ -652,6 +716,54 @@ pub mod responses { lazy_static! { pub static ref GET_EDITGROUP_GENERIC_ERROR: Mime = mime!(Application / Json); } + /// Create Mime objects for the response content types for GetEditgroupAnnotations + lazy_static! { + pub static ref GET_EDITGROUP_ANNOTATIONS_SUCCESS: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetEditgroupAnnotations + lazy_static! { + pub static ref GET_EDITGROUP_ANNOTATIONS_BAD_REQUEST: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetEditgroupAnnotations + lazy_static! { + pub static ref GET_EDITGROUP_ANNOTATIONS_NOT_AUTHORIZED: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetEditgroupAnnotations + lazy_static! { + pub static ref GET_EDITGROUP_ANNOTATIONS_FORBIDDEN: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetEditgroupAnnotations + lazy_static! { + pub static ref GET_EDITGROUP_ANNOTATIONS_NOT_FOUND: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetEditgroupAnnotations + lazy_static! { + pub static ref GET_EDITGROUP_ANNOTATIONS_GENERIC_ERROR: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetEditorAnnotations + lazy_static! { + pub static ref GET_EDITOR_ANNOTATIONS_SUCCESS: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetEditorAnnotations + lazy_static! { + pub static ref GET_EDITOR_ANNOTATIONS_BAD_REQUEST: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetEditorAnnotations + lazy_static! { + pub static ref GET_EDITOR_ANNOTATIONS_NOT_AUTHORIZED: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetEditorAnnotations + lazy_static! { + pub static ref GET_EDITOR_ANNOTATIONS_FORBIDDEN: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetEditorAnnotations + lazy_static! { + pub static ref GET_EDITOR_ANNOTATIONS_NOT_FOUND: Mime = mime!(Application / Json); + } + /// Create Mime objects for the response content types for GetEditorAnnotations + lazy_static! { + pub static ref GET_EDITOR_ANNOTATIONS_GENERIC_ERROR: Mime = mime!(Application / Json); + } /// Create Mime objects for the response content types for CreateFile lazy_static! { pub static ref CREATE_FILE_CREATED_ENTITY: Mime = mime!(Application / Json); @@ -1781,6 +1893,10 @@ pub mod requests { lazy_static! { pub static ref AUTH_OIDC: Mime = mime!(Application / Json); } + /// Create Mime objects for the request content types for UpdateEditgroup + lazy_static! { + pub static ref UPDATE_EDITGROUP: Mime = mime!(Application / Json); + } /// Create Mime objects for the request content types for UpdateEditor lazy_static! { pub static ref UPDATE_EDITOR: Mime = mime!(Application / Json); @@ -1789,6 +1905,10 @@ pub mod requests { lazy_static! { pub static ref CREATE_EDITGROUP: Mime = mime!(Application / Json); } + /// Create Mime objects for the request content types for CreateEditgroupAnnotation + lazy_static! { + pub static ref CREATE_EDITGROUP_ANNOTATION: Mime = mime!(Application / Json); + } /// Create Mime objects for the request content types for CreateFile lazy_static! { pub static ref CREATE_FILE: Mime = mime!(Application / Json); diff --git a/rust/fatcat-api-spec/src/models.rs b/rust/fatcat-api-spec/src/models.rs index a5c588a0..d07aa320 100644 --- a/rust/fatcat-api-spec/src/models.rs +++ b/rust/fatcat-api-spec/src/models.rs @@ -234,6 +234,10 @@ pub struct Editgroup { #[serde(skip_serializing_if = "Option::is_none")] pub editor_id: Option, + #[serde(rename = "submitted")] + #[serde(skip_serializing_if = "Option::is_none")] + pub submitted: Option>, + #[serde(rename = "description")] #[serde(skip_serializing_if = "Option::is_none")] pub description: Option, @@ -242,6 +246,10 @@ pub struct Editgroup { #[serde(skip_serializing_if = "Option::is_none")] pub extra: Option, + #[serde(rename = "annotations")] + #[serde(skip_serializing_if = "Option::is_none")] + pub annotations: Option>, + #[serde(rename = "edits")] #[serde(skip_serializing_if = "Option::is_none")] pub edits: Option, @@ -252,13 +260,58 @@ impl Editgroup { Editgroup { editgroup_id: None, editor_id: None, + submitted: None, description: None, extra: None, + annotations: None, edits: None, } } } +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +pub struct EditgroupAnnotation { + /// UUID (lower-case, dash-separated, hex-encoded 128-bit) + #[serde(rename = "annotation_id")] + #[serde(skip_serializing_if = "Option::is_none")] + pub annotation_id: Option, + + /// base32-encoded unique identifier + #[serde(rename = "editgroup_id")] + #[serde(skip_serializing_if = "Option::is_none")] + pub editgroup_id: Option, + + /// base32-encoded unique identifier + #[serde(rename = "editor_id")] + #[serde(skip_serializing_if = "Option::is_none")] + pub editor_id: Option, + + #[serde(rename = "created")] + #[serde(skip_serializing_if = "Option::is_none")] + pub created: Option>, + + #[serde(rename = "comment_markdown")] + #[serde(skip_serializing_if = "Option::is_none")] + pub comment_markdown: Option, + + #[serde(rename = "extra")] + #[serde(skip_serializing_if = "Option::is_none")] + pub extra: Option, +} + +impl EditgroupAnnotation { + pub fn new() -> EditgroupAnnotation { + EditgroupAnnotation { + annotation_id: None, + editgroup_id: None, + editor_id: None, + created: None, + comment_markdown: None, + extra: None, + } + } +} + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct EditgroupEdits { #[serde(rename = "containers")] diff --git a/rust/fatcat-api-spec/src/server.rs b/rust/fatcat-api-spec/src/server.rs index 03875a38..8b616959 100644 --- a/rust/fatcat-api-spec/src/server.rs +++ b/rust/fatcat-api-spec/src/server.rs @@ -38,18 +38,18 @@ use swagger::{ApiError, Context, XSpanId}; use models; use { AcceptEditgroupResponse, Api, AuthCheckResponse, AuthOidcResponse, CreateContainerBatchResponse, CreateContainerResponse, CreateCreatorBatchResponse, CreateCreatorResponse, - CreateEditgroupResponse, CreateFileBatchResponse, CreateFileResponse, CreateFilesetBatchResponse, CreateFilesetResponse, CreateReleaseBatchResponse, CreateReleaseResponse, - CreateWebcaptureBatchResponse, CreateWebcaptureResponse, CreateWorkBatchResponse, CreateWorkResponse, DeleteContainerEditResponse, DeleteContainerResponse, DeleteCreatorEditResponse, - DeleteCreatorResponse, DeleteFileEditResponse, DeleteFileResponse, DeleteFilesetEditResponse, DeleteFilesetResponse, DeleteReleaseEditResponse, DeleteReleaseResponse, + CreateEditgroupAnnotationResponse, CreateEditgroupResponse, CreateFileBatchResponse, CreateFileResponse, CreateFilesetBatchResponse, CreateFilesetResponse, CreateReleaseBatchResponse, + CreateReleaseResponse, CreateWebcaptureBatchResponse, CreateWebcaptureResponse, CreateWorkBatchResponse, CreateWorkResponse, DeleteContainerEditResponse, DeleteContainerResponse, + DeleteCreatorEditResponse, DeleteCreatorResponse, DeleteFileEditResponse, DeleteFileResponse, DeleteFilesetEditResponse, DeleteFilesetResponse, DeleteReleaseEditResponse, DeleteReleaseResponse, DeleteWebcaptureEditResponse, DeleteWebcaptureResponse, DeleteWorkEditResponse, DeleteWorkResponse, GetChangelogEntryResponse, GetChangelogResponse, GetContainerEditResponse, GetContainerHistoryResponse, GetContainerRedirectsResponse, GetContainerResponse, GetContainerRevisionResponse, GetCreatorEditResponse, GetCreatorHistoryResponse, GetCreatorRedirectsResponse, - GetCreatorReleasesResponse, GetCreatorResponse, GetCreatorRevisionResponse, GetEditgroupResponse, GetEditorChangelogResponse, GetEditorResponse, GetFileEditResponse, GetFileHistoryResponse, - GetFileRedirectsResponse, GetFileResponse, GetFileRevisionResponse, GetFilesetEditResponse, GetFilesetHistoryResponse, GetFilesetRedirectsResponse, GetFilesetResponse, GetFilesetRevisionResponse, - GetReleaseEditResponse, GetReleaseFilesResponse, GetReleaseFilesetsResponse, GetReleaseHistoryResponse, GetReleaseRedirectsResponse, GetReleaseResponse, GetReleaseRevisionResponse, - GetReleaseWebcapturesResponse, GetWebcaptureEditResponse, GetWebcaptureHistoryResponse, GetWebcaptureRedirectsResponse, GetWebcaptureResponse, GetWebcaptureRevisionResponse, GetWorkEditResponse, - GetWorkHistoryResponse, GetWorkRedirectsResponse, GetWorkReleasesResponse, GetWorkResponse, GetWorkRevisionResponse, LookupContainerResponse, LookupCreatorResponse, LookupFileResponse, - LookupReleaseResponse, UpdateContainerResponse, UpdateCreatorResponse, UpdateEditorResponse, UpdateFileResponse, UpdateFilesetResponse, UpdateReleaseResponse, UpdateWebcaptureResponse, - UpdateWorkResponse, + GetCreatorReleasesResponse, GetCreatorResponse, GetCreatorRevisionResponse, GetEditgroupAnnotationsResponse, GetEditgroupResponse, GetEditgroupsReviewableResponse, GetEditorAnnotationsResponse, + GetEditorEditgroupsResponse, GetEditorResponse, GetFileEditResponse, GetFileHistoryResponse, GetFileRedirectsResponse, GetFileResponse, GetFileRevisionResponse, GetFilesetEditResponse, + GetFilesetHistoryResponse, GetFilesetRedirectsResponse, GetFilesetResponse, GetFilesetRevisionResponse, GetReleaseEditResponse, GetReleaseFilesResponse, GetReleaseFilesetsResponse, + GetReleaseHistoryResponse, GetReleaseRedirectsResponse, GetReleaseResponse, GetReleaseRevisionResponse, GetReleaseWebcapturesResponse, GetWebcaptureEditResponse, GetWebcaptureHistoryResponse, + GetWebcaptureRedirectsResponse, GetWebcaptureResponse, GetWebcaptureRevisionResponse, GetWorkEditResponse, GetWorkHistoryResponse, GetWorkRedirectsResponse, GetWorkReleasesResponse, + GetWorkResponse, GetWorkRevisionResponse, LookupContainerResponse, LookupCreatorResponse, LookupFileResponse, LookupReleaseResponse, UpdateContainerResponse, UpdateCreatorResponse, + UpdateEditgroupResponse, UpdateEditorResponse, UpdateFileResponse, UpdateFilesetResponse, UpdateReleaseResponse, UpdateWebcaptureResponse, UpdateWorkResponse, }; header! { (Warning, "Warning") => [String] } @@ -2883,6 +2883,87 @@ where "AuthOidc", ); + let api_clone = api.clone(); + router.get( + "/v0/editgroup/reviewable", + move |req: &mut Request| { + let mut context = Context::default(); + + // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). + fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result + where + T: Api, + { + context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); + context.auth_data = req.extensions.remove::(); + context.authorization = req.extensions.remove::(); + + // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) + let query_params = req.get::().unwrap_or_default(); + let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_limit = query_params.get("limit").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_before = query_params.get("before").and_then(|list| list.first()).and_then(|x| x.parse::>().ok()); + let param_since = query_params.get("since").and_then(|list| list.first()).and_then(|x| x.parse::>().ok()); + + match api.get_editgroups_reviewable(param_expand, param_limit, param_before, param_since, context).wait() { + Ok(rsp) => match rsp { + GetEditgroupsReviewableResponse::Found(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(200), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_EDITGROUPS_REVIEWABLE_FOUND.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + GetEditgroupsReviewableResponse::BadRequest(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(400), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_EDITGROUPS_REVIEWABLE_BAD_REQUEST.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + GetEditgroupsReviewableResponse::NotFound(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(404), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_EDITGROUPS_REVIEWABLE_NOT_FOUND.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + GetEditgroupsReviewableResponse::GenericError(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(500), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_EDITGROUPS_REVIEWABLE_GENERIC_ERROR.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) + } + } + } + + handle_request(req, &api_clone, &mut context).or_else(|mut response| { + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + Ok(response) + }) + }, + "GetEditgroupsReviewable", + ); + let api_clone = api.clone(); router.get( "/v0/editor/:editor_id", @@ -2974,7 +3055,7 @@ where let api_clone = api.clone(); router.get( - "/v0/editor/:editor_id/changelog", + "/v0/editor/:editor_id/editgroups", move |req: &mut Request| { let mut context = Context::default(); @@ -3002,46 +3083,207 @@ where .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter editor_id: {}", e))))? }; - match api.get_editor_changelog(param_editor_id, context).wait() { + // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) + let query_params = req.get::().unwrap_or_default(); + let param_limit = query_params.get("limit").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_before = query_params.get("before").and_then(|list| list.first()).and_then(|x| x.parse::>().ok()); + let param_since = query_params.get("since").and_then(|list| list.first()).and_then(|x| x.parse::>().ok()); + + match api.get_editor_editgroups(param_editor_id, param_limit, param_before, param_since, context).wait() { Ok(rsp) => match rsp { - GetEditorChangelogResponse::Found(body) => { + GetEditorEditgroupsResponse::Found(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_CHANGELOG_FOUND.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_EDITGROUPS_FOUND.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - GetEditorChangelogResponse::BadRequest(body) => { + GetEditorEditgroupsResponse::BadRequest(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_CHANGELOG_BAD_REQUEST.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_EDITGROUPS_BAD_REQUEST.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - GetEditorChangelogResponse::NotFound(body) => { + GetEditorEditgroupsResponse::NotFound(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(404), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_CHANGELOG_NOT_FOUND.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_EDITGROUPS_NOT_FOUND.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); Ok(response) } - GetEditorChangelogResponse::GenericError(body) => { + GetEditorEditgroupsResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); let mut response = Response::with((status::Status::from_u16(500), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_CHANGELOG_GENERIC_ERROR.clone())); + response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_EDITGROUPS_GENERIC_ERROR.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) + } + } + } + + handle_request(req, &api_clone, &mut context).or_else(|mut response| { + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + Ok(response) + }) + }, + "GetEditorEditgroups", + ); + + let api_clone = api.clone(); + router.put( + "/v0/editgroup/:editgroup_id", + move |req: &mut Request| { + let mut context = Context::default(); + + // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). + fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result + where + T: Api, + { + context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); + context.auth_data = req.extensions.remove::(); + context.authorization = req.extensions.remove::(); + + let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?; + + // Path parameters + let param_editgroup_id = { + let param = req + .extensions + .get::() + .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? + .find("editgroup_id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editgroup_id".to_string())))?; + percent_decode(param.as_bytes()) + .decode_utf8() + .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? + .parse() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter editgroup_id: {}", e))))? + }; + + // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) + let query_params = req.get::().unwrap_or_default(); + let param_submit = query_params.get("submit").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + + // Body parameters (note that non-required body parameters will ignore garbage + // values, rather than causing a 400 response). Produce warning header and logs for + // any unused fields. + + let param_editgroup = req + .get::() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter editgroup - not valid UTF-8: {}", e))))?; + + let mut unused_elements = Vec::new(); + + let param_editgroup = if let Some(param_editgroup_raw) = param_editgroup { + let deserializer = &mut serde_json::Deserializer::from_str(¶m_editgroup_raw); + + let param_editgroup: Option = serde_ignored::deserialize(deserializer, |path| { + warn!("Ignoring unknown field in body: {}", path); + unused_elements.push(path.to_string()); + }) + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter editgroup - doesn't match schema: {}", e))))?; + + param_editgroup + } else { + None + }; + let param_editgroup = param_editgroup.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter editgroup".to_string())))?; + + match api.update_editgroup(param_editgroup_id, param_editgroup, param_submit, context).wait() { + Ok(rsp) => match rsp { + UpdateEditgroupResponse::UpdatedEditgroup(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(200), body_string)); + response.headers.set(ContentType(mimetypes::responses::UPDATE_EDITGROUP_UPDATED_EDITGROUP.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + if !unused_elements.is_empty() { + response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); + } + Ok(response) + } + UpdateEditgroupResponse::BadRequest(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(400), body_string)); + response.headers.set(ContentType(mimetypes::responses::UPDATE_EDITGROUP_BAD_REQUEST.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + if !unused_elements.is_empty() { + response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); + } + Ok(response) + } + UpdateEditgroupResponse::NotAuthorized { body, www_authenticate } => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(401), body_string)); + header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } + response.headers.set(ResponseWwwAuthenticate(www_authenticate)); + + response.headers.set(ContentType(mimetypes::responses::UPDATE_EDITGROUP_NOT_AUTHORIZED.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + if !unused_elements.is_empty() { + response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); + } + Ok(response) + } + UpdateEditgroupResponse::Forbidden(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(403), body_string)); + response.headers.set(ContentType(mimetypes::responses::UPDATE_EDITGROUP_FORBIDDEN.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + if !unused_elements.is_empty() { + response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); + } + Ok(response) + } + UpdateEditgroupResponse::NotFound(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(404), body_string)); + response.headers.set(ContentType(mimetypes::responses::UPDATE_EDITGROUP_NOT_FOUND.clone())); context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + if !unused_elements.is_empty() { + response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); + } + Ok(response) + } + UpdateEditgroupResponse::GenericError(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(500), body_string)); + response.headers.set(ContentType(mimetypes::responses::UPDATE_EDITGROUP_GENERIC_ERROR.clone())); + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + if !unused_elements.is_empty() { + response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); + } Ok(response) } }, @@ -3058,7 +3300,7 @@ where Ok(response) }) }, - "GetEditorChangelog", + "UpdateEditgroup", ); let api_clone = api.clone(); @@ -3473,8 +3715,8 @@ where ); let api_clone = api.clone(); - router.get( - "/v0/changelog", + router.post( + "/v0/editgroup/:editgroup_id/annotation", move |req: &mut Request| { let mut context = Context::default(); @@ -3487,31 +3729,182 @@ where context.auth_data = req.extensions.remove::(); context.authorization = req.extensions.remove::(); - // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) - let query_params = req.get::().unwrap_or_default(); - let param_limit = query_params.get("limit").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?; - match api.get_changelog(param_limit, context).wait() { - Ok(rsp) => match rsp { - GetChangelogResponse::Success(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + // Path parameters + let param_editgroup_id = { + let param = req + .extensions + .get::() + .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? + .find("editgroup_id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editgroup_id".to_string())))?; + percent_decode(param.as_bytes()) + .decode_utf8() + .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? + .parse() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter editgroup_id: {}", e))))? + }; - let mut response = Response::with((status::Status::from_u16(200), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_CHANGELOG_SUCCESS.clone())); + // Body parameters (note that non-required body parameters will ignore garbage + // values, rather than causing a 400 response). Produce warning header and logs for + // any unused fields. - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + let param_annotation = req + .get::() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter annotation - not valid UTF-8: {}", e))))?; - Ok(response) - } - GetChangelogResponse::BadRequest(body) => { - let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + let mut unused_elements = Vec::new(); - let mut response = Response::with((status::Status::from_u16(400), body_string)); - response.headers.set(ContentType(mimetypes::responses::GET_CHANGELOG_BAD_REQUEST.clone())); + let param_annotation = if let Some(param_annotation_raw) = param_annotation { + let deserializer = &mut serde_json::Deserializer::from_str(¶m_annotation_raw); - context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + let param_annotation: Option = serde_ignored::deserialize(deserializer, |path| { + warn!("Ignoring unknown field in body: {}", path); + unused_elements.push(path.to_string()); + }) + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter annotation - doesn't match schema: {}", e))))?; - Ok(response) + param_annotation + } else { + None + }; + let param_annotation = param_annotation.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter annotation".to_string())))?; + + match api.create_editgroup_annotation(param_editgroup_id, param_annotation, context).wait() { + Ok(rsp) => match rsp { + CreateEditgroupAnnotationResponse::Created(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(201), body_string)); + response.headers.set(ContentType(mimetypes::responses::CREATE_EDITGROUP_ANNOTATION_CREATED.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + if !unused_elements.is_empty() { + response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); + } + Ok(response) + } + CreateEditgroupAnnotationResponse::BadRequest(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(400), body_string)); + response.headers.set(ContentType(mimetypes::responses::CREATE_EDITGROUP_ANNOTATION_BAD_REQUEST.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + if !unused_elements.is_empty() { + response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); + } + Ok(response) + } + CreateEditgroupAnnotationResponse::NotAuthorized { body, www_authenticate } => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(401), body_string)); + header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } + response.headers.set(ResponseWwwAuthenticate(www_authenticate)); + + response.headers.set(ContentType(mimetypes::responses::CREATE_EDITGROUP_ANNOTATION_NOT_AUTHORIZED.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + if !unused_elements.is_empty() { + response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); + } + Ok(response) + } + CreateEditgroupAnnotationResponse::Forbidden(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(403), body_string)); + response.headers.set(ContentType(mimetypes::responses::CREATE_EDITGROUP_ANNOTATION_FORBIDDEN.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + if !unused_elements.is_empty() { + response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); + } + Ok(response) + } + CreateEditgroupAnnotationResponse::NotFound(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(404), body_string)); + response.headers.set(ContentType(mimetypes::responses::CREATE_EDITGROUP_ANNOTATION_NOT_FOUND.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + if !unused_elements.is_empty() { + response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); + } + Ok(response) + } + CreateEditgroupAnnotationResponse::GenericError(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(500), body_string)); + response.headers.set(ContentType(mimetypes::responses::CREATE_EDITGROUP_ANNOTATION_GENERIC_ERROR.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + if !unused_elements.is_empty() { + response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements))); + } + Ok(response) + } + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) + } + } + } + + handle_request(req, &api_clone, &mut context).or_else(|mut response| { + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + Ok(response) + }) + }, + "CreateEditgroupAnnotation", + ); + + let api_clone = api.clone(); + router.get( + "/v0/changelog", + move |req: &mut Request| { + let mut context = Context::default(); + + // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). + fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result + where + T: Api, + { + context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); + context.auth_data = req.extensions.remove::(); + context.authorization = req.extensions.remove::(); + + // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) + let query_params = req.get::().unwrap_or_default(); + let param_limit = query_params.get("limit").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + + match api.get_changelog(param_limit, context).wait() { + Ok(rsp) => match rsp { + GetChangelogResponse::Success(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(200), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_CHANGELOG_SUCCESS.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + GetChangelogResponse::BadRequest(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(400), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_CHANGELOG_BAD_REQUEST.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) } GetChangelogResponse::GenericError(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); @@ -3718,6 +4111,242 @@ where "GetEditgroup", ); + let api_clone = api.clone(); + router.get( + "/v0/editgroup/:editgroup_id/annotations", + move |req: &mut Request| { + let mut context = Context::default(); + + // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). + fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result + where + T: Api, + { + context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); + context.auth_data = req.extensions.remove::(); + context.authorization = req.extensions.remove::(); + + let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?; + + // Path parameters + let param_editgroup_id = { + let param = req + .extensions + .get::() + .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? + .find("editgroup_id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editgroup_id".to_string())))?; + percent_decode(param.as_bytes()) + .decode_utf8() + .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? + .parse() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter editgroup_id: {}", e))))? + }; + + // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) + let query_params = req.get::().unwrap_or_default(); + let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + + match api.get_editgroup_annotations(param_editgroup_id, param_expand, context).wait() { + Ok(rsp) => match rsp { + GetEditgroupAnnotationsResponse::Success(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(200), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_EDITGROUP_ANNOTATIONS_SUCCESS.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + GetEditgroupAnnotationsResponse::BadRequest(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(400), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_EDITGROUP_ANNOTATIONS_BAD_REQUEST.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + GetEditgroupAnnotationsResponse::NotAuthorized { body, www_authenticate } => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(401), body_string)); + header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } + response.headers.set(ResponseWwwAuthenticate(www_authenticate)); + + response.headers.set(ContentType(mimetypes::responses::GET_EDITGROUP_ANNOTATIONS_NOT_AUTHORIZED.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + GetEditgroupAnnotationsResponse::Forbidden(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(403), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_EDITGROUP_ANNOTATIONS_FORBIDDEN.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + GetEditgroupAnnotationsResponse::NotFound(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(404), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_EDITGROUP_ANNOTATIONS_NOT_FOUND.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + GetEditgroupAnnotationsResponse::GenericError(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(500), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_EDITGROUP_ANNOTATIONS_GENERIC_ERROR.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) + } + } + } + + handle_request(req, &api_clone, &mut context).or_else(|mut response| { + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + Ok(response) + }) + }, + "GetEditgroupAnnotations", + ); + + let api_clone = api.clone(); + router.get( + "/v0/editor/:editor_id/annotations", + move |req: &mut Request| { + let mut context = Context::default(); + + // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). + fn handle_request(req: &mut Request, api: &T, context: &mut Context) -> Result + where + T: Api, + { + context.x_span_id = Some(req.headers.get::().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string())); + context.auth_data = req.extensions.remove::(); + context.authorization = req.extensions.remove::(); + + // Path parameters + let param_editor_id = { + let param = req + .extensions + .get::() + .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))? + .find("editor_id") + .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editor_id".to_string())))?; + percent_decode(param.as_bytes()) + .decode_utf8() + .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))? + .parse() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter editor_id: {}", e))))? + }; + + // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) + let query_params = req.get::().unwrap_or_default(); + let param_limit = query_params.get("limit").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_before = query_params.get("before").and_then(|list| list.first()).and_then(|x| x.parse::>().ok()); + let param_since = query_params.get("since").and_then(|list| list.first()).and_then(|x| x.parse::>().ok()); + + match api.get_editor_annotations(param_editor_id, param_limit, param_before, param_since, context).wait() { + Ok(rsp) => match rsp { + GetEditorAnnotationsResponse::Success(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(200), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_ANNOTATIONS_SUCCESS.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + GetEditorAnnotationsResponse::BadRequest(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(400), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_ANNOTATIONS_BAD_REQUEST.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + GetEditorAnnotationsResponse::NotAuthorized { body, www_authenticate } => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(401), body_string)); + header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] } + response.headers.set(ResponseWwwAuthenticate(www_authenticate)); + + response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_ANNOTATIONS_NOT_AUTHORIZED.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + GetEditorAnnotationsResponse::Forbidden(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(403), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_ANNOTATIONS_FORBIDDEN.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + GetEditorAnnotationsResponse::NotFound(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(404), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_ANNOTATIONS_NOT_FOUND.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + GetEditorAnnotationsResponse::GenericError(body) => { + let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); + + let mut response = Response::with((status::Status::from_u16(500), body_string)); + response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_ANNOTATIONS_GENERIC_ERROR.clone())); + + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + + Ok(response) + } + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + Err(Response::with((status::InternalServerError, "An internal error occurred".to_string()))) + } + } + } + + handle_request(req, &api_clone, &mut context).or_else(|mut response| { + context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone()))); + Ok(response) + }) + }, + "GetEditorAnnotations", + ); + let api_clone = api.clone(); router.post( "/v0/file", -- cgit v1.2.3