Skip to content

Commit ed5b547

Browse files
authored
Feature - Jobs (#7)
* Jobs API Client * Additional Documentation on DoxyFiles and Jobs * Version 0.2.0 with Jobs Unit Tests * Reconfigure Directory and Include Jobs_Types.h
1 parent cc3c521 commit ed5b547

35 files changed

+1148
-53
lines changed

.github/workflows/docs.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Deploy Documentation
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
concurrency:
14+
group: "pages"
15+
cancel-in-progress: false
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
25+
- name: Install Doxygen
26+
run: |
27+
sudo apt-get update
28+
sudo apt-get install -y doxygen graphviz
29+
30+
- name: Generate Documentation
31+
run: doxygen Doxyfile
32+
33+
- name: Setup Pages
34+
uses: actions/configure-pages@v4
35+
36+
- name: Upload artifact
37+
uses: actions/upload-pages-artifact@v3
38+
with:
39+
path: 'docs/html'
40+
41+
deploy:
42+
environment:
43+
name: github-pages
44+
url: ${{ steps.deployment.outputs.page_url }}
45+
runs-on: ubuntu-latest
46+
needs: build
47+
48+
steps:
49+
- name: Deploy to GitHub Pages
50+
id: deployment
51+
uses: actions/deploy-pages@v4

CMakeLists.txt

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required(VERSION 3.14)
22
project(databricks_sdk
3-
VERSION 0.1.0
3+
VERSION 0.2.0
44
DESCRIPTION "Databricks C++ SDK"
55
LANGUAGES CXX)
66

@@ -86,27 +86,33 @@ endif()
8686

8787
# External libraries
8888
find_package(spdlog CONFIG REQUIRED)
89+
find_package(CURL REQUIRED)
90+
find_package(nlohmann_json REQUIRED)
8991

9092
# Library sources
9193
set(SOURCES
92-
src/client.cpp
93-
src/config.cpp
94+
src/core/client.cpp
95+
src/core/config.cpp
96+
src/jobs/jobs.cpp
9497
src/connection_pool.cpp
9598
src/internal/pool_manager.cpp
9699
src/internal/logger.cpp
100+
src/internal/http_client.cpp
97101
)
98102

99103
set(HEADERS
100-
include/databricks/client.h
101-
include/databricks/config.h
104+
include/databricks/core/client.h
105+
include/databricks/core/config.h
102106
include/databricks/connection_pool.h
103107
include/databricks/version.h
108+
include/databricks/jobs/jobs.h
104109
)
105110

106111
# Internal headers (not installed)
107112
set(INTERNAL_HEADERS
108113
src/internal/pool_manager.h
109114
src/internal/logger.h
115+
src/internal/http_client.h
110116
)
111117

112118
# Create library target
@@ -122,16 +128,17 @@ target_include_directories(databricks_sdk
122128
)
123129

124130
# Link ODBC libraries
125-
target_link_libraries(databricks_sdk PRIVATE
131+
target_link_libraries(databricks_sdk PRIVATE
126132
${ODBC_LIBRARIES}
127133
spdlog::spdlog
134+
CURL::libcurl
135+
nlohmann_json::nlohmann_json
128136
)
129137

130138
# Set library properties
131139
set_target_properties(databricks_sdk PROPERTIES
132140
VERSION ${PROJECT_VERSION}
133141
SOVERSION ${PROJECT_VERSION_MAJOR}
134-
PUBLIC_HEADER "${HEADERS}"
135142
)
136143

137144
# Set RPATH for finding ODBC libraries at runtime (Unix/Linux/macOS only)
@@ -170,7 +177,12 @@ install(TARGETS databricks_sdk
170177
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
171178
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
172179
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
173-
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/databricks
180+
)
181+
182+
# Install headers with directory structure preserved
183+
install(DIRECTORY include/databricks/
184+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/databricks
185+
FILES_MATCHING PATTERN "*.h"
174186
)
175187

176188
install(EXPORT databricks_sdk-targets

Doxyfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ GENERATE_HTML = YES
1818
GENERATE_LATEX = NO
1919
HTML_OUTPUT = html
2020
HTML_FILE_EXTENSION = .html
21+
HTML_EXTRA_FILES = docs/html/.nojekyll
2122

2223
# Documentation extraction
2324
EXTRACT_ALL = YES

README.md

Lines changed: 110 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,15 @@
22

33
[![Latest Release](https://img.shields.io/github/v/release/calvinjmin/databricks-sdk-cpp?display_name=tag&sort=semver)](https://github.com/calvinjmin/databricks-sdk-cpp/releases/latest)
44
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5+
[![Documentation](https://img.shields.io/badge/docs-online-blue.svg)](https://calvinjmin.github.io/databricks-sdk-cpp/)
56

67
A C++ SDK for Databricks, providing an interface for interacting with Databricks services.
78

8-
**Latest Release**: [v0.1.0](https://github.com/calvinjmin/databricks-sdk-cpp/releases/tag/v0.1.0) | **Author**: Calvin Min ([email protected])
9+
**Latest Release**: [v0.1.0](https://github.com/calvinjmin/databricks-sdk-cpp/releases/tag/v0.1.0)
10+
11+
**Author**: Calvin Min ([email protected])
12+
13+
---
914

1015
## Table of Contents
1116

@@ -112,7 +117,7 @@ include(FetchContent)
112117
FetchContent_Declare(
113118
databricks_sdk
114119
GIT_REPOSITORY https://github.com/calvinjmin/databricks-sdk-cpp.git
115-
GIT_TAG v0.1.0 # or use 'main' for latest
120+
GIT_TAG main # latest tag or declare a specific version like 0.1.0
116121
)
117122
118123
FetchContent_MakeAvailable(databricks_sdk)
@@ -494,6 +499,9 @@ After building with `BUILD_EXAMPLES=ON`, examples are organized by feature:
494499
```bash
495500
# Simple SQL query
496501
./examples/simple_query
502+
503+
# Jobs API - list jobs, get details, trigger runs
504+
./examples/jobs_example
497505
```
498506

499507
### Connection Pooling Examples
@@ -571,6 +579,58 @@ Async operations reduce perceived latency by performing work in the background:
571579

572580
## Advanced Usage
573581

582+
### Jobs API
583+
584+
Interact with Databricks Jobs to automate and orchestrate data workflows:
585+
586+
```cpp
587+
#include <databricks/jobs.h>
588+
#include <databricks/config.h>
589+
590+
int main() {
591+
// Load auth configuration
592+
databricks::AuthConfig auth = databricks::AuthConfig::from_environment();
593+
594+
// Create Jobs API client
595+
databricks::Jobs jobs(auth);
596+
597+
// List all jobs
598+
auto job_list = jobs.list_jobs(25, 0);
599+
for (const auto& job : job_list) {
600+
std::cout << "Job: " << job.name
601+
<< " (ID: " << job.job_id << ")" << std::endl;
602+
}
603+
604+
// Get specific job details
605+
auto job = jobs.get_job(123456789);
606+
std::cout << "Created by: " << job.creator_user_name << std::endl;
607+
608+
// Trigger a job run with parameters
609+
std::map<std::string, std::string> params;
610+
params["date"] = "2024-01-01";
611+
params["environment"] = "production";
612+
613+
uint64_t run_id = jobs.run_now(123456789, params);
614+
std::cout << "Started run: " << run_id << std::endl;
615+
616+
return 0;
617+
}
618+
```
619+
620+
**Key Features:**
621+
- **List jobs**: Paginated listing with limit/offset support
622+
- **Get job details**: Retrieve full job configuration and metadata
623+
- **Trigger runs**: Start jobs with optional notebook parameters
624+
- **Type-safe IDs**: Uses `uint64_t` to correctly handle large job IDs
625+
- **JSON parsing**: Built on `nlohmann/json` for reliable parsing
626+
627+
**API Compatibility:**
628+
- Uses Jobs API 2.2 for full feature support including pagination
629+
- Timestamps returned as Unix milliseconds (`uint64_t`)
630+
- Automatic error handling with descriptive messages
631+
632+
For a complete example, see `examples/basic/jobs_example.cpp`.
633+
574634
### Direct ConnectionPool Management
575635

576636
For advanced users who need fine-grained control over connection pools:
@@ -605,24 +665,60 @@ std::cout << "Available: " << stats.available_connections << std::endl;
605665
606666
## Documentation
607667
608-
Generate API documentation from code comments:
668+
The SDK includes comprehensive API documentation generated from code comments using Doxygen.
669+
670+
### 📚 View Online Documentation
671+
672+
**Live Documentation**: [https://calvinjmin.github.io/databricks-sdk-cpp/](https://calvinjmin.github.io/databricks-sdk-cpp/)
673+
674+
The documentation is automatically built and published via GitHub Actions whenever changes are pushed to the `main` branch.
675+
676+
### Generate Documentation Locally
609677
610678
```bash
611-
# Install Doxygen (macOS)
612-
brew install doxygen
679+
# Install Doxygen
680+
brew install doxygen # macOS
681+
# or: sudo apt-get install doxygen # Linux
613682
614-
# Generate documentation
615-
make docs
683+
# Generate docs (creates docs/html/)
684+
doxygen Doxyfile
616685
617-
# Open documentation in browser
618-
open docs/html/index.html
686+
# View in browser
687+
open docs/html/index.html # macOS
688+
# or: xdg-open docs/html/index.html # Linux
689+
```
690+
691+
### Documentation Features
692+
693+
The generated documentation includes:
694+
695+
- **Complete API Reference**: All public classes, methods, and structs with detailed descriptions
696+
- **README Integration**: Full README displayed as the main landing page
697+
- **Code Examples**: Inline examples from header comments
698+
- **Jobs API Documentation**: Full reference for `databricks::Jobs`, `Job`, and `JobRun` types
699+
- **SQL Client Documentation**: Complete `databricks::Client` API reference
700+
- **Connection Pooling**: `databricks::ConnectionPool` and configuration types
701+
- **Source Browser**: Browse source code with syntax highlighting
702+
- **Search Functionality**: Quick search across all documentation
703+
- **Cross-references**: Navigate between related classes and methods
704+
705+
### Quick Links (After Generation)
706+
707+
- **Main Page**: `docs/html/index.html` - README and getting started
708+
- **Classes**: `docs/html/annotated.html` - All classes and structs
709+
- **Jobs API**: `docs/html/classdatabricks_1_1_jobs.html` - Jobs API reference
710+
- **Client API**: `docs/html/classdatabricks_1_1_client.html` - SQL client reference
711+
- **Files**: `docs/html/files.html` - Browse by file
712+
713+
### Example: Viewing Jobs API Docs
714+
715+
```bash
716+
# Generate and open Jobs API documentation
717+
doxygen Doxyfile
718+
open docs/html/classdatabricks_1_1_jobs.html
619719
```
620720

621-
The documentation includes:
622-
- API reference for all classes and methods
623-
- Code examples from comments
624-
- Class diagrams and inheritance trees
625-
- Search functionality
721+
The documentation is automatically generated from the inline comments in header files, ensuring it stays synchronized with the code.
626722

627723
## License
628724

examples/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ target_link_libraries(secure_query PRIVATE databricks_sdk)
1010
add_executable(modular_config_example basic/modular_config_example.cpp)
1111
target_link_libraries(modular_config_example PRIVATE databricks_sdk)
1212

13+
add_executable(jobs_example basic/jobs_example.cpp)
14+
target_link_libraries(jobs_example PRIVATE databricks_sdk)
15+
1316
# ========== Connection Pooling Examples ==========
1417
add_executable(transparent_pooling pooling/transparent_pooling.cpp)
1518
target_link_libraries(transparent_pooling PRIVATE databricks_sdk)
@@ -33,6 +36,7 @@ set_target_properties(
3336
benchmark
3437
async_operations
3538
pool_async_combined
39+
jobs_example
3640
PROPERTIES
3741
BUILD_RPATH "${CMAKE_BINARY_DIR};/opt/homebrew/lib;/usr/local/lib"
3842
INSTALL_RPATH "/opt/homebrew/lib;/usr/local/lib"

examples/async/async_operations.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include <databricks/client.h>
1+
#include <databricks/core/client.h>
22
#include "../common/config_helper.h"
33
#include <iostream>
44
#include <chrono>

examples/async/pool_async_combined.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include <databricks/client.h>
1+
#include <databricks/core/client.h>
22
#include <databricks/connection_pool.h>
33
#include "../common/config_helper.h"
44
#include <iostream>

0 commit comments

Comments
 (0)