Skip to content

Commit dd6a964

Browse files
committed
Added upload / download audio file helpers to all applicable commands
1 parent 1db76ae commit dd6a964

18 files changed

Lines changed: 1156 additions & 460 deletions

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,40 @@ webex messaging rooms list
5353
webex messaging messages list --room-id <id>
5454
```
5555

56+
## Audio File & Recording Downloads
57+
58+
Several commands provide streamlined binary download and multipart upload for audio files and recordings:
59+
60+
```bash
61+
# Download a meeting recording (audio, video, or transcript)
62+
webex meetings recordings download --recording-id <id> --output meeting.mp3
63+
webex meetings recordings download --recording-id <id> --output meeting.mp4 --type recording
64+
webex meetings recordings download --recording-id <id> --output meeting.vtt --type transcript
65+
66+
# Download a converged recording (Webex Calling call recording)
67+
webex calling converged-recordings download --recording-id <id> --output call.mp3
68+
69+
# Upload/download Contact Center audio files
70+
webex cc audio-files download --id <id> --output prompt.wav
71+
webex cc audio-files upload --file prompt.wav --name "Main Greeting"
72+
73+
# Upload/download CC agent personal greetings
74+
webex cc agent-personal-greeting-files download --id <id> --output greeting.wav
75+
webex cc agent-personal-greeting-files upload --agent-id <id> --file greeting.wav
76+
77+
# Upload announcement greetings (org or location level)
78+
webex calling announcement-repository upload-binary-greeting --file greeting.wav --name "Greeting"
79+
webex calling announcement-repository upload-binary-greeting-2 --file greeting.wav --name "Greeting" --location-id <id>
80+
81+
# Upload voicemail/intercept greetings (person, virtual line, workspace, or self)
82+
webex calling user-call update-busy-voicemail-greeting-person --person-id <id> --file greeting.wav
83+
webex calling call-settings-for-me upload-voicemail-busy-greeting --file greeting.wav
84+
webex calling virtual-line-call update-busy-voicemail-greeting --virtual-line-id <id> --file greeting.wav
85+
webex calling workspace-call update-busy-voicemail-greeting-place --workspace-id <id> --file greeting.wav
86+
```
87+
88+
All upload commands support `--dry-run` to preview the request without sending it.
89+
5690
## API Coverage
5791

5892
### Calling (`webex calling`)

cmd/calling/announcement_repository.go

Lines changed: 0 additions & 96 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/calling/call_settings_for_me.go

Lines changed: 0 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
package calling
2+
3+
import (
4+
"fmt"
5+
"os"
6+
"path/filepath"
7+
"strings"
8+
9+
"github.com/Cloverhound/webex-cli/internal/audio"
10+
"github.com/Cloverhound/webex-cli/internal/config"
11+
"github.com/Cloverhound/webex-cli/internal/output"
12+
"github.com/spf13/cobra"
13+
)
14+
15+
func init() {
16+
registerAnnouncementUpload()
17+
registerAnnouncementUploadLocation()
18+
registerAnnouncementUpdate()
19+
registerAnnouncementUpdateLocation()
20+
}
21+
22+
// registerAnnouncementCmd is a helper that registers one announcement upload/update command.
23+
func registerAnnouncementCmd(use, short, long string, method string,
24+
buildURL func(orgID, locationID, announcementID string) string,
25+
needsLocation, needsAnnouncement bool) {
26+
27+
var filePath string
28+
var name string
29+
var orgID string
30+
var locationID string
31+
var announcementID string
32+
33+
cmd := &cobra.Command{
34+
Use: use,
35+
Short: short,
36+
Long: long,
37+
RunE: func(c *cobra.Command, args []string) error {
38+
f, err := os.Open(filePath)
39+
if err != nil {
40+
return fmt.Errorf("opening audio file: %w", err)
41+
}
42+
defer f.Close()
43+
44+
url := buildURL(orgID, locationID, announcementID)
45+
46+
parts := []audio.MultipartPart{
47+
{
48+
FieldName: "name",
49+
ContentType: "text/plain",
50+
Data: strings.NewReader(name),
51+
},
52+
{
53+
FieldName: "file",
54+
FileName: filepath.Base(filePath),
55+
ContentType: "audio/wav",
56+
Data: f,
57+
},
58+
}
59+
60+
body, statusCode, err := audio.UploadMultipart(method, url, parts)
61+
if err != nil {
62+
return err
63+
}
64+
65+
return output.Print(body, statusCode)
66+
},
67+
}
68+
69+
cmd.Flags().StringVar(&filePath, "file", "", "Path to WAV file to upload")
70+
cmd.MarkFlagRequired("file")
71+
cmd.Flags().StringVar(&name, "name", "", "Announcement name")
72+
cmd.MarkFlagRequired("name")
73+
cmd.Flags().StringVar(&orgID, "org-id", "", "Organization ID")
74+
if needsLocation {
75+
cmd.Flags().StringVar(&locationID, "location-id", "", "Location ID")
76+
cmd.MarkFlagRequired("location-id")
77+
}
78+
if needsAnnouncement {
79+
cmd.Flags().StringVar(&announcementID, "announcement-id", "", "Announcement ID")
80+
cmd.MarkFlagRequired("announcement-id")
81+
}
82+
83+
announcementRepositoryCmd.AddCommand(cmd)
84+
}
85+
86+
func registerAnnouncementUpload() {
87+
registerAnnouncementCmd(
88+
"upload-binary-greeting",
89+
"Upload Binary Announcement Greeting",
90+
`Upload an announcement greeting (WAV) at the organization level.
91+
92+
Uses multipart/form-data with a "name" text field and a "file" binary part.
93+
94+
Examples:
95+
webex calling announcement-repository upload-binary-greeting --file greeting.wav --name "Main Greeting"
96+
webex calling announcement-repository upload-binary-greeting --file greeting.wav --name "Main Greeting" --dry-run`,
97+
"POST",
98+
func(orgID, _, _ string) string {
99+
url := config.CallingBaseURL + "/telephony/config/announcements"
100+
if orgID != "" {
101+
url += "?orgId=" + orgID
102+
}
103+
return url
104+
},
105+
false, false,
106+
)
107+
}
108+
109+
func registerAnnouncementUploadLocation() {
110+
registerAnnouncementCmd(
111+
"upload-binary-greeting-2",
112+
"Upload Binary Announcement Greeting at Location",
113+
`Upload an announcement greeting (WAV) at a specific location.
114+
115+
Uses multipart/form-data with a "name" text field and a "file" binary part.
116+
117+
Examples:
118+
webex calling announcement-repository upload-binary-greeting-2 --file greeting.wav --name "Lobby Greeting" --location-id <loc-id>
119+
webex calling announcement-repository upload-binary-greeting-2 --file greeting.wav --name "Lobby Greeting" --location-id <loc-id> --dry-run`,
120+
"POST",
121+
func(orgID, locationID, _ string) string {
122+
url := config.CallingBaseURL + "/telephony/config/locations/" + locationID + "/announcements"
123+
if orgID != "" {
124+
url += "?orgId=" + orgID
125+
}
126+
return url
127+
},
128+
true, false,
129+
)
130+
}
131+
132+
func registerAnnouncementUpdate() {
133+
registerAnnouncementCmd(
134+
"update-binary-greeting",
135+
"Update Binary Announcement Greeting",
136+
`Update an existing announcement greeting (WAV) at the organization level.
137+
138+
Uses multipart/form-data with a "name" text field and a "file" binary part.
139+
140+
Examples:
141+
webex calling announcement-repository update-binary-greeting --file greeting.wav --name "Updated Greeting" --announcement-id <ann-id>
142+
webex calling announcement-repository update-binary-greeting --file greeting.wav --name "Updated Greeting" --announcement-id <ann-id> --dry-run`,
143+
"PUT",
144+
func(orgID, _, announcementID string) string {
145+
url := config.CallingBaseURL + "/telephony/config/announcements/" + announcementID
146+
if orgID != "" {
147+
url += "?orgId=" + orgID
148+
}
149+
return url
150+
},
151+
false, true,
152+
)
153+
}
154+
155+
func registerAnnouncementUpdateLocation() {
156+
registerAnnouncementCmd(
157+
"update-binary-greeting-2",
158+
"Update Binary Announcement Greeting at Location",
159+
`Update an existing announcement greeting (WAV) at a specific location.
160+
161+
Uses multipart/form-data with a "name" text field and a "file" binary part.
162+
163+
Examples:
164+
webex calling announcement-repository update-binary-greeting-2 --file greeting.wav --name "Updated Greeting" --location-id <loc-id> --announcement-id <ann-id>`,
165+
"PUT",
166+
func(orgID, locationID, announcementID string) string {
167+
url := config.CallingBaseURL + "/telephony/config/locations/" + locationID + "/announcements/" + announcementID
168+
if orgID != "" {
169+
url += "?orgId=" + orgID
170+
}
171+
return url
172+
},
173+
true, true,
174+
)
175+
}

0 commit comments

Comments
 (0)