github.com/googleapis/api-linter@v1.65.2/docs/rules/0165/http-parent-variable.md (about) 1 --- 2 rule: 3 aip: 165 4 name: [core, '0165', http-parent-variable] 5 summary: Purge methods must map the parent field to the URI. 6 permalink: /165/http-parent-variable 7 redirect_from: 8 - /0165/http-parent-variable 9 --- 10 11 # Purge methods: HTTP URI parent variable 12 13 This rule enforces that all `Purge` RPCs map the `parent` field to the HTTP 14 URI, as mandated in [AIP-165][]. 15 16 ## Details 17 18 This rule looks at any message beginning with `Purge`, and complains 19 if the `parent` variable is not included in the URI. It _does_ check additional 20 bindings if they are present. 21 22 ## Examples 23 24 **Incorrect** code for this rule: 25 26 ```proto 27 // Incorrect. 28 rpc PurgeBooks(PurgeBooksRequest) returns (google.longrunning.Operation) { 29 option (google.api.http) = { 30 post: "/v1/publishers/*/books:purge" // The `parent` field should be extracted. 31 body: "*" 32 }; 33 option (google.longrunning.operation_info) = { 34 response_type: "PurgeBooksResponse" 35 metadata_type: "PurgeBooksMetadata" 36 }; 37 } 38 ``` 39 40 **Correct** code for this rule: 41 42 ```proto 43 // Correct. 44 rpc PurgeBooks(PurgeBooksRequest) returns (google.longrunning.Operation) { 45 option (google.api.http) = { 46 post: "/v1/{parent=publishers/*}/books:purge" 47 body: "*" 48 }; 49 option (google.longrunning.operation_info) = { 50 response_type: "PurgeBooksResponse" 51 metadata_type: "PurgeBooksMetadata" 52 }; 53 } 54 ``` 55 56 ## Disabling 57 58 If you need to violate this rule, use a leading comment above the method. 59 Remember to also include an [aip.dev/not-precedent][] comment explaining why. 60 61 ```proto 62 // (-- api-linter: core::0165::http-parent-variable=disabled 63 // aip.dev/not-precedent: We need to do this because reasons. --) 64 rpc PurgeBooks(PurgeBooksRequest) returns (google.longrunning.Operation) { 65 option (google.api.http) = { 66 post: "/v1/publishers/*/books:purge" 67 body: "*"" 68 }; 69 option (google.longrunning.operation_info) = { 70 response_type: "PurgeBooksResponse" 71 metadata_type: "PurgeBooksMetadata" 72 }; 73 } 74 ``` 75 76 If you need to violate this rule for an entire file, place the comment at the 77 top of the file. 78 79 [aip-165]: https://aip.dev/165 80 [aip.dev/not-precedent]: https://aip.dev/not-precedent