5.8. 创建应用程序计划

使用 3scale toolbox 在 Developer Portal 中创建、更新、列出、删除、显示或导出/导入应用程序计划。

5.8.1. 创建新应用程序计划

使用以下步骤创建新应用程序计划:

  • 您必须提供应用计划名称。
  • 要覆盖 system-name,请使用可选参数。
  • 如果存在具有相同名称的应用计划,您将看到错误消息。
  • 使用 --default 标志,将应用计划设置为 --default
  • 使用 --publish 标志创建一个发布的应用计划。

    • 默认情况下,它将被 隐藏
  • 使用 --disabled 标志创建 禁用 的应用程序计划。

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

    • toolbox 使用其中任一个。

以下命令创建新应用程序计划:

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

在创建应用程序计划时使用以下选项:

Options
       --approval-required=<value>    The application requires approval:
                                      true or false
       --cost-per-month=<value>       Cost per month
       --default                      Make the default application plan
       --disabled                     Disable all methods and metrics in
                                      the application plan
    -o --output=<value>               Output format on stdout:
                                      one of json|yaml
    -p --published                    Publish the application plan
       --setup-fee=<value>            Set-up fee
    -t --system-name=<value>          Set application plan system name
       --trial-period-days=<value>    The trial period in days

Options for application-plan
    -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.8.2. 创建或更新应用程序计划

如果使用以下步骤创建新应用程序计划(如果不存在),或更新现有应用程序计划:

  • 使用 --default 标志更新 默认 应用计划。
  • 使用 --publish 标志,更新 发布的 应用计划。
  • 使用 --hide 标志更新 隐藏 的应用计划。
  • 使用 --disabled 标志更新 禁用 的应用程序计划。
  • 使用 --enabled 标志,更新 启用 的应用计划。
注意
  • 服务 位置参数是服务引用,可以是服务 ID 或 service system_name

    • toolbox 使用其中任一个。
  • plan 位置参数是计划引用,可以是计划 id 或 plan system_name

    • toolbox 使用其中任一个。

以下命令更新应用程序计划:

3scale application-plan create [opts] <remote> <service> <plan>

在更新应用程序计划时使用以下选项:

Options
       --approval-required=<value>    The application requires approval:
                                      true or false
       --cost-per-month=<value>       Cost per month
       --default                      Make the default application plan
       --disabled                     Disable all methods and metrics in
                                      the application plan
       --enabled                      Enable the application plan
       --hide                         Hide the application plan
    -n --name=<value>                 Set the plan name
    -o --output=<value>               Output format on stdout:
                                      one of json|yaml
    -p --publish                      Publish the application plan
       --setup-fee=<value>            Set-up fee
       --trial-period-days=<value>    The trial period in days

Options for application-plan
    -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.8.3. 列出应用计划

以下命令列出应用程序计划:

3scale application-plan list [opts] <remote> <service>

在列出应用程序计划时使用以下选项:

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

Options for application-plan
    -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.8.4. 显示应用程序计划

以下命令显示应用程序计划:

3scale application-plan show [opts] <remote> <service> <plan>

在显示应用程序计划时使用以下选项:

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

Options for application-plan
    -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.8.5. 删除应用程序计划

以下命令删除应用程序计划:

3scale application-plan delete [opts] <remote> <service> <plan>

在删除应用程序计划时使用以下选项:

Options for application-plan
    -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.8.6. 导出/导入应用程序计划

您可以将单个应用程序计划导出或导入到 yaml 内容。

注意以下几点:

  • 包括了应用程序计划中定义的限制。
  • 包括了应用程序计划中定义的定价规则。
  • 包括根据限制和价格规则引用的指标/方法。
  • 应用程序计划中定义的功能包括:
  • 服务可以被 idsystem_name 引用。
  • 应用程序计划可以被 idsystem_name 来引用。

5.8.6.1. 将应用计划导出到文件

以下命令导出应用程序计划:

3scale application-plan export [opts] <remote> <service_system_name> <plan_system_name>

示例

$ podman run -u root -v $PWD:/tmp registry.redhat.io/3scale-amp2/toolbox-rhel8:3scale2.11 3scale application-plan export --file=/tmp/plan.yaml remote_name service_name plan_name

本例使用 Podman 卷将输出结果中的导出文件挂载到当前的 $PWD 文件夹。

注意

特定于 export 命令:

  • 对远程服务和应用计划进行只读操作.
  • 命令输出可以是 stdout 或文件。

    • 如果没有由 -f 选项指定,则默认情况下,yaml 内容将写入 stdout

在导出应用程序计划时使用以下选项:

Options
    -f --file=<value>             Write to file instead of stdout

Options for application-plan
    -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.8.6.2. 从文件导入应用计划

以下命令导入应用程序计划:

3scale application-plan import [opts] <remote> <service_system_name>

示例

$ podman run -v $PWD/plan.yaml:/tmp/plan.yaml registry.redhat.io/3scale-amp2/toolbox-rhel8:3scale2.11 3scale application-plan import --file=/tmp/plan.yaml remote_name service_name

本例使用 Podman 卷从当前的 $PWD 文件夹挂载容器中导入的文件。

5.8.6.3. 从 URL 导入应用计划

3scale application-plan import -f http[s]://domain/resource/path.yaml remote_name service_name
注意

特定于导入命令:

  • 命令输入内容可以 stdin、文件或 URL 格式。

    • 如果没有由 -f 选项指定,默认情况下,yaml 内容将从 stdin 中读取。
  • 如果无法在远程服务中找到应用计划,它将被创建。
  • 可选的 param -p--plan,用于覆盖远程目标应用程序计划 idsystem_name

    • 如果没有通过 -p 选项指定,默认情况下,应用程序计划将由来自 yaml 内容的计划属性 system_name from 引用。
  • 将创建在远程服务中没有的 yaml 内容中的任何指标或方法。

导入应用程序计划时使用以下选项:

Options
    -f --file=<value>                  Read from file or URL instead of
                                       stdin
    -p --plan=<value>                  Override application plan reference

Options for application-plan
    -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