[comment]: # translation:outdated

[comment]: # ({065d382b-065d382b})
# hanode.get

[comment]: # ({/065d382b-065d382b})

[comment]: # ({ced44c2d-6959a37d})
### Opis

`integer/array hanode.get(object parameters)`

Ta metoda umożliwia pobranie listy węzłów klastra wysokiej dostępności
zgodnie z podanymi parametrami.

::: noteclassic
Ta metoda jest dostępna tylko dla użytkowników typu *Super admin*.
Więcej informacji można znaleźć w sekcji [User
roles](/manual/web_interface/frontend_sections/users/user_roles).
:::

[comment]: # ({/ced44c2d-6959a37d})

[comment]: # ({be1dbd39-029d9518})
### Parametry

`(object)` Parametry definiujące żądane dane wyjściowe.

Metoda obsługuje następujące parametry.

|Parametr|[Typ](/manual/api/reference_commentary#data-types)|Opis|
|--|--|------|
|ha\_nodeids|ID/array|Zwraca tylko węzły o podanych identyfikatorach węzłów.|
|filter|object|Zwraca tylko te wyniki, które dokładnie odpowiadają podanemu filtrowi.<br><br>Akceptuje obiekt, w którym kluczami są nazwy właściwości, a wartościami są pojedyncza wartość lub tablica wartości do dopasowania.<br><br>Obsługiwane właściwości: `name`, `address`, `status`.|
|sortfield|string/array|Sortuje wynik według podanych właściwości.<br><br>Możliwe wartości: `name`, `lastaccess`, `status`.|
|countOutput|flag|Te parametry opisano w [komentarzu referencyjnym](/manual/api/reference_commentary#common-get-method-parameters).|
|limit|integer|^|
|output|query|^|
|preservekeys|boolean|^|
|sortorder|string/array|^|

[comment]: # ({/be1dbd39-029d9518})

[comment]: # ({7223bab1-7223bab1})
### Zwracane wartości

`(integer/array)` Zwraca:

-   tablicę obiektów;
-   liczbę pobranych obiektów, jeśli został użyty parametr `countOutput`.

[comment]: # ({/7223bab1-7223bab1})

[comment]: # ({b41637d2-b41637d2})
### Przykłady

[comment]: # ({/b41637d2-b41637d2})

[comment]: # ({3c66d4ac-ed719206})
#### Pobierz listę węzłów uporządkowaną według statusu

[Żądanie](/manual/api#performing-requests):

```json
{
    "jsonrpc": "2.0",
    "method": "hanode.get",
    "params": {
        "preservekeys": true,
        "sortfield": "status",
        "sortorder": "DESC"
    },
    "id": 1
}
```

Odpowiedź:

```json
{
  "jsonrpc": "2.0",
  "result": {
    "ckuo7i1nw000h0sajj3l3hh8u": {
      "ha_nodeid": "ckuo7i1nw000h0sajj3l3hh8u",
      "name": "node-active",
      "address": "192.168.1.13",
      "port": "10051",
      "lastaccess": "1635335704",
      "status": "3"
    },
    "ckuo7i1nw000e0sajwfttc1mp": {
      "ha_nodeid": "ckuo7i1nw000e0sajwfttc1mp",
      "name": "node6",
      "address": "192.168.1.10",
      "port": "10053",
      "lastaccess": "1635332902",
      "status": "2"
    },
    "ckuo7i1nv000c0sajz85xcrtt": {
      "ha_nodeid": "ckuo7i1nv000c0sajz85xcrtt",
      "name": "node4",
      "address": "192.168.1.8",
      "port": "10052",
      "lastaccess": "1635334214",
      "status": "1"
    },
    "ckuo7i1nv000a0saj1fcdkeu4": {
      "ha_nodeid": "ckuo7i1nv000a0saj1fcdkeu4",
      "name": "node2",
      "address": "192.168.1.6",
      "port": "10051",
      "lastaccess": "1635335705",
      "status": "0"
    }
  },
  "id": 1
}
```

[comment]: # ({/3c66d4ac-ed719206})

[comment]: # ({92e44ed9-7cb963f4})
#### Pobierz listę określonych węzłów według ich identyfikatorów

[Żądanie](/manual/api#performing-requests):

```json
{
    "jsonrpc": "2.0",
    "method": "hanode.get",
    "params": {
        "ha_nodeids": ["ckuo7i1nw000e0sajwfttc1mp", "ckuo7i1nv000c0sajz85xcrtt"]
    },
    "id": 1
}
```

Odpowiedź:

```json
{
    "jsonrpc": "2.0",
    "result": [
        {
            "ha_nodeid": "ckuo7i1nv000c0sajz85xcrtt",
            "name": "node4",
            "address": "192.168.1.8",
            "port": "10052",
            "lastaccess": "1635334214",
            "status": "1"
        },
        {
            "ha_nodeid": "ckuo7i1nw000e0sajwfttc1mp",
            "name": "node6",
            "address": "192.168.1.10",
            "port": "10053",
            "lastaccess": "1635332902",
            "status": "2"
        }
    ],
    "id": 1
}
```

[comment]: # ({/92e44ed9-7cb963f4})

[comment]: # ({2eba6468-acac81bc})
#### Pobierz listę zatrzymanych węzłów

[Żądanie](/manual/api#performing-requests):

```json
{
    "jsonrpc": "2.0",
    "method": "hanode.get",
    "params": {
        "output": ["ha_nodeid", "address", "port"],
        "filter": {
            "status": 1
        }
    },
    "id": 1
}
```

Odpowiedź:

```json
{
    "jsonrpc": "2.0",
    "result": [
        {
            "ha_nodeid": "ckuo7i1nw000g0sajjsjre7e3",
            "address": "192.168.1.12",
            "port": "10051"
        },
        {
            "ha_nodeid": "ckuo7i1nv000c0sajz85xcrtt",
            "address": "192.168.1.8",
            "port": "10052"
        },
        {
            "ha_nodeid": "ckuo7i1nv000d0sajd95y1b6x",
            "address": "192.168.1.9",
            "port": "10053"
        }
    ],
    "id": 1
}
```

[comment]: # ({/2eba6468-acac81bc})

[comment]: # ({810f375f-f14ff801})
#### Pobierz liczbę węzłów zapasowych

[Żądanie](/manual/api#performing-requests):

```json
{
    "jsonrpc": "2.0",
    "method": "hanode.get",
    "params": {
        "countOutput": true,
        "filter": {
            "status": 0
        }
    },
    "id": 1
}
```

Odpowiedź:

```json
{
    "jsonrpc": "2.0",
    "result": "3",
    "id": 1
}
```

[comment]: # ({/810f375f-f14ff801})

[comment]: # ({b5cf86b7-ed7236c1})
#### Sprawdzenie statusu węzłów pod określonymi adresami IP

[Żądanie](/manual/api#performing-requests):

```json
{
    "jsonrpc": "2.0",
    "method": "hanode.get",
    "params": {
        "output": ["name", "status"],
        "filter": {
            "address": ["192.168.1.7", "192.168.1.13"]
        }
    },
    "id": 1
}
```

Odpowiedź:

```json
{
    "jsonrpc": "2.0",
    "result": [
        {
            "name": "node3",
            "status": "0"
        },
        {
            "name": "node-active",
            "status": "3"
        }
    ],
    "id": 1
}
```

[comment]: # ({/b5cf86b7-ed7236c1})

[comment]: # ({698a6e58-698a6e58})
### Źródło

CHaNode::get() w *ui/include/classes/api/services/CHaNode.php*.

[comment]: # ({/698a6e58-698a6e58})
