Пример #1
0
        /// <summary>Snippet for CreateFunction</summary>
        public void CreateFunctionResourceNames()
        {
            // Snippet: CreateFunction(LocationName, CloudFunction, CallSettings)
            // Create client
            CloudFunctionsServiceClient cloudFunctionsServiceClient = CloudFunctionsServiceClient.Create();
            // Initialize request argument(s)
            LocationName  location = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]");
            CloudFunction function = new CloudFunction();
            // Make the request
            Operation <CloudFunction, OperationMetadataV1> response = cloudFunctionsServiceClient.CreateFunction(location, function);

            // Poll until the returned long-running operation is complete
            Operation <CloudFunction, OperationMetadataV1> completedResponse = response.PollUntilCompleted();
            // Retrieve the operation result
            CloudFunction result = completedResponse.Result;

            // Or get the name of the operation
            string operationName = response.Name;
            // This name can be stored, then the long-running operation retrieved later by name
            Operation <CloudFunction, OperationMetadataV1> retrievedResponse = cloudFunctionsServiceClient.PollOnceCreateFunction(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                CloudFunction retrievedResult = retrievedResponse.Result;
            }
            // End snippet
        }
Пример #2
0
        /// <summary>Snippet for UpdateFunctionAsync</summary>
        public async Task UpdateFunctionAsync()
        {
            // Snippet: UpdateFunctionAsync(CloudFunction, CallSettings)
            // Additional: UpdateFunctionAsync(CloudFunction, CancellationToken)
            // Create client
            CloudFunctionsServiceClient cloudFunctionsServiceClient = await CloudFunctionsServiceClient.CreateAsync();

            // Initialize request argument(s)
            CloudFunction function = new CloudFunction();
            // Make the request
            Operation <CloudFunction, OperationMetadataV1> response = await cloudFunctionsServiceClient.UpdateFunctionAsync(function);

            // Poll until the returned long-running operation is complete
            Operation <CloudFunction, OperationMetadataV1> completedResponse = await response.PollUntilCompletedAsync();

            // Retrieve the operation result
            CloudFunction result = completedResponse.Result;

            // Or get the name of the operation
            string operationName = response.Name;
            // This name can be stored, then the long-running operation retrieved later by name
            Operation <CloudFunction, OperationMetadataV1> retrievedResponse = await cloudFunctionsServiceClient.PollOnceUpdateFunctionAsync(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                CloudFunction retrievedResult = retrievedResponse.Result;
            }
            // End snippet
        }
Пример #3
0
        /// <summary>Snippet for CreateFunctionAsync</summary>
        public async Task CreateFunctionRequestObjectAsync()
        {
            // Snippet: CreateFunctionAsync(CreateFunctionRequest, CallSettings)
            // Additional: CreateFunctionAsync(CreateFunctionRequest, CancellationToken)
            // Create client
            CloudFunctionsServiceClient cloudFunctionsServiceClient = await CloudFunctionsServiceClient.CreateAsync();

            // Initialize request argument(s)
            CreateFunctionRequest request = new CreateFunctionRequest
            {
                LocationAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
                Function = new CloudFunction(),
            };
            // Make the request
            Operation <CloudFunction, OperationMetadataV1> response = await cloudFunctionsServiceClient.CreateFunctionAsync(request);

            // Poll until the returned long-running operation is complete
            Operation <CloudFunction, OperationMetadataV1> completedResponse = await response.PollUntilCompletedAsync();

            // Retrieve the operation result
            CloudFunction result = completedResponse.Result;

            // Or get the name of the operation
            string operationName = response.Name;
            // This name can be stored, then the long-running operation retrieved later by name
            Operation <CloudFunction, OperationMetadataV1> retrievedResponse = await cloudFunctionsServiceClient.PollOnceCreateFunctionAsync(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                CloudFunction retrievedResult = retrievedResponse.Result;
            }
            // End snippet
        }
Пример #4
0
        /// <summary>Snippet for UpdateFunction</summary>
        public void UpdateFunctionRequestObject()
        {
            // Snippet: UpdateFunction(UpdateFunctionRequest, CallSettings)
            // Create client
            CloudFunctionsServiceClient cloudFunctionsServiceClient = CloudFunctionsServiceClient.Create();
            // Initialize request argument(s)
            UpdateFunctionRequest request = new UpdateFunctionRequest
            {
                Function   = new CloudFunction(),
                UpdateMask = new FieldMask(),
            };
            // Make the request
            Operation <CloudFunction, OperationMetadataV1> response = cloudFunctionsServiceClient.UpdateFunction(request);

            // Poll until the returned long-running operation is complete
            Operation <CloudFunction, OperationMetadataV1> completedResponse = response.PollUntilCompleted();
            // Retrieve the operation result
            CloudFunction result = completedResponse.Result;

            // Or get the name of the operation
            string operationName = response.Name;
            // This name can be stored, then the long-running operation retrieved later by name
            Operation <CloudFunction, OperationMetadataV1> retrievedResponse = cloudFunctionsServiceClient.PollOnceUpdateFunction(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                CloudFunction retrievedResult = retrievedResponse.Result;
            }
            // End snippet
        }
Пример #5
0
        public async stt::Task GetFunctionRequestObjectAsync()
        {
            moq::Mock <CloudFunctionsService.CloudFunctionsServiceClient> mockGrpcClient = new moq::Mock <CloudFunctionsService.CloudFunctionsServiceClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetFunctionRequest request = new GetFunctionRequest
            {
                CloudFunctionName = CloudFunctionName.FromProjectLocationFunction("[PROJECT]", "[LOCATION]", "[FUNCTION]"),
            };
            CloudFunction expectedResponse = new CloudFunction
            {
                CloudFunctionName   = CloudFunctionName.FromProjectLocationFunction("[PROJECT]", "[LOCATION]", "[FUNCTION]"),
                Description         = "description2cf9da67",
                SourceArchiveUrl    = "source_archive_url88af9b91",
                SourceRepository    = new SourceRepository(),
                HttpsTrigger        = new HttpsTrigger(),
                EventTrigger        = new EventTrigger(),
                Status              = CloudFunctionStatus.Offline,
                EntryPoint          = "entry_pointb3d450a5",
                Timeout             = new wkt::Duration(),
                AvailableMemoryMb   = 1905057947,
                ServiceAccountEmail = "service_account_emailb0c3703d",
                UpdateTime          = new wkt::Timestamp(),
                VersionId           = 8696643459580522033L,
                Labels              =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                SourceUploadUrl      = "source_upload_urle9bc6ad5",
                EnvironmentVariables =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                Network      = "networkd22ce091",
                Runtime      = "runtime2519a6b4",
                MaxInstances = -1449803711,
                VpcConnector = "vpc_connectordc82c0cc",
                VpcConnectorEgressSettings = CloudFunction.Types.VpcConnectorEgressSettings.AllTraffic,
                IngressSettings            = CloudFunction.Types.IngressSettings.AllowAll,
                BuildId = "build_id2ab7699b",
            };

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

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            CloudFunction responseCancellationToken = await client.GetFunctionAsync(request, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Пример #6
0
        private double SumTotalPrice(CloudVM key1, CloudStorage key2, CloudFunction key3, CloudDbSQL key4)
        {
            double sum = 0;

            sum += key1 != null ? key1.Price : 0;
            sum += key2 != null ? key2.Price : 0;
            sum += key3 != null ? key3.Price : 0;
            sum += key4 != null ? key4.Price : 0;
            return(sum);
        }
Пример #7
0
 /// <summary>Snippet for GetFunction</summary>
 public void GetFunctionResourceNames()
 {
     // Snippet: GetFunction(CloudFunctionName, CallSettings)
     // Create client
     CloudFunctionsServiceClient cloudFunctionsServiceClient = CloudFunctionsServiceClient.Create();
     // Initialize request argument(s)
     CloudFunctionName name = CloudFunctionName.FromProjectLocationFunction("[PROJECT]", "[LOCATION]", "[FUNCTION]");
     // Make the request
     CloudFunction response = cloudFunctionsServiceClient.GetFunction(name);
     // End snippet
 }
Пример #8
0
 /// <summary>Snippet for GetFunction</summary>
 public void GetFunction()
 {
     // Snippet: GetFunction(string, CallSettings)
     // Create client
     CloudFunctionsServiceClient cloudFunctionsServiceClient = CloudFunctionsServiceClient.Create();
     // Initialize request argument(s)
     string name = "projects/[PROJECT]/locations/[LOCATION]/functions/[FUNCTION]";
     // Make the request
     CloudFunction response = cloudFunctionsServiceClient.GetFunction(name);
     // End snippet
 }
Пример #9
0
        /// <summary>Snippet for GetFunctionAsync</summary>
        public async Task GetFunctionResourceNamesAsync()
        {
            // Snippet: GetFunctionAsync(CloudFunctionName, CallSettings)
            // Additional: GetFunctionAsync(CloudFunctionName, CancellationToken)
            // Create client
            CloudFunctionsServiceClient cloudFunctionsServiceClient = await CloudFunctionsServiceClient.CreateAsync();

            // Initialize request argument(s)
            CloudFunctionName name = CloudFunctionName.FromProjectLocationFunction("[PROJECT]", "[LOCATION]", "[FUNCTION]");
            // Make the request
            CloudFunction response = await cloudFunctionsServiceClient.GetFunctionAsync(name);

            // End snippet
        }
Пример #10
0
        /// <summary>Snippet for GetFunctionAsync</summary>
        public async Task GetFunctionAsync()
        {
            // Snippet: GetFunctionAsync(string, CallSettings)
            // Additional: GetFunctionAsync(string, CancellationToken)
            // Create client
            CloudFunctionsServiceClient cloudFunctionsServiceClient = await CloudFunctionsServiceClient.CreateAsync();

            // Initialize request argument(s)
            string name = "projects/[PROJECT]/locations/[LOCATION]/functions/[FUNCTION]";
            // Make the request
            CloudFunction response = await cloudFunctionsServiceClient.GetFunctionAsync(name);

            // End snippet
        }
Пример #11
0
 /// <summary>Snippet for GetFunction</summary>
 public void GetFunctionRequestObject()
 {
     // Snippet: GetFunction(GetFunctionRequest, CallSettings)
     // Create client
     CloudFunctionsServiceClient cloudFunctionsServiceClient = CloudFunctionsServiceClient.Create();
     // Initialize request argument(s)
     GetFunctionRequest request = new GetFunctionRequest
     {
         CloudFunctionName = CloudFunctionName.FromProjectLocationFunction("[PROJECT]", "[LOCATION]", "[FUNCTION]"),
     };
     // Make the request
     CloudFunction response = cloudFunctionsServiceClient.GetFunction(request);
     // End snippet
 }
        public CloudFunction Get(int id)
        {
            try
            {
                CloudFunction result = _uow.CloudFunction.Get(id);
                if (result == null)
                {
                    throw new Exception("Not found");
                }

                return(result);
            }
            catch (Exception ex)
            {
                throw new Exception("Failed to get by id", ex);
            }
        }
 public object Add(CloudFunction entity)
 {
     try
     {
         _uow.CloudFunction.Add(entity);
         _uow.Complete();
         return(new { message = "Succesfully added" });
     }
     catch (Exception ex)
     {
         throw new Exception("Failed at adding new object", ex);
     }
     finally
     {
         _uow.Dispose();
     }
 }
 public object Update(CloudFunction entity)
 {
     try
     {
         _uow.CloudFunction.Update(entity);
         _uow.Complete();
         return(new { message = "Succesfully updated" });
     }
     catch (Exception ex)
     {
         throw new Exception("Failed to update", ex);
     }
     finally
     {
         _uow.Dispose();
     }
 }
        private string GenerateAzureFunctionsCSharp()
        {
            StringBuilder        azureFunctionsSource = new StringBuilder();
            List <CloudFunction> cloudFunctions       = this.GetAllCloudFunctions();
            CloudFunction        last = cloudFunctions.Last();

            foreach (var cloudFunction in cloudFunctions)
            {
                azureFunctionsSource.Append(this.GenerateAzureFunctionCSharp(cloudFunction));

                if (cloudFunction != last)
                {
                    azureFunctionsSource.AppendLine();
                }
            }

            return(azureFunctionsSource.ToString());
        }
        private string GenerateAzureFunctionCSharp(CloudFunction cloudFunction)
        {
            string returnType         = cloudFunction.ResultType == "Task" ? "Task" : "Task<object>";
            string authorizationLevel = cloudFunction.Type == CloudFunction.CloudFunctionType.Anonymous ? "AuthorizationLevel.Anonymous" : "AuthorizationLevel.Function";

            bool   returnsObject              = cloudFunction.ResultType != "Task";
            string functionReturnStatement    = returnsObject ? "return JsonUtil.Serialize(await" : "await";
            string functionReturnStatementEnd = returnsObject ? ")" : string.Empty;

            StringBuilder function = new StringBuilder();

            function.AppendLine($"    [FunctionName(\"{cloudFunction.FullName}\")]");
            function.AppendLine($"    public static async {returnType} {cloudFunction.FullName}([HttpTrigger({authorizationLevel}, \"post\", Route = null)] FunctionExecutionContext req, HttpRequest httpRequest, ILogger log)");
            function.AppendLine(@"    {");
            function.AppendLine($"        using (new AzureFunctionWrapper(req, httpRequest, log, out CloudFunctionContext context))");
            function.AppendLine(@"        {");

            if (cloudFunction.Type == CloudFunction.CloudFunctionType.Development)
            {
                function.AppendLine($"            await DoNotRunInProductionCheck(context);");
            }

            if (string.IsNullOrEmpty(cloudFunction.RequestType))
            {
                function.AppendLine($"            {functionReturnStatement} {cloudFunction.FullFunctionPath}(context){functionReturnStatementEnd};");
            }
            else
            {
                function.AppendLine($"            {functionReturnStatement} {cloudFunction.FullFunctionPath}(context, JsonUtil.Deserialize<{cloudFunction.RequestType}>(req?.FunctionArgument)){functionReturnStatementEnd};");
            }

            function.AppendLine(@"        }");
            function.AppendLine(@"    }");

            return(function.ToString());
        }
        public void GenerateClientWrapperFiles()
        {
            foreach (var csharpFilePath in this.GetAllCSharpFiles())
            {
                List <CloudFunction> cloudFunctions = this.GetAllCloudFunctionsFromFilePath(csharpFilePath).OrderBy(x => x.Category).ToList();

                if (cloudFunctions.Count == 0)
                {
                    continue;
                }

                string clientOutputFilePath = csharpFilePath.Replace(".cs", "Extensions.cs");
                string className            = Path.GetFileNameWithoutExtension(clientOutputFilePath);

                StringBuilder clientFile        = new StringBuilder();
                CloudFunction lastCloudFunction = cloudFunctions.Last();

                clientFile.AppendLine("// <auto-generated/>");
                clientFile.AppendLine("#pragma warning disable");
                clientFile.AppendLine();
                clientFile.AppendLine("#if USING_PLAYFAB");
                clientFile.AppendLine();
                clientFile.AppendLine($"namespace Lost.CloudFunctions");
                clientFile.AppendLine("{");
                clientFile.AppendLine("    using System;");
                clientFile.AppendLine("    using System.Collections.Generic;");
                clientFile.AppendLine("    using System.Threading.Tasks;");

                // Adding in extra usings
                foreach (var extraUsing in this.extraUsings)
                {
                    clientFile.AppendLine($"    using {extraUsing};");
                }

                clientFile.AppendLine();
                clientFile.AppendLine($"    public static class {className}");
                clientFile.AppendLine(@"    {");

                foreach (var cloudFunction in cloudFunctions)
                {
                    var templateType = cloudFunction.ResultType != "Task" ?
                                       $"<{cloudFunction.ResultType.Substring(0, cloudFunction.ResultType.Length - 1).Replace("Task<", string.Empty)}>" :
                                       string.Empty;

                    if (cloudFunction.RequestType != null)
                    {
                        clientFile.AppendLine($"        public static Task<Result{templateType}> {cloudFunction.FullName}(this CloudFunctionsManager cloudFunctionsManager, {cloudFunction.RequestType} request) => cloudFunctionsManager.Execute{templateType}(\"{cloudFunction.FullName}\", request);");
                    }
                    else
                    {
                        clientFile.AppendLine($"        public static Task<Result{templateType}> {cloudFunction.FullName}(this CloudFunctionsManager cloudFunctionsManager) => cloudFunctionsManager.Execute{templateType}(\"{cloudFunction.FullName}\");");
                    }

                    if (cloudFunction != lastCloudFunction)
                    {
                        clientFile.AppendLine();
                    }
                }

                clientFile.AppendLine("    }");
                clientFile.AppendLine("}");
                clientFile.AppendLine();
                clientFile.AppendLine("#endif");

                Debug.Log($"Writing Client Wrapper File {clientOutputFilePath}");
                FileUtil.CreateOrUpdateFile(clientFile.ToString(), clientOutputFilePath, true);
            }

            AssetDatabase.Refresh();
        }
        private List <CloudFunction> GetAllCloudFunctions(string csharpSource, string attributString, CloudFunction.CloudFunctionType type)
        {
            var result = new List <CloudFunction>();

            string fileNamespace = GetNamespace(csharpSource);
            string className     = GetClassName(csharpSource);
            int    index         = csharpSource.IndexOf(attributString);

            while (index > 0)
            {
                var function = new CloudFunction
                {
                    Type      = type,
                    Namespace = fileNamespace,
                };

                // Calcuating the Category and Name
                int endOfAttributeIndex = csharpSource.IndexOf("]", index);
                var categoryAndName     = csharpSource.Substring(index, endOfAttributeIndex - index)
                                          .Replace(attributString, string.Empty)
                                          .Replace("\"", string.Empty)
                                          .Replace(" ", string.Empty)
                                          .Replace(")", string.Empty)
                                          .Replace("(", string.Empty)
                                          .Split(',');

                function.Category = categoryAndName[0];
                function.Name     = categoryAndName[1];

                // Calculating ResultType and FullFunctionPath
                int    parenIndex            = csharpSource.IndexOf("(", endOfAttributeIndex);
                string functionAndReturnType = csharpSource.Substring(endOfAttributeIndex + 1, parenIndex - endOfAttributeIndex - 1)
                                               .Replace("public", string.Empty)
                                               .Replace("private", string.Empty)
                                               .Replace("protected", string.Empty)
                                               .Replace("async", string.Empty)
                                               .Replace("static", string.Empty)
                                               .Trim();

                string functionName = functionAndReturnType.Substring(functionAndReturnType.LastIndexOf(' ')).Trim();
                function.ResultType = functionAndReturnType.Substring(0, functionAndReturnType.LastIndexOf(' ')).Trim();

                function.FullFunctionPath = string.IsNullOrEmpty(fileNamespace) == false ?
                                            $"{fileNamespace}.{className}.{functionName}" :
                                            $"{className}.{functionName}";

                // Calculate RequestType
                string[] parameters = csharpSource.Substring(parenIndex + 1, csharpSource.IndexOf(')', parenIndex) - parenIndex - 1).Split(',');

                if (parameters.Length == 1 || parameters.Length == 2)
                {
                    if (parameters[0].Contains("CloudFunctionContext") == false)
                    {
                        Debug.LogError($"Cloud Function {function.FullName} first parameter must be a CloudFunctionContext!  Skipping...");
                    }

                    if (parameters.Length == 2)
                    {
                        var secondParameter = parameters[1].Trim();

                        function.RequestType = secondParameter.Substring(0, secondParameter.IndexOf(" ")).Trim();
                    }
                }

                // Making sure it's a valid cloud function
                if (function.ResultType.StartsWith("Task") == false)
                {
                    Debug.LogError($"Cloud Function {function.FullName} does not return a Task!  Skipping...");
                }
                else if (parameters.Length != 1 && parameters.Length != 2)
                {
                    Debug.LogError($"Cloud Function {function.FullName} must contain 1 or 2 parameters.  Skipping...");
                }
                else
                {
                    result.Add(function);
                }

                index = csharpSource.IndexOf(attributString, index + attributString.Length);
            }

            return(result.OrderBy(x => x.Category).ToList());

            string GetNamespace(string csharpCode)
            {
                using (StringReader reader = new StringReader(csharpCode))
                {
                    string line;

                    while ((line = reader.ReadLine()) != null)
                    {
                        if (line.Trim().StartsWith("namespace"))
                        {
                            return(line
                                   .Replace("namespace", string.Empty)
                                   .Replace("{", string.Empty)
                                   .Trim());
                        }
                    }
                }

                return(null);
            }

            string GetClassName(string csharpCode)
            {
                using (StringReader reader = new StringReader(csharpCode))
                {
                    string line;

                    while ((line = reader.ReadLine()) != null)
                    {
                        if (line.Trim().Contains(" class "))
                        {
                            return(line
                                   .Replace("public", string.Empty)
                                   .Replace("static", string.Empty)
                                   .Replace("class", string.Empty)
                                   .Replace("{", string.Empty)
                                   .Trim());
                        }
                    }
                }

                return(null);
            }
        }
 public ActionResult Update([FromBody] CloudFunction cloudFunction)
 {
     return(Ok(_cloudFunctionService.Update(cloudFunction)));
 }
 public ActionResult Remove([FromBody] CloudFunction cloudFunction)
 {
     return(Ok(_cloudFunctionService.Remove(cloudFunction)));
 }
Пример #21
0
        public void GetFunctionRequestObject()
        {
            moq::Mock <CloudFunctionsService.CloudFunctionsServiceClient> mockGrpcClient = new moq::Mock <CloudFunctionsService.CloudFunctionsServiceClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetFunctionRequest request = new GetFunctionRequest
            {
                CloudFunctionName = CloudFunctionName.FromProjectLocationFunction("[PROJECT]", "[LOCATION]", "[FUNCTION]"),
            };
            CloudFunction expectedResponse = new CloudFunction
            {
                CloudFunctionName   = CloudFunctionName.FromProjectLocationFunction("[PROJECT]", "[LOCATION]", "[FUNCTION]"),
                Description         = "description2cf9da67",
                SourceArchiveUrl    = "source_archive_url88af9b91",
                SourceRepository    = new SourceRepository(),
                HttpsTrigger        = new HttpsTrigger(),
                EventTrigger        = new EventTrigger(),
                Status              = CloudFunctionStatus.Offline,
                EntryPoint          = "entry_pointb3d450a5",
                Timeout             = new wkt::Duration(),
                AvailableMemoryMb   = 1905057947,
                ServiceAccountEmail = "service_account_emailb0c3703d",
                UpdateTime          = new wkt::Timestamp(),
                VersionId           = 8696643459580522033L,
                Labels              =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                SourceUploadUrl      = "source_upload_urle9bc6ad5",
                EnvironmentVariables =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                Network      = "networkd22ce091",
                Runtime      = "runtime2519a6b4",
                MaxInstances = -1449803711,
                VpcConnector = "vpc_connectordc82c0cc",
                VpcConnectorEgressSettings = CloudFunction.Types.VpcConnectorEgressSettings.AllTraffic,
                IngressSettings            = CloudFunction.Types.IngressSettings.AllowAll,
                KmsKeyNameAsCryptoKeyName  = CryptoKeyName.FromProjectLocationKeyRingCryptoKey("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]"),
                BuildWorkerPool            = "build_worker_pool4c1ad1a6",
                BuildId = "build_id2ab7699b",
                BuildEnvironmentVariables =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                SecretEnvironmentVariables = { new SecretEnvVar(), },
                SecretVolumes = { new SecretVolume(), },
                SourceToken   = "source_tokenecdd3693",
                MinInstances  = 445814344,
                BuildName     = "build_namead3cc4b7",
                DockerRepositoryAsRepositoryName = RepositoryName.FromProjectLocationRepository("[PROJECT]", "[LOCATION]", "[REPOSITORY]"),
            };

            mockGrpcClient.Setup(x => x.GetFunction(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            CloudFunctionsServiceClient client = new CloudFunctionsServiceClientImpl(mockGrpcClient.Object, null);
            CloudFunction response             = client.GetFunction(request);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
 public ActionResult Add([FromBody] CloudFunction cloudFunction)
 {
     return(Ok(_cloudFunctionService.Add(cloudFunction)));
 }