How to use the @esri/arcgis-rest-request.getPortalUrl function in @esri/arcgis-rest-request

To help you get started, we’ve selected a few @esri/arcgis-rest-request examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Esri / arcgis-rest-js / packages / arcgis-rest-items / src / items.ts View on Github external
export function getItemResources(
  requestOptions: IItemIdRequestOptions
): Promise {
  const url = `${getPortalUrl(requestOptions)}/content/items/${
    requestOptions.id
  }/resources`;

  // mix in user supplied params
  requestOptions.params = {
    ...requestOptions.params,
    num: 1000
  };

  return request(url, requestOptions);
}
github Esri / arcgis-rest-js / packages / arcgis-rest-items / src / items.ts View on Github external
export function addItemData(
  requestOptions: IItemDataAddRequestOptions
): Promise {
  const owner = determineOwner(requestOptions);

  const url = `${getPortalUrl(requestOptions)}/content/users/${owner}/items/${
    requestOptions.id
  }/update`;

  // Portal API requires that the 'data' be POSTed in a `file` form field.
  requestOptions.params = {
    file: requestOptions.data,
    ...requestOptions.params
  };

  return request(url, requestOptions);
}
/**
github Esri / arcgis-rest-js / packages / arcgis-rest-items / src / update.ts View on Github external
export function updateItemResource(
  requestOptions: IItemResourceRequestOptions
): Promise {
  const owner = determineOwner(requestOptions);
  const url = `${getPortalUrl(requestOptions)}/content/users/${owner}/items/${
    requestOptions.id
  }/updateResources`;

  // mix in user supplied params
  requestOptions.params = {
    file: requestOptions.resource,
    fileName: requestOptions.name,
    text: requestOptions.content,
    ...requestOptions.params
  };

  // only override whatever access was specified previously if 'private' was passed explicitly
  if (typeof requestOptions.private !== "undefined") {
    requestOptions.params.access = requestOptions.private
      ? "private"
      : "inherit";
github Esri / arcgis-rest-js / packages / arcgis-rest-items / src / remove.ts View on Github external
export function removeItemResource(
  requestOptions: IItemResourceRequestOptions
): Promise {
  const owner = determineOwner(requestOptions);
  const url = `${getPortalUrl(requestOptions)}/content/users/${owner}/items/${
    requestOptions.id
  }/removeResources`;

  // mix in user supplied params
  requestOptions.params = {
    ...requestOptions.params,
    resource: requestOptions.resource
  };
  return request(url, requestOptions);
}
github Esri / arcgis-rest-js / packages / arcgis-rest-items / src / items.ts View on Github external
export function addItemJsonData(
  requestOptions: IItemDataAddRequestOptions
): Promise {
  const owner = determineOwner(requestOptions);
  const url = `${getPortalUrl(requestOptions)}/content/users/${owner}/items/${
    requestOptions.id
  }/update`;

  // Portal API requires that the 'data' be stringified and POSTed in
  // a `text` form field. It can also be sent with the `.create` call by sending
  // a `.data` property.
  requestOptions.params = {
    text: JSON.stringify(requestOptions.data),
    ...requestOptions.params
  };

  return request(url, requestOptions);
}
/**
github Esri / arcgis-rest-js / packages / arcgis-rest-items / src / items.ts View on Github external
params: {}
  };

  if (typeof search === "string") {
    options.params.q = search;
  } else {
    options.params = search.searchForm;
    // mixin, giving user supplied requestOptions precedence
    options = {
      ...options,
      ...search
    };
  }

  // construct the search url
  const url = `${getPortalUrl(options)}/search`;

  // send the request
  return request(url, options);
}
github Esri / arcgis-rest-js / packages / arcgis-rest-items / src / items.ts View on Github external
export function getItem(
  id: string,
  requestOptions?: IRequestOptions
): Promise {
  const url = `${getPortalUrl(requestOptions)}/content/items/${id}`;

  // default to a GET request
  const options: IRequestOptions = {
    ...{ httpMethod: "GET" },
    ...requestOptions
  };
  return request(url, options);
}
github Esri / arcgis-rest-js / packages / arcgis-rest-items / src / remove.ts View on Github external
export function removeFolder(
  requestOptions: IFolderIdRequestOptions
): Promise<{
  success: boolean;
  folder: {
    username: string;
    id: string;
    title: string;
  };
}> {
  const owner = determineOwner(requestOptions);
  const url = `${getPortalUrl(
    requestOptions
  )}/content/users/${encodeURIComponent(owner)}/${
    requestOptions.folderId
  }/delete`;
  return request(url, requestOptions);
}
github Esri / arcgis-rest-js / packages / arcgis-rest-items / src / items.ts View on Github external
export function unprotectItem(
  requestOptions: IItemIdRequestOptions
): Promise {
  const owner = determineOwner(requestOptions);
  const url = `${getPortalUrl(requestOptions)}/content/users/${owner}/items/${
    requestOptions.id
  }/unprotect`;
  return request(url, requestOptions);
}
github Esri / arcgis-rest-js / packages / arcgis-rest-items / src / items.ts View on Github external
export function protectItem(
  requestOptions: IItemIdRequestOptions
): Promise {
  const owner = determineOwner(requestOptions);
  const url = `${getPortalUrl(requestOptions)}/content/users/${owner}/items/${
    requestOptions.id
  }/protect`;
  return request(url, requestOptions);
}