예제 #1
0
        private async Task <IHttpActionResult> DeleteFunctionSecretAsync(string keyName, string functionName = null)
        {
            if (keyName == null || keyName.StartsWith("_"))
            {
                // System keys cannot be deleted.
                return(BadRequest("Invalid key name."));
            }

            if ((functionName != null && !_scriptHostManager.Instance.Functions.Any(f => string.Equals(f.Name, functionName, StringComparison.OrdinalIgnoreCase))) ||
                !await _secretManager.DeleteSecretAsync(keyName, functionName))
            {
                // Either the function or the key were not found
                return(NotFound());
            }

            _traceWriter.VerboseFormat(Resources.TraceKeysApiSecretChange, keyName, functionName ?? "host", "Deleted");

            return(StatusCode(HttpStatusCode.NoContent));
        }
        private async Task <IHttpActionResult> DeleteFunctionSecretAsync(string keyName, string keyScope, ScriptSecretsType secretsType)
        {
            if (keyName == null || keyName.StartsWith("_"))
            {
                // System keys cannot be deleted.
                return(BadRequest("Invalid key name."));
            }

            if ((secretsType == ScriptSecretsType.Function && !_scriptHostManager.Instance.IsFunction(keyScope)) ||
                !await _secretManager.DeleteSecretAsync(keyName, keyScope, secretsType))
            {
                // Either the function or the key were not found
                return(NotFound());
            }

            _traceWriter.VerboseFormat(Resources.TraceKeysApiSecretChange, keyName, keyScope ?? "host", "Deleted");

            return(StatusCode(HttpStatusCode.NoContent));
        }
        private async Task <IActionResult> DeleteFunctionSecretAsync(string keyName, string keyScope, ScriptSecretsType secretsType)
        {
            if (keyName == null || keyName.StartsWith("_"))
            {
                // System keys cannot be deleted.
                return(BadRequest("Invalid key name."));
            }

            if ((secretsType == ScriptSecretsType.Function && keyScope != null && !IsFunction(keyScope)) ||
                !await _secretManager.DeleteSecretAsync(keyName, keyScope, secretsType))
            {
                // Either the function or the key were not found
                return(NotFound());
            }

            _logger.LogDebug(string.Format(Resources.TraceKeysApiSecretChange, keyName, keyScope ?? "host", "Deleted"));

            return(StatusCode(StatusCodes.Status204NoContent));
        }