コード例 #1
0
        public async Task GetCosSpaceMonitorDataTest()
        {
            var result = await TencentCloudApiRequester.SendRequestAsync <GetMonitorDataResponse>(
                new GetMonitorDataRequest(
                    "ap-chengdu",
                    new List <Instance>
            {
                new Instance
                {
                    Dimensions = new List <Dimension>
                    {
                        new Dimension("appid", TencentCloudCommonOptions.AppId)
                    }
                },
                new Instance
                {
                    Dimensions = new List <Dimension>
                    {
                        new Dimension("bucket", "246e0ec0-a410-4bfb-b566")
                    }
                }
            },
                    "QCE/COS",
                    "StdStorage",
                    3600
                    ),
                TencentCloudCloudMonitorOptions.EndPoint);

            result.ShouldNotBeNull();
        }
コード例 #2
0
        public async Task GetCosMonitorDataTest()
        {
            var result = await TencentCloudApiRequester.SendRequestAsync <GetMonitorDataResponse>(
                new GetMonitorDataRequest(
                    "ap-chengdu",
                    new List <Instance>
            {
                new Instance
                {
                    Dimensions = new List <Dimension>
                    {
                        new Dimension("appid", TencentCloudCommonOptions.AppId)
                    }
                },
                new Instance
                {
                    Dimensions = new List <Dimension>
                    {
                        new Dimension("bucket", "246e0ec0-a410-4bfb-b566")
                    }
                }
            },
                    "QCE/COS",
                    "InternetTraffic",
                    3600,
                    new DateTime(2020, 3, 3, 0, 0, 0).ToString("yyyy-MM-dd HH:mm:ss"),
                    new DateTime(2020, 3, 4, 0, 0, 0).ToString("yyyy-MM-dd HH:mm:ss")),
                TencentCloudCloudMonitorOptions.EndPoint);

            result.ShouldNotBeNull();
            // 单位是 MB。
            var totalFlux = (result.DataPoints.SelectMany(x => x.Values).Sum(x => x) / 1000 / 1000);

            totalFlux.ShouldBeGreaterThan(0);
        }
コード例 #3
0
        public async Task DescribeLiveStreamPushInfoListRequest_Test()
        {
            var resp = await TencentCloudApiRequester.SendRequestAsync <DescribeLiveStreamPushInfoListResponse>(
                new DescribeLiveStreamPushInfoListRequest(),
                TencentCloudCloudLiveOptions.EndPoint);

            resp.RequestId.ShouldNotBeNull();
        }
コード例 #4
0
        public async Task DescribeStreamDayPlayInfoListRequest_Test()
        {
            var resp = await TencentCloudApiRequester.SendRequestAsync <DescribeStreamDayPlayInfoListResponse>(
                new DescribeStreamDayPlayInfoListRequest(
                    "2020-03-12"),
                TencentCloudCloudLiveOptions.EndPoint);

            resp.RequestId.ShouldNotBeNull();
            resp.DataInfoList.Count.ShouldBeGreaterThan(0);
        }
コード例 #5
0
        public async Task DescribeStreamPlayInfoListRequest_Test()
        {
            var resp = await TencentCloudApiRequester.SendRequestAsync <DescribeStreamPlayInfoListResponse>(
                new DescribeStreamPlayInfoListRequest(
                    new DateTime(2020, 3, 3, 0, 0, 0).ToString("yyyy-MM-dd HH:mm:ss"),
                    new DateTime(2020, 3, 4, 0, 0, 0).ToString("yyyy-MM-dd HH:mm:ss"),
                    null,
                    "7396CB03-E2C7-4C96-8919-E9BA2FC0D1DC-GD1517841547"),
                TencentCloudCloudLiveOptions.EndPoint);

            resp.RequestId.ShouldNotBeNull();
            var allFlux      = resp.DataInfoList.Where(x => x.Flux > 0).Sum(x => x.Flux);
            var maxBandwidth = resp.DataInfoList.Where(x => x.Bandwidth > 0).Max(x => x.Bandwidth);
        }
コード例 #6
0
        public async Task SendSmsTest()
        {
            var result = await TencentCloudApiRequester.SendRequestAsync <SendSmsResponse>(
                new SendSmsRequest(
                    new [] { "+8613000000000" },
                    "400000",
                    "",
                    "多态科技",
                    new [] { "123456" }),
                TencentCloudSmsOptions.EndPoint);

            result.ShouldNotBeNull();
            result.Error.ShouldBeNull();
            result.SendStatusSet.ShouldNotBeNull();
            result.SendStatusSet.ShouldNotBeEmpty();
            result.SendStatusSet.First().Code.ShouldBe("Ok");
        }
コード例 #7
0
        public async Task Should_Get_Logs()
        {
            var result = await TencentCloudApiRequester.SendRequestAsync <SearchLogResponse>(
                new SearchLogRequest(
                    "",
                    "",
                    DateTime.Now.AddDays(-7),
                    DateTime.Now,
                    "",
                    100),
                TencentCloudClsOptions.EndPoint);

            result.ShouldNotBeNull();
            result.Error.ShouldBeNull();
            result.Results.ShouldNotBeEmpty();
            result.Results.First().Content.ShouldNotBeNullOrEmpty();
        }
コード例 #8
0
        public async Task GenerateFederationTokenTest()
        {
            var policy = new Policy
            {
                Version    = "2.0",
                Statements = new List <Statement>
                {
                    new Statement
                    {
                        Effect = "allow",
                        Action = new List <string>
                        {
                            "name/cos:PutObject",
                            "name/cos:PostObject",
                            "name/cos:InitiateMultipartUpload",
                            "name/cos:ListMultipartUploads",
                            "name/cos:ListParts",
                            "name/cos:UploadPart",
                            "name/cos:CompleteMultipartUpload",
                            "name/cos:AbortMultipartUpload",
                            "name/cos:GetBucket",
                            "name/cos:HeadObject"
                        },
                        Resource = new List <string>
                        {
                            // TODO: 如果是 COS 的话,需要手动构造前缀。
                            $"qcs::cos:ap-chengdu:uid/{TencentCloudCommonOptions.AppId}:d780c447-3f23-9212-f4d3-39f3d9a69a3e-{TencentCloudCommonOptions.AppId}/*"
                        }
                    }
                }
            };

            var result = await TencentCloudApiRequester.SendRequestAsync <GetFederationTokenResponse>(
                new GetFederationTokenRequest(
                    "ap-chengdu",
                    "ETS",
                    policy,
                    7200), "sts.tencentcloudapi.com"
                );

            result.ShouldNotBeNull();
        }