Class: Zitadel::Client::Zitadel

Inherits:
Object
  • Object
show all
Defined in:
lib/zitadel/client/zitadel.rb

Overview

Main entry point for the Zitadel SDK.

Initializes and configures the SDK with the provided authentication strategy. Sets up service APIs for interacting with various Zitadel features. noinspection RubyTooManyInstanceVariablesInspection

Instance Attribute Summary collapse

Authentication Entry Points collapse

Instance Method Summary collapse

Constructor Details

#initialize(authenticator) {|@configuration| ... } ⇒ Zitadel

Initialize the Zitadel SDK.

rubocop:disable Metrics/MethodLength, Metrics/AbcSize

Parameters:

  • authenticator (Authenticator)

    the authentication strategy to use

Yields:

  • (@configuration)


46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/zitadel/client/zitadel.rb', line 46

def initialize(authenticator)
  # noinspection RubyArgCount
  @configuration = Configuration.new(authenticator)
  yield @configuration if block_given?

  client = ApiClient.new(@configuration)

  @features = Api::FeatureServiceApi.new(client)
  @idps = Api::IdentityProviderServiceApi.new(client)
  @oidc = Api::OIDCServiceApi.new(client)
  @organizations = Api::OrganizationServiceApi.new(client)
  @saml = Api::SAMLServiceApi.new(client)
  @sessions = Api::SessionServiceApi.new(client)
  @settings = Api::SettingsServiceApi.new(client)
  @users = Api::UserServiceApi.new(client)
  @webkeys = Api::WebKeyServiceApi.new(client)
  @actions = Api::ActionServiceApi.new(client)
  @applications = Api::ApplicationServiceApi.new(client)
  @authorizations = Api::AuthorizationServiceApi.new(client)
  @beta_projects = Api::BetaProjectServiceApi.new(client)
  @beta_apps = Api::BetaAppServiceApi.new(client)
  @beta_oidc = Api::BetaOIDCServiceApi.new(client)
  @beta_users = Api::BetaUserServiceApi.new(client)
  @beta_organizations = Api::BetaOrganizationServiceApi.new(client)
  @beta_settings = Api::BetaSettingsServiceApi.new(client)
  @beta_permissions = Api::BetaInternalPermissionServiceApi.new(client)
  @beta_authorizations = Api::BetaAuthorizationServiceApi.new(client)
  @beta_sessions = Api::BetaSessionServiceApi.new(client)
  @beta_instance = Api::BetaInstanceServiceApi.new(client)
  @beta_telemetry = Api::BetaTelemetryServiceApi.new(client)
  @instances = Api::InstanceServiceApi.new(client)
  @internal_permissions = Api::InternalPermissionServiceApi.new(client)
  @beta_features = Api::BetaFeatureServiceApi.new(client)
  @beta_webkeys = Api::BetaWebKeyServiceApi.new(client)
  @beta_actions = Api::BetaActionServiceApi.new(client)
  @projects = Api::ProjectServiceApi.new(client)
end

Instance Attribute Details

#actionsObject (readonly)

rubocop:disable Metrics/ClassLength



11
12
13
# File 'lib/zitadel/client/zitadel.rb', line 11

def actions
  @actions
end

#applicationsObject (readonly)

rubocop:disable Metrics/ClassLength



11
12
13
# File 'lib/zitadel/client/zitadel.rb', line 11

def applications
  @applications
end

#authorizationsObject (readonly)

rubocop:disable Metrics/ClassLength



11
12
13
# File 'lib/zitadel/client/zitadel.rb', line 11

def authorizations
  @authorizations
end

#beta_actionsObject (readonly)

rubocop:disable Metrics/ClassLength



11
12
13
# File 'lib/zitadel/client/zitadel.rb', line 11

def beta_actions
  @beta_actions
end

#beta_appsObject (readonly)

rubocop:disable Metrics/ClassLength



11
12
13
# File 'lib/zitadel/client/zitadel.rb', line 11

def beta_apps
  @beta_apps
end

#beta_authorizationsObject (readonly)

rubocop:disable Metrics/ClassLength



11
12
13
# File 'lib/zitadel/client/zitadel.rb', line 11

def beta_authorizations
  @beta_authorizations
end

#beta_featuresObject (readonly)

rubocop:disable Metrics/ClassLength



11
12
13
# File 'lib/zitadel/client/zitadel.rb', line 11

def beta_features
  @beta_features
end

#beta_instanceObject (readonly)

rubocop:disable Metrics/ClassLength



11
12
13
# File 'lib/zitadel/client/zitadel.rb', line 11

def beta_instance
  @beta_instance
end

#beta_oidcObject (readonly)

rubocop:disable Metrics/ClassLength



11
12
13
# File 'lib/zitadel/client/zitadel.rb', line 11

def beta_oidc
  @beta_oidc
end

#beta_organizationsObject (readonly)

rubocop:disable Metrics/ClassLength



11
12
13
# File 'lib/zitadel/client/zitadel.rb', line 11

def beta_organizations
  @beta_organizations
end

#beta_permissionsObject (readonly)

rubocop:disable Metrics/ClassLength



11
12
13
# File 'lib/zitadel/client/zitadel.rb', line 11

def beta_permissions
  @beta_permissions
end

#beta_projectsObject (readonly)

rubocop:disable Metrics/ClassLength



11
12
13
# File 'lib/zitadel/client/zitadel.rb', line 11

def beta_projects
  @beta_projects
end

#beta_sessionsObject (readonly)

rubocop:disable Metrics/ClassLength



11
12
13
# File 'lib/zitadel/client/zitadel.rb', line 11

def beta_sessions
  @beta_sessions
end

#beta_settingsObject (readonly)

rubocop:disable Metrics/ClassLength



11
12
13
# File 'lib/zitadel/client/zitadel.rb', line 11

def beta_settings
  @beta_settings
end

#beta_telemetryObject (readonly)

rubocop:disable Metrics/ClassLength



11
12
13
# File 'lib/zitadel/client/zitadel.rb', line 11

def beta_telemetry
  @beta_telemetry
end

#beta_usersObject (readonly)

rubocop:disable Metrics/ClassLength



11
12
13
# File 'lib/zitadel/client/zitadel.rb', line 11

def beta_users
  @beta_users
end

#beta_webkeysObject (readonly)

rubocop:disable Metrics/ClassLength



11
12
13
# File 'lib/zitadel/client/zitadel.rb', line 11

def beta_webkeys
  @beta_webkeys
end

#featuresObject (readonly)

rubocop:disable Metrics/ClassLength



11
12
13
# File 'lib/zitadel/client/zitadel.rb', line 11

def features
  @features
end

#idpsObject (readonly)

rubocop:disable Metrics/ClassLength



11
12
13
# File 'lib/zitadel/client/zitadel.rb', line 11

def idps
  @idps
end

#instancesObject (readonly)

rubocop:disable Metrics/ClassLength



11
12
13
# File 'lib/zitadel/client/zitadel.rb', line 11

def instances
  @instances
end

#internal_permissionsObject (readonly)

rubocop:disable Metrics/ClassLength



11
12
13
# File 'lib/zitadel/client/zitadel.rb', line 11

def internal_permissions
  @internal_permissions
end

#oidcObject (readonly)

rubocop:disable Metrics/ClassLength



11
12
13
# File 'lib/zitadel/client/zitadel.rb', line 11

def oidc
  @oidc
end

#organizationsObject (readonly)

rubocop:disable Metrics/ClassLength



11
12
13
# File 'lib/zitadel/client/zitadel.rb', line 11

def organizations
  @organizations
end

#projectsObject (readonly)

rubocop:disable Metrics/ClassLength



11
12
13
# File 'lib/zitadel/client/zitadel.rb', line 11

def projects
  @projects
end

#samlObject (readonly)

rubocop:disable Metrics/ClassLength



11
12
13
# File 'lib/zitadel/client/zitadel.rb', line 11

def saml
  @saml
end

#sessionsObject (readonly)

rubocop:disable Metrics/ClassLength



11
12
13
# File 'lib/zitadel/client/zitadel.rb', line 11

def sessions
  @sessions
end

#settingsObject (readonly)

rubocop:disable Metrics/ClassLength



11
12
13
# File 'lib/zitadel/client/zitadel.rb', line 11

def settings
  @settings
end

#usersObject (readonly)

rubocop:disable Metrics/ClassLength



11
12
13
# File 'lib/zitadel/client/zitadel.rb', line 11

def users
  @users
end

#webkeysObject (readonly)

rubocop:disable Metrics/ClassLength



11
12
13
# File 'lib/zitadel/client/zitadel.rb', line 11

def webkeys
  @webkeys
end

Class Method Details

.with_access_token(host, access_token, transport_options: nil, &block) ⇒ Zitadel

Initialize the SDK with a Personal Access Token (PAT).

Parameters:

  • host (String)

    API URL (e.g. “api.zitadel.example.com”).

  • access_token (String)

    Personal Access Token for Bearer authentication.

  • transport_options (TransportOptions, nil) (defaults to: nil)

    Optional transport options for TLS, proxy, and headers.

Returns:

  • (Zitadel)

    Configured Zitadel client instance.

See Also:



96
97
98
99
100
101
102
# File 'lib/zitadel/client/zitadel.rb', line 96

def with_access_token(host, access_token, transport_options: nil, &block)
  resolved = transport_options || TransportOptions.defaults
  new(Auth::PersonalAccessTokenAuthenticator.new(host, access_token)) do |config|
    apply_transport_options(config, resolved)
    block&.call(config)
  end
end

.with_client_credentials(host, client_id, client_secret, transport_options: nil, &block) ⇒ Zitadel

Initialize the SDK using OAuth2 Client Credentials flow.

Parameters:

  • host (String)

    API URL.

  • client_id (String)

    OAuth2 client identifier.

  • client_secret (String)

    OAuth2 client secret.

  • transport_options (TransportOptions, nil) (defaults to: nil)

    Optional transport options for TLS, proxy, and headers.

Returns:

  • (Zitadel)

    Configured Zitadel client instance with token auto-refresh.

See Also:



112
113
114
115
116
117
118
119
120
121
122
# File 'lib/zitadel/client/zitadel.rb', line 112

def with_client_credentials(host, client_id, client_secret, transport_options: nil, &block)
  resolved = transport_options || TransportOptions.defaults
  new(
    Auth::ClientCredentialsAuthenticator
      .builder(host, client_id, client_secret, transport_options: resolved)
      .build
  ) do |config|
    apply_transport_options(config, resolved)
    block&.call(config)
  end
end

.with_private_key(host, key_file, transport_options: nil, &block) ⇒ Zitadel

Initialize the SDK via Private Key JWT assertion.

Parameters:

  • host (String)

    API URL.

  • key_file (String)

    Path to service account JSON/PEM key file.

  • transport_options (TransportOptions, nil) (defaults to: nil)

    Optional transport options for TLS, proxy, and headers.

Returns:

  • (Zitadel)

    Configured Zitadel client instance using JWT assertion.

See Also:



131
132
133
134
135
136
137
138
# File 'lib/zitadel/client/zitadel.rb', line 131

def with_private_key(host, key_file, transport_options: nil, &block)
  resolved = transport_options || TransportOptions.defaults
  new(Auth::WebTokenAuthenticator.from_json(host, key_file,
                                            transport_options: resolved)) do |config|
    apply_transport_options(config, resolved)
    block&.call(config)
  end
end