示例#1
0
        public void CreateFeed()
        {
            moq::Mock <AssetService.AssetServiceClient> mockGrpcClient = new moq::Mock <AssetService.AssetServiceClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            CreateFeedRequest request = new CreateFeedRequest
            {
                Parent = "parent7858e4d0",
            };
            Feed expectedResponse = new Feed
            {
                FeedName   = FeedName.FromProjectFeed("[PROJECT]", "[FEED]"),
                AssetNames =
                {
                    "asset_namese42cd316",
                },
                AssetTypes =
                {
                    "asset_types44c0f429",
                },
                ContentType      = ContentType.IamPolicy,
                FeedOutputConfig = new FeedOutputConfig(),
                Condition        = new gt::Expr(),
            };

            mockGrpcClient.Setup(x => x.CreateFeed(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            AssetServiceClient client = new AssetServiceClientImpl(mockGrpcClient.Object, null);
            Feed response             = client.CreateFeed(request.Parent);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
示例#2
0
        public async Task <CreateFeedResponse> CreateFeedAsync(CreateFeedRequest request)
        {
            AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new AlibabaCloud.TeaUtil.Models.RuntimeOptions();
            CreateFeedHeaders headers = new CreateFeedHeaders();

            return(await CreateFeedWithOptionsAsync(request, headers, runtime));
        }
示例#3
0
        public async stt::Task CreateFeedAsync()
        {
            moq::Mock <AssetService.AssetServiceClient> mockGrpcClient = new moq::Mock <AssetService.AssetServiceClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            CreateFeedRequest request = new CreateFeedRequest
            {
                Parent = "parent7858e4d0",
            };
            Feed expectedResponse = new Feed
            {
                FeedName   = FeedName.FromProjectFeed("[PROJECT]", "[FEED]"),
                AssetNames =
                {
                    "asset_namese42cd316",
                },
                AssetTypes =
                {
                    "asset_types44c0f429",
                },
                ContentType      = ContentType.IamPolicy,
                FeedOutputConfig = new FeedOutputConfig(),
                Condition        = new gt::Expr(),
            };

            mockGrpcClient.Setup(x => x.CreateFeedAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Feed>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            AssetServiceClient client = new AssetServiceClientImpl(mockGrpcClient.Object, null);
            Feed responseCallSettings = await client.CreateFeedAsync(request.Parent, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            Feed responseCancellationToken = await client.CreateFeedAsync(request.Parent, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
示例#4
0
        public async Task CreateFeedAsync2()
        {
            Mock <AssetService.AssetServiceClient> mockGrpcClient = new Mock <AssetService.AssetServiceClient>(MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient())
            .Returns(new Mock <Operations.OperationsClient>().Object);
            CreateFeedRequest request = new CreateFeedRequest
            {
                Parent = "parent-995424086",
                FeedId = "feedId-976011428",
                Feed   = new Feed(),
            };
            Feed expectedResponse = new Feed
            {
                Name = "name3373707",
            };

            mockGrpcClient.Setup(x => x.CreateFeedAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <Feed>(Task.FromResult(expectedResponse), null, null, null, null));
            AssetServiceClient client = new AssetServiceClientImpl(mockGrpcClient.Object, null);
            Feed response             = await client.CreateFeedAsync(request);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
示例#5
0
        public CreateFeedResponse CreateFeed(CreateFeedRequest request)
        {
            AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new AlibabaCloud.TeaUtil.Models.RuntimeOptions();
            CreateFeedHeaders headers = new CreateFeedHeaders();

            return(CreateFeedWithOptions(request, headers, runtime));
        }
示例#6
0
        public async Task <ActionResult <FeedViewModel> > CreateFeedAsync([FromQuery] CreateFeedRequest request)
        {
            request.Photos = Request.Form.Files;
            var createdEntity = await _feedService.AddAsync(request);

            return(Created(string.Format(CreateEntityPattern, RoutePattern, createdEntity.Id), createdEntity));
        }
示例#7
0
 /// <summary>Snippet for CreateFeed</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void CreateFeedRequestObject()
 {
     // Create client
     AssetServiceClient assetServiceClient = AssetServiceClient.Create();
     // Initialize request argument(s)
     CreateFeedRequest request = new CreateFeedRequest
     {
         Parent = "",
         FeedId = "",
         Feed   = new Feed(),
     };
     // Make the request
     Feed response = assetServiceClient.CreateFeed(request);
 }
示例#8
0
        public ActionResult <Guid> Create([FromBody] CreateFeedRequest createRequest)
        {
            Feed feed = new Feed
            {
                Id   = Guid.NewGuid(),
                Name = createRequest.Name,
                Tags = createRequest.Tags,
            };

            if (createRequest != null && _feedRepository.Create(feed))
            {
                return(Ok(feed.Id));
            }
            return(BadRequest());
        }
        /// <summary>Snippet for CreateFeedAsync</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public async Task CreateFeedRequestObjectAsync()
        {
            // Create client
            AssetServiceClient assetServiceClient = await AssetServiceClient.CreateAsync();

            // Initialize request argument(s)
            CreateFeedRequest request = new CreateFeedRequest
            {
                Parent = "",
                FeedId = "",
                Feed   = new Feed(),
            };
            // Make the request
            Feed response = await assetServiceClient.CreateFeedAsync(request);
        }
示例#10
0
        public async Task <IActionResult> Create([FromBody] CreateFeedRequest request)
        {
            try
            {
                await _feedsService.CreateFeed(request);
            }
            catch (MoreThanOneFeedForUserException)
            {
                return(BadRequest("Allowed only one feed for one user, this user already have one"));

                throw;
            }

            return(Ok());
        }
示例#11
0
        public IActionResult Put(Guid id, [FromBody] CreateFeedRequest request)
        {
            var collection = _collections.Find(Builders <CollectionDto> .Filter.Eq(c => c.Id, id)).SingleOrDefault();

            if (collection == null)
            {
                return(NotFound("Collection is not exist"));
            }

            var feed = new FeedDto {
                Id = Guid.NewGuid(), CollectionId = id, Summary = request.Summary, Text = request.Text
            };

            _feeds.InsertOne(feed);
            _cache.Remove(id);
            return(Ok(feed));
        }
 /// <summary>Snippet for CreateFeedAsync</summary>
 public async Task CreateFeedRequestObjectAsync()
 {
     // Snippet: CreateFeedAsync(CreateFeedRequest, CallSettings)
     // Additional: CreateFeedAsync(CreateFeedRequest, CancellationToken)
     // Create client
     AssetServiceClient assetServiceClient = await AssetServiceClient.CreateAsync();
     // Initialize request argument(s)
     CreateFeedRequest request = new CreateFeedRequest
     {
         Parent = "",
         FeedId = "",
         Feed = new Feed(),
     };
     // Make the request
     Feed response = await assetServiceClient.CreateFeedAsync(request);
     // End snippet
 }
示例#13
0
        public async Task CreateFeed(CreateFeedRequest request)
        {
            var feedToSave = _mapper.Map <Feed>(request);

            _repository.Create(feedToSave);

            try
            {
                await _repository.SaveChangesAsync();
            }
            catch (DbUpdateException e)
            {
                if (e.InnerException.Message.Contains("23505"))
                {
                    throw new MoreThanOneFeedForUserException();
                }

                throw;
            }
        }
        public void Simple()
        {
            var newFeed = new CreateFeedRequest
            {
                FeedUrl   = "http://example.com/atom.",
                BroadCast = true,
                Template  = new Template
                {
                    FeedPayload = new FeedPayload
                    {
                        Alert = "MyAlert",
                        Badge = 10,
                        Sound = "MySound"
                    },
                    Tags = new List <string> {
                        "tag1", "tag2"
                    }
                },
            };
            var text     = newFeed.Serialize().FormatAsJson();
            var expected = @"
{
  'template': {
    'aps': {
      'alert': 'MyAlert',
      'badge': 10,
      'sound': 'MySound'
    },
    'tags': [
      'tag1',
      'tag2'
    ]
  },
  'feed_url': 'http://example.com/atom.',
  'broadcast': true
}".Replace("\r\n", "\n");

            Assert.AreEqual(expected, text);
        }
示例#15
0
        public async Task <CreateFeedResponse> CreateFeedWithOptionsAsync(CreateFeedRequest request, CreateFeedHeaders headers, AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime)
        {
            AlibabaCloud.TeaUtil.Common.ValidateModel(request);
            Dictionary <string, object> body = new Dictionary <string, object>()
            {
            };

            if (!AlibabaCloud.TeaUtil.Common.IsUnset(request.CourseInfo.ToMap()))
            {
                body["courseInfo"] = request.CourseInfo;
            }
            if (!AlibabaCloud.TeaUtil.Common.IsUnset(request.CreateUserId))
            {
                body["createUserId"] = request.CreateUserId;
            }
            if (!AlibabaCloud.TeaUtil.Common.IsUnset(request.FeedInfo.ToMap()))
            {
                body["feedInfo"] = request.FeedInfo;
            }
            Dictionary <string, string> realHeaders = new Dictionary <string, string>()
            {
            };

            if (!AlibabaCloud.TeaUtil.Common.IsUnset(headers.CommonHeaders))
            {
                realHeaders = headers.CommonHeaders;
            }
            if (!AlibabaCloud.TeaUtil.Common.IsUnset(headers.XAcsDingtalkAccessToken))
            {
                realHeaders["x-acs-dingtalk-access-token"] = AlibabaCloud.TeaUtil.Common.ToJSONString(headers.XAcsDingtalkAccessToken);
            }
            AlibabaCloud.OpenApiClient.Models.OpenApiRequest req = new AlibabaCloud.OpenApiClient.Models.OpenApiRequest
            {
                Headers = realHeaders,
                Body    = AlibabaCloud.OpenApiUtil.Client.ParseToMap(body),
            };
            return(TeaModel.ToObject <CreateFeedResponse>(await DoROARequestAsync("CreateFeed", "content_1.0", "HTTP", "POST", "AK", "/v1.0/content/feeds", "json", req, runtime)));
        }
    public void Simple()
    {
        var service = new CreateFeedService
        {
            RequestBuilder = ServerRequestBuilder.Instance
        };
        var notification = new CreateFeedRequest
        {
            FeedUrl  = "http://example.com/atom.xml",
            Template = new Template
            {
                FeedPayload = new FeedPayload
                {
                    Badge = 1,
                    Sound = "cat.caf",
                    Alert = "New item from some place! {{ title }}"
                }
            },
            BroadCast = true
        };

        service.Execute(notification, Callback, ExceptionHandler.Handle);
    }
示例#17
0
        public void CreateFeed()
        {
            Mock <AssetService.AssetServiceClient> mockGrpcClient = new Mock <AssetService.AssetServiceClient>(MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient())
            .Returns(new Mock <Operations.OperationsClient>().Object);
            CreateFeedRequest expectedRequest = new CreateFeedRequest
            {
                Parent = "parent-995424086",
            };
            Feed expectedResponse = new Feed
            {
                Name = "name3373707",
            };

            mockGrpcClient.Setup(x => x.CreateFeed(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            AssetServiceClient client = new AssetServiceClientImpl(mockGrpcClient.Object, null);
            string             parent = "parent-995424086";
            Feed response             = client.CreateFeed(parent);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
示例#18
0
        /// <summary>
        /// Creates an RSS feed with the given parameters. The created feed object is returned.
        /// </summary>
        public async Task <Feed> CreateFeed(CreateFeedRequest request)
        {
            var response = await _apiClient.ExecutePostWithResponseAsync <CreateFeedResponse>($"rss/create", request);

            return(response.Feed);
        }