44 "context"
55 "fmt"
66 "net/http"
7+ "net/url"
78 "strings"
89
910 "google.golang.org/protobuf/encoding/protojson"
@@ -15,7 +16,7 @@ var ProtojsonUnmarshaler = protojson.UnmarshalOptions{DiscardUnknown: true}
1516
1617// deleteResource deletes the resource by name.
1718func (c * client ) deleteResource (ctx context.Context , name string ) error {
18- req , err := http .NewRequestWithContext (ctx , "DELETE" , fmt .Sprintf ("%s/%s/%s" , c .url , c .version , name ), nil )
19+ req , err := http .NewRequestWithContext (ctx , "DELETE" , fmt .Sprintf ("%s/%s/%s" , c .url , c .version , url . QueryEscape ( name ) ), nil )
1920 if err != nil {
2021 return err
2122 }
@@ -28,7 +29,7 @@ func (c *client) deleteResource(ctx context.Context, name string) error {
2829
2930// undeleteResource undeletes the resource by name.
3031func (c * client ) undeleteResource (ctx context.Context , name string ) ([]byte , error ) {
31- req , err := http .NewRequestWithContext (ctx , "POST" , fmt .Sprintf ("%s/%s/%s:undelete" , c .url , c .version , name ), nil )
32+ req , err := http .NewRequestWithContext (ctx , "POST" , fmt .Sprintf ("%s/%s/%s:undelete" , c .url , c .version , url . QueryEscape ( name ) ), nil )
3233 if err != nil {
3334 return nil , err
3435 }
@@ -48,7 +49,7 @@ func (c *client) updateResource(ctx context.Context, name string, patch protoref
4849 return nil , err
4950 }
5051
51- req , err := http .NewRequestWithContext (ctx , "PATCH" , fmt .Sprintf ("%s/%s/%s?update_mask=%s&allow_missing=%v" , c .url , c .version , name , strings .Join (updateMasks , "," ), allowMissing ), strings .NewReader (string (payload )))
52+ req , err := http .NewRequestWithContext (ctx , "PATCH" , fmt .Sprintf ("%s/%s/%s?update_mask=%s&allow_missing=%v" , c .url , c .version , url . QueryEscape ( name ) , strings .Join (updateMasks , "," ), allowMissing ), strings .NewReader (string (payload )))
5253 if err != nil {
5354 return nil , err
5455 }
@@ -63,7 +64,7 @@ func (c *client) updateResource(ctx context.Context, name string, patch protoref
6364
6465// getResource gets the resource by name.
6566func (c * client ) getResource (ctx context.Context , name string ) ([]byte , error ) {
66- req , err := http .NewRequestWithContext (ctx , "GET" , fmt .Sprintf ("%s/%s/%s" , c .url , c .version , name ), nil )
67+ req , err := http .NewRequestWithContext (ctx , "GET" , fmt .Sprintf ("%s/%s/%s" , c .url , c .version , url . QueryEscape ( name ) ), nil )
6768 if err != nil {
6869 return nil , err
6970 }
0 commit comments