MCPcopy Create free account
hub / github.com/GetStream/stream-cli / upsertCmd

Function upsertCmd

pkg/cmd/chat/push/push.go:23–95  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

21}
22
23func upsertCmd() *cobra.Command {
24 cmd := &cobra.Command{
25 Use: "upsert-pushprovider --properties [raw-json]",
26 Short: "Create or updates a push provider",
27 Long: `
28 The "--properties" parameter expects a raw json string that can be
29 unmarshalled into a stream_chat.PushProvider object on the Go SDK side.
30 See the example section.
31 Available properties:
32 type
33 name
34 description
35 disabled_at
36 disabled_reason
37
38 apn_auth_key
39 apn_key_id
40 apn_team_id
41 apn_topic
42
43 firebase_notification_template
44 firebase_apn_template
45 firebase_credentials
46
47 huawei_app_id
48 huawei_app_secret
49
50 xiaomi_package_name
51 xiaomi_app_secret
52 `,
53 Example: heredoc.Doc(`
54 # Setting up an APN push provider
55 $ stream-cli chat upsert-pushprovider --properties "{'type': 'apn', 'name': 'staging', 'apn_auth_key': 'key', 'apn_key_id': 'id', 'apn_topic': 'topic', 'apn_team_id': 'id'}"
56
57 # Setting up a Firebase push provider
58 $ stream-cli chat upsert-pushprovider --properties "{'type': 'firebase', 'name': 'staging', 'firebase_credentials': 'credentials'}"
59
60 # Setting up a Huawei push provider
61 $ stream-cli chat upsert-pushprovider --properties "{'type': 'huawei', 'name': 'staging', 'huawei_app_id': 'id', 'huawei_app_secret': 'secret'}"
62
63 # Setting up a Xiaomi push provider
64 $ stream-cli chat upsert-pushprovider --properties "{'type': 'xiaomi', 'name': 'staging', 'xiaomi_package_name': 'name', 'xiaomi_app_secret': 'secret'}"
65 `),
66 RunE: func(cmd *cobra.Command, args []string) error {
67 c, err := config.GetConfig(cmd).GetClient(cmd)
68 if err != nil {
69 return err
70 }
71
72 prop, _ := cmd.Flags().GetString("properties")
73
74 var p stream_chat.PushProvider
75 err = json.Unmarshal([]byte(prop), &p)
76 if err != nil {
77 return err
78 }
79
80 _, err = c.UpsertPushProvider(cmd.Context(), &p)

Callers 1

NewCmdsFunction · 0.70

Calls 2

GetConfigFunction · 0.92
GetClientMethod · 0.80

Tested by

no test coverage detected