ValidateEventCollectionName() 공개 정적인 메소드

Apply the collection name restrictions. Throws KeenException with an explanation if a collection name is unacceptable.
public static ValidateEventCollectionName ( string collection ) : void
collection string
리턴 void
예제 #1
0
        /// <summary>
        /// Add a single event to the specified collection.
        /// </summary>
        /// <param name="collection">Collection name</param>
        /// <param name="eventInfo">The event to add.</param>
        /// <param name="addOns">Optional collection of Data Enhancement Add-ons</param>
        public async Task AddEventAsync(string collection, object eventInfo, IEnumerable <AddOn> addOns = null)
        {
            // Preconditions
            KeenUtil.ValidateEventCollectionName(collection);
            if (null == eventInfo)
            {
                throw new KeenException("Event data is required.");
            }
            if (string.IsNullOrWhiteSpace(_prjSettings.WriteKey))
            {
                throw new KeenException("Write API key is required for AddEvent");
            }

            var jEvent = PrepareUserObject(eventInfo, addOns);

            // If an event cache has been provided, cache this event insead of sending it.
            if (null != EventCache)
            {
                await EventCache.Add(new CachedEvent(collection, jEvent))
                .ConfigureAwait(false);
            }
            else
            {
                await EventCollection.AddEvent(collection, jEvent)
                .ConfigureAwait(false);
            }
        }
예제 #2
0
        /// <summary>
        /// Retrieve the schema for the specified collection. This requires
        /// a value for the project settings Master API key.
        /// </summary>
        /// <param name="collection"></param>
        public async Task <dynamic> GetSchemaAsync(string collection)
        {
            // Preconditions
            KeenUtil.ValidateEventCollectionName(collection);
            if (string.IsNullOrWhiteSpace(_prjSettings.MasterKey))
            {
                throw new KeenException("Master API key is required for GetSchema");
            }

            return(await EventCollection.GetSchema(collection)
                   .ConfigureAwait(continueOnCapturedContext: false));
        }
예제 #3
0
        /// <summary>
        /// Delete the specified collection. Deletion may be denied for collections with many events.
        /// Master API key is required.
        /// </summary>
        /// <param name="collection">Name of collection to delete.</param>
        public async Task DeleteCollectionAsync(string collection)
        {
            // Preconditions
            KeenUtil.ValidateEventCollectionName(collection);
            if (string.IsNullOrWhiteSpace(_prjSettings.MasterKey))
            {
                throw new KeenException("Master API key is required for DeleteCollection");
            }

            await EventCollection.DeleteCollection(collection)
            .ConfigureAwait(continueOnCapturedContext: false);
        }