/// <summary>
        /// 删除函数/版本
        /// </summary>
        public static void DeleteFunction(FunctionGraphClient client)
        {
            DeleteFunctionRequest req = new DeleteFunctionRequest
            {
                FunctionUrn = "urn:fss:cn-north-7:46b6f338fc3445b8846c71dfb1fbd9e8:function:CsharpSdkTest:csharpSdkTest"
            };

            try
            {
                DeleteFunctionResponse resp = client.DeleteFunction(req);
                Console.WriteLine("DeleteFunction StatusCode=" + resp.HttpStatusCode);
            }
            catch (ClientRequestException e)
            {
                Console.WriteLine(e.HttpStatusCode);
                Console.WriteLine(e.ErrorCode);
                Console.WriteLine(e.ErrorMsg);
            }
            catch (ConnectionException e)
            {
                Console.WriteLine(e.ErrorMessage);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
Example #2
0
        public override async Task <bool> ExecuteAsync()
        {
            try
            {
                var deleteRequest = new DeleteFunctionRequest
                {
                    FunctionName = this.GetStringValueOrDefault(this.FunctionName, DefinedCommandOptions.ARGUMENT_FUNCTION_NAME, true)
                };


                try
                {
                    await this.LamdbaClient.DeleteFunctionAsync(deleteRequest);
                }
                catch (Exception e)
                {
                    throw new LambdaToolsException("Error deleting Lambda function: " + e.Message);
                }

                this.Logger.WriteLine($"Lambda function {deleteRequest.FunctionName} deleted");
            }
            catch (LambdaToolsException e)
            {
                this.Logger.WriteLine(e.Message);
                return(false);
            }
            catch (Exception e)
            {
                this.Logger.WriteLine($"Unknown error deleting Lambda function: {e.Message}");
                this.Logger.WriteLine(e.StackTrace);
                return(false);
            }

            return(true);
        }
Example #3
0
        /// <summary>
        /// Deletes a function.
        /// </summary>
        /// <param name="request">The request object containing the details to send. Required.</param>
        /// <param name="retryConfiguration">The retry configuration that will be used by to send this request. Optional.</param>
        /// <param name="cancellationToken">The cancellation token to cancel this operation. Optional.</param>
        /// <returns>A response object containing details about the completed operation</returns>
        /// <example>Click <a href="https://docs.cloud.oracle.com/en-us/iaas/tools/dot-net-examples/latest/functions/DeleteFunction.cs.html">here</a> to see an example of how to use DeleteFunction API.</example>
        public async Task <DeleteFunctionResponse> DeleteFunction(DeleteFunctionRequest request, RetryConfiguration retryConfiguration = null, CancellationToken cancellationToken = default)
        {
            logger.Trace("Called deleteFunction");
            Uri                uri            = new Uri(this.restClient.GetEndpoint(), System.IO.Path.Combine(basePathWithoutHost, "/functions/{functionId}".Trim('/')));
            HttpMethod         method         = new HttpMethod("DELETE");
            HttpRequestMessage requestMessage = Converter.ToHttpRequestMessage(uri, method, request);

            requestMessage.Headers.Add("Accept", "application/json");
            GenericRetrier      retryingClient = Retrier.GetPreferredRetrier(retryConfiguration, this.retryConfiguration);
            HttpResponseMessage responseMessage;

            try
            {
                if (retryingClient != null)
                {
                    responseMessage = await retryingClient.MakeRetryingCall(this.restClient.HttpSend, requestMessage, cancellationToken).ConfigureAwait(false);
                }
                else
                {
                    responseMessage = await this.restClient.HttpSend(requestMessage).ConfigureAwait(false);
                }
                this.restClient.CheckHttpResponseMessage(requestMessage, responseMessage);

                return(Converter.FromHttpResponseMessage <DeleteFunctionResponse>(responseMessage));
            }
            catch (Exception e)
            {
                logger.Error($"DeleteFunction failed with error: {e.Message}");
                throw;
            }
        }
Example #4
0
        internal DeleteFunctionResponse DeleteFunction(DeleteFunctionRequest request)
        {
            var marshaller   = new DeleteFunctionRequestMarshaller();
            var unmarshaller = DeleteFunctionResponseUnmarshaller.Instance;

            return(Invoke <DeleteFunctionRequest, DeleteFunctionResponse>(request, marshaller, unmarshaller));
        }
Example #5
0
        /// <summary>
        /// Deletes the specified Lambda function code and configuration.
        ///
        ///
        /// <para>
        /// This operation requires permission for the <code>lambda:DeleteFunction</code> action.
        /// </para>
        /// </summary>
        /// <param name="functionName">The Lambda function to delete.</param>
        ///
        /// <returns>The response from the DeleteFunction service method, as returned by Lambda.</returns>
        /// <exception cref="Amazon.Lambda.Model.ResourceNotFoundException">
        /// The function or the event source specified in the request does not exist.
        /// </exception>
        /// <exception cref="Amazon.Lambda.Model.ServiceException">
        /// The AWS Lambda service encountered an internal error.
        /// </exception>
        public DeleteFunctionResponse DeleteFunction(string functionName)
        {
            var request = new DeleteFunctionRequest();

            request.FunctionName = functionName;
            return(DeleteFunction(request));
        }
Example #6
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();

            if (!ConfirmDelete("OCIFunctionsFunction", "Remove"))
            {
                return;
            }

            DeleteFunctionRequest request;

            try
            {
                request = new DeleteFunctionRequest
                {
                    FunctionId   = FunctionId,
                    IfMatch      = IfMatch,
                    OpcRequestId = OpcRequestId
                };

                response = client.DeleteFunction(request).GetAwaiter().GetResult();
                WriteOutput(response);
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
Example #7
0
        /// <summary>Snippet for DeleteFunctionAsync</summary>
        public async Task DeleteFunctionRequestObjectAsync()
        {
            // Snippet: DeleteFunctionAsync(DeleteFunctionRequest, CallSettings)
            // Additional: DeleteFunctionAsync(DeleteFunctionRequest, CancellationToken)
            // Create client
            CloudFunctionsServiceClient cloudFunctionsServiceClient = await CloudFunctionsServiceClient.CreateAsync();

            // Initialize request argument(s)
            DeleteFunctionRequest request = new DeleteFunctionRequest
            {
                CloudFunctionName = CloudFunctionName.FromProjectLocationFunction("[PROJECT]", "[LOCATION]", "[FUNCTION]"),
            };
            // Make the request
            Operation <Empty, OperationMetadataV1> response = await cloudFunctionsServiceClient.DeleteFunctionAsync(request);

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

            // Retrieve the operation result
            Empty 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 <Empty, OperationMetadataV1> retrievedResponse = await cloudFunctionsServiceClient.PollOnceDeleteFunctionAsync(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                Empty retrievedResult = retrievedResponse.Result;
            }
            // End snippet
        }
Example #8
0
        /// <summary>
        /// Deletes the specified Lambda function code and configuration.
        ///
        ///
        /// <para>
        /// When you delete a function the associated access policy is also deleted. You will
        /// need to delete the event source mappings explicitly.
        /// </para>
        ///
        /// <para>
        /// This operation requires permission for the <code>lambda:DeleteFunction</code> action.
        /// </para>
        /// </summary>
        /// <param name="functionName">The Lambda function to delete.  You can specify an unqualified function name (for example, "Thumbnail") or you can specify Amazon Resource Name (ARN) of the function (for example, "arn:aws:lambda:us-west-2:account-id:function:ThumbNail"). AWS Lambda also allows you to specify only the account ID qualifier (for example, "account-id:Thumbnail"). Note that the length constraint applies only to the ARN. If you specify only the function name, it is limited to 64 character in length. </param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        ///
        /// <returns>The response from the DeleteFunction service method, as returned by Lambda.</returns>
        /// <exception cref="Amazon.Lambda.Model.ResourceNotFoundException">
        /// The resource (for example, a Lambda function or access policy statement) specified
        /// in the request does not exist.
        /// </exception>
        /// <exception cref="Amazon.Lambda.Model.ServiceException">
        /// The AWS Lambda service encountered an internal error.
        /// </exception>
        /// <exception cref="Amazon.Lambda.Model.TooManyRequestsException">
        ///
        /// </exception>
        public Task <DeleteFunctionResponse> DeleteFunctionAsync(string functionName, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var request = new DeleteFunctionRequest();

            request.FunctionName = functionName;
            return(DeleteFunctionAsync(request, cancellationToken));
        }
Example #9
0
        /// <summary>
        /// Initiates the asynchronous execution of the DeleteFunction operation.
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the DeleteFunction operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        public Task <DeleteFunctionResponse> DeleteFunctionAsync(DeleteFunctionRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller   = new DeleteFunctionRequestMarshaller();
            var unmarshaller = DeleteFunctionResponseUnmarshaller.Instance;

            return(InvokeAsync <DeleteFunctionRequest, DeleteFunctionResponse>(request, marshaller,
                                                                               unmarshaller, cancellationToken));
        }
Example #10
0
        /**
         * Deletes a Function and waits for it to be deleted.
         *
         * @param fnManagementClient the service client to use to delete the Function.
         * @param functionId the Function to delete.
         */
        private static async Task DeleteFunction(FunctionsManagementClient fnManagementClient, string functionId)
        {
            // Delete the specified function
            var deleteFunctionRequest = new DeleteFunctionRequest
            {
                FunctionId = functionId
            };
            await fnManagementClient.DeleteFunction(deleteFunctionRequest);

            logger.Info($"Function deleted: {FunctionName}");
        }
Example #11
0
        /// <summary>
        /// 删除函数/版本。
        /// </summary>
        public async Task <DeleteFunctionResponse> DeleteFunctionAsync(DeleteFunctionRequest deleteFunctionRequest)
        {
            Dictionary <string, string> urlParam = new Dictionary <string, string>();

            urlParam.Add("function_urn", deleteFunctionRequest.FunctionUrn.ToString());
            string              urlPath  = HttpUtils.AddUrlPath("/v2/{project_id}/fgs/functions/{function_urn}", urlParam);
            SdkRequest          request  = HttpUtils.InitSdkRequest(urlPath, "application/json", deleteFunctionRequest);
            HttpResponseMessage response = await DoHttpRequestAsync("DELETE", request);

            return(JsonUtils.DeSerializeNull <DeleteFunctionResponse>(response));
        }
Example #12
0
        /// <summary>
        /// 删除函数/版本。
        /// </summary>
        public DeleteFunctionResponse DeleteFunction(DeleteFunctionRequest deleteFunctionRequest)
        {
            Dictionary <string, string> urlParam = new Dictionary <string, string>();

            urlParam.Add("function_urn", deleteFunctionRequest.FunctionUrn.ToString());
            string      urlPath  = HttpUtils.AddUrlPath("/v2/{project_id}/fgs/functions/{function_urn}", urlParam);
            SdkRequest  request  = HttpUtils.InitSdkRequest(urlPath, deleteFunctionRequest);
            SdkResponse response = DoHttpRequest("DELETE", request);

            return(JsonUtils.DeSerializeNull <DeleteFunctionResponse>(response));
        }
Example #13
0
        /// <summary>
        /// DeleteFunction接口的同步版本,该接口根据传入参数删除函数。
        /// </summary>
        /// <param name="req">参考<see cref="DeleteFunctionRequest"/></param>
        /// <returns>参考<see cref="DeleteFunctionResponse"/>实例</returns>
        public DeleteFunctionResponse DeleteFunctionSync(DeleteFunctionRequest req)
        {
            JsonResponseModel <DeleteFunctionResponse> rsp = null;

            try
            {
                var strResp = this.InternalRequestSync(req, "DeleteFunction");
                rsp = JsonConvert.DeserializeObject <JsonResponseModel <DeleteFunctionResponse> >(strResp);
            }
            catch (JsonSerializationException e)
            {
                throw new TencentCloudSDKException(e.Message);
            }
            return(rsp.Response);
        }
Example #14
0
        private static async Task DeleteFunctionIfExistsAsync(AmazonLambdaClient lambdaClient)
        {
            var request = new DeleteFunctionRequest
            {
                FunctionName = FunctionName
            };

            try
            {
                var response = await lambdaClient.DeleteFunctionAsync(request);
            }
            catch (ResourceNotFoundException)
            {
                // no problem
            }
        }
Example #15
0
        protected override async Task <bool> PerformActionAsync()
        {
            var deleteRequest = new DeleteFunctionRequest
            {
                FunctionName = this.GetStringValueOrDefault(this.FunctionName, LambdaDefinedCommandOptions.ARGUMENT_FUNCTION_NAME, true)
            };


            try
            {
                await this.LambdaClient.DeleteFunctionAsync(deleteRequest);
            }
            catch (Exception e)
            {
                throw new LambdaToolsException("Error deleting Lambda function: " + e.Message, LambdaToolsException.LambdaErrorCode.LambdaDeleteFunction, e);
            }

            this.Logger?.WriteLine($"Lambda function {deleteRequest.FunctionName} deleted");

            return(true);
        }
 public void DeleteFunctionAsync(DeleteFunctionRequest request, AmazonServiceCallback <DeleteFunctionRequest, DeleteFunctionResponse> callback, AsyncOptions options = null)
 {
     throw new System.NotImplementedException();
 }
Example #17
0
 /// <summary>
 ///  删除函数
 /// </summary>
 /// <param name="request">请求参数信息</param>
 /// <returns>请求结果信息</returns>
 public DeleteFunctionResponse DeleteFunction(DeleteFunctionRequest request)
 {
     return(new DeleteFunctionExecutor().Client(this).Execute <DeleteFunctionResponse, DeleteFunctionResult, DeleteFunctionRequest>(request));
 }
Example #18
0
 /// <summary>
 ///  删除函数
 /// </summary>
 /// <param name="request">请求参数信息</param>
 /// <returns>请求结果信息</returns>
 public async Task <DeleteFunctionResponse> DeleteFunction(DeleteFunctionRequest request)
 {
     return(await new DeleteFunctionExecutor().Client(this).Execute <DeleteFunctionResponse, DeleteFunctionResult, DeleteFunctionRequest>(request).ConfigureAwait(false));
 }
Example #19
0
 /// <summary>
 /// Deletes the function.
 /// </summary>
 /// <returns>The function.</returns>
 /// <param name="deleteFunctionRequest">Delete function request.</param>
 public DeleteFunctionResponse DeleteFunction(DeleteFunctionRequest deleteFunctionRequest)
 {
     return(this.DoRequestCommon <DeleteFunctionResponse>(deleteFunctionRequest.GenHttpRequest(Config)));
 }
        public async Task TearDownResourcesAsync()
        {
            using (var cfClient = new AmazonCloudFormationClient())
            {
                var request = new DeleteStackRequest
                {
                    StackName = this.FrontendCloudFormationStack
                };

                try
                {
                    await cfClient.DeleteStackAsync(request);

                    Console.WriteLine($"Frontend CloudFormation Stack {this.FrontendCloudFormationStack} is deleted");
                }
                catch (Exception e)
                {
                    Console.WriteLine($"Frontend CloudFormation Stack {this.FrontendCloudFormationStack} was not deleted: {e.Message}");
                }
            }

            using (var lambdaClient = new AmazonLambdaClient())
            {
                var request = new DeleteFunctionRequest
                {
                    FunctionName = this.DynanmoDBStreamLambdaFunction
                };

                try
                {
                    await lambdaClient.DeleteFunctionAsync(request);

                    Console.WriteLine($"Function {this.DynanmoDBStreamLambdaFunction} is deleted");
                }
                catch (Exception e)
                {
                    Console.WriteLine($"Function {this.DynanmoDBStreamLambdaFunction} was not deleted: {e.Message}");
                }
            }

            using (var cognitoClient = new AmazonCognitoIdentityProviderClient())
            {
                var userPool = (await cognitoClient.ListUserPoolsAsync(new ListUserPoolsRequest {
                    MaxResults = 60
                })).UserPools
                               .FirstOrDefault(x => string.Equals(this.CognitoUserPool, x.Name));

                if (userPool != null)
                {
                    var request = new DeleteUserPoolRequest
                    {
                        UserPoolId = userPool.Id
                    };

                    try
                    {
                        await cognitoClient.DeleteUserPoolAsync(request);

                        Console.WriteLine($"Cognito User Pool {this.CognitoUserPool} is deleted");
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine($"Cognito User Pool {this.CognitoUserPool} was not deleted: {e.Message}");
                    }
                }
            }

            using (var ssmClient = new AmazonSimpleSystemsManagementClient())
            {
                try
                {
                    var parameters = (await ssmClient.GetParametersByPathAsync(new GetParametersByPathRequest
                    {
                        Path = this.ParameterStorePrefix,
                        Recursive = true
                    })).Parameters;

                    Console.WriteLine($"Found {parameters.Count} SSM parameters starting with {this.ParameterStorePrefix}");

                    foreach (var parameter in parameters)
                    {
                        try
                        {
                            await ssmClient.DeleteParameterAsync(new DeleteParameterRequest { Name = parameter.Name });

                            Console.WriteLine($"Parameter {parameter.Name} is deleted");
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine($"Parameter {parameter.Name} was not deleted: {e.Message}");
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine($"Error deleting SSM Parameters: {e.Message}");
                }
            }

            using (var ddbClient = new AmazonDynamoDBClient())
            {
                var request = new DeleteTableRequest
                {
                    TableName = this.DynamoDBTableName
                };

                try
                {
                    await ddbClient.DeleteTableAsync(request);

                    Console.WriteLine($"Table {this.DynamoDBTableName} is deleted");
                }
                catch (Exception e)
                {
                    Console.WriteLine($"Table {this.DynamoDBTableName} was not deleted: {e.Message}");
                }
            }
        }