コード例 #1
0
        public override async Task <Response <RegistrationResourceAttributes> > ProcessDeleteResourceAsync(Request <RegistrationResourceProperties> request)
        {
            var properties = request.ResourceProperties;

            switch (request.ResourceProperties.ResourceType)
            {
            case "LambdaSharp::Registration::Module": {
                LogInfo($"Removing Module: Id={properties.ModuleId}, Info={properties.Module}");

                // delete old rollbar project

                // TODO (2018-10-22, bjorg): only delete rollbar project if ALL registrations have been deleted

                // if(_rollbarClient.HasTokens) {
                //     var owner = await _registrations.GetOwnerMetaDataAsync($"M:{properties.ModuleId}");
                //     try {
                //         if(owner.RollbarProjectId > 0) {
                //             await _rollbarClient.DeleteProject(owner.RollbarProjectId);
                //         }
                //     } catch(Exception e) {
                //         LogErrorAsWarning(e, "failed to delete rollbar project: {0}", owner.RollbarProjectId);
                //     }
                // }

                // delete owner record
                await _registrations.DeleteOwnerMetaDataAsync($"M:{properties.ModuleId}");

                break;
            }

            case "LambdaSharp::Registration::Function": {
                LogInfo($"Removing Function: Id={properties.FunctionId}, Name={properties.FunctionName}, LogGroup={properties.FunctionLogGroupName}");
                await _registrations.DeleteOwnerMetaDataAsync($"F:{properties.FunctionId}");

                break;
            }

            default:

                // nothing to do since we didn't process this request successfully in the first place!
                break;
            }
            return(new Response <RegistrationResourceAttributes>());
        }