GetInstanceDatabaseID returns the instance ID and database ID from a resource name.
(name string)
| 26 | |
| 27 | // GetInstanceDatabaseID returns the instance ID and database ID from a resource name. |
| 28 | func GetInstanceDatabaseID(name string) (string, string, error) { |
| 29 | // the instance request should be instances/{instance-id}/databases/{database-id} |
| 30 | tokens, err := GetNameParentTokens(name, InstanceNamePrefix, DatabaseIDPrefix) |
| 31 | if err != nil { |
| 32 | return "", "", err |
| 33 | } |
| 34 | return tokens[0], tokens[1], nil |
| 35 | } |
| 36 | |
| 37 | // GetNameParentTokens returns the tokens from a resource name. |
| 38 | func GetNameParentTokens(name string, tokenPrefixes ...string) ([]string, error) { |
no test coverage detected