or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

data-sources.mddata-types.mdindex.mdscheduling.mdservice-clients.mdtransfer-configs.mdtransfer-runs.md

service-clients.mddocs/

0

# Service Clients

1

2

Primary client interfaces for interacting with Google Cloud BigQuery Data Transfer Service. Both synchronous and asynchronous clients provide identical functionality with comprehensive CRUD operations for transfer configurations and monitoring capabilities.

3

4

## Capabilities

5

6

### DataTransferServiceClient

7

8

The main synchronous client class providing access to all BigQuery Data Transfer Service operations.

9

10

```python { .api }

11

class DataTransferServiceClient:

12

def __init__(

13

self,

14

credentials: Optional[ga_credentials.Credentials] = None,

15

transport: Optional[Union[str, DataTransferServiceTransport]] = None,

16

client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None,

17

client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,

18

):

19

"""

20

Instantiate the data transfer service client.

21

22

Args:

23

credentials: The authorization credentials to attach to requests.

24

transport: The transport to use for API calls.

25

client_options: Client options for configuring requests.

26

client_info: Information about the client library.

27

"""

28

```

29

30

#### Client Configuration

31

32

```python { .api }

33

@property

34

def transport(self) -> DataTransferServiceTransport:

35

"""Returns the transport used by the client instance."""

36

37

@property

38

def api_endpoint(self) -> str:

39

"""Return the API endpoint used by the client instance."""

40

41

@property

42

def universe_domain(self) -> str:

43

"""Return the universe domain used by the client instance."""

44

```

45

46

#### Alternative Constructors

47

48

```python { .api }

49

@classmethod

50

def from_service_account_info(cls, info: dict, *args, **kwargs):

51

"""

52

Create a client from service account info dict.

53

54

Args:

55

info: Service account info in Google format.

56

57

Returns:

58

DataTransferServiceClient: The constructed client.

59

"""

60

61

@classmethod

62

def from_service_account_file(cls, filename: str, *args, **kwargs):

63

"""

64

Create a client from a service account json file.

65

66

Args:

67

filename: Path to service account json file.

68

69

Returns:

70

DataTransferServiceClient: The constructed client.

71

"""

72

```

73

74

#### Context Manager Support

75

76

```python { .api }

77

def __enter__(self) -> "DataTransferServiceClient":

78

"""Enter context manager."""

79

80

def __exit__(self, type, value, traceback):

81

"""Exit context manager."""

82

```

83

84

### DataTransferServiceAsyncClient

85

86

The asynchronous version of the client providing the same functionality with async/await support.

87

88

```python { .api }

89

class DataTransferServiceAsyncClient:

90

def __init__(

91

self,

92

credentials: Optional[ga_credentials.Credentials] = None,

93

transport: Optional[Union[str, DataTransferServiceAsyncTransport]] = None,

94

client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None,

95

client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,

96

):

97

"""

98

Instantiate the async data transfer service client.

99

100

Args:

101

credentials: The authorization credentials to attach to requests.

102

transport: The transport to use for API calls.

103

client_options: Client options for configuring requests.

104

client_info: Information about the client library.

105

"""

106

```

107

108

All methods in `DataTransferServiceAsyncClient` mirror those in `DataTransferServiceClient` but return coroutines that must be awaited.

109

110

## Usage Examples

111

112

### Basic Client Setup

113

114

```python

115

from google.cloud import bigquery_datatransfer

116

117

# Using default credentials

118

client = bigquery_datatransfer.DataTransferServiceClient()

119

120

# Using service account file

121

client = bigquery_datatransfer.DataTransferServiceClient.from_service_account_file(

122

"path/to/service-account.json"

123

)

124

125

# Using service account info

126

service_account_info = {

127

"type": "service_account",

128

"project_id": "your-project",

129

# ... other service account fields

130

}

131

client = bigquery_datatransfer.DataTransferServiceClient.from_service_account_info(

132

service_account_info

133

)

134

```

135

136

### Async Client Usage

137

138

```python

139

import asyncio

140

from google.cloud import bigquery_datatransfer

141

142

async def main():

143

# Create async client

144

client = bigquery_datatransfer.DataTransferServiceAsyncClient()

145

146

# Use async methods

147

parent = f"projects/{project_id}/locations/{location}"

148

response = await client.list_data_sources(parent=parent)

149

150

async for data_source in response:

151

print(f"Data Source: {data_source.display_name}")

152

153

# Clean up

154

await client.transport.close()

155

156

# Run async function

157

asyncio.run(main())

158

```

159

160

### Context Manager Usage

161

162

```python

163

from google.cloud import bigquery_datatransfer

164

165

# Automatic resource cleanup

166

with bigquery_datatransfer.DataTransferServiceClient() as client:

167

parent = f"projects/{project_id}/locations/{location}"

168

data_sources = client.list_data_sources(parent=parent)

169

170

for data_source in data_sources:

171

print(f"Data Source: {data_source.display_name}")

172

```

173

174

## Resource Path Utilities

175

176

Both client classes provide static methods for constructing and parsing resource paths:

177

178

```python { .api }

179

@staticmethod

180

def data_source_path(project: str, location: str, data_source: str) -> str:

181

"""Return a fully-qualified data source string."""

182

183

@staticmethod

184

def parse_data_source_path(path: str) -> Dict[str, str]:

185

"""Parse a data source path into its component segments."""

186

187

@staticmethod

188

def transfer_config_path(project: str, location: str, transfer_config: str) -> str:

189

"""Return a fully-qualified transfer config string."""

190

191

@staticmethod

192

def parse_transfer_config_path(path: str) -> Dict[str, str]:

193

"""Parse a transfer config path into its component segments."""

194

195

@staticmethod

196

def run_path(project: str, location: str, transfer_config: str, run: str) -> str:

197

"""Return a fully-qualified run string."""

198

199

@staticmethod

200

def parse_run_path(path: str) -> Dict[str, str]:

201

"""Parse a run path into its component segments."""

202

```

203

204

### Common Resource Paths

205

206

```python { .api }

207

@staticmethod

208

def common_billing_account_path(billing_account: str) -> str:

209

"""Return a fully-qualified billing account string."""

210

211

@staticmethod

212

def common_folder_path(folder: str) -> str:

213

"""Return a fully-qualified folder string."""

214

215

@staticmethod

216

def common_organization_path(organization: str) -> str:

217

"""Return a fully-qualified organization string."""

218

219

@staticmethod

220

def common_project_path(project: str) -> str:

221

"""Return a fully-qualified project string."""

222

223

@staticmethod

224

def common_location_path(project: str, location: str) -> str:

225

"""Return a fully-qualified location string."""

226

```