Skip to content

Commit

Permalink
derive jsonschema for generated sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
mach-kernel committed Jul 15, 2024
1 parent db21400 commit f57c48d
Show file tree
Hide file tree
Showing 19 changed files with 37 additions and 16 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ gsed -r -i -e 's/(\[dependencies\])/\1\nschemars = "0.8.11"/' dbr_repo/Cargo.tom

# Secrets API
openapi-generator generate -g rust -i openapi/secrets-aws.yaml -c openapi/config-secrets.yaml -o dbr_secrets
sed -i -e 's/derive(Clone/derive(JsonSchema, Clone/' dbr_secrets/src/models/*
sed -i -e 's/\/\*/use schemars::JsonSchema;\n\/\*/' dbr_secrets/src/models/*
sed -r -i -e 's/(\[dependencies\])/\1\nschemars = "0.8.11"/' dbr_secrets/Cargo.toml
```
### Expand CRD macros
Expand Down
1 change: 1 addition & 0 deletions databricks-rust-secrets/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ license = "Unlicense"
edition = "2021"

[dependencies]
schemars = "0.8.11"
serde = { version = "^1.0", features = ["derive"] }
serde_json = "^1.0"
url = "^2.5"
Expand Down
3 changes: 2 additions & 1 deletion databricks-rust-secrets/src/models/workspace_acl_item.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use schemars::JsonSchema;
/*
* Databricks Accounts and Workspace REST API on ALL
*
Expand All @@ -11,7 +12,7 @@
use crate::models;
use serde::{Deserialize, Serialize};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
#[derive(JsonSchema, Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct WorkspaceAclItem {
/// The permission level applied to the principal.
#[serde(rename = "permission")]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use schemars::JsonSchema;
/*
* Databricks Accounts and Workspace REST API on ALL
*
Expand All @@ -12,7 +13,7 @@ use crate::models;
use serde::{Deserialize, Serialize};

///
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
#[derive(JsonSchema, Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum WorkspaceAclPermission {
#[serde(rename = "READ")]
Read,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use schemars::JsonSchema;
/*
* Databricks Accounts and Workspace REST API on ALL
*
Expand All @@ -11,7 +12,7 @@
use crate::models;
use serde::{Deserialize, Serialize};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
#[derive(JsonSchema, Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct WorkspaceAzureKeyVaultSecretScopeMetadata {
/// The DNS of the KeyVault
#[serde(rename = "dns_name")]
Expand Down
3 changes: 2 additions & 1 deletion databricks-rust-secrets/src/models/workspace_create_scope.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use schemars::JsonSchema;
/*
* Databricks Accounts and Workspace REST API on ALL
*
Expand All @@ -11,7 +12,7 @@
use crate::models;
use serde::{Deserialize, Serialize};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
#[derive(JsonSchema, Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct WorkspaceCreateScope {
/// The metadata for the secret scope if the type is `AZURE_KEYVAULT`
#[serde(rename = "backend_azure_keyvault", skip_serializing_if = "Option::is_none")]
Expand Down
3 changes: 2 additions & 1 deletion databricks-rust-secrets/src/models/workspace_delete_acl.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use schemars::JsonSchema;
/*
* Databricks Accounts and Workspace REST API on ALL
*
Expand All @@ -11,7 +12,7 @@
use crate::models;
use serde::{Deserialize, Serialize};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
#[derive(JsonSchema, Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct WorkspaceDeleteAcl {
/// The principal to remove an existing ACL from.
#[serde(rename = "principal")]
Expand Down
3 changes: 2 additions & 1 deletion databricks-rust-secrets/src/models/workspace_delete_scope.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use schemars::JsonSchema;
/*
* Databricks Accounts and Workspace REST API on ALL
*
Expand All @@ -11,7 +12,7 @@
use crate::models;
use serde::{Deserialize, Serialize};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
#[derive(JsonSchema, Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct WorkspaceDeleteScope {
/// Name of the scope to delete.
#[serde(rename = "scope")]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use schemars::JsonSchema;
/*
* Databricks Accounts and Workspace REST API on ALL
*
Expand All @@ -11,7 +12,7 @@
use crate::models;
use serde::{Deserialize, Serialize};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
#[derive(JsonSchema, Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct WorkspaceDeleteSecret {
/// Name of the secret to delete.
#[serde(rename = "key")]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use schemars::JsonSchema;
/*
* Databricks Accounts and Workspace REST API on ALL
*
Expand All @@ -11,7 +12,7 @@
use crate::models;
use serde::{Deserialize, Serialize};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
#[derive(JsonSchema, Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct WorkspaceGetSecretResponse {
/// A unique name to identify the secret.
#[serde(rename = "key", skip_serializing_if = "Option::is_none")]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use schemars::JsonSchema;
/*
* Databricks Accounts and Workspace REST API on ALL
*
Expand All @@ -11,7 +12,7 @@
use crate::models;
use serde::{Deserialize, Serialize};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
#[derive(JsonSchema, Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct WorkspaceListAclsResponse {
/// The associated ACLs rule applied to principals in the given scope.
#[serde(rename = "items", skip_serializing_if = "Option::is_none")]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use schemars::JsonSchema;
/*
* Databricks Accounts and Workspace REST API on ALL
*
Expand All @@ -11,7 +12,7 @@
use crate::models;
use serde::{Deserialize, Serialize};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
#[derive(JsonSchema, Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct WorkspaceListScopesResponse {
/// The available secret scopes.
#[serde(rename = "scopes", skip_serializing_if = "Option::is_none")]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use schemars::JsonSchema;
/*
* Databricks Accounts and Workspace REST API on ALL
*
Expand All @@ -11,7 +12,7 @@
use crate::models;
use serde::{Deserialize, Serialize};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
#[derive(JsonSchema, Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct WorkspaceListSecretsResponse {
/// Metadata information of all secrets contained within the given scope.
#[serde(rename = "secrets", skip_serializing_if = "Option::is_none")]
Expand Down
3 changes: 2 additions & 1 deletion databricks-rust-secrets/src/models/workspace_put_acl.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use schemars::JsonSchema;
/*
* Databricks Accounts and Workspace REST API on ALL
*
Expand All @@ -11,7 +12,7 @@
use crate::models;
use serde::{Deserialize, Serialize};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
#[derive(JsonSchema, Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct WorkspacePutAcl {
/// The permission level applied to the principal.
#[serde(rename = "permission")]
Expand Down
3 changes: 2 additions & 1 deletion databricks-rust-secrets/src/models/workspace_put_secret.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use schemars::JsonSchema;
/*
* Databricks Accounts and Workspace REST API on ALL
*
Expand All @@ -11,7 +12,7 @@
use crate::models;
use serde::{Deserialize, Serialize};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
#[derive(JsonSchema, Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct WorkspacePutSecret {
/// If specified, value will be stored as bytes.
#[serde(rename = "bytes_value", skip_serializing_if = "Option::is_none")]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use schemars::JsonSchema;
/*
* Databricks Accounts and Workspace REST API on ALL
*
Expand All @@ -12,7 +13,7 @@ use crate::models;
use serde::{Deserialize, Serialize};

///
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
#[derive(JsonSchema, Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum WorkspaceScopeBackendType {
#[serde(rename = "DATABRICKS")]
Databricks,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use schemars::JsonSchema;
/*
* Databricks Accounts and Workspace REST API on ALL
*
Expand All @@ -11,7 +12,7 @@
use crate::models;
use serde::{Deserialize, Serialize};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
#[derive(JsonSchema, Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct WorkspaceSecretMetadata {
/// A unique name to identify the secret.
#[serde(rename = "key", skip_serializing_if = "Option::is_none")]
Expand Down
3 changes: 2 additions & 1 deletion databricks-rust-secrets/src/models/workspace_secret_scope.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use schemars::JsonSchema;
/*
* Databricks Accounts and Workspace REST API on ALL
*
Expand All @@ -11,7 +12,7 @@
use crate::models;
use serde::{Deserialize, Serialize};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
#[derive(JsonSchema, Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct WorkspaceSecretScope {
/// The type of secret scope backend.
#[serde(rename = "backend_type", skip_serializing_if = "Option::is_none")]
Expand Down

0 comments on commit f57c48d

Please sign in to comment.