예제 #1
0
        private static async Task CreateOrPatchUserDefinedFunction(
            HttpClient httpClient,
            ILogger logger,
            UserDefinedFunctionDescription description,
            string js,
            Guid spaceId,
            IEnumerable <Matcher> matchers)
        {
            var userDefinedFunction = await requests.FindUserDefinedFunction(httpClient, logger, description.name, spaceId);

            if (userDefinedFunction != null)
            {
                await requests.UpdateUserDefinedFunction(
                    httpClient,
                    logger,
                    description.ToUserDefinedFunctionUpdate(userDefinedFunction.Id, spaceId, matchers.Select(m => m.Id)),
                    js);
            }
            else
            {
                await requests.CreateUserDefinedFunction(
                    httpClient,
                    logger,
                    description.ToUserDefinedFunctionCreate(spaceId, matchers.Select(m => m.Id)),
                    js);
            }
        }
예제 #2
0
 public static UserDefinedFunctionCreate ToUserDefinedFunctionCreate(this UserDefinedFunctionDescription description, Guid spaceId, IEnumerable <string> matcherIds)
 => new UserDefinedFunctionCreate()
 {
     Name     = description.name,
     SpaceId  = spaceId.ToString(),
     Matchers = matcherIds,
 };