diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteComponentTcbExtensions.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteComponentTcbExtensions.cs index 2c77bec8..e06fcb18 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteComponentTcbExtensions.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteComponentTcbExtensions.cs @@ -112,6 +112,29 @@ namespace SKIT.FlurlHttpClient.Wechat.Api } #endregion + #region CloudBaseEnvironment + /// + /// 异步调用 [POST] /componenttcb/describecloudbaserunenvs 接口。 + /// REF: https://developers.weixin.qq.com/doc/oplatform/openApi/OpenApiDoc/cloudrun-batch/cloudenv-mgnt/getWxCloudBaseRunEnvs.html + /// + /// + /// + /// + /// + public static async Task ExecuteComponentTcbDescribeCloudBaseRunEnvironmentsAsync(this WechatApiClient client, Models.ComponentTcbDescribeCloudBaseRunEnvironmentsRequest request, CancellationToken cancellationToken = default) + { + if (client is null) throw new ArgumentNullException(nameof(client)); + if (request is null) throw new ArgumentNullException(nameof(request)); + + IFlurlRequest flurlReq = client + .CreateRequest(request, HttpMethod.Post, "componenttcb", "describecloudbaserunenvs") + .SetQueryParam("access_token", request.ComponentAccessToken); + + return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); + } + + #endregion + #region SCF /// /// 异步调用 [POST] /componenttcb/batchuploadscf 接口。 diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/ComponentTcb/CloudBaseEnvironment/ComponentTcbDescribeCloudBaseRunEnvironmentsRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/ComponentTcb/CloudBaseEnvironment/ComponentTcbDescribeCloudBaseRunEnvironmentsRequest.cs new file mode 100644 index 00000000..78d57556 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/ComponentTcb/CloudBaseEnvironment/ComponentTcbDescribeCloudBaseRunEnvironmentsRequest.cs @@ -0,0 +1,15 @@ +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [POST] /componenttcb/describecloudbaserunenvs 接口的请求。 + /// + public class ComponentTcbDescribeCloudBaseRunEnvironmentsRequest : WechatApiRequest, IInferable + { + /// + /// 获取或设置第三方平台 AccessToken。 + /// + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] + public string ComponentAccessToken { get; set; } = string.Empty; + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/ComponentTcb/CloudBaseEnvironment/ComponentTcbDescribeCloudBaseRunEnvironmentsResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/ComponentTcb/CloudBaseEnvironment/ComponentTcbDescribeCloudBaseRunEnvironmentsResponse.cs new file mode 100644 index 00000000..a13eca12 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/ComponentTcb/CloudBaseEnvironment/ComponentTcbDescribeCloudBaseRunEnvironmentsResponse.cs @@ -0,0 +1,368 @@ +using System; + +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [POST] /componenttcb/describecloudbaserunenvs 接口的响应。 + /// + public class ComponentTcbDescribeCloudBaseRunEnvironmentsResponse : WechatApiResponse + { + public static class Types + { + public class Environment + { + public static class Types + { + public class Database + { + /// + /// 获取或设置数据库所属地域。 + /// + [Newtonsoft.Json.JsonProperty("region")] + [System.Text.Json.Serialization.JsonPropertyName("region")] + public string Region { get; set; } = default!; + + /// + /// 获取或设置数据库唯一标识。 + /// + [Newtonsoft.Json.JsonProperty("instance_id")] + [System.Text.Json.Serialization.JsonPropertyName("instance_id")] + public string InstanceId { get; set; } = default!; + + /// + /// 获取或设置状态。 + /// + [Newtonsoft.Json.JsonProperty("status")] + [System.Text.Json.Serialization.JsonPropertyName("status")] + public string Status { get; set; } = default!; + } + + public class Storage + { + /// + /// 获取或设置存储所属地域。 + /// + [Newtonsoft.Json.JsonProperty("region")] + [System.Text.Json.Serialization.JsonPropertyName("region")] + public string Region { get; set; } = default!; + + /// + /// 获取或设置桶名。 + /// + [Newtonsoft.Json.JsonProperty("bucket")] + [System.Text.Json.Serialization.JsonPropertyName("bucket")] + public string Bucket { get; set; } = default!; + + /// + /// 获取或设置 CDN 域名。 + /// + [Newtonsoft.Json.JsonProperty("cdn_domain")] + [System.Text.Json.Serialization.JsonPropertyName("cdn_domain")] + public string? CDNDomain { get; set; } + + /// + /// 获取或设置资源所属用户的腾讯云 AppId。 + /// + [Newtonsoft.Json.JsonProperty("app_id")] + [System.Text.Json.Serialization.JsonPropertyName("app_id")] + public string? AppId { get; set; } + } + + public class StaticStorage + { + /// + /// 获取或设置静态资源所属地域。 + /// + [Newtonsoft.Json.JsonProperty("region")] + [System.Text.Json.Serialization.JsonPropertyName("region")] + public string Region { get; set; } = default!; + + /// + /// 获取或设置存储桶名。 + /// + [Newtonsoft.Json.JsonProperty("bucket")] + [System.Text.Json.Serialization.JsonPropertyName("bucket")] + public string Bucket { get; set; } = default!; + + /// + /// 获取或设置资源状态。 + /// + [Newtonsoft.Json.JsonProperty("status")] + [System.Text.Json.Serialization.JsonPropertyName("status")] + public string Status { get; set; } = default!; + + /// + /// 获取或设置静态 CDN 域名。 + /// + [Newtonsoft.Json.JsonProperty("static_domain")] + [System.Text.Json.Serialization.JsonPropertyName("static_domain")] + public string StaticDomain { get; set; } = default!; + + /// + /// 获取或设置静态 CDN 默认文件夹。 + /// + [Newtonsoft.Json.JsonProperty("default_dir_name")] + [System.Text.Json.Serialization.JsonPropertyName("default_dir_name")] + public string DefaultDirectoryName { get; set; } = default!; + } + + public class Function + { + /// + /// 获取或设置函数所属地域。 + /// + [Newtonsoft.Json.JsonProperty("region")] + [System.Text.Json.Serialization.JsonPropertyName("region")] + public string Region { get; set; } = default!; + + /// + /// 获取或设置命名空间。 + /// + [Newtonsoft.Json.JsonProperty("namespace")] + [System.Text.Json.Serialization.JsonPropertyName("namespace")] + public string Namespace { get; set; } = default!; + } + + public class LogService + { + /// + /// 获取或设置日志所属地域。 + /// + [Newtonsoft.Json.JsonProperty("region")] + [System.Text.Json.Serialization.JsonPropertyName("region")] + public string Region { get; set; } = default!; + + /// + /// 获取或设置日志 ID。 + /// + [Newtonsoft.Json.JsonProperty("logset_id")] + [System.Text.Json.Serialization.JsonPropertyName("logset_id")] + public string LogsetId { get; set; } = default!; + + /// + /// 获取或设置日志名。 + /// + [Newtonsoft.Json.JsonProperty("logset_name")] + [System.Text.Json.Serialization.JsonPropertyName("logset_name")] + public string LogsetName { get; set; } = default!; + + /// + /// 获取或设置主题 ID。 + /// + [Newtonsoft.Json.JsonProperty("topic_id")] + [System.Text.Json.Serialization.JsonPropertyName("topic_id")] + public string TopicId { get; set; } = default!; + + /// + /// 获取或设置主题名。 + /// + [Newtonsoft.Json.JsonProperty("topic_name")] + [System.Text.Json.Serialization.JsonPropertyName("topic_name")] + public string TopicName { get; set; } = default!; + } + + public class CustomLogService + { + /// + /// 获取或设置静态资源所属地域。 + /// + [Newtonsoft.Json.JsonProperty("cls_region")] + [System.Text.Json.Serialization.JsonPropertyName("cls_region")] + public string Region { get; set; } = default!; + + /// + /// 获取或设置日志 ID。 + /// + [Newtonsoft.Json.JsonProperty("cls_logset_id")] + [System.Text.Json.Serialization.JsonPropertyName("cls_logset_id")] + public string LogsetId { get; set; } = default!; + + /// + /// 获取或设置主题 ID。 + /// + [Newtonsoft.Json.JsonProperty("cls_topic_id")] + [System.Text.Json.Serialization.JsonPropertyName("cls_topic_id")] + public string TopicId { get; set; } = default!; + + /// + /// 获取或设置创建时间。 + /// + [Newtonsoft.Json.JsonProperty("create_time")] + [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.RegularDateTimeOffsetConverter))] + [System.Text.Json.Serialization.JsonPropertyName("create_time")] + [System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Converters.RegularDateTimeOffsetConverter))] + public DateTimeOffset CreateTime { get; set; } + } + + public class Tag + { + /// + /// 获取或设置标签键。 + /// + [Newtonsoft.Json.JsonProperty("key")] + [System.Text.Json.Serialization.JsonPropertyName("key")] + public string Key { get; set; } = default!; + + /// + /// 获取或设置标签值。 + /// + [Newtonsoft.Json.JsonProperty("value")] + [System.Text.Json.Serialization.JsonPropertyName("value")] + public string Value { get; set; } = default!; + } + } + + /// + /// 获取或设置环境所属地域。 + /// + [Newtonsoft.Json.JsonProperty("region")] + [System.Text.Json.Serialization.JsonPropertyName("region")] + public string Region { get; set; } = default!; + + /// + /// 获取或设置环境 ID。 + /// + [Newtonsoft.Json.JsonProperty("env_id")] + [System.Text.Json.Serialization.JsonPropertyName("env_id")] + public string EnvironmentId { get; set; } = default!; + + /// + /// 获取或设置环境来源。 + /// + [Newtonsoft.Json.JsonProperty("source")] + [System.Text.Json.Serialization.JsonPropertyName("source")] + public string Source { get; set; } = default!; + + /// + /// 获取或设置环境别名。 + /// + [Newtonsoft.Json.JsonProperty("alias")] + [System.Text.Json.Serialization.JsonPropertyName("alias")] + public string Alias { get; set; } = default!; + + /// + /// 获取或设置环境状态。 + /// + [Newtonsoft.Json.JsonProperty("status")] + [System.Text.Json.Serialization.JsonPropertyName("status")] + public string Status { get; set; } = default!; + + /// + /// 获取或设置产品套餐 ID。 + /// + [Newtonsoft.Json.JsonProperty("package_id")] + [System.Text.Json.Serialization.JsonPropertyName("package_id")] + public string? PackageId { get; set; } + + /// + /// 获取或设置产品套餐名称。 + /// + [Newtonsoft.Json.JsonProperty("package_name")] + [System.Text.Json.Serialization.JsonPropertyName("package_name")] + public string? PackageName { get; set; } + + /// + /// 获取或设置数据库列表。 + /// + [Newtonsoft.Json.JsonProperty("databases")] + [System.Text.Json.Serialization.JsonPropertyName("databases")] + public Types.Database[]? DatabaseList { get; set; } + + /// + /// 获取或设置存储列表。 + /// + [Newtonsoft.Json.JsonProperty("storages")] + [System.Text.Json.Serialization.JsonPropertyName("storages")] + public Types.Storage[]? StorageList { get; set; } + + /// + /// 获取或设置静态资源列表。 + /// + [Newtonsoft.Json.JsonProperty("static_storages")] + [System.Text.Json.Serialization.JsonPropertyName("static_storages")] + public Types.StaticStorage[]? StaticStorageList { get; set; } + + /// + /// 获取或设置函数列表。 + /// + [Newtonsoft.Json.JsonProperty("functions")] + [System.Text.Json.Serialization.JsonPropertyName("functions")] + public Types.Function[]? FunctionList { get; set; } + + /// + /// 获取或设置云日志服务列表。 + /// + [Newtonsoft.Json.JsonProperty("log_services")] + [System.Text.Json.Serialization.JsonPropertyName("log_services")] + public Types.LogService[]? LogServiceList { get; set; } + + /// + /// 获取或设置自定义日志服务列表。 + /// + [Newtonsoft.Json.JsonProperty("custom_log_services")] + [System.Text.Json.Serialization.JsonPropertyName("custom_log_services")] + public Types.CustomLogService[]? CustomLogServiceList { get; set; } + + /// + /// 获取或设置是否到期自动降为免费版。 + /// + [Newtonsoft.Json.JsonProperty("is_auto_degrade")] + [System.Text.Json.Serialization.JsonPropertyName("is_auto_degrade")] + public bool IsAutoDegrade { get; set; } + + /// + /// 获取或设置环境渠道。 + /// + [Newtonsoft.Json.JsonProperty("env_channel")] + [System.Text.Json.Serialization.JsonPropertyName("env_channel")] + public string? EnvironmentChannel { get; set; } + + /// + /// 获取或设置支付方式。 + /// + [Newtonsoft.Json.JsonProperty("pay_mode")] + [System.Text.Json.Serialization.JsonPropertyName("pay_mode")] + public string PayMode { get; set; } = default!; + + /// + /// 获取或设置是否为默认环境。 + /// + [Newtonsoft.Json.JsonProperty("is_default")] + [System.Text.Json.Serialization.JsonPropertyName("is_default")] + public bool IsDefault { get; set; } + + /// + /// 获取或设置环境标签列表。 + /// + [Newtonsoft.Json.JsonProperty("tags")] + [System.Text.Json.Serialization.JsonPropertyName("tags")] + public Types.Tag[] TagList { get; set; } = default!; + + /// + /// 获取或设置修改时间。 + /// + [Newtonsoft.Json.JsonProperty("update_time")] + [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.RegularDateTimeOffsetConverter))] + [System.Text.Json.Serialization.JsonPropertyName("update_time")] + [System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Converters.RegularDateTimeOffsetConverter))] + public DateTimeOffset UpdateTime { get; set; } + + /// + /// 获取或设置创建时间。 + /// + [Newtonsoft.Json.JsonProperty("create_time")] + [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.RegularDateTimeOffsetConverter))] + [System.Text.Json.Serialization.JsonPropertyName("create_time")] + [System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Converters.RegularDateTimeOffsetConverter))] + public DateTimeOffset CreateTime { get; set; } + } + } + + /// + /// 获取或设置环境列表。 + /// + [Newtonsoft.Json.JsonProperty("env_list")] + [System.Text.Json.Serialization.JsonPropertyName("env_list")] + public Types.Environment[] EnvironmentList { get; set; } = default!; + } +} diff --git a/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/ComponentTcb/CloudBaseEnvironment/ComponentTcbDescribeCloudBaseRunEnvironmentsResponse.json b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/ComponentTcb/CloudBaseEnvironment/ComponentTcbDescribeCloudBaseRunEnvironmentsResponse.json new file mode 100644 index 00000000..a186e411 --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/ComponentTcb/CloudBaseEnvironment/ComponentTcbDescribeCloudBaseRunEnvironmentsResponse.json @@ -0,0 +1,68 @@ +{ + "errcode": 0, + "errmsg": "ok", + "env_list": [ + { + "env_id": "wxc47dec912cf1b447-qd-5a17787412", + "source": "miniapp", + "alias": "wxc47dec912cf1b447-qd", + "create_time": "2021-12-16 15:06:52", + "update_time": "2021-12-16 15:06:58", + "status": "NORMAL", + "databases": [], + "storages": [ + { + "region": "ap-shanghai", + "bucket": "7778-wxc47dec912cf1b447-qd-5a17787412-1308820263", + "cdn_domain": "7778-wxc47dec912cf1b447-qd-5a17787412-1308820263.tcb.qcloud.la", + "app_id": "1308820263" + } + ], + "functions": [ + { + "namespace": "", + "region": "" + } + ], + "package_id": "", + "package_name": "", + "log_services": [ + { + "logset_name": "tcb-logset-wxc47dec912cf1b447-qd-5a17787412", + "logset_id": "af0676b8-4c88-445f-90b4-3ba6cd93a74a", + "topic_name": "tcb-topic-wxc47dec912cf1b447-qd-5a17787412", + "topic_id": "6cffd67f-5700-4238-8523-bba514e2b2bf", + "region": "ap-shanghai" + } + ], + "static_storages": [ + { + "static_domain": "", + "default_dir_name": "", + "status": "", + "region": "", + "bucket": "" + } + ], + "is_auto_degrade": false, + "env_channel": "wxrun", + "pay_mode": "postpaid", + "is_default": true, + "region": "ap-shanghai", + "tags": [ + { + "key": "", + "value": "" + } + ], + "custom_log_services": [ + { + "cls_region": "", + "cls_logset_id": "", + "cls_topic_id": "", + "create_time": "2021-12-16 15:06:52" + } + ] + } + ] +}