Skip to content

Commit

Permalink
Merge pull request #9 from EasyAbp/region
Browse files Browse the repository at this point in the history
Use `Region` in `AbpTencentCloudCommonOptions`
  • Loading branch information
gdlcf88 authored Mar 12, 2023
2 parents 5abdf2c + 1898b34 commit 90867bd
Show file tree
Hide file tree
Showing 17 changed files with 117 additions and 37 deletions.
39 changes: 20 additions & 19 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- main
jobs:
publish:
runs-on: windows-latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: NuGet/setup-nuget@v1
Expand Down Expand Up @@ -38,36 +38,37 @@ jobs:
# run: dotnet test -c Release --no-restore --no-build

- name: dotnet pack
run: dotnet pack -c Release --no-build -o dest
run: dotnet pack -c Release --no-build --property PackageOutputPath=${{ github.workspace }}/nugetPackages/

- name: remove unused packages
run: |
cd dest
del * -Exclude EasyAbp.*
del * -Exclude *.${{ steps.getVersion.outputs.first_match }}.nupkg
del *.Blazor.Host.*
del *.Blazor.Server.Host.*
del *.Host.Shared.*
del *.HttpApi.Host.*
del *.IdentityServer.*
del *.AuthServer.*
del *.Web.Host.*
del *.Web.Unified.*
del *.HttpApi.Client.ConsoleTestApp.*
del *.Tests.*
del *.TestBase.*
dir -name
cd ${{ github.workspace }}/nugetPackages
shopt -s extglob
rm -f !(EasyAbp.*)
rm -f !(*.${{ steps.getVersion.outputs.first_match }}.nupkg)
rm -f *.Blazor.Host.*
rm -f *.Blazor.Server.Host.*
rm -f *.Host.Shared.*
rm -f *.HttpApi.Host.*
rm -f *.IdentityServer.*
rm -f *.AuthServer.*
rm -f *.Web.Host.*
rm -f *.Web.Unified.*
rm -f *.HttpApi.Client.ConsoleTestApp.*
rm -f *.Tests.*
rm -f *.TestBase.*
ls
- name: dotnet nuget push to GitHub
uses: tanaka-takayoshi/[email protected]
with:
nupkg-path: 'dest\*.nupkg'
nupkg-path: '${{ github.workspace }}/nugetPackages/*.nupkg'
repo-owner: 'EasyAbp'
gh-user: 'EasyAbp'
token: ${{ secrets.GITHUB_TOKEN }}

- name: dotnet nuget push to NuGet
run: dotnet nuget push dest\*.nupkg -k ${{secrets.NUGET_API_KEY}} -s https://api.nuget.org/v3/index.json --skip-duplicate
run: dotnet nuget push ${{ github.workspace }}/nugetPackages/*.nupkg -k ${{secrets.NUGET_API_KEY}} -s https://api.nuget.org/v3/index.json --skip-duplicate

- name: determine if the tag exists
uses: mukunku/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion common.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<LangVersion>latest</LangVersion>
<Version>1.9.0</Version>
<Version>1.10.0</Version>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>EasyAbp Team</Authors>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ namespace EasyAbp.Abp.TencentCloud.CAM.STS
{
public class GetFederationTokenRequest : CommonRequest
{
public GetFederationTokenRequest(string region,
public GetFederationTokenRequest(
string name,
Policy policy,
int? durationSeconds = null)
{
SetAction("GetFederationToken");
SetVersion("2018-08-13");
SetRegion(region);

if (durationSeconds > 7200) throw new ArgumentOutOfRangeException(nameof(durationSeconds), "有效期最大时长不得超过 7200 秒。");

Expand Down
5 changes: 0 additions & 5 deletions src/EasyAbp.Abp.TencentCloud.COS/AbpTencentCloudCOSOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
{
public class AbpTencentCloudCOSOptions
{
/// <summary>
/// 存储桶的默认地域。
/// </summary>
public string Region { get; set; }

/// <summary>
/// 连接超时时间,单位是秒,默认值为 60 秒。
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ private CosXmlConfig BuildConfig()
.SetReadWriteTimeoutMs(TimeSpan.FromSeconds(_abpTencentCloudCOSOptions.ReadWriteTimeout).TotalMilliseconds.To<int>())
.IsHttps(true)
.SetAppid(_abpTencentCloudCommonOptions.AppId)
.SetRegion(_abpTencentCloudCOSOptions.Region)
.SetRegion(_abpTencentCloudCommonOptions.Region)
.SetDebugLog(false)
.Build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace EasyAbp.Abp.TencentCloud.CloudMonitor.BaseMonitor
{
public class GetMonitorDataRequest : CommonRequest
{
public GetMonitorDataRequest(string region,
public GetMonitorDataRequest(
List<Instance> instances,
string @namespace,
string metricName,
Expand All @@ -16,7 +16,6 @@ public GetMonitorDataRequest(string region,
{
SetAction("GetMonitorData");
SetVersion("2018-07-24");
SetRegion(region);

SetRequestBody(new
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ public class AbpTencentCloudCommonOptions
public string SecretKey { get; set; }

public string AppId { get; set; }

public string Region { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public virtual async Task<TResponse> SendRequestAsync<TResponse>(ICommonRequest
{
request.SetEndpoint(endpoint);
request.SetAuthorization(options.SecretId, options.SecretKey);
request.SetRegion(options.Region);

using var response = await HttpClient.SendAsync(request.HttpRequestMessage);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using EasyAbp.Abp.TencentCloud.Common.Models;

namespace EasyAbp.Abp.TencentCloud.Sms.SmsTemplates
{
public class DescribeSmsTemplateListRequest : CommonRequest
{
public DescribeSmsTemplateListRequest(
bool international,
int[] templateIdSet,
int? limit = null,
int? offset = null)
{
SetAction("DescribeSmsTemplateList");
SetVersion("2021-01-11");

SetRequestBody(new
{
International = international ? 1 : 0,
TemplateIdSet = templateIdSet,
Limit = limit,
Offset = offset
});
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.Collections.Generic;
using EasyAbp.Abp.TencentCloud.Common.Models;

namespace EasyAbp.Abp.TencentCloud.Sms.SmsTemplates
{
public class DescribeSmsTemplateListResponse : CommonResponse
{
public List<DescribeTemplateStatusSet> DescribeTemplateStatusSet { get; set; }
}

public class DescribeTemplateStatusSet
{
public int TemplateId { get; set; }

public int International { get; set; }

public int StatusCode { get; set; }

public string ReviewReply { get; set; }

public string TemplateName { get; set; }

public string CreateTime { get; set; }

public string TemplateContent { get; set; }
}
}
1 change: 0 additions & 1 deletion test/EasyAbp.Abp.TencentCloud.CAM.Tests/STSTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public async Task GenerateFederationTokenTest()

var result = await TencentCloudApiRequester.SendRequestAsync<GetFederationTokenResponse>(
new GetFederationTokenRequest(
"ap-chengdu",
"ETS",
policy,
7200), "sts.tencentcloudapi.com"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Volo.Abp.Modularity;
using EasyAbp.Abp.TencentCloud.Common;
using Volo.Abp.Modularity;
using EasyAbp.Abp.TencentCloud.TestBase;

namespace EasyAbp.Abp.TencentCloud.COS.Tests
Expand All @@ -9,9 +10,9 @@ public class AbpTencentCloudCOSTestsModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpTencentCloudCOSOptions>(op =>
Configure<AbpTencentCloudCommonOptions>(op =>
{
op.Region = "ap-chengdu";
op.Region = AbpTencentCloudConsts.Region;
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public async Task GetCosMonitorDataTest()
{
var result = await TencentCloudApiRequester.SendRequestAsync<GetMonitorDataResponse>(
new GetMonitorDataRequest(
"ap-chengdu",
new List<Instance>
{
new Instance
Expand Down Expand Up @@ -51,7 +50,6 @@ public async Task GetCosSpaceMonitorDataTest()
{
var result = await TencentCloudApiRequester.SendRequestAsync<GetMonitorDataResponse>(
new GetMonitorDataRequest(
"ap-chengdu",
new List<Instance>
{
new Instance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpTencentCloudClsOptions>(op =>
{
op.Region = "ap-guangzhou";
op.Region = AbpTencentCloudConsts.Region;
op.IsIntranet = false;
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System.Threading.Tasks;
using EasyAbp.Abp.TencentCloud.Sms.SmsTemplates;
using Shouldly;
using Xunit;

namespace EasyAbp.Abp.TencentCloud.Sms.Tests
{
public class DescribeSmsTemplateListTests : AbpTencentCloudSmsTestBase
{
[Fact]
public async Task DescribeTemplateStatusSetTest()
{
var result = await TencentCloudApiRequester.SendRequestAsync<DescribeSmsTemplateListResponse>(
new DescribeSmsTemplateListRequest(
false,
new[] { 1039198, 686954 }),
TencentCloudSmsOptions.EndPoint);

result.ShouldNotBeNull();
result.Error.ShouldBeNull();
result.DescribeTemplateStatusSet.ShouldNotBeEmpty();
result.DescribeTemplateStatusSet.Count.ShouldBe(2);
result.DescribeTemplateStatusSet.ShouldContain(x =>
x.TemplateId == 1039198 && x.StatusCode == 0 && x.TemplateName == "绑定手机验证码" &&
x.TemplateContent == "您正在进行绑定手机操作,{1} 为您的验证码,如非本人操作,请忽略本短信。");
result.DescribeTemplateStatusSet.ShouldContain(x =>
x.TemplateId == 686954 && x.StatusCode == 0 && x.TemplateName == "验证码" &&
x.TemplateContent == "验证码为:{1},您正在登录,若非本人操作,请勿泄露。");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
public class AbpTencentCloudConsts
{
public const string Region = "ap-guangzhou"; // ap-guangzhou ap-chengdu
public const string SecretId = "";
public const string SecretKey = "";
public const string AppId = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public override void ConfigureServices(ServiceConfigurationContext context)
op.SecretId = AbpTencentCloudConsts.SecretId;
op.SecretKey = AbpTencentCloudConsts.SecretKey;
op.AppId = AbpTencentCloudConsts.AppId;
op.Region = AbpTencentCloudConsts.Region;
});
}
}
Expand Down

0 comments on commit 90867bd

Please sign in to comment.