Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@ovh-ux/ng-ovh-api-wrappers

ovh-ux6.3kBSD-3-Clausedeprecated5.1.0

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

AngularJS component designed to configure ApiEndpoints with the same interface as a $resource yet allow for extended configuration by providing ApiRequests objects that can be modified with chained methods to define the parameters sent Iceberg.

angularjs, component, endpoint, ovh, ovhcloud

readme

ng-ovh-api-wrappers

AngularJS component designed to configure Api Endpoints with the same interface as a $resource yet allow for extended configuration by providing ApiRequests objects that can be modified with chained methods to define the headers to Iceberg.

Downloads Dependencies Dev Dependencies

Install

$ yarn add @ovh-ux/ng-ovh-api-wrappers

Usage

// index.js
import angular from 'angular';
import ngOvhApiWrappers from '@ovh-ux/ng-ovh-api-wrappers';

angular.module('myApp', [ngOvhApiWrappers]);

Iceberg

Simple request

// service.js
function getElements() {
  return iceberg('/api/elements')
    .query()
    .execute({ ...queryParams }, resetCache)
    .$promise;
}

Response is formatted like

{
  data // data returned by the API
  headers // response headers returned
  status // call status
}

Enable aggregation

// service.js
function getAggregatedElements() {
  return iceberg('/api/elements')
    .query()
    .expand(aggregationMode)
    .execute();
}

aggregationMode can be one of those values:

  • CachedObjectList-Cursor
  • CachedObjectList-Pages

Paginate

// service.js
function getPaginatedElements() {
  return iceberg('/api/elements')
    .query()
    .expand('CachedObjectList-Pages')
    .limit(10) // get only 10 results by page
    .offset(2) // get results for page 2
    .execute();
}

Filter

// service.js
function getFilteredElements() {
  return iceberg('/api/elements')
    .query()
    .expand('CachedObjectList-Pages')
    .addFilter('name', 'like', 'iceberg') // get element with name matching iceberg
    .execute();
}
// service.js
function getFilteredElements() {
  return iceberg('/api/elements')
    .query()
    .expand('CachedObjectList-Pages')
    .addFilter('name', 'like', ['iceberg', 'awesome']) // get element with name matching iceberg and awesome
    .execute();
}

Sort

// service.js
function getSortedElements() {
  return iceberg('/api/elements')
    .query()
    .expand('CachedObjectList-Pages')
    .sort('name') // sort elements by ascending names
    .execute();
}
// service.js
function getAggregatedElements() {
  return iceberg('/api/elements')
    .query()
    .expand('CachedObjectList-Pages')
    .sort('name', 'desc') // sort elements by descending names
    .execute();
}

Test

$ yarn test

Contributing

Always feel free to help out! Whether it's filing bugs and feature requests or working on some of the open issues, our contributing guide will help get you started.

License

BSD-3-Clause © OVH SAS

changelog

5.1.0 (2023-01-30)

Features

5.0.0 (2022-07-08)

Code Refactoring

BREAKING CHANGES

  • drop APIv7 support

4.0.11 (2022-03-25)

4.0.10 (2021-12-01)

Bug Fixes

4.0.9 (2021-11-08)

Bug Fixes

  • iceberg: encodeURIComponent filter values (#64) (e4138de)

4.0.8 (2020-08-18)

Bug Fixes

  • deps: add some resolutions (e755fb3)

4.0.7 (2020-03-16)

4.0.6 (2020-01-08)

4.0.5 (2019-11-08)

4.0.4 (2019-08-30)

Bug Fixes

  • deps: upgrade component-rollup-config to v6.0.2 (#40) (20ca5d7)

4.0.3 (2019-08-27)

4.0.2 (2019-07-16)

4.0.1 (2019-07-09)

Bug Fixes

4.0.0 (2019-07-04)

Features

  • iceberg: return response headers (#15) (280ead4)

BREAKING CHANGES

  • iceberg: change response type to return headers Before: returned data After: returns an object formatted like { data, headers, status }

3.0.0 (2019-03-06)

Features

  • iceberg: add request support (5f37d62)
  • add expand with iceberg (22f72ad)
  • iceberg: handle cache cleaning (3e5a776)
  • iceberg: handle cursor mode offset (cd416fa)
  • iceberg: manage iceberg filters (5d2b0f5)
  • iceberg: update descriptions (5faa71a)
  • rename module (aa30929)

BREAKING CHANGES

  • module is now named as ngOvhApiWrappers

2.0.0 (2019-02-19)

Bug Fixes

Code Refactoring

  • update stack with component-rollup-config (fbe0fea)

BREAKING CHANGES

  • module is now named as ngOvhApiv7

1.2.8 (2018-06-14)

Bug Fixes

1.2.5 (2018-06-14)

1.2.4 (2018-06-14)

1.2.3 (2018-04-18)

1.2.2 (2018-04-18)

1.2.1 (2018-04-17)

Bug Fixes

  • package.json: fix repository entry in package.json (e18ed01)

1.2.0 (2018-01-24)

Features

  • aggregation: add possibility to aggregate calls on multiple params (bdfdc0f)

1.1.1 (2017-06-29)