5.10. 创建方法

使用 3scale toolbox 在 Developer Portal 中创建、应用、列出和删除方法。

5.10.1. 创建方法

使用以下步骤创建方法:

  • 您必须提供方法名称。
  • 要覆盖 system-name,请使用可选参数。
  • 如果存在具有相同名称的方法,您将看到错误消息。
  • 通过 --disabled 标志创建 禁用 的方法。

    • 默认情况下将 启用 它。
注意
  • 服务 位置参数是服务引用,可以是服务 ID 或 service system_name

    • toolbox 使用其中任一个。

以下命令创建一个方法:

3scale method create [opts] <remote> <service> <method-name>

在创建方法时使用以下选项:

Options
       --description=<value>      Set a method description
       --disabled                 Disable this method in all
                                  application plans
    -o --output=<value>           Output format on stdout:
                                  one of json|yaml
    -t --system-name=<value>      Set the method system name

Options for method
    -c --config-file=<value>      3scale toolbox configuration file:
                                  defaults to $HOME/.3scalerc.yaml
    -h --help                     Print help for this command
    -k --insecure                 Proceed and operate even for server
                                  connections otherwise considered insecure
    -v --version                  Print the version of this command
       --verbose                  Verbose mode

5.10.2. 创建或更新方法

如果方法不存在,请使用以下步骤创建新方法,或更新现有的方法:

  • 如果存在具有相同名称的方法,命令将返回错误消息。
  • 使用 --disabled 标志 更新为 禁用 的方法。
  • 使用 --enabled 标志 更新为 启用 的方法。
注意
  • 服务 位置参数是服务引用,可以是服务 ID 或 service system_name

    • toolbox 使用其中任一个。
  • method 位置参数是方法引用,可以是方法 id 或方法 system_name

    • toolbox 使用其中任一个。

以下命令更新方法:

3scale method apply [opts] <remote> <service> <method>

在更新方法时使用以下选项:

Options
       --description=<value>      Set a method description
       --disabled                 Disable this method in all
                                  application plans
       --enabled                  Enable this method in all
                                  application plans
    -n --name=<value>             Set the method name
    -o --output=<value>           Output format on stdout:
                                  one of json|yaml

Options for method
    -c --config-file=<value>      3scale toolbox configuration file:
                                  defaults to $HOME/.3scalerc.yaml
    -h --help                     Print help for this command
    -k --insecure                 Proceed and operate even for server
                                  connections otherwise considered insecure
    -v --version                  Print the version of this command
       --verbose                  Verbose mode

5.10.3. 列出方法

以下命令列出方法:

3scale method list [opts] <remote> <service>

在列出方法时使用以下选项:

Options
    -o --output=<value>           Output format on stdout:
                                  one of json|yaml

Options for method
    -c --config-file=<value>      3scale toolbox configuration file:
                                  defaults to $HOME/.3scalerc.yaml
    -h --help                     Print help for this command
    -k --insecure                 Proceed and operate even for server
                                  connections otherwise considered insecure
    -v --version                  Print the version of this command
       --verbose                  Verbose mode

5.10.4. 删除方法

以下命令删除方法:

3scale method delete [opts] <remote> <service> <metric>

在删除方法时使用以下选项:

Options for method
    -c --config-file=<value>      3scale toolbox configuration file:
                                  defaults to $HOME/.3scalerc.yaml
    -h --help                     Print help for this command
    -k --insecure                 Proceed and operate even for server
                                  connections otherwise considered insecure
    -v --version                  Print the version of this command
       --verbose                  Verbose mode