New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support for data stores #192
base: master
Are you sure you want to change the base?
Changes from all commits
95a5b04
396a946
0d5bff3
82dbb12
77e7581
cea171d
56926e8
1d8f1ea
c1eabc0
2c8adf2
01fa099
191595e
e217089
d1c2447
3980f89
5223be1
8b0f11d
c65d454
7829c3f
ed4d97e
7b353b8
7574934
c16b85d
77d875c
34fa2e6
74805ec
d33ac05
4fd0b0c
7473634
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json | ||
reviews: | ||
path_filters: | ||
- "!**/*.mod" | ||
- "!**/*.sum" | ||
- "!docs/docs/cmd/*.md" | ||
auto_review: | ||
enabled: true |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package datastore | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/xavidop/dialogflow-cx-cli/cmd/cmdutils" | ||
cmdducment "github.com/xavidop/dialogflow-cx-cli/cmd/datastore/document" | ||
) | ||
|
||
// datastoreCmd represents the datastore root command | ||
var datastoreCmd = &cobra.Command{ | ||
Use: "datastore", | ||
Aliases: []string{"ds"}, | ||
Short: "Actions on datastore commands", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
if err := cmd.Help(); err != nil { | ||
os.Exit(1) | ||
} | ||
os.Exit(0) | ||
}, | ||
PersistentPreRun: func(cmd *cobra.Command, args []string) { | ||
cmdutils.PreRun(cmd.Name()) | ||
}, | ||
PersistentPostRun: func(cmd *cobra.Command, args []string) { | ||
}, | ||
} | ||
|
||
func Register(rootCmd *cobra.Command) { | ||
rootCmd.AddCommand(datastoreCmd) | ||
} | ||
|
||
func init() { | ||
cmdducment.Register(datastoreCmd) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package datastore | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/xavidop/dialogflow-cx-cli/cmd/cmdutils" | ||
"github.com/xavidop/dialogflow-cx-cli/internal/global" | ||
"github.com/xavidop/dialogflow-cx-cli/pkg/datastore" | ||
) | ||
|
||
// deleteCmd represents the search datastore set command | ||
var deleteCmd = &cobra.Command{ | ||
Use: "delete [name]", | ||
Aliases: []string{"deletes", "d", "del"}, | ||
Short: "delete a datastore", | ||
Args: cobra.ExactArgs(1), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
// Get the information | ||
locationID, _ := cmd.Flags().GetString("location-id") | ||
projectID, _ := cmd.Flags().GetString("project-id") | ||
name := args[0] | ||
|
||
if err := datastore.Delete(name, locationID, projectID); err != nil { | ||
global.Log.Errorf(err.Error()) | ||
os.Exit(1) | ||
} | ||
}, | ||
PersistentPreRun: func(cmd *cobra.Command, args []string) { | ||
cmdutils.PreRun(cmd.Name()) | ||
}, | ||
PersistentPostRun: func(cmd *cobra.Command, args []string) { | ||
}, | ||
} | ||
|
||
func init() { | ||
datastoreCmd.AddCommand(deleteCmd) | ||
|
||
deleteCmd.Flags().StringP("project-id", "p", "", "Data Store Project ID (required)") | ||
if err := deleteCmd.MarkFlagRequired("project-id"); err != nil { | ||
global.Log.Errorf(err.Error()) | ||
os.Exit(1) | ||
} | ||
deleteCmd.Flags().StringP("location-id", "l", "", "Data Store Location ID of the Project (required)") | ||
if err := deleteCmd.MarkFlagRequired("location-id"); err != nil { | ||
global.Log.Errorf(err.Error()) | ||
os.Exit(1) | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package document | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/xavidop/dialogflow-cx-cli/cmd/cmdutils" | ||
) | ||
|
||
// documentCmd represents the datastore root command | ||
var documentCmd = &cobra.Command{ | ||
Use: "document", | ||
Aliases: []string{"dc"}, | ||
Short: "Actions on datastore document commands", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
if err := cmd.Help(); err != nil { | ||
os.Exit(1) | ||
} | ||
os.Exit(0) | ||
}, | ||
PersistentPreRun: func(cmd *cobra.Command, args []string) { | ||
cmdutils.PreRun(cmd.Name()) | ||
}, | ||
PersistentPostRun: func(cmd *cobra.Command, args []string) { | ||
}, | ||
} | ||
|
||
func Register(rootCmd *cobra.Command) { | ||
rootCmd.AddCommand(documentCmd) | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,56 @@ | ||||||||||||||
package datastore | ||||||||||||||
|
||||||||||||||
import ( | ||||||||||||||
"os" | ||||||||||||||
|
||||||||||||||
"github.com/spf13/cobra" | ||||||||||||||
"github.com/xavidop/dialogflow-cx-cli/cmd/cmdutils" | ||||||||||||||
"github.com/xavidop/dialogflow-cx-cli/internal/global" | ||||||||||||||
"github.com/xavidop/dialogflow-cx-cli/pkg/datastore" | ||||||||||||||
) | ||||||||||||||
|
||||||||||||||
// searchCmd represents the search datastore set command | ||||||||||||||
var searchCmd = &cobra.Command{ | ||||||||||||||
Use: "search [name]", | ||||||||||||||
Aliases: []string{"searches", "s"}, | ||||||||||||||
Short: "search in a datastore", | ||||||||||||||
Args: cobra.ExactArgs(1), | ||||||||||||||
Run: func(cmd *cobra.Command, args []string) { | ||||||||||||||
// Get the information | ||||||||||||||
locationID, _ := cmd.Flags().GetString("location-id") | ||||||||||||||
projectID, _ := cmd.Flags().GetString("project-id") | ||||||||||||||
query, _ := cmd.Flags().GetString("query") | ||||||||||||||
name := args[0] | ||||||||||||||
|
||||||||||||||
if err := datastore.Search(name, locationID, projectID, query); err != nil { | ||||||||||||||
global.Log.Errorf(err.Error()) | ||||||||||||||
os.Exit(1) | ||||||||||||||
Comment on lines
+25
to
+27
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Improve error context. To provide more context in the error message, consider wrapping the error with additional information. - global.Log.Errorf(err.Error())
+ global.Log.Errorf("failed to search datastore: %v", err) Committable suggestion
Suggested change
|
||||||||||||||
} | ||||||||||||||
}, | ||||||||||||||
PersistentPreRun: func(cmd *cobra.Command, args []string) { | ||||||||||||||
cmdutils.PreRun(cmd.Name()) | ||||||||||||||
}, | ||||||||||||||
PersistentPostRun: func(cmd *cobra.Command, args []string) { | ||||||||||||||
}, | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
func init() { | ||||||||||||||
datastoreCmd.AddCommand(searchCmd) | ||||||||||||||
|
||||||||||||||
searchCmd.Flags().StringP("query", "r", "", "Query to search (required)") | ||||||||||||||
if err := searchCmd.MarkFlagRequired("query"); err != nil { | ||||||||||||||
global.Log.Errorf(err.Error()) | ||||||||||||||
os.Exit(1) | ||||||||||||||
} | ||||||||||||||
searchCmd.Flags().StringP("project-id", "p", "", "Data Store Project ID (required)") | ||||||||||||||
if err := searchCmd.MarkFlagRequired("project-id"); err != nil { | ||||||||||||||
global.Log.Errorf(err.Error()) | ||||||||||||||
os.Exit(1) | ||||||||||||||
} | ||||||||||||||
searchCmd.Flags().StringP("location-id", "l", "", "Data Store Location ID of the Project (required)") | ||||||||||||||
if err := searchCmd.MarkFlagRequired("location-id"); err != nil { | ||||||||||||||
global.Log.Errorf(err.Error()) | ||||||||||||||
os.Exit(1) | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -31,6 +31,7 @@ cxcli [flags] | |||||
|
||||||
* [cxcli agent](/cmd/cxcli_agent/) - Actions on agent commands | ||||||
* [cxcli completion](/cmd/cxcli_completion/) - Generate the autocompletion script for the specified shell | ||||||
* [cxcli datastore](/cmd/cxcli_datastore/) - Actions on datastore commands | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace hard tabs with spaces. - * [cxcli datastore](/cmd/cxcli_datastore/) - Actions on datastore commands
+ * [cxcli datastore](/cmd/cxcli_datastore/) - Actions on datastore commands Committable suggestion
Suggested change
|
||||||
* [cxcli dialog](/cmd/cxcli_dialog/) - Test your CX Agent interactively directly from your terminal | ||||||
* [cxcli entity-type](/cmd/cxcli_entity-type/) - Actions on entity type commands | ||||||
* [cxcli environment](/cmd/cxcli_environment/) - Actions on environment | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# cxcli datastore | ||
|
||
Actions on datastore commands | ||
|
||
``` | ||
cxcli datastore [flags] | ||
``` | ||
Comment on lines
+5
to
+7
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Specify the language for the code block. - ```
+ ```sh |
||
|
||
## Options | ||
|
||
``` | ||
-h, --help help for datastore | ||
``` | ||
Comment on lines
+11
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Specify the language for the code block. - ```
+ ```sh |
||
|
||
## Options inherited from parent commands | ||
|
||
``` | ||
-c, --credentials string Google Cloud credentials JSON file path (optional) | ||
-o, --output-format string Output Format. Options: text, json. Default: text (optional) (default "text") | ||
-u, --skip-update-check Skip the check for updates check run before every command (optional) | ||
-v, --verbose verbose error output (with stack trace) (optional) | ||
``` | ||
Comment on lines
+17
to
+22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Specify the language for the code block. - ```
+ ```sh |
||
|
||
## See also | ||
|
||
* [cxcli](/cmd/cxcli/) - Dialogflow CX CLI | ||
* [cxcli datastore search](/cmd/cxcli_datastore_search/) - search in a datastore | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,30 @@ | ||||||
# cxcli datastore search | ||||||
|
||||||
search in a datastore | ||||||
|
||||||
``` | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Specify language for code block. To improve readability, specify the language for the code block. - ```
+ ```sh |
||||||
cxcli datastore search [name] [flags] | ||||||
``` | ||||||
|
||||||
## Options | ||||||
|
||||||
``` | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Specify language for code block. To improve readability, specify the language for the code block. - ```
+ ```sh |
||||||
-h, --help help for search | ||||||
-l, --location-id string Data Store Location ID of the Project (required) | ||||||
-p, --project-id string Data Store Project ID (required) | ||||||
-r, --query string Query to search (required) | ||||||
``` | ||||||
|
||||||
## Options inherited from parent commands | ||||||
|
||||||
``` | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Specify language for code block. To improve readability, specify the language for the code block. - ```
+ ```sh |
||||||
-c, --credentials string Google Cloud credentials JSON file path (optional) | ||||||
-o, --output-format string Output Format. Options: text, json. Default: text (optional) (default "text") | ||||||
-u, --skip-update-check Skip the check for updates check run before every command (optional) | ||||||
-v, --verbose verbose error output (with stack trace) (optional) | ||||||
``` | ||||||
|
||||||
## See also | ||||||
|
||||||
* [cxcli datastore](/cmd/cxcli_datastore/) - Actions on datastore commands | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove hard tabs. Replace hard tabs with spaces for consistent formatting. - * [cxcli datastore](/cmd/cxcli_datastore/) - Actions on datastore commands
+ * [cxcli datastore](/cmd/cxcli_datastore/) - Actions on datastore commands Committable suggestion
Suggested change
|
||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Webhooks | ||
|
||
## What is this? | ||
|
||
Webhooks serve as platforms for hosting your business logic or invoking other services. Within a session, webhooks enable you to utilize the data extracted through Dialogflow's natural language processing to generate dynamic responses, verify gathered data, or initiate actions on the backend. | ||
|
||
There are two types of webhooks: standard webhooks and flexible webhooks. In the case of a standard webhook, the request and response fields are determined by Dialogflow. On the other hand, a flexible webhook allows you to specify the request and response fields according to your requirements. | ||
|
||
With `cxcli`, you can easily interact with the webhooks of your Dialogflow CX agents. | ||
|
||
All of the commands that you have available in `cxcli` to interact with your webhooks are located within the `cxcli webhook` subcommand. | ||
|
||
You can create, update or delete standard and flexible webhooks with `cxcli` for a specific environment by setting the `--environment` parameter. If you do not specify an environment, the `cxcli` will create, update or delete this webhook for all environments. | ||
|
||
## Create | ||
|
||
The `cxcli` has a command that allows you to create a standard or flexible webhook. You can find a more detailed information [here](/webhooks/create). | ||
|
||
## Update | ||
|
||
The `cxcli` has a command that allows you to update a standard or flexible webhook. You can find a more detailed information [here](/webhooks/update). | ||
|
||
## Delete | ||
|
||
The `cxcli` has a command that allows you to delete your standard or flexible webhook. You can find a more detailed explanation [here](/webhooks/delete). | ||
|
||
## Useful Links | ||
|
||
If you want to see the full usage of the `cxcli webhook` command, please refer to this [page](/cmd/cxcli_webhook). | ||
|
||
If you want to learn more about Dialogflow CX webhooks, refer to the [official documentation](https://cloud.google.com/dialogflow/cx/docs/concept/webhook). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improve error context.
To provide more context in the error message, consider wrapping the error with additional information.
Committable suggestion