public async Task CommitAsync2()
        {
            Mock <Datastore.DatastoreClient> mockGrpcClient = new Mock <Datastore.DatastoreClient>(MockBehavior.Strict);
            CommitRequest expectedRequest = new CommitRequest
            {
                ProjectId = "projectId-1969970175",
                Mode      = CommitRequest.Types.Mode.Unspecified,
                Mutations = { },
            };
            CommitResponse expectedResponse = new CommitResponse
            {
                IndexUpdates = 1425228195,
            };

            mockGrpcClient.Setup(x => x.CommitAsync(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <CommitResponse>(Task.FromResult(expectedResponse), null, null, null, null));
            DatastoreClient client    = new DatastoreClientImpl(mockGrpcClient.Object, null);
            string          projectId = "projectId-1969970175";

            CommitRequest.Types.Mode mode      = CommitRequest.Types.Mode.Unspecified;
            IEnumerable <Mutation>   mutations = new List <Mutation>();
            CommitResponse           response  = await client.CommitAsync(projectId, mode, mutations);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public void Commit()
        {
            Mock <Datastore.DatastoreClient> mockGrpcClient = new Mock <Datastore.DatastoreClient>(MockBehavior.Strict);
            CommitRequest expectedRequest = new CommitRequest
            {
                ProjectId   = "projectId-1969970175",
                Mode        = CommitRequest.Types.Mode.Unspecified,
                Transaction = ByteString.CopyFromUtf8("-34"),
                Mutations   = { },
            };
            CommitResponse expectedResponse = new CommitResponse
            {
                IndexUpdates = 1425228195,
            };

            mockGrpcClient.Setup(x => x.Commit(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            DatastoreClient client    = new DatastoreClientImpl(mockGrpcClient.Object, null);
            string          projectId = "projectId-1969970175";

            CommitRequest.Types.Mode mode      = CommitRequest.Types.Mode.Unspecified;
            ByteString             transaction = ByteString.CopyFromUtf8("-34");
            IEnumerable <Mutation> mutations   = new List <Mutation>();
            CommitResponse         response    = client.Commit(projectId, mode, transaction, mutations);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
 /// <summary>
 /// Commit a transaction, optionally creating, deleting or modifying some
 /// entities.
 /// </summary>
 /// <param name="project_id">Project ID against which to make the request.</param>
 /// <param name="mode">The type of commit to perform. Defaults to `TRANSACTIONAL`.</param>
 /// <param name="mutations">
 /// The mutations to perform.
 ///
 /// When mode is `TRANSACTIONAL`, mutations affecting a single entity are
 /// applied in order. The following sequences of mutations affecting a single
 /// entity are not permitted in a single `Commit` request:
 /// - `insert` followed by `insert`
 /// - `update` followed by `insert`
 /// - `upsert` followed by `insert`
 /// - `delete` followed by `update`
 ///
 /// When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single
 /// entity.
 /// </param>
 /// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
 /// <returns>The RPC response.</returns>
 public virtual CommitResponse Commit(
     string projectId,
     CommitRequest.Types.Mode mode,
     IEnumerable <Mutation> mutations,
     CallSettings callSettings = null)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 /// Commit a transaction, optionally creating, deleting or modifying some
 /// entities.
 /// </summary>
 /// <param name="project_id">Project ID against which to make the request.</param>
 /// <param name="mode">The type of commit to perform. Defaults to `TRANSACTIONAL`.</param>
 /// <param name="mutations">
 /// The mutations to perform.
 ///
 /// When mode is `TRANSACTIONAL`, mutations affecting a single entity are
 /// applied in order. The following sequences of mutations affecting a single
 /// entity are not permitted in a single `Commit` request:
 /// - `insert` followed by `insert`
 /// - `update` followed by `insert`
 /// - `upsert` followed by `insert`
 /// - `delete` followed by `update`
 ///
 /// When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single
 /// entity.
 /// </param>
 /// <param name="cancellationToken">If not null, a <see cref="CancellationToken"/> to use for this RPC.</param>
 /// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
 /// <returns>A Task containing the RPC response.</returns>
 public virtual Task <CommitResponse> CommitAsync(
     string projectId,
     CommitRequest.Types.Mode mode,
     IEnumerable <Mutation> mutations,
     CancellationToken?cancellationToken = null,
     CallSettings callSettings           = null)
 {
     throw new NotImplementedException();
 }
Esempio n. 5
0
        public void Commit2()
        {
            // Snippet: Commit(string,CommitRequest.Types.Mode,IEnumerable<Mutation>,CallSettings)
            // Create client
            DatastoreClient datastoreClient = DatastoreClient.Create();
            // Initialize request argument(s)
            string projectId = "";

            CommitRequest.Types.Mode mode      = CommitRequest.Types.Mode.Unspecified;
            IEnumerable <Mutation>   mutations = new List <Mutation>();
            // Make the request
            CommitResponse response = datastoreClient.Commit(projectId, mode, mutations);
            // End snippet
        }
Esempio n. 6
0
        /// <summary>Snippet for Commit</summary>
        public void Commit1()
        {
            // Snippet: Commit(string, CommitRequest.Types.Mode, ByteString, IEnumerable<Mutation>, CallSettings)
            // Create client
            DatastoreClient datastoreClient = DatastoreClient.Create();
            // Initialize request argument(s)
            string projectId = "";

            CommitRequest.Types.Mode mode      = CommitRequest.Types.Mode.Unspecified;
            ByteString             transaction = ByteString.Empty;
            IEnumerable <Mutation> mutations   = new Mutation[] { new Mutation(), };
            // Make the request
            CommitResponse response = datastoreClient.Commit(projectId, mode, transaction, mutations);
            // End snippet
        }
        /// <summary>Snippet for Commit</summary>
        public void Commit1()
        {
            // Snippet: Commit(string,CommitRequest.Types.Mode,ByteString,IEnumerable<Mutation>,CallSettings)
            // Create client
            DatastoreClient datastoreClient = DatastoreClient.Create();
            // Initialize request argument(s)
            string projectId = "";

            CommitRequest.Types.Mode mode      = CommitRequest.Types.Mode.Unspecified;
            ByteString             transaction = Google.Protobuf.ByteString.CopyFromUtf8("");
            IEnumerable <Mutation> mutations   = new List <Mutation>();
            // Make the request
            CommitResponse response = datastoreClient.Commit(projectId, mode, transaction, mutations);
            // End snippet
        }
        public async Task CommitAsync2()
        {
            // Snippet: CommitAsync(string,CommitRequest.Types.Mode,IEnumerable<Mutation>,CallSettings)
            // Additional: CommitAsync(string,CommitRequest.Types.Mode,IEnumerable<Mutation>,CancellationToken)
            // Create client
            DatastoreClient datastoreClient = DatastoreClient.Create();
            // Initialize request argument(s)
            string projectId = "";

            CommitRequest.Types.Mode mode      = CommitRequest.Types.Mode.Unspecified;
            IEnumerable <Mutation>   mutations = new List <Mutation>();
            // Make the request
            CommitResponse response = await datastoreClient.CommitAsync(projectId, mode, mutations);

            // End snippet
        }
        /// <summary>
        /// Commit a transaction, optionally creating, deleting or modifying some
        /// entities.
        /// </summary>
        /// <param name="project_id">Project ID against which to make the request.</param>
        /// <param name="mode">The type of commit to perform. Defaults to `TRANSACTIONAL`.</param>
        /// <param name="mutations">
        /// The mutations to perform.
        ///
        /// When mode is `TRANSACTIONAL`, mutations affecting a single entity are
        /// applied in order. The following sequences of mutations affecting a single
        /// entity are not permitted in a single `Commit` request:
        /// - `insert` followed by `insert`
        /// - `update` followed by `insert`
        /// - `upsert` followed by `insert`
        /// - `delete` followed by `update`
        ///
        /// When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single
        /// entity.
        /// </param>
        /// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
        /// <returns>The RPC response.</returns>
        public override CommitResponse Commit(
            string projectId,
            CommitRequest.Types.Mode mode,
            IEnumerable <Mutation> mutations,
            CallSettings callSettings = null)
        {
            CommitRequest request = new CommitRequest
            {
                ProjectId = projectId,
                Mode      = mode,
                Mutations = { mutations },
            };

            return(GrpcClient.Commit(
                       request,
                       _clientHelper.BuildCallOptions(null, callSettings)));
        }
Esempio n. 10
0
        /// <summary>Snippet for CommitAsync</summary>
        public async Task Commit1Async()
        {
            // Snippet: CommitAsync(string, CommitRequest.Types.Mode, ByteString, IEnumerable<Mutation>, CallSettings)
            // Additional: CommitAsync(string, CommitRequest.Types.Mode, ByteString, IEnumerable<Mutation>, CancellationToken)
            // Create client
            DatastoreClient datastoreClient = await DatastoreClient.CreateAsync();

            // Initialize request argument(s)
            string projectId = "";

            CommitRequest.Types.Mode mode      = CommitRequest.Types.Mode.Unspecified;
            ByteString             transaction = ByteString.Empty;
            IEnumerable <Mutation> mutations   = new Mutation[] { new Mutation(), };
            // Make the request
            CommitResponse response = await datastoreClient.CommitAsync(projectId, mode, transaction, mutations);

            // End snippet
        }
        /// <summary>
        /// Commit a transaction, optionally creating, deleting or modifying some
        /// entities.
        /// </summary>
        /// <param name="project_id">Project ID against which to make the request.</param>
        /// <param name="mode">The type of commit to perform. Defaults to `TRANSACTIONAL`.</param>
        /// <param name="mutations">
        /// The mutations to perform.
        ///
        /// When mode is `TRANSACTIONAL`, mutations affecting a single entity are
        /// applied in order. The following sequences of mutations affecting a single
        /// entity are not permitted in a single `Commit` request:
        /// - `insert` followed by `insert`
        /// - `update` followed by `insert`
        /// - `upsert` followed by `insert`
        /// - `delete` followed by `update`
        ///
        /// When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single
        /// entity.
        /// </param>
        /// <param name="cancellationToken">If not null, a <see cref="CancellationToken"/> to use for this RPC.</param>
        /// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
        /// <returns>A Task containing the RPC response.</returns>
        public override Task <CommitResponse> CommitAsync(
            string projectId,
            CommitRequest.Types.Mode mode,
            IEnumerable <Mutation> mutations,
            CancellationToken?cancellationToken = null,
            CallSettings callSettings           = null)
        {
            CommitRequest request = new CommitRequest
            {
                ProjectId = projectId,
                Mode      = mode,
                Mutations = { mutations },
            };

            return(GrpcClient.CommitAsync(
                       request,
                       _clientHelper.BuildCallOptions(cancellationToken, callSettings)
                       ).ResponseAsync);
        }