private static async Task AttachAdminPolicyToAdminGroup(IAmazonIdentityManagementService client, CancellationToken token) { const string policyDocument = @" { ""Version"": ""2012-10-17"", ""Statement"": [ { ""Effect"": ""Allow"", ""Action"": ""*"", ""Resource"": ""*"" } ] }"; CreatePolicyRequest request = new CreatePolicyRequest() { Description = "Policy for Administrators", PolicyDocument = policyDocument, PolicyName = "AllAccess" }; CreatePolicyResponse response = await client.CreatePolicyAsync(request, token); //throw new NotImplementedException(); }
public async stt::Task CreatePolicyResourceNames3Async() { moq::Mock <OrgPolicy.OrgPolicyClient> mockGrpcClient = new moq::Mock <OrgPolicy.OrgPolicyClient>(moq::MockBehavior.Strict); CreatePolicyRequest request = new CreatePolicyRequest { ParentAsProjectName = gagr::ProjectName.FromProject("[PROJECT]"), Policy = new Policy(), }; Policy expectedResponse = new Policy { PolicyName = PolicyName.FromProjectPolicy("[PROJECT]", "[POLICY]"), Spec = new PolicySpec(), Alternate = new AlternatePolicySpec(), }; mockGrpcClient.Setup(x => x.CreatePolicyAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Policy>(stt::Task.FromResult(expectedResponse), null, null, null, null)); OrgPolicyClient client = new OrgPolicyClientImpl(mockGrpcClient.Object, null); Policy responseCallSettings = await client.CreatePolicyAsync(request.ParentAsOrganizationName, request.Policy, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); Policy responseCancellationToken = await client.CreatePolicyAsync(request.ParentAsOrganizationName, request.Policy, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public CreatePolicyResponse CreatePolicy(CreatePolicyRequest inputParameters, Broker broker) { Client client = Mapper.Map <Client>(inputParameters.RegisteredKeeper); if (inputParameters.RegisteredKeeper.IsLegalPerson) { client.LegalPerson = Mapper.Map <LegalPerson>(inputParameters.RegisteredKeeper); client.LegalPerson.Address = Mapper.Map <AddressDto>(inputParameters.RegisteredKeeper); client.LegalPerson.MailingAddress = Mapper.Map <MailingAddressDto>(inputParameters.RegisteredKeeper); } else { client.Person = Mapper.Map <Person>(inputParameters.RegisteredKeeper); client.Person.Address = Mapper.Map <AddressDto>(inputParameters.RegisteredKeeper); client.Person.MailingAddress = Mapper.Map <MailingAddressDto>(inputParameters.RegisteredKeeper); } Vehicle vehicle = Mapper.Map <Vehicle>(inputParameters.Vehicle); Policy savedPolicy = DataAccess.SavePolicy(inputParameters.QuoteGuid, client, vehicle, broker); CreatePolicyResponse result = new CreatePolicyResponse() { PolicyNumber = savedPolicy.PolicyNumber }; return(result); }
/// <summary> /// 创建内容转发策略 /// </summary> /// <param name="requestParams">请求参数.</param> /// <returns>返回对象<see cref="UCloudSDK.Models.CreatePolicyResponse"/></returns> public CreatePolicyResponse CreatePolicy(CreatePolicyRequest requestParams) { var request = new RestRequest(Method.GET); request.AddUObject(requestParams); return(Execute <CreatePolicyResponse>(request)); }
/// <summary> /// 创建策略 /// </summary> public async Task <CreatePolicyResponse> CreatePolicyAsync(CreatePolicyRequest createPolicyRequest) { Dictionary <string, string> urlParam = new Dictionary <string, string>(); string urlPath = HttpUtils.AddUrlPath("/v3/{project_id}/policies", urlParam); SdkRequest request = HttpUtils.InitSdkRequest(urlPath, "application/json;charset=UTF-8", createPolicyRequest); HttpResponseMessage response = await DoHttpRequestAsync("POST", request); return(JsonUtils.DeSerialize <CreatePolicyResponse>(response)); }
public void CreatePolicyTest() { var back = new NList() { backendId }; var entity = new CreatePolicyRequest(Config.region, groupId, "ok", ulbId, vServerId, back); var response = ulb.CreatePolicy(entity); Assert.AreEqual(response.RetCode, 0); }
// snippet-end:[IAM.dotnetv3.CreateAccessKey] // snippet-start:[IAM.dotnetv3.CreatePolicyAsync] /// <summary> /// Create a policy to allow a user to list the buckets in an account. /// </summary> /// <param name="client">The initialized IAM client object.</param> /// <param name="policyName">The name of the poicy to create.</param> /// <param name="policyDocument">The permissions policy document.</param> /// <returns>The newly created ManagedPolicy object.</returns> public static async Task <ManagedPolicy> CreatePolicyAsync( AmazonIdentityManagementServiceClient client, string policyName, string policyDocument) { var request = new CreatePolicyRequest { PolicyName = policyName, PolicyDocument = policyDocument, }; var response = await client.CreatePolicyAsync(request); return(response.Policy); }
/// <summary> /// 本接口(CreatePolicy)可用于创建策略。 /// </summary> /// <param name="req">参考<see cref="CreatePolicyRequest"/></param> /// <returns>参考<see cref="CreatePolicyResponse"/>实例</returns> public async Task <CreatePolicyResponse> CreatePolicy(CreatePolicyRequest req) { JsonResponseModel <CreatePolicyResponse> rsp = null; try { var strResp = await this.InternalRequest(req, "CreatePolicy"); rsp = JsonConvert.DeserializeObject <JsonResponseModel <CreatePolicyResponse> >(strResp); } catch (JsonSerializationException e) { throw new TencentCloudSDKException(e.Message); } return(rsp.Response); }
//Button3 - Policy private void button3_Click(object sender, EventArgs e) { txtOutput.Text += "Creating Policy" + "\r\n"; var client = new AmazonIdentityManagementServiceClient(); string policyDoc = GenerateUserPolicyDocument(bucketName); var request = new CreatePolicyRequest { PolicyName = bucketName + "Policy", PolicyDocument = policyDoc }; try { var createPolicyResponse = client.CreatePolicy(request); txtOutput.Text += "Policy named " + createPolicyResponse.Policy.PolicyName + " Created." + "\r\n"; policyarn = createPolicyResponse.Policy.Arn; } catch (EntityAlreadyExistsException) { txtOutput.Text += "Policy " + bucketName + " already exits." + "\r\n"; } txtOutput.Text += "Attaching policy to User" + "\r\n"; var attachrequest = new AttachUserPolicyRequest { UserName = bucketName, PolicyArn = policyarn }; try { var createPolicyResponse = client.AttachUserPolicy(attachrequest); txtOutput.Text += "Policy applied" + "\r\n"; } catch (Exception) { txtOutput.Text += "Attach Failed" + "\r\n"; } txtOutput.ScrollToCaret(); }
public void CreatePolicyResourceNames3() { moq::Mock <OrgPolicy.OrgPolicyClient> mockGrpcClient = new moq::Mock <OrgPolicy.OrgPolicyClient>(moq::MockBehavior.Strict); CreatePolicyRequest request = new CreatePolicyRequest { ParentAsProjectName = gagr::ProjectName.FromProject("[PROJECT]"), Policy = new Policy(), }; Policy expectedResponse = new Policy { PolicyName = PolicyName.FromProjectPolicy("[PROJECT]", "[POLICY]"), Spec = new PolicySpec(), Alternate = new AlternatePolicySpec(), }; mockGrpcClient.Setup(x => x.CreatePolicy(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); OrgPolicyClient client = new OrgPolicyClientImpl(mockGrpcClient.Object, null); Policy response = client.CreatePolicy(request.ParentAsOrganizationName, request.Policy); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
protected override void ProcessRecord() { base.ProcessRecord(); CreatePolicyRequest request; try { request = new CreatePolicyRequest { CreatePolicyDetails = CreatePolicyDetails, OpcRetryToken = OpcRetryToken }; response = client.CreatePolicy(request).GetAwaiter().GetResult(); WriteOutput(response, response.Policy); FinishProcessing(response); } catch (Exception ex) { TerminatingErrorDuringExecution(ex); } }
/// <summary> /// Creates the policy. /// </summary> /// <param name="inputParameters">The input parameters.</param> /// <returns></returns> /// <exception cref="FaultException{ExceptionFaultContract}">new ExceptionFaultContract(CreatePolicy, not implemented, )</exception> /// <exception cref="ExceptionFaultContract">CreatePolicy;not implemented</exception> public CreatePolicyResponse CreatePolicy(CreatePolicyRequest inputParameters) { try { //to do AUTH IncomingWebRequestContext request = WebOperationContext.Current.IncomingRequest; WebHeaderCollection headers = request.Headers; //var url = HttpContext.Current.Request.Url.AbsoluteUri; Broker broker = new Broker() { ID = 1, Name = "Test" }; CreatePolicyResponse result = Wservice.CreatePolicy(inputParameters, broker); return(result); } catch (Exception ex) { //throw new FaultException("CreatePolicy error description"); throw new FaultException <ExceptionFaultContract>(new ExceptionFaultContract("CreatePolicy", "Error during creating the policy", ex.Message), ""); } }
public async override Task <ManagedPolicyDto> Handle(CreatePolicyCommand command, CancellationToken cancellationToken = default) { using var client = _awsClientFactory.Create <AmazonIdentityManagementServiceClient>(command.AssumeProfile); var request = new CreatePolicyRequest() { PolicyName = command.PolicyName, PolicyDocument = command.PolicyDocument }; ManagedPolicyDto result; try { result = _mapper.Map <ManagedPolicy, ManagedPolicyDto>((await client.CreatePolicyAsync(request, cancellationToken)).Policy); } catch (AmazonServiceException e) { throw new AwsFacadeException(e.Message, e); } return(result); }
public static void CreatePolicy() { var client = new AmazonIdentityManagementServiceClient(); // GenerateRolePolicyDocument() is a custom method. string policyDoc = GenerateRolePolicyDocument(); var request = new CreatePolicyRequest { PolicyName = "DemoEC2Permissions", PolicyDocument = policyDoc }; try { var createPolicyResponse = client.CreatePolicy(request); Console.WriteLine("Make a note, Policy named " + createPolicyResponse.Policy.PolicyName + " has Arn: : " + createPolicyResponse.Policy.Arn); } catch (EntityAlreadyExistsException) { Console.WriteLine ("Policy 'DemoEC2Permissions' already exits."); } }
private async Task CreatePolicy(string policyName) { var existingPolicy = await _client.GetPolicyAsync(policyName); if (existingPolicy == null) { var createPolicyRequest = new CreatePolicyRequest() { PolicyDocument = LoadPolicy(policyName), PolicyName = policyName }; await _client.CreatePolicyAsync(createPolicyRequest); } else { CreatePolicyVersionRequest createPolicyVersionRequest = new CreatePolicyVersionRequest() { PolicyDocument = LoadPolicy(policyName), PolicyName = policyName, SetAsDefault = true }; await _client.CreatePolicyVersionAsync(createPolicyVersionRequest); } }
public CreatePolicyResponse CreatePolicy(CreatePolicyRequest parameter) { var product = this.virtuClient.GetProducts().Single(A => A.Name, "Верное решение"); var risks = this.virtuClient.GetRisks(product.ID); var insuranceSums = this.virtuClient.GetInsuranceSums(product.ID); var insurancePeriods = this.virtuClient.GetInsurancePeriods(product.ID); var currencies = this.virtuClient.GetCurrencies(product.ID); var getBuyoutTariffs = this.virtuClient.GetBuyouts(product.ID); var strategyDetails = this.virtuClient.StrategiesSearch(new StrategiesSearchInput() { IsActive = true, ReadRedefined = true, }); var documentTypes = this.virtuClient.GetDocumentTypes(product.ID); var insuredDocumentTypes = this.virtuClient.InsuredDocumentTypes(product.ID); var calculate = this.virtuClient.Calculate(new CalculateInput() { ProductID = product.ID, Premium = parameter.amount.ToString(), }); var status = this.virtuClient.GetStatuses(product.ID).Single(A => A.Name, "Проект"); DateTime today = DateTime.Today; DateTime effectiveDate = today; int periodInYears = int.Parse(parameter.policyTerm); var insured = parameter.insurantIsInsured ? parameter.insurant : parameter.insured; var strategyDetail = strategyDetails.Single(A => A.ID, parameter.strategyId); var strategyCurrency = currencies.Single(A => A.ID, strategyDetail.OptionCurrency); var currency = getCurrency(parameter.currency, currencies); var insurancePeriod = insurancePeriods.Single(A => A.ID, strategyDetail.OptionPeriod); var insuranceSum = insuranceSums.FirstOrDefault(A => decimal.Parse(A.Name) == parameter.amount); var documentType = documentTypes.Single(A => A.Name, "Паспорт гражданина Российской Федерации"); var policy = this.virtuClient.Save(new Policy() { InsurerType = "FL", ProductID = parameter.productId, DocumentDate = getDate(today), EffectiveDate = getDate(effectiveDate), ExpirationDate = getDate(effectiveDate.AddYears(periodInYears)), InsuredName = getFullName(insured), AmountCurrencyName = "", AmountCurrencyCode = "", SumInsuredCurrencyCode = "", //CreatorUser = null, //Хз //CreatorName = null, //хз //InsurerRepresentId = null, //Хз //SallerDivisionID = null, //Хз //SallerDivision = "\"Электронный\"", //InsurerRepresentName = null, //Хз InvestmentStrategy = strategyDetail.InvestmentStrategy, InvestmentStrategyRaw = strategyDetail.InvestmentStrategyRaw, InvestmentStrategyData = new Investmentstrategydata() { BaseIndex = strategyDetail.BaseIndex, BaseIndexOnStartDate = strategyDetail.BaseIndexOnStartDate, Coefficient = strategyDetail.Coefficient, CurrencyRate = strategyDetail.CurrencyRate, ExpirationDate = strategyDetail.ExpirationDate, FIPart = strategyDetail.FIPart, GFPart = strategyDetail.GFPart, ID = strategyDetail.ID, InsuranceCurrencyRate = strategyDetail.InsuranceCurrencyRate, InvestmentStartDate = strategyDetail.InvestmentStartDate, InvestmentStrategy = strategyDetail.InvestmentStrategy, InvestmentStrategyRaw = strategyDetail.InvestmentStrategyRaw, IsActive = strategyDetail.IsActive, OptionKind = strategyDetail.OptionKind, OptionID = strategyDetail.OptionID, OptionPeriod = strategyDetail.OptionPeriod, OptionCurrency = strategyDetail.OptionCurrency, OptionCurrencyRaw = strategyDetail.OptionCurrencyRaw, OptionPrice = strategyDetail.OptionPrice, OptionPriceRUR = strategyDetail.OptionPriceRUR, OptionType = strategyDetail.OptionType, OptionTypeRaw = strategyDetail.OptionTypeRaw, OptionValue = strategyDetail.OptionValue, OptionValueRUR = strategyDetail.OptionValueRUR, Profitability = strategyDetail.Profitability, SellingEndDate = strategyDetail.SellingEndDate, SellingStartDate = strategyDetail.SellingStartDate, VersionCode = strategyDetail.VersionCode, RateOfReturn = strategyDetail.RateOfReturn, isNotBought = strategyDetail.isNotBought, FIPartRUR = strategyDetail.FIPartRUR, GFPartRUR = strategyDetail.GFPartRUR, }, StrategyCurrency = strategyCurrency.ID, StrategyCurrencyRaw = strategyCurrency.Name, InsurancePeriod = insurancePeriod.ID, InsurancePeriodRaw = insurancePeriod.Name, ParticipationCoefficient = strategyDetail.Coefficient, InsuranceSum = insuranceSum != null ? insuranceSum?.ID : "", ManualInsuranceSum = insuranceSum == null ? parameter.amount.ToString() : "", ContributionsFrequency = "1", Premium = parameter.amount, Currency = currency.ID, LastName = parameter.insurant.lastName, FirstName = parameter.insurant.firstName, Patronymic = parameter.insurant.patronymicName, BirthDate = getDate(parameter.insurant.dateOfBirth), BirthPlace = parameter.insurant.placeOfBirth, Sex = getSex(parameter.insurant.sex), INN = parameter.insurant.inn, Cityzenship = "1", InsuranceSumType = insuranceSum == null ? "2" : "1", OtherCityzenship = "", Resident = "1", StayingDocumentType = "", StayingDocumentTypeRaw = "", StayingDocumentSerial = "", StayingDocumentNumber = "", StayingDocumentDate = null, StayingDocumentOrganisation = "", StayingDocumentEndDate = null, MigrationCardSerial = "", MigrationCardNumber = "", MigrationCardDate = null, StartStayingDate = null, EndStayingDate = null, Phone = "не указан", Email = "не указан", AddressInputType = "2", Address = new Address() { KLADRCode = "000000000000000", }, AddressText = getFullAddress(parameter.insurant.addresses.First(A => A.type, addressType.registration)), AgreeForSpam = false, DocumentType = documentType.ID, DocumentTypeRaw = documentType.Name, PassportSerial = parameter.insurant.documentSerie, PassportNumber = parameter.insurant.documentNumber, PassportDate = getDate(parameter.insurant.documentIssueDate), PassportOrganisation = parameter.insurant.documentOrganisation, PassportCode = parameter.insurant.documentOrganisationCode, ActInOwnInterests = "1", ActInPublicFaceInterest = "5", IsCreatorOfPublicOrganisation = "2", IsResidentOfEconomicZone = "2", IsPublicFace = "2", InsuredIsInsurer = parameter.insurantIsInsured, // insured InsuredLastName = insured.lastName, InsuredFirstName = insured.firstName, InsuredPatronymic = insured.patronymicName, InsuredBirthDate = getDate(insured.dateOfBirth), InsuredBirthPlace = insured.placeOfBirth, InsuredSex = getSex(insured.sex), InsuredINN = insured.inn, InsuredCityzenship = "1", InsuredOtherCityzenship = "", InsuredResident = "1", InsuredStayingDocumentType = "", InsuredStayingDocumentTypeRaw = "", InsuredStayingDocumentSerial = "", InsuredStayingDocumentNumber = "", InsuredStayingDocumentDate = null, InsuredStayingDocumentOrganisation = "", InsuredStayingDocumentEndDate = null, InsuredMigrationCardSerial = "", InsuredMigrationCardNumber = "", InsuredMigrationCardDate = null, InsuredStartStayingDate = null, InsuredEndStayingDate = null, InsuredPhone = "не указан", InsuredEmail = "не указан", InsuredAddressInputType = "2", InsuredAddress = new Insuredaddress() { KLADRCode = "000000000000000", }, InsuredAddressText = getFullAddress(insured.addresses.First(A => A.type, addressType.registration)), InsuredAgreeForSpam = false, InsuredDocumentType = documentType.ID, InsuredDocumentTypeRaw = documentType.Name, InsuredPassportSerial = insured.documentSerie, InsuredPassportNumber = insured.documentNumber, InsuredPassportDate = getDate(insured.documentIssueDate), InsuredPassportOrganisation = insured.documentOrganisation, InsuredPassportCode = insured.documentOrganisationCode, InsuredActInOwnInterests = "1", InsuredActInPublicFaceInterest = "5", InsuredIsCreatorOfPublicOrganisation = "2", InsuredIsResidentOfEconomicZone = "2", InsuredIsPublicFace = "2", IsSuccessor = parameter.beneficiaries?.Any() == true ? "2" : "1", Beneficiaries = parameter.beneficiaries?.Select(beneficiary => new Beneficiary() { LastName = beneficiary.lastName, FirstName = beneficiary.firstName, Patronymic = beneficiary.patronymicName, BirthDate = getDate(beneficiary.dateOfBirth), BirthPlace = beneficiary.placeOfBirth, DocumentType = documentType.ID, DocumentTypeRaw = documentType.Name, DocumentSerial = beneficiary.documentSerie, DocumentNumber = beneficiary.documentNumber, DocumentDate = getDate(beneficiary.documentIssueDate), DocumentOrganisation = beneficiary.documentOrganisation, DocumentOrganisationCode = beneficiary.documentOrganisationCode, Part = beneficiary.percent, })?.ToArray() ?? new Beneficiary[0], PaymentType = "", PaymentDocumentDate = getDate(today), SellerComment = "", ReceiptDate = null, ReceiptSum = 0, SalesChannel = "400", Bayout = getBuyoutTariffs.Select(A => new Bayout() { InsPeriod = A.InsPeriod.value, InsSum = A.InsSum.value, }).ToArray(), UserTown = "Москва", KvPartner1Percent = calculate.KvPartner1Percent, KvPartner1Rub = calculate.KvPartner1Rub, KvPartner2Percent = calculate.KvPartner2Percent, KvPartner2Rub = calculate.KvPartner2Rub, Partner1Name = this.virtuClient.GetProfileElements(ProfileType.Partner1Name, product.ID), Partner2Name = this.virtuClient.GetProfileElements(ProfileType.Partner2Name, product.ID), CheafName = this.virtuClient.GetProfileElements(ProfileType.CheafName, product.ID), SellerDivisionHierarchyInfo = "", ScanWasSent = false, SalesPartner = "", SalesPartner2 = "", IsForeignTaxpayer = "2", StatusID = status.ID, DocumentStatusID = status.ID, }); return(new CreatePolicyResponse() { policyId = policy.ID, policyNumber = policy.SERIAL + " " + policy.NUMBER, }); }
public IActionResult CreatePolicy([FromBody] CreatePolicyRequest request) { var result = policyService.CreatePolicy(request); return(Ok(result)); }
public Task <CreatePolicyResponse> CreatePolicyAsync(CreatePolicyRequest request, CancellationToken cancellationToken = new CancellationToken()) { throw new System.NotImplementedException(); }