# usage()

Canonical URL: https://developers.iagenify.com/ar/sdk/ref/cloud/usage/
Language: ar

`api.cloud.usage() → Promise<Usage>`

كل ما يُبقي الحساب في IaGenify سحابة، في كائن واحد: الخطة، الخدمات الثلاث، كل تخزين مع سقفه الخاص، والإضافات.

Status: GET /api/cloud/usage · free · computed on read

لا شيء هنا هو مخبأ: الأحجام هي الأحجام المسجلة لكل مخزن، والسقفات يعاد حسابها من الخطة و الإضافات في اللحظة التي تسأل. يدعو اثنان أي جانب من الكتابة الكبيرة يعطي جوابين مختلفين.

## القيمة المُعادة {#returns}

```javascript
{
  pack: "go",                              // "free" | "go" | "starter"

  nosql: {
    usedBytes: 8_720_384,
    includedBytes: 1_048_576_000,          // ceiling × how many the plan allows
    quotaBytes: 1_048_576_000,             // included + the add-on pool
    perBaseBytes: 524_288_000,             // the ceiling of ONE storage
    bases: 2,
    maxBases: 2,
    overQuota: false,
    available: true,
    storages: [
      { id: "…", label: "App data",  usedBytes: 8_716_288, quotaBytes: 524_288_000, overQuota: false },
      { id: "…", label: "Reporting", usedBytes: 4_096,     quotaBytes: 524_288_000, overQuota: false }
    ]
  },

  sql:    { /* same shape */ },
  object: { /* same shape */ , hostingBytes: 2_310_144 },

  addons: {
    databaseGb: 0,
    objectGb: 1,
    renewsAt: "2026-11-02T10:14:00.000Z",
    lapsed: false,
    monthlyCredits: 200,
    pricePerGb: { database: 100, object: 200 }
  }
}
```

## مجموع الخدمة، الميدان حسب الميدان {#service}

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `usedBytes` | integer |  | كل ما تحمله الخدمة `object` أنه **مُدرج** `hostingBytes`. |
| `includedBytes` | integer |  | `perBaseBytes × maxBases` - ما تقدمه الخطة قبل أي إضافة |
| `quotaBytes` | integer |  | `includedBytes` بالإضافة إلى المسبح الإضافي المتاح لهذه الخدمة |
| `perBaseBytes` | integer |  | سقف مخزن وحيد **الرقم الذي تم الحكم عليه بالكتابة** |
| `bases` | integer |  | كم عدد المخازن الموجودة لهذه الخدمة. |
| `maxBases` | integer |  | عدد ما تسمح به الخطة. `bases` يعني رفض واحد آخر. |
| `overQuota` | boolean |  | « متى المجمل » أي ما يكون المحق : `quotaBytes` *أو* أي تخزين واحد يمر بسقفه الخاص |
| `available` | boolean |  | ما إذا كان يمكن استخدام الخدمة الآن. |
| `storages` | array |  | قيد واحد لكل مخزن: `id`, `label`, `usedBytes`, `quotaBytes`, `overQuota`. |

## ما هو العدد الذي يظهر، وما الذي يجب العمل على {#which-number}

> **الدالة الدالة الدالة الدالة الدالة الدالة الدالة الدالة الدالة الدالة الدالة الدالة الدالة الدالة الدالة  na**
>
> يمكن أن يكون شريط التقدم في مجموع الخدمة عند 40% بينما يتم رفض إدخال، لأن تخزين واحد كامل. أظهر الرقم لكل مخزن حيثما كان المستخدم على وشك الكتابة، واحتفظ بالمجموع لموجز.

```javascript
function roomFor(usage, storage) {
  const service = usage[storage.service];                       // "nosql" | "sql" | "object"
  const base = service.storages.find((s) => s.id === storage.id);
  return base ? Math.max(0, base.quotaBytes - base.usedBytes) : null;
}
```

## لـ سببان {#overquota}

It is true when the service total passes what the account has, **and** when a single storage passes its own ceiling — the second being the case a total can never reveal. Reading the per-storage flag tells you which.

## جاريتات، على كائن فقط {#hosting}

ما يبقيه مضيفي الحساب على الإنترنت. يتم إخراجه من سقف الجسم قبل حساب الرقم المطابق للخزنة، IaGenify -لحساب الحساب

## الـ اض// كتلة {#addons}

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `databaseGb · objectGb` | integer |  | Gigabytes حالياً محتجزة، حسب الإضافة. |
| `renewsAt` | string|null |  | عندما تنتهي الفترة، يقسم المبلغ الذي يُشتري قبل ذلك المبلغ تناسبيا. |
| `lapsed` | boolean |  | ولم يكن من الممكن دفع مبلغ التجديد: فصندوق النقدية المشترك معلق، والسقف يعود إلى الخطة. |
| `monthlyCredits` | integer |  | ما هي تكلفة إضافة إلى كل فترة، كل معا. |
| `pricePerGb` | object |  | `{ database: 100, object: 200 }` - الأرصدة الدائنة لكل غيغابايت عن كل فترة. |

> **"مُمَا سَيُثَقَتَمَتَهُ هَيَز**
>
> وبالإضافة إلى ذلك، يتم تعليق السقف مرة أخرى إلى أسفل، لذلك التخزين الذي كان مريحا يصبح كاملا دون أي شيء مكتوب. يتم إعادة تجربة بركة السباحة، وتعود بمجرد أن تكون الأرصدة هناك.

## هناك أمران يستحقان أن يفعلا بها {#patterns}

```javascript
// 1. Before creating a storage — is one allowed at all?
const usage = await api.cloud.usage();
if (usage.nosql.bases >= usage.nosql.maxBases) {
  // api.storage.create() would answer cloud_storage_limit
}

// 2. Before a large write — will it fit?
const bytes = Buffer.byteLength(payload);
const left = usage.object.storages[0].quotaBytes - usage.object.storages[0].usedBytes;
if (bytes > left) {
  // Free something, or api.cloud.addons.buy({ service: "object", gb: 1 })
}
```

- [addons.buy()](/ar/sdk/ref/cloud/addons-buy): رفع السقف، وما يكلفه.
- [الحصص والخطط](/ar/sdk/ref/cloud/quotas): ما تتضمنه كل خطة، كل تخزين
- [IaGenify سحاب](/ar/sdk/ref/providers/iagenify-cloud): التخزين هذا هو الإجراء

```python
{
    "pack": "go",                              # "free" | "go" | "starter"

    "nosql": {
        "usedBytes": 8_720_384,
        "includedBytes": 1_048_576_000,        # ceiling × how many the plan allows
        "quotaBytes": 1_048_576_000,           # included + the add-on pool
        "perBaseBytes": 524_288_000,           # the ceiling of ONE storage
        "bases": 2,
        "maxBases": 2,
        "overQuota": False,
        "available": True,
        "storages": [
            {"id": "…", "label": "App data",  "usedBytes": 8_716_288, "quotaBytes": 524_288_000, "overQuota": False},
            {"id": "…", "label": "Reporting", "usedBytes": 4_096,     "quotaBytes": 524_288_000, "overQuota": False},
        ],
    },

    "sql": {},                                 # same shape as nosql
    "object": {"hostingBytes": 2_310_144},     # same shape as nosql, plus hostingBytes

    "addons": {
        "databaseGb": 0,
        "objectGb": 1,
        "renewsAt": "2026-11-02T10:14:00.000Z",
        "lapsed": False,
        "monthlyCredits": 200,
        "pricePerGb": {"database": 100, "object": 200},
    },
}
```

```python
def room_for(usage, storage):
    service = usage[storage.service]                    # "nosql" | "sql" | "object"
    base = next((s for s in service["storages"] if s["id"] == storage.id), None)
    return max(0, base["quotaBytes"] - base["usedBytes"]) if base else None
```

```python
# 1. Before creating a storage — is one allowed at all?
usage = api.cloud.usage()
if usage["nosql"]["bases"] >= usage["nosql"]["maxBases"]:
    pass  # api.storage.create() would answer cloud_storage_limit

# 2. Before a large write — will it fit?
size = len(payload)
first = usage["object"]["storages"][0]
if size > first["quotaBytes"] - first["usedBytes"]:
    pass  # Free something, or api.cloud.addons.buy(service="object", gb=1)
```
