/* * Copyright (c) 2018 THL A29 Limited, a Tencent company. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ namespace TencentCloud.Sts.V20180813 { using Newtonsoft.Json; using System.Threading.Tasks; using TencentCloud.Common; using TencentCloud.Common.Profile; using TencentCloud.Sts.V20180813.Models; public class StsClient : AbstractClient{ private const string endpoint = "sts.tencentcloudapi.com"; private const string version = "2018-08-13"; /// /// Client constructor. /// /// Credentials. /// Region name, such as "ap-guangzhou". public StsClient(Credential credential, string region) : this(credential, region, new ClientProfile()) { } /// /// Client Constructor. /// /// Credentials. /// Region name, such as "ap-guangzhou". /// Client profiles. public StsClient(Credential credential, string region, ClientProfile profile) : base(endpoint, version, credential, region, profile) { } /// /// 申请扮演角色 /// /// /// public async Task AssumeRole(AssumeRoleRequest req) { JsonResponseModel rsp = null; try { var strResp = await this.InternalRequest(req, "AssumeRole"); rsp = JsonConvert.DeserializeObject>(strResp); } catch (JsonSerializationException e) { throw new TencentCloudSDKException(e.Message); } return rsp.Response; } /// /// 申请扮演角色 /// /// /// public AssumeRoleResponse AssumeRoleSync(AssumeRoleRequest req) { JsonResponseModel rsp = null; try { var strResp = this.InternalRequestSync(req, "AssumeRole"); rsp = JsonConvert.DeserializeObject>(strResp); } catch (JsonSerializationException e) { throw new TencentCloudSDKException(e.Message); } return rsp.Response; } /// /// 本接口(AssumeRoleWithSAML)用于根据 SAML 断言申请角色临时凭证。 /// /// /// public async Task AssumeRoleWithSAML(AssumeRoleWithSAMLRequest req) { JsonResponseModel rsp = null; try { var strResp = await this.InternalRequest(req, "AssumeRoleWithSAML"); rsp = JsonConvert.DeserializeObject>(strResp); } catch (JsonSerializationException e) { throw new TencentCloudSDKException(e.Message); } return rsp.Response; } /// /// 本接口(AssumeRoleWithSAML)用于根据 SAML 断言申请角色临时凭证。 /// /// /// public AssumeRoleWithSAMLResponse AssumeRoleWithSAMLSync(AssumeRoleWithSAMLRequest req) { JsonResponseModel rsp = null; try { var strResp = this.InternalRequestSync(req, "AssumeRoleWithSAML"); rsp = JsonConvert.DeserializeObject>(strResp); } catch (JsonSerializationException e) { throw new TencentCloudSDKException(e.Message); } return rsp.Response; } /// /// 获取联合身份临时访问凭证 /// /// /// public async Task GetFederationToken(GetFederationTokenRequest req) { JsonResponseModel rsp = null; try { var strResp = await this.InternalRequest(req, "GetFederationToken"); rsp = JsonConvert.DeserializeObject>(strResp); } catch (JsonSerializationException e) { throw new TencentCloudSDKException(e.Message); } return rsp.Response; } /// /// 获取联合身份临时访问凭证 /// /// /// public GetFederationTokenResponse GetFederationTokenSync(GetFederationTokenRequest req) { JsonResponseModel rsp = null; try { var strResp = this.InternalRequestSync(req, "GetFederationToken"); rsp = JsonConvert.DeserializeObject>(strResp); } catch (JsonSerializationException e) { throw new TencentCloudSDKException(e.Message); } return rsp.Response; } /// /// 拉取API密钥列表 /// /// /// public async Task QueryApiKey(QueryApiKeyRequest req) { JsonResponseModel rsp = null; try { var strResp = await this.InternalRequest(req, "QueryApiKey"); rsp = JsonConvert.DeserializeObject>(strResp); } catch (JsonSerializationException e) { throw new TencentCloudSDKException(e.Message); } return rsp.Response; } /// /// 拉取API密钥列表 /// /// /// public QueryApiKeyResponse QueryApiKeySync(QueryApiKeyRequest req) { JsonResponseModel rsp = null; try { var strResp = this.InternalRequestSync(req, "QueryApiKey"); rsp = JsonConvert.DeserializeObject>(strResp); } catch (JsonSerializationException e) { throw new TencentCloudSDKException(e.Message); } return rsp.Response; } } }