| 134 | } |
| 135 | |
| 136 | func updateCmd() *cobra.Command { |
| 137 | cmd := &cobra.Command{ |
| 138 | Use: "update-channel-type --type [channel-type] --properties [raw-json-properties]", |
| 139 | Short: "Update channel type", |
| 140 | Long: heredoc.Doc(` |
| 141 | This command updates an existing channel type. The 'properties' are raw JSON string. |
| 142 | The available fields can be checked here: |
| 143 | https://getstream.io/chat/docs/rest/#channel-types-updatechanneltype |
| 144 | `), |
| 145 | Example: heredoc.Doc(` |
| 146 | # Enabling quotes in an existing channel type |
| 147 | $ stream-cli chat update-channel-type --type my-channel-type --properties '{"quotes": true}' |
| 148 | `), |
| 149 | RunE: func(cmd *cobra.Command, args []string) error { |
| 150 | c, err := config.GetConfig(cmd).GetClient(cmd) |
| 151 | if err != nil { |
| 152 | return err |
| 153 | } |
| 154 | |
| 155 | ct, _ := cmd.Flags().GetString("type") |
| 156 | properties, _ := cmd.Flags().GetString("properties") |
| 157 | |
| 158 | props := make(map[string]interface{}) |
| 159 | err = json.Unmarshal([]byte(properties), &props) |
| 160 | if err != nil { |
| 161 | return err |
| 162 | } |
| 163 | |
| 164 | _, err = c.UpdateChannelType(cmd.Context(), ct, props) |
| 165 | if err != nil { |
| 166 | return err |
| 167 | } |
| 168 | |
| 169 | cmd.Println("Successfully updated channel type.") |
| 170 | return nil |
| 171 | }, |
| 172 | } |
| 173 | |
| 174 | fl := cmd.Flags() |
| 175 | fl.StringP("type", "t", "", "[required] Channel type") |
| 176 | fl.StringP("properties", "p", "", "[required] Raw JSON properties") |
| 177 | _ = cmd.MarkFlagRequired("type") |
| 178 | _ = cmd.MarkFlagRequired("properties") |
| 179 | |
| 180 | return cmd |
| 181 | } |
| 182 | |
| 183 | func listCmd() *cobra.Command { |
| 184 | cmd := &cobra.Command{ |