File size: 2,978 Bytes
1477a90
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.

import { type Client } from '../core.js'
import { unwrap, type RequestOptions } from '../lib/types.js'
import { paginatePages } from '../lib/paginate.js'
import {
  listPlanAddons,
  createPlanAddon,
  getPlanAddon,
  updatePlanAddon,
  deletePlanAddon,
} from '../funcs/planAddons.js'
import type {
  ListPlanAddonsRequest,
  ListPlanAddonsResponse,
  CreatePlanAddonRequest,
  CreatePlanAddonResponse,
  GetPlanAddonRequest,
  GetPlanAddonResponse,
  UpdatePlanAddonRequest,
  UpdatePlanAddonResponse,
  DeletePlanAddonRequest,
  DeletePlanAddonResponse,
} from '../models/operations/planAddons.js'
import type { PlanAddon } from '../models/types.js'

export class PlanAddons {
  constructor(private readonly _client: Client) {}

  /**
   * List add-ons for plan
   *
   * List add-ons associated with a plan.
   *
   * GET /openmeter/plans/{planId}/addons
   */
  async list(
    request: ListPlanAddonsRequest,
    options?: RequestOptions,
  ): Promise<ListPlanAddonsResponse> {
    return unwrap(await listPlanAddons(this._client, request, options))
  }

  /**
   * List add-ons for plan
   *
   * List add-ons associated with a plan.
   *
   * Iterates every item across all pages, fetching more as the returned iterable is consumed.
   *
   * GET /openmeter/plans/{planId}/addons
   */
  listAll(
    request: ListPlanAddonsRequest,
    options?: RequestOptions,
  ): AsyncIterable<PlanAddon> {
    return paginatePages(
      (req, opts) => listPlanAddons(this._client, req, opts),
      request,
      options,
    )
  }

  /**
   * Add add-on to plan
   *
   * Add an add-on to a plan.
   *
   * POST /openmeter/plans/{planId}/addons
   */
  async create(
    request: CreatePlanAddonRequest,
    options?: RequestOptions,
  ): Promise<CreatePlanAddonResponse> {
    return unwrap(await createPlanAddon(this._client, request, options))
  }

  /**
   * Get add-on association for plan
   *
   * Get an add-on association for a plan.
   *
   * GET /openmeter/plans/{planId}/addons/{planAddonId}
   */
  async get(
    request: GetPlanAddonRequest,
    options?: RequestOptions,
  ): Promise<GetPlanAddonResponse> {
    return unwrap(await getPlanAddon(this._client, request, options))
  }

  /**
   * Update add-on association for plan
   *
   * Update an add-on association for a plan.
   *
   * PUT /openmeter/plans/{planId}/addons/{planAddonId}
   */
  async update(
    request: UpdatePlanAddonRequest,
    options?: RequestOptions,
  ): Promise<UpdatePlanAddonResponse> {
    return unwrap(await updatePlanAddon(this._client, request, options))
  }

  /**
   * Remove add-on from plan
   *
   * Remove an add-on from a plan.
   *
   * DELETE /openmeter/plans/{planId}/addons/{planAddonId}
   */
  async delete(
    request: DeletePlanAddonRequest,
    options?: RequestOptions,
  ): Promise<DeletePlanAddonResponse> {
    return unwrap(await deletePlanAddon(this._client, request, options))
  }
}