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