# BranchesApi

All URIs are relative to *https://www.gitlab.com/api/v4*

|Method | HTTP request | Description|
|------------- | ------------- | -------------|
|[**deleteApiV4ProjectsIdRepositoryBranchesBranch**](#deleteapiv4projectsidrepositorybranchesbranch) | **DELETE** /projects/{id}/repository/branches/{branch} | |
|[**deleteApiV4ProjectsIdRepositoryMergedBranches**](#deleteapiv4projectsidrepositorymergedbranches) | **DELETE** /projects/{id}/repository/merged_branches | |
|[**getApiV4ProjectsIdRepositoryBranches**](#getapiv4projectsidrepositorybranches) | **GET** /projects/{id}/repository/branches | |
|[**getApiV4ProjectsIdRepositoryBranchesBranch**](#getapiv4projectsidrepositorybranchesbranch) | **GET** /projects/{id}/repository/branches/{branch} | |
|[**headApiV4ProjectsIdRepositoryBranchesBranch**](#headapiv4projectsidrepositorybranchesbranch) | **HEAD** /projects/{id}/repository/branches/{branch} | |
|[**postApiV4ProjectsIdRepositoryBranches**](#postapiv4projectsidrepositorybranches) | **POST** /projects/{id}/repository/branches | |
|[**putApiV4ProjectsIdRepositoryBranchesBranchProtect**](#putapiv4projectsidrepositorybranchesbranchprotect) | **PUT** /projects/{id}/repository/branches/{branch}/protect | |
|[**putApiV4ProjectsIdRepositoryBranchesBranchUnprotect**](#putapiv4projectsidrepositorybranchesbranchunprotect) | **PUT** /projects/{id}/repository/branches/{branch}/unprotect | |

# **deleteApiV4ProjectsIdRepositoryBranchesBranch**
> deleteApiV4ProjectsIdRepositoryBranchesBranch()

Delete a branch

### Example

```typescript
import {
    BranchesApi,
    Configuration,
    DeleteApiV4ProjectsIdRepositoryMergedBranchesIdParameter
} from 'berg';

const configuration = new Configuration();
const apiInstance = new BranchesApi(configuration);

let id: DeleteApiV4ProjectsIdRepositoryMergedBranchesIdParameter; //The ID or [URL-encoded path of the project](https://docs.gitlab.com/api/rest/#namespaced-paths). (default to undefined)
let branch: string; //The name of the branch (default to undefined)

const { status, data } = await apiInstance.deleteApiV4ProjectsIdRepositoryBranchesBranch(
    id,
    branch
);
```

### Parameters

|Name | Type | Description  | Notes|
|------------- | ------------- | ------------- | -------------|
| **id** | **DeleteApiV4ProjectsIdRepositoryMergedBranchesIdParameter** | The ID or [URL-encoded path of the project](https://docs.gitlab.com/api/rest/#namespaced-paths). | defaults to undefined|
| **branch** | [**string**] | The name of the branch | defaults to undefined|


### Return type

void (empty response body)

### Authorization

[ApiKeyAuth](../README.md#ApiKeyAuth)

### HTTP request headers

 - **Content-Type**: Not defined
 - **Accept**: Not defined


### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
|**204** | Delete a branch |  -  |
|**404** | Branch Not Found |  -  |

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

# **deleteApiV4ProjectsIdRepositoryMergedBranches**
> deleteApiV4ProjectsIdRepositoryMergedBranches()

Delete all merged branches

### Example

```typescript
import {
    BranchesApi,
    Configuration,
    DeleteApiV4ProjectsIdRepositoryMergedBranchesIdParameter
} from 'berg';

const configuration = new Configuration();
const apiInstance = new BranchesApi(configuration);

let id: DeleteApiV4ProjectsIdRepositoryMergedBranchesIdParameter; //The ID or [URL-encoded path of the project](https://docs.gitlab.com/api/rest/#namespaced-paths). (default to undefined)

const { status, data } = await apiInstance.deleteApiV4ProjectsIdRepositoryMergedBranches(
    id
);
```

### Parameters

|Name | Type | Description  | Notes|
|------------- | ------------- | ------------- | -------------|
| **id** | **DeleteApiV4ProjectsIdRepositoryMergedBranchesIdParameter** | The ID or [URL-encoded path of the project](https://docs.gitlab.com/api/rest/#namespaced-paths). | defaults to undefined|


### Return type

void (empty response body)

### Authorization

[ApiKeyAuth](../README.md#ApiKeyAuth)

### HTTP request headers

 - **Content-Type**: Not defined
 - **Accept**: Not defined


### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
|**202** | 202 Accepted |  -  |
|**404** | 404 Project Not Found |  -  |

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

# **getApiV4ProjectsIdRepositoryBranches**
> Array<APIEntitiesBranch> getApiV4ProjectsIdRepositoryBranches()

Get a project repository branches

### Example

```typescript
import {
    BranchesApi,
    Configuration,
    DeleteApiV4ProjectsIdRepositoryMergedBranchesIdParameter
} from 'berg';

const configuration = new Configuration();
const apiInstance = new BranchesApi(configuration);

let id: DeleteApiV4ProjectsIdRepositoryMergedBranchesIdParameter; //The ID or [URL-encoded path of the project](https://docs.gitlab.com/api/rest/#namespaced-paths). (default to undefined)
let page: number; //Current page number (optional) (default to 1)
let perPage: number; //Number of items per page (optional) (default to 20)
let search: string; //Return list of branches matching the search criteria (optional) (default to undefined)
let regex: string; //Return list of branches matching the regex (optional) (default to undefined)
let sort: 'name_asc' | 'updated_asc' | 'updated_desc'; //Return list of branches sorted by the given field (optional) (default to undefined)
let pageToken: string; //Name of branch to start the pagination from (optional) (default to undefined)

const { status, data } = await apiInstance.getApiV4ProjectsIdRepositoryBranches(
    id,
    page,
    perPage,
    search,
    regex,
    sort,
    pageToken
);
```

### Parameters

|Name | Type | Description  | Notes|
|------------- | ------------- | ------------- | -------------|
| **id** | **DeleteApiV4ProjectsIdRepositoryMergedBranchesIdParameter** | The ID or [URL-encoded path of the project](https://docs.gitlab.com/api/rest/#namespaced-paths). | defaults to undefined|
| **page** | [**number**] | Current page number | (optional) defaults to 1|
| **perPage** | [**number**] | Number of items per page | (optional) defaults to 20|
| **search** | [**string**] | Return list of branches matching the search criteria | (optional) defaults to undefined|
| **regex** | [**string**] | Return list of branches matching the regex | (optional) defaults to undefined|
| **sort** | [**&#39;name_asc&#39; | &#39;updated_asc&#39; | &#39;updated_desc&#39;**]**Array<&#39;name_asc&#39; &#124; &#39;updated_asc&#39; &#124; &#39;updated_desc&#39;>** | Return list of branches sorted by the given field | (optional) defaults to undefined|
| **pageToken** | [**string**] | Name of branch to start the pagination from | (optional) defaults to undefined|


### Return type

**Array<APIEntitiesBranch>**

### Authorization

[ApiKeyAuth](../README.md#ApiKeyAuth)

### HTTP request headers

 - **Content-Type**: Not defined
 - **Accept**: application/json


### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
|**200** | Get a project repository branches |  -  |
|**404** | 404 Project Not Found |  -  |

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

# **getApiV4ProjectsIdRepositoryBranchesBranch**
> APIEntitiesBranch getApiV4ProjectsIdRepositoryBranchesBranch()

Get a single repository branch

### Example

```typescript
import {
    BranchesApi,
    Configuration,
    DeleteApiV4ProjectsIdRepositoryMergedBranchesIdParameter
} from 'berg';

const configuration = new Configuration();
const apiInstance = new BranchesApi(configuration);

let id: DeleteApiV4ProjectsIdRepositoryMergedBranchesIdParameter; //The ID or [URL-encoded path of the project](https://docs.gitlab.com/api/rest/#namespaced-paths). (default to undefined)
let branch: number; // (default to undefined)

const { status, data } = await apiInstance.getApiV4ProjectsIdRepositoryBranchesBranch(
    id,
    branch
);
```

### Parameters

|Name | Type | Description  | Notes|
|------------- | ------------- | ------------- | -------------|
| **id** | **DeleteApiV4ProjectsIdRepositoryMergedBranchesIdParameter** | The ID or [URL-encoded path of the project](https://docs.gitlab.com/api/rest/#namespaced-paths). | defaults to undefined|
| **branch** | [**number**] |  | defaults to undefined|


### Return type

**APIEntitiesBranch**

### Authorization

[ApiKeyAuth](../README.md#ApiKeyAuth)

### HTTP request headers

 - **Content-Type**: Not defined
 - **Accept**: application/json


### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
|**200** | Get a single repository branch |  -  |
|**404** | Branch Not Found |  -  |

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

# **headApiV4ProjectsIdRepositoryBranchesBranch**
> headApiV4ProjectsIdRepositoryBranchesBranch()

Check if a branch exists

### Example

```typescript
import {
    BranchesApi,
    Configuration,
    DeleteApiV4ProjectsIdRepositoryMergedBranchesIdParameter
} from 'berg';

const configuration = new Configuration();
const apiInstance = new BranchesApi(configuration);

let id: DeleteApiV4ProjectsIdRepositoryMergedBranchesIdParameter; //The ID or [URL-encoded path of the project](https://docs.gitlab.com/api/rest/#namespaced-paths). (default to undefined)
let branch: string; //The name of the branch (default to undefined)

const { status, data } = await apiInstance.headApiV4ProjectsIdRepositoryBranchesBranch(
    id,
    branch
);
```

### Parameters

|Name | Type | Description  | Notes|
|------------- | ------------- | ------------- | -------------|
| **id** | **DeleteApiV4ProjectsIdRepositoryMergedBranchesIdParameter** | The ID or [URL-encoded path of the project](https://docs.gitlab.com/api/rest/#namespaced-paths). | defaults to undefined|
| **branch** | [**string**] | The name of the branch | defaults to undefined|


### Return type

void (empty response body)

### Authorization

[ApiKeyAuth](../README.md#ApiKeyAuth)

### HTTP request headers

 - **Content-Type**: Not defined
 - **Accept**: Not defined


### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
|**204** | No Content |  -  |
|**404** | Not Found |  -  |

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

# **postApiV4ProjectsIdRepositoryBranches**
> APIEntitiesBranch postApiV4ProjectsIdRepositoryBranches()

Create branch

### Example

```typescript
import {
    BranchesApi,
    Configuration,
    DeleteApiV4ProjectsIdRepositoryMergedBranchesIdParameter
} from 'berg';

const configuration = new Configuration();
const apiInstance = new BranchesApi(configuration);

let id: DeleteApiV4ProjectsIdRepositoryMergedBranchesIdParameter; //The ID or [URL-encoded path of the project](https://docs.gitlab.com/api/rest/#namespaced-paths). (default to undefined)
let branch: string; //The name of the branch (default to undefined)
let ref: string; //Create branch from commit sha or existing branch (default to undefined)

const { status, data } = await apiInstance.postApiV4ProjectsIdRepositoryBranches(
    id,
    branch,
    ref
);
```

### Parameters

|Name | Type | Description  | Notes|
|------------- | ------------- | ------------- | -------------|
| **id** | **DeleteApiV4ProjectsIdRepositoryMergedBranchesIdParameter** | The ID or [URL-encoded path of the project](https://docs.gitlab.com/api/rest/#namespaced-paths). | defaults to undefined|
| **branch** | [**string**] | The name of the branch | defaults to undefined|
| **ref** | [**string**] | Create branch from commit sha or existing branch | defaults to undefined|


### Return type

**APIEntitiesBranch**

### Authorization

[ApiKeyAuth](../README.md#ApiKeyAuth)

### HTTP request headers

 - **Content-Type**: Not defined
 - **Accept**: application/json


### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
|**201** | Create branch |  -  |
|**400** | Failed to create branch |  -  |

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

# **putApiV4ProjectsIdRepositoryBranchesBranchProtect**
> APIEntitiesBranch putApiV4ProjectsIdRepositoryBranchesBranchProtect()

Protect a single branch

### Example

```typescript
import {
    BranchesApi,
    Configuration,
    DeleteApiV4ProjectsIdRepositoryMergedBranchesIdParameter,
    PutApiV4ProjectsIdRepositoryBranchesBranchProtectRequest
} from 'berg';

const configuration = new Configuration();
const apiInstance = new BranchesApi(configuration);

let id: DeleteApiV4ProjectsIdRepositoryMergedBranchesIdParameter; //The ID or [URL-encoded path of the project](https://docs.gitlab.com/api/rest/#namespaced-paths). (default to undefined)
let branch: string; //The name of the branch (default to undefined)
let putApiV4ProjectsIdRepositoryBranchesBranchProtectRequest: PutApiV4ProjectsIdRepositoryBranchesBranchProtectRequest; // (optional)

const { status, data } = await apiInstance.putApiV4ProjectsIdRepositoryBranchesBranchProtect(
    id,
    branch,
    putApiV4ProjectsIdRepositoryBranchesBranchProtectRequest
);
```

### Parameters

|Name | Type | Description  | Notes|
|------------- | ------------- | ------------- | -------------|
| **putApiV4ProjectsIdRepositoryBranchesBranchProtectRequest** | **PutApiV4ProjectsIdRepositoryBranchesBranchProtectRequest**|  | |
| **id** | **DeleteApiV4ProjectsIdRepositoryMergedBranchesIdParameter** | The ID or [URL-encoded path of the project](https://docs.gitlab.com/api/rest/#namespaced-paths). | defaults to undefined|
| **branch** | [**string**] | The name of the branch | defaults to undefined|


### Return type

**APIEntitiesBranch**

### Authorization

[ApiKeyAuth](../README.md#ApiKeyAuth)

### HTTP request headers

 - **Content-Type**: application/json
 - **Accept**: application/json


### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
|**200** | Protect a single branch |  -  |
|**404** | 404 Branch Not Found |  -  |

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

# **putApiV4ProjectsIdRepositoryBranchesBranchUnprotect**
> APIEntitiesBranch putApiV4ProjectsIdRepositoryBranchesBranchUnprotect()

Unprotect a single branch

### Example

```typescript
import {
    BranchesApi,
    Configuration,
    DeleteApiV4ProjectsIdRepositoryMergedBranchesIdParameter
} from 'berg';

const configuration = new Configuration();
const apiInstance = new BranchesApi(configuration);

let id: DeleteApiV4ProjectsIdRepositoryMergedBranchesIdParameter; //The ID or [URL-encoded path of the project](https://docs.gitlab.com/api/rest/#namespaced-paths). (default to undefined)
let branch: string; //The name of the branch (default to undefined)

const { status, data } = await apiInstance.putApiV4ProjectsIdRepositoryBranchesBranchUnprotect(
    id,
    branch
);
```

### Parameters

|Name | Type | Description  | Notes|
|------------- | ------------- | ------------- | -------------|
| **id** | **DeleteApiV4ProjectsIdRepositoryMergedBranchesIdParameter** | The ID or [URL-encoded path of the project](https://docs.gitlab.com/api/rest/#namespaced-paths). | defaults to undefined|
| **branch** | [**string**] | The name of the branch | defaults to undefined|


### Return type

**APIEntitiesBranch**

### Authorization

[ApiKeyAuth](../README.md#ApiKeyAuth)

### HTTP request headers

 - **Content-Type**: Not defined
 - **Accept**: application/json


### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
|**200** | Unprotect a single branch |  -  |
|**404** | 404 Project Not Found |  -  |

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

