github.com/twilio/twilio-go@v1.20.1/client/jwt/taskrouter/taskrouter_utils.go (about) 1 package taskrouter 2 3 import ( 4 "fmt" 5 "strings" 6 ) 7 8 const ( 9 Version = "v1" 10 RouterBaseUrl = "https://taskrouter.twilio.com" 11 WebsocketBaseUrl = "https://event-bridge.twilio.com/v1/wschannels" 12 Get = "GET" 13 Post = "POST" 14 ) 15 16 func Workspaces() string { 17 return fmt.Sprint(strings.Join([]string{RouterBaseUrl, Version, "Workspaces"}, "/")) 18 } 19 20 func Workspace(workspaceSid string) string { 21 return fmt.Sprint(strings.Join([]string{RouterBaseUrl, Version, "Workspaces", workspaceSid}, "/")) 22 } 23 24 func AllWorkspaces() string { 25 return fmt.Sprint(strings.Join([]string{RouterBaseUrl, Version, "Workspaces", "**"}, "/")) 26 } 27 28 func Tasks(workspaceSid string) string { 29 return fmt.Sprint(strings.Join([]string{Workspace(workspaceSid), "Tasks"}, "/")) 30 } 31 32 func Task(workspaceSid string, tasksSid string) string { 33 return fmt.Sprint(strings.Join([]string{Workspace(workspaceSid), "Tasks", tasksSid}, "/")) 34 } 35 36 func AllTasks(workspaceSid string) string { 37 return fmt.Sprint(strings.Join([]string{Workspace(workspaceSid), "Tasks", "**"}, "/")) 38 } 39 40 func TaskQueues(workspaceSid string) string { 41 return fmt.Sprint(strings.Join([]string{Workspace(workspaceSid), "TaskQueues"}, "/")) 42 } 43 44 func TaskQueue(workspaceSid string, taskQueueSid string) string { 45 return fmt.Sprint(strings.Join([]string{Workspace(workspaceSid), "TaskQueues", taskQueueSid}, "/")) 46 } 47 48 func AllTaskQueues(workspaceSid string) string { 49 return fmt.Sprint(strings.Join([]string{Workspace(workspaceSid), "TaskQueues", "**"}, "/")) 50 } 51 52 func Activities(workspaceSid string) string { 53 return fmt.Sprint(strings.Join([]string{Workspace(workspaceSid), "Activities"}, "/")) 54 } 55 56 func Activity(workspaceSid string, activitySid string) string { 57 return fmt.Sprint(strings.Join([]string{Workspace(workspaceSid), "Activities", activitySid}, "/")) 58 } 59 60 func AllActivities(workspaceSid string) string { 61 return fmt.Sprint(strings.Join([]string{Workspace(workspaceSid), "Activities", "**"}, "/")) 62 } 63 64 func Workers(workspaceSid string) string { 65 return fmt.Sprint(strings.Join([]string{Workspace(workspaceSid), "Workers"}, "/")) 66 } 67 68 func Worker(workspaceSid string, workerSid string) string { 69 return fmt.Sprint(strings.Join([]string{Workspace(workspaceSid), "Workers", workerSid}, "/")) 70 } 71 72 func AllWorkers(workspaceSid string) string { 73 return fmt.Sprint(strings.Join([]string{Workspace(workspaceSid), "Workers", "**"}, "/")) 74 } 75 76 func Reservations(workspaceSid string, workerSid string) string { 77 return fmt.Sprint(strings.Join([]string{Worker(workspaceSid, workerSid), "Reservations"}, "/")) 78 } 79 80 func Reservation(workspaceSid string, workerSid string, reservationSid string) string { 81 return fmt.Sprint(strings.Join([]string{Worker(workspaceSid, workerSid), "Reservations", reservationSid}, "/")) 82 } 83 84 func AllReservations(workspaceSid string, workerSid string) string { 85 return fmt.Sprint(strings.Join([]string{Worker(workspaceSid, workerSid), "Reservations", "**"}, "/")) 86 } 87 88 func WebSocketPolicies(accountSid string, channelSid string) []Policy { 89 url := fmt.Sprint(strings.Join([]string{WebsocketBaseUrl, accountSid, channelSid}, "/")) 90 get := GeneratePolicy(url, Get, true, nil, nil) 91 post := GeneratePolicy(url, Post, true, nil, nil) 92 return []Policy{get, post} 93 } 94 95 func WorkerPolicies(workspaceSid string, workerSid string) []Policy { 96 activities := GeneratePolicy(Activities(workspaceSid), Get, true, nil, nil) 97 tasks := GeneratePolicy(AllTasks(workspaceSid), Get, true, nil, nil) 98 reservations := GeneratePolicy(AllReservations(workspaceSid, workerSid), Get, true, nil, nil) 99 fetch := GeneratePolicy(Worker(workspaceSid, workerSid), Get, true, nil, nil) 100 return []Policy{activities, tasks, reservations, fetch} 101 }