/*! * Copyright (c) 2019 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 * * SPDX-License-Identifier: EPL-2.0 */ import { Filter } from './filter.options'; export interface RequestOptions { /** * Provides the specified URL options. * * @returns The string to attach to the URL */ getOptions(): Map; /** * Provides the specified header options. * * @returns The headers */ getHeaders(): Map; } export interface AddRequestOptions> extends RequestOptions { /** * Adds a URl option. * * @param id - The ID of the option to add. * @param value - The body of the option to add. */ addRequestParameter(id: string, value: string): T; /** * Adds a header option. * * @param name - The name of the header to add. * @param value - The body of the header to add. */ addHeader(name: string, value: string): T; } /** * Option provider for options. Options will be replaced if methods are called multiple times. */ export declare abstract class AbstractRequestOptions> implements AddRequestOptions { private readonly options; private readonly headers; protected constructor(); getOptions(): Map; getHeaders(): Map; addRequestParameter(id: string, value: string): T; addHeader(name: string, value: string): T; } export interface HasMatch> { /** * Sets an If-Match option. * * @param tag - The tags to match. * @returns This Options instance with the added option */ ifMatch(...tag: string[]): T; /** * Shortcut for If-Match: * * @returns This Options instance with the added option */ ifMatchAny(): T; /** * Sets an If-None-Match option. * * @param tag - The tags to match. * @returns This Options instance with the added option */ ifNoneMatch(...tag: string[]): T; /** * Shortcut for If-None-Match: * * @returns This Options instance with the added option */ ifNoneMatchAny(): T; } export interface HasFields> { /** * Sets a fields option. * * @param fields - The fields to return. * @returns This Options instance with the added option */ withFields(...fields: string[]): T; } export interface HasFilterAndNamespace> { /** * Sets a filter option. * * @param rawFilterString - The string to filter by. * @returns This Options instance with the added option */ withRawFilter(rawFilterString: string): T; /** * Sets a filter option. * * @param filter - The instance of Filter to use. * @returns This Options instance with the added option */ withFilter(filter: Filter): T; /** * Sets a namespaces option. * * @param namespaces - The namespaces to set. * @returns This Options instance with the added option */ withNamespaces(...namespaces: string[]): T; } export interface RequestOptionsWithMatchOptions> extends AddRequestOptions>, HasMatch> { } export declare abstract class AbstractRequestOptionsWithMatchOptions> extends AbstractRequestOptions> implements RequestOptionsWithMatchOptions> { ifMatch(...tags: string[]): T; ifNoneMatch(...tags: string[]): T; ifMatchAny(): T; ifNoneMatchAny(): T; } /** * Option provider for If-Match / If-None-Match headers */ export interface MatchOptions extends RequestOptionsWithMatchOptions { } export declare class DefaultMatchOptions extends AbstractRequestOptionsWithMatchOptions implements MatchOptions { private constructor(); /** * Provides an instance of MatchOptions. * * @returns The MatchOptions */ static getInstance(): DefaultMatchOptions; } export declare class MatchOptionsHelper { static getWithMergeHeader(options?: MatchOptions): MatchOptions; } /** * Option provider for some get requests */ export interface FieldsOptions extends RequestOptionsWithMatchOptions, HasFields { withFields(...fields: string[]): FieldsOptions; } export declare class DefaultFieldsOptions extends AbstractRequestOptionsWithMatchOptions implements FieldsOptions { private constructor(); /** * Provides an instance of FieldsOptions. * * @returns The FieldsOptions */ static getInstance(): DefaultFieldsOptions; withFields(...fields: string[]): DefaultFieldsOptions; } /** * Option provider for count requests */ export interface CountOptions extends AddRequestOptions, HasFilterAndNamespace { } export declare class DefaultCountOptions extends AbstractRequestOptions implements CountOptions { protected constructor(); /** * Provides an instance of DefaultCountOptions. * * @returns The DefaultCountOptions */ static getInstance(): DefaultCountOptions; withRawFilter(rawFilterString: string): DefaultCountOptions; withFilter(filter: Filter): DefaultCountOptions; withNamespaces(...namespaces: string[]): DefaultCountOptions; } /** * Option provider for search requests */ export interface SearchOptions extends AddRequestOptions, HasFilterAndNamespace, HasFields { /** * @param offset - The index to start at. * @param count - The number of things to return. * @returns The instance of SearchOptions with the added option * * @Deprecated See {@link https://www.eclipse.dev/ditto/basic-search.html#rql-paging-deprecated} Use cursor pagination instead * Sets a limit option. */ withLimit(offset: number, count: number): SearchOptions; /** * Sets a sort option. * * @param sortOperation - The string to sort by. * @returns The instance of SearchOptions with the added option */ withSort(sortOperation: string): SearchOptions; /** * Sets a cursor option * * @param cursor - The cursor to use for pagination, returned by a previous search request */ withCursor(cursor: string): SearchOptions; /** * Sets the page size for pagination. * Only works with cursor pagination. * Maximum page size supported by ditto is 200. * @param pageSize Number of items to return per page */ withPageSize(pageSize: number): SearchOptions; } export declare class DefaultSearchOptions extends AbstractRequestOptions implements SearchOptions { /** * Map of name-value pairs to add to the request parameters as "option" */ private optionParameters; private constructor(); /** * Provides an instance of DefaultSearchOptions. * * @returns The DefaultSearchOptions */ static getInstance(): DefaultSearchOptions; withNamespaces(...namespaces: string[]): DefaultSearchOptions; withFields(...fields: string[]): DefaultSearchOptions; withRawFilter(rawFilterString: string): DefaultSearchOptions; withFilter(filter: Filter): DefaultSearchOptions; withLimit(offset: number, count: number): DefaultSearchOptions; withSort(sortOperation: string): DefaultSearchOptions; withCursor(cursor: string): DefaultSearchOptions; withPageSize(pageSize: number): DefaultSearchOptions; /** * Constructs the 'option' option out of the values of limit and sort. * * @returns The instance of DefaultSearchOptions with the constructed option */ private setOption; } /** * Option provider for get Things requests */ export interface GetThingsOptions extends AddRequestOptions, HasFields { setThingIds(ids: string[]): GetThingsOptions; } export declare class DefaultGetThingsOptions extends AbstractRequestOptions implements GetThingsOptions { private constructor(); /** * Provides an instance of GetThingsOptions. * * @returns The GetThingsOptions */ static getInstance(): DefaultGetThingsOptions; withFields(...fields: string[]): DefaultGetThingsOptions; setThingIds(ids: string[]): DefaultGetThingsOptions; } /** * Option provider for Messages requests */ export interface MessagesOptions extends AddRequestOptions { /** * Sets a timeout option. * * @param timeout - The timeout in milliseconds to use. * @returns The instance of MessagesOptions with the added option */ withTimeout(timeout: number): MessagesOptions; } export declare class DefaultMessagesOptions extends AbstractRequestOptions implements MessagesOptions { private constructor(); /** * Provides an instance of MessagesOptions. * * @returns The MessagesOptions */ static getInstance(): DefaultMessagesOptions; withTimeout(timeout: number): DefaultMessagesOptions; } /** * Option provider for post Connection requests */ export interface PostConnectionOptions extends AddRequestOptions { /** * Sets a dry-run option to test a Connection. * * @param dryRun - If the connection should only be tested, but not already created. * @returns The instance of DefaultPostConnectionOptions with the added option */ asDryRun(dryRun: boolean): DefaultPostConnectionOptions; } export declare class DefaultPostConnectionOptions extends AbstractRequestOptions implements PostConnectionOptions { private constructor(); /** * Provides an instance of DefaultPostConnectionOptions. * * @returns The DefaultPostConnectionOptions */ static getInstance(): DefaultPostConnectionOptions; /** * Gets an instance of DefaultPostConnectionOptions with the dry-run parameter set to true to test Connections. * * @returns The instance of MessagesOptions */ static getDryRunInstance(): DefaultPostConnectionOptions; asDryRun(dryRun: boolean): DefaultPostConnectionOptions; } //# sourceMappingURL=request.options.d.ts.map