import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'


Every issue identified and reported by the Glasswall engine has a unique issue ID associated. This API provides a summary of all possible issue ID numbers and corresponding high level descriptions.

For a **session** the **GW2GetAllIdInfo** function places XML data populated with Glasswall Issue ID descriptions and value ranges in an output buffer.

<Tabs>

<TabItem value="C++" label="C++" default>

**Synopsis**

For session **session** the **GW2GetAllIdInfo** function places in the object pointed to by **outputBuffer** a pointer to XML data populated with Glasswall Issue ID descriptions and value ranges. The length, in bytes, of the populated output buffer is placed in the **size_t** object pointed to by **bufferLength**.

```cpp

#include "glasswall.core2.api.h"

int GW2GetAllIdInfo(
    Session session,
    size_t *bufferLength,
    char **outputBuffer);

```

**Returns**

Returns an integer `GW2_RetStatus` enum value. Negative numbers indicate a failure. If successful, output buffer
contains the XML file.

**Example**

```cpp
#include "glasswall.core2.api.h"

...

char *outbuf = NULL;
size_t buflen = 0;

if (GW2OpenSession())
    /* error opening session*/
else
{
    int status = GW2GetAllIdInfo(session, &buflen, &outbuf);
    /* Buffer contains the XML file.
    * Either process the data pointed to, or copy the data and process it
    * after the session is closed
    */

    if (GW2CloseSession())
        /* error closing session */
}
```

</TabItem>

<TabItem value="C#" label="C#">

**Synopsis**

```csharp
public int GetAllIdInfo(
    int session,
    ref UIntPtr bufferLength,
    out IntPtr outputBuffer)

```

**Returns**

Returns an integer `GW2_RetStatus` enum value. Negative numbers indicate a failure. If successful, output buffer
contains the XML file.

**Example**

```csharp
...

UIntPtr bufferLength = UIntPtr.Zero;
IntPtr buffer        = new IntPtr();

int session = glasswall.OpenSession();
int returnStatus = glasswall.GetAllIdInfo(session, ref bufferLength, out buffer);

using (StreamWriter writer = new StreamWriter(fileStream))
{
    writer.WriteLine($"GW2GetAllIdInfo completed with status code {returnStatus}");

    if ((int)bufferLength != 0)
    {
        WriteBytesToFile(Path.Combine(di.FullName, $"22 - GW2GetAllIdInfo.xml"),
            glasswall.CreateArrayFromBuffer(buffer, bufferLength)
        );
    }
}

```


</TabItem>

<TabItem value="Java" label="Java">

```java
import com.glasswall.core2javabridge.*;

public String GW2GetAllIdInfoString(int session) throws GlasswallException
```

**Note**

This functionality previously required two separate function calls to retrieve the ID data. This has now been streamlined to return the settings as a `String`. The two original functions have been deprecated.

**Returns**

The **GW2GetAllIdInfoString** function returns a `String` containing a description of all Glasswall IDs.

A **GlasswallException** exception will be thrown if `session` is invalid, or if all ID information could not be retrieved.

**Synopsis - Deprecated Functions**

```java
import com.glasswall.core2javabridge.*;

(Deprecated)
public int GW2GetAllIdInfo(int session) throws GlasswallException
public byte[] GetAllIDBuffer(int session) throws GlasswallException
```

**Description - Deprecated Functions**

The **GW2GetAllIdInfo** function outputs the description of all Glasswall IDs for the session specified by `session` to internal All ID Buffer. Retrieve this data through use of the **GetAllIDBuffer** function. 

**Returns - Deprecated Functions**

The **GW2GetAllIdInfo** function returns a **GW2_RetStatus** enumeration converted to `int`. The value will be negative if an error occurred. `0` indicates success. Refer to the API Overview/Return types for details. 

The **GetAllIDBuffer** returns a byte array containing the Glasswall ID descriptions. This will be null if **GW2GetAllIdInfo** has not been called.

A **GlasswallException** exception will be thrown if `session` is invalid, or if all ID information could not be retrieved.

</TabItem>

<TabItem value="Python" label="Python">

**Synopsis**

Retrieves the XML containing all the Issue ID ranges with their group descriptions.

```py
def get_all_id_info(self, output_file: Optional[str] = None, raise_unsupported: bool = True) -> str:
    """ Retrieves the XML containing all the Issue ID ranges with their group descriptions

    Args:
        output_file (Optional[str], optional): The output file path where the analysis file will be written.
        raise_unsupported (bool, optional): Default True. Raise exceptions when Glasswall encounters an error. Fail silently if False.

    Returns:
        all_id_info (str): A string XML analysis report containing all id info.
    """
```

**Returns**

A string XML analysis report containing all id info.

</TabItem>

<TabItem value="JavaScript" label="JavaScript">


**Synopsis**

```jsx

/**
* This function places a pointer in a specified location to XML data populated with
* Glasswall Issue ID descriptions and value ranges, for a specified session.
*
* @param {number} session The ID of the session.
* @param {number} bufferLength The length of the buffer.
* @param {string} outputBuffer The location of the output buffer.
*/
GW2GetAllIdInfo(
    session,
    bufferLength,
    outputBuffer)

```

**Returns**

Returns an integer `GW2_RetStatus` enum value. Negative numbers indicate a failure.

**Example**
```jsx

const ref = require('ref-napi');

...

function buffer_to_string(buffer, buffer_size) {

    if (!buffer.isNull() && ref.deref(buffer_size) > 0) {
        return Buffer.from(ref.reinterpret(ref.deref(buffer), ref.deref(buffer_size), 0)).toString();
    }
    else {
        return "";
    }
}

...

let output_file_buffer = ref.alloc(ref.refType(ref.types.CString));
let output_buffer_size = ref.alloc(ref.types.size_t, 0);
let return_status      = gw.GW2GetAllIdInfo(session_id, output_buffer_size, output_file_buffer);

let xml_string = buffer_to_string(output_file_buffer, output_buffer_size);

...

```

</TabItem>

</Tabs>