type AccessKey = record {
  updated_at : nat64;
  metadata : vec record { text; text };
  kind : opt AccessKeyKind;
  created_at : nat64;
  scope : AccessKeyScope;
  expires_at : opt nat64;
};
type AccessKeyKind = variant { Emulator; Automation };
type AccessKeyScope = variant { Write; Admin; Submit };
type AssetEncodingNoContent = record {
  modified : nat64;
  sha256 : blob;
  total_length : nat;
};
type AssetKey = record {
  token : opt text;
  collection : text;
  owner : principal;
  name : text;
  description : opt text;
  full_path : text;
};
type AssetNoContent = record {
  key : AssetKey;
  updated_at : nat64;
  encodings : vec record { text; AssetEncodingNoContent };
  headers : vec record { text; text };
  created_at : nat64;
  version : opt nat64;
};
type AssetsUpgradeOptions = record { clear_existing_assets : opt bool };
type AuthenticateAutomationArgs = variant {
  OpenId : OpenIdPrepareAutomationArgs;
};
type AuthenticateAutomationResultResponse = variant {
  Ok : record { principal; AutomationController };
  Err : AuthenticationAutomationError;
};
type AuthenticateResultResponse = variant {
  Ok : Authentication;
  Err : AuthenticationError;
};
type Authentication = record { doc : Doc; delegation : PreparedDelegation };
type AuthenticationArgs = variant { OpenId : OpenIdPrepareDelegationArgs };
type AuthenticationAutomationError = variant {
  PrepareAutomation : PrepareAutomationError;
  RegisterController : text;
  SaveWorkflowMetadata : text;
  SaveUniqueJtiToken : text;
};
type AuthenticationConfig = record {
  updated_at : opt nat64;
  openid : opt AuthenticationConfigOpenId;
  created_at : opt nat64;
  version : opt nat64;
  internet_identity : opt AuthenticationConfigInternetIdentity;
  rules : opt AuthenticationRules;
};
type AuthenticationConfigInternetIdentity = record {
  derivation_origin : opt text;
  external_alternative_origins : opt vec text;
};
type AuthenticationConfigOpenId = record {
  observatory_id : opt principal;
  providers : vec record { OpenIdDelegationProvider; OpenIdAuthProviderConfig };
};
type AuthenticationError = variant {
  PrepareDelegation : PrepareDelegationError;
  RegisterUser : text;
};
type AuthenticationRules = record { allowed_callers : vec principal };
type AutomationConfig = record {
  updated_at : opt nat64;
  openid : opt AutomationConfigOpenId;
  created_at : opt nat64;
  version : opt nat64;
};
type AutomationConfigOpenId = record {
  observatory_id : opt principal;
  providers : vec record {
    OpenIdAutomationProvider;
    OpenIdAutomationProviderConfig;
  };
};
type AutomationController = record {
  scope : AutomationScope;
  expires_at : nat64;
};
type AutomationScope = variant { Write; Submit };
type CertifyAssetsArgs = record {
  cursor : CertifyAssetsCursor;
  strategy : CertifyAssetsStrategy;
  chunk_size : opt nat32;
};
type CertifyAssetsCursor = variant {
  Heap : record { offset : nat64 };
  Stable : record { key : opt AssetKey };
};
type CertifyAssetsResult = record { next_cursor : opt CertifyAssetsCursor };
type CertifyAssetsStrategy = variant { Append; Clear; AppendWithRouting };
type CollectionType = variant { Db; Storage };
type CommitBatch = record {
  batch_id : nat;
  headers : vec record { text; text };
  chunk_ids : vec nat;
};
type CommitProposal = record { sha256 : blob; proposal_id : nat };
type Config = record {
  db : opt DbConfig;
  authentication : opt AuthenticationConfig;
  storage : StorageConfig;
  automation : opt AutomationConfig;
};
type ConfigMaxMemorySize = record { stable : opt nat64; heap : opt nat64 };
type CustomDomain = record {
  updated_at : nat64;
  created_at : nat64;
  version : opt nat64;
  bn_id : opt text;
};
type DbConfig = record {
  updated_at : opt nat64;
  created_at : opt nat64;
  version : opt nat64;
  max_memory_size : opt ConfigMaxMemorySize;
};
type DelDoc = record { version : opt nat64 };
type DelRule = record { version : opt nat64 };
type Delegation = record {
  pubkey : blob;
  targets : opt vec principal;
  expiration : nat64;
};
type DeleteControllersArgs = record { controllers : vec principal };
type DeleteProposalAssets = record { proposal_ids : vec nat };
type DepositCyclesArgs = record { cycles : nat; destination_id : principal };
type Doc = record {
  updated_at : nat64;
  owner : principal;
  data : blob;
  description : opt text;
  created_at : nat64;
  version : opt nat64;
};
type GetDelegationArgs = variant { OpenId : OpenIdGetDelegationArgs };
type GetDelegationError = variant {
  JwtFindProvider : JwtFindProviderError;
  GetCachedJwks;
  NoSuchDelegation;
  JwtVerify : JwtVerifyError;
  GetOrFetchJwks : GetOrRefreshJwksError;
  DeriveSeedFailed : text;
  InvalidObservatoryId : text;
};
type GetDelegationResultResponse = variant {
  Ok : SignedDelegation;
  Err : GetDelegationError;
};
type GetOrRefreshJwksError = variant {
  InvalidConfig : text;
  MissingKid;
  BadClaim : text;
  KeyNotFoundCooldown;
  CertificateNotFound;
  BadSig : text;
  MissingLastAttempt : text;
  KeyNotFound;
  FetchFailed : text;
};
type HttpRequest = record {
  url : text;
  method : text;
  body : blob;
  headers : vec record { text; text };
  certificate_version : opt nat16;
};
type HttpResponse = record {
  body : blob;
  headers : vec record { text; text };
  streaming_strategy : opt StreamingStrategy;
  status_code : nat16;
};
type InitAssetKey = record {
  token : opt text;
  collection : text;
  name : text;
  description : opt text;
  encoding_type : opt text;
  full_path : text;
};
type InitSatelliteArgs = record {
  controllers : vec principal;
  storage : opt InitStorageArgs;
};
type InitStorageArgs = record { system_memory : opt Memory };
type InitUploadResult = record { batch_id : nat };
type JwtFindProviderError = variant {
  BadClaim : text;
  BadSig : text;
  NoMatchingProvider;
};
type JwtVerifyError = variant {
  WrongKeyType;
  MissingKid;
  BadClaim : text;
  BadSig : text;
  NoKeyForKid;
};
type ListMatcher = record {
  key : opt text;
  updated_at : opt TimestampMatcher;
  description : opt text;
  created_at : opt TimestampMatcher;
};
type ListOrder = record { field : ListOrderField; desc : bool };
type ListOrderField = variant { UpdatedAt; Keys; CreatedAt };
type ListPaginate = record { start_after : opt text; limit : opt nat64 };
type ListParams = record {
  order : opt ListOrder;
  owner : opt principal;
  matcher : opt ListMatcher;
  paginate : opt ListPaginate;
};
type ListProposalResults = record {
  matches_length : nat64;
  items : vec record { ProposalKey; Proposal };
  items_length : nat64;
};
type ListProposalsOrder = record { desc : bool };
type ListProposalsPaginate = record { start_after : opt nat; limit : opt nat };
type ListProposalsParams = record {
  order : opt ListProposalsOrder;
  paginate : opt ListProposalsPaginate;
};
type ListResults = record {
  matches_pages : opt nat64;
  matches_length : nat64;
  items_page : opt nat64;
  items : vec record { text; AssetNoContent };
  items_length : nat64;
};
type ListResults_1 = record {
  matches_pages : opt nat64;
  matches_length : nat64;
  items_page : opt nat64;
  items : vec record { text; Doc };
  items_length : nat64;
};
type ListRulesMatcher = record { include_system : bool };
type ListRulesParams = record { matcher : opt ListRulesMatcher };
type ListRulesResults = record {
  matches_length : nat64;
  items : vec record { text; Rule };
  items_length : nat64;
};
type Memory = variant { Heap; Stable };
type MemorySize = record { stable : nat64; heap : nat64 };
type OpenIdAuthProviderConfig = record {
  delegation : opt OpenIdAuthProviderDelegationConfig;
  client_id : text;
};
type OpenIdAuthProviderDelegationConfig = record {
  targets : opt vec principal;
  max_time_to_live : opt nat64;
};
type OpenIdAutomationProvider = variant { GitHub };
type OpenIdAutomationProviderConfig = record {
  controller : opt OpenIdAutomationProviderControllerConfig;
  repositories : vec record { RepositoryKey; OpenIdAutomationRepositoryConfig };
};
type OpenIdAutomationProviderControllerConfig = record {
  scope : opt AutomationScope;
  max_time_to_live : opt nat64;
};
type OpenIdAutomationRepositoryConfig = record { refs : opt vec text };
type OpenIdDelegationProvider = variant { GitHub; Google };
type OpenIdGetDelegationArgs = record {
  jwt : text;
  session_key : blob;
  salt : blob;
  expiration : nat64;
};
type OpenIdPrepareAutomationArgs = record { jwt : text; salt : blob };
type OpenIdPrepareDelegationArgs = record {
  jwt : text;
  session_key : blob;
  salt : blob;
};
type Permission = variant { Controllers; Private; Public; Managed };
type PrepareAutomationError = variant {
  JwtFindProvider : JwtFindProviderError;
  InvalidController : text;
  GetCachedJwks;
  JwtVerify : JwtVerifyError;
  GetOrFetchJwks : GetOrRefreshJwksError;
  ControllerAlreadyExists;
  InvalidObservatoryId : text;
  TooManyControllers : text;
};
type PrepareDelegationError = variant {
  JwtFindProvider : JwtFindProviderError;
  GetCachedJwks;
  JwtVerify : JwtVerifyError;
  GetOrFetchJwks : GetOrRefreshJwksError;
  DeriveSeedFailed : text;
  InvalidObservatoryId : text;
};
type PreparedDelegation = record { user_key : blob; expiration : nat64 };
type Proposal = record {
  status : ProposalStatus;
  updated_at : nat64;
  sha256 : opt blob;
  executed_at : opt nat64;
  owner : principal;
  created_at : nat64;
  version : opt nat64;
  proposal_type : ProposalType;
};
type ProposalKey = record { proposal_id : nat };
type ProposalStatus = variant {
  Initialized;
  Failed;
  Open;
  Rejected;
  Executed;
  Accepted;
};
type ProposalType = variant {
  AssetsUpgrade : AssetsUpgradeOptions;
  SegmentsDeployment : SegmentsDeploymentOptions;
};
type RateConfig = record { max_tokens : nat64; time_per_token_ns : nat64 };
type RepositoryKey = record { owner : text; name : text };
type Rule = record {
  max_capacity : opt nat32;
  memory : opt Memory;
  updated_at : nat64;
  max_size : opt nat;
  read : Permission;
  created_at : nat64;
  version : opt nat64;
  mutable_permissions : opt bool;
  rate_config : opt RateConfig;
  write : Permission;
  max_changes_per_user : opt nat32;
};
type SegmentsDeploymentOptions = record {
  orbiter : opt text;
  mission_control_version : opt text;
  satellite_version : opt text;
};
type SetAccessKey = record {
  metadata : vec record { text; text };
  kind : opt AccessKeyKind;
  scope : AccessKeyScope;
  expires_at : opt nat64;
};
type SetAuthenticationConfig = record {
  openid : opt AuthenticationConfigOpenId;
  version : opt nat64;
  internet_identity : opt AuthenticationConfigInternetIdentity;
  rules : opt AuthenticationRules;
};
type SetAutomationConfig = record {
  openid : opt AutomationConfigOpenId;
  version : opt nat64;
};
type SetControllersArgs = record {
  controller : SetAccessKey;
  controllers : vec principal;
};
type SetDbConfig = record {
  version : opt nat64;
  max_memory_size : opt ConfigMaxMemorySize;
};
type SetDoc = record {
  data : blob;
  description : opt text;
  version : opt nat64;
};
type SetRule = record {
  max_capacity : opt nat32;
  memory : opt Memory;
  max_size : opt nat;
  read : Permission;
  version : opt nat64;
  mutable_permissions : opt bool;
  rate_config : opt RateConfig;
  write : Permission;
  max_changes_per_user : opt nat32;
};
type SetStorageConfig = record {
  iframe : opt StorageConfigIFrame;
  rewrites : vec record { text; text };
  headers : vec record { text; vec record { text; text } };
  version : opt nat64;
  max_memory_size : opt ConfigMaxMemorySize;
  raw_access : opt StorageConfigRawAccess;
  redirects : opt vec record { text; StorageConfigRedirect };
};
type SetStorageConfigOptions = record { skip_certification : opt bool };
type SetStorageConfigWithOptions = record {
  config : SetStorageConfig;
  options : SetStorageConfigOptions;
};
type SignedDelegation = record { signature : blob; delegation : Delegation };
type StorageConfig = record {
  iframe : opt StorageConfigIFrame;
  updated_at : opt nat64;
  rewrites : vec record { text; text };
  headers : vec record { text; vec record { text; text } };
  created_at : opt nat64;
  version : opt nat64;
  max_memory_size : opt ConfigMaxMemorySize;
  raw_access : opt StorageConfigRawAccess;
  redirects : opt vec record { text; StorageConfigRedirect };
};
type StorageConfigIFrame = variant { Deny; AllowAny; SameOrigin };
type StorageConfigRawAccess = variant { Deny; Allow };
type StorageConfigRedirect = record { status_code : nat16; location : text };
type StreamingCallbackHttpResponse = record {
  token : opt StreamingCallbackToken;
  body : blob;
};
type StreamingCallbackToken = record {
  memory : Memory;
  token : opt text;
  sha256 : opt blob;
  headers : vec record { text; text };
  index : nat64;
  encoding_type : text;
  full_path : text;
};
type StreamingStrategy = variant {
  Callback : record {
    token : StreamingCallbackToken;
    callback : func () -> () query;
  };
};
type TimestampMatcher = variant {
  Equal : nat64;
  Between : record { nat64; nat64 };
  GreaterThan : nat64;
  LessThan : nat64;
};
type UploadChunk = record {
  content : blob;
  batch_id : nat;
  order_id : opt nat;
};
type UploadChunkResult = record { chunk_id : nat };
service : (InitSatelliteArgs) -> {
  authenticate : (AuthenticationArgs) -> (AuthenticateResultResponse);
  authenticate_automation : (AuthenticateAutomationArgs) -> (
      AuthenticateAutomationResultResponse,
    );
  certify_assets_chunk : (CertifyAssetsArgs) -> (CertifyAssetsResult);
  commit_asset_upload : (CommitBatch) -> ();
  commit_proposal : (CommitProposal) -> (null);
  commit_proposal_asset_upload : (CommitBatch) -> ();
  commit_proposal_many_assets_upload : (vec CommitBatch) -> ();
  count_assets : (text, ListParams) -> (nat64) query;
  count_collection_assets : (text) -> (nat64) query;
  count_collection_docs : (text) -> (nat64) query;
  count_docs : (text, ListParams) -> (nat64) query;
  count_proposals : () -> (nat64) query;
  del_asset : (text, text) -> ();
  del_assets : (text) -> ();
  del_controller_self : () -> ();
  del_controllers : (DeleteControllersArgs) -> (
      vec record { principal; AccessKey },
    );
  del_custom_domain : (text) -> ();
  del_doc : (text, text, DelDoc) -> ();
  del_docs : (text) -> ();
  del_filtered_assets : (text, ListParams) -> ();
  del_filtered_docs : (text, ListParams) -> ();
  del_many_assets : (vec record { text; text }) -> ();
  del_many_docs : (vec record { text; text; DelDoc }) -> ();
  del_rule : (CollectionType, text, DelRule) -> ();
  delete_proposal_assets : (DeleteProposalAssets) -> ();
  deposit_cycles : (DepositCyclesArgs) -> ();
  get_asset : (text, text) -> (opt AssetNoContent) query;
  get_auth_config : () -> (opt AuthenticationConfig) query;
  get_automation_config : () -> (opt AutomationConfig) query;
  get_config : () -> (Config);
  get_db_config : () -> (opt DbConfig) query;
  get_delegation : (GetDelegationArgs) -> (GetDelegationResultResponse) query;
  get_doc : (text, text) -> (opt Doc) query;
  get_many_assets : (vec record { text; text }) -> (
      vec record { text; opt AssetNoContent },
    ) query;
  get_many_docs : (vec record { text; text }) -> (
      vec record { text; opt Doc },
    ) query;
  get_proposal : (nat) -> (opt Proposal) query;
  get_rule : (CollectionType, text) -> (opt Rule) query;
  get_storage_config : () -> (StorageConfig) query;
  http_request : (HttpRequest) -> (HttpResponse) query;
  http_request_streaming_callback : (StreamingCallbackToken) -> (
      StreamingCallbackHttpResponse,
    ) query;
  init_asset_upload : (InitAssetKey) -> (InitUploadResult);
  init_proposal : (ProposalType) -> (nat, Proposal);
  init_proposal_asset_upload : (InitAssetKey, nat) -> (InitUploadResult);
  init_proposal_many_assets_upload : (vec InitAssetKey, nat) -> (
      vec record { text; InitUploadResult },
    );
  list_assets : (text, ListParams) -> (ListResults) query;
  list_controllers : () -> (vec record { principal; AccessKey }) query;
  list_custom_domains : () -> (vec record { text; CustomDomain }) query;
  list_docs : (text, ListParams) -> (ListResults_1) query;
  list_proposals : (ListProposalsParams) -> (ListProposalResults) query;
  list_rules : (CollectionType, ListRulesParams) -> (ListRulesResults) query;
  memory_size : () -> (MemorySize) query;
  reject_proposal : (CommitProposal) -> (null);
  set_asset_token : (text, text, opt text) -> ();
  set_auth_config : (SetAuthenticationConfig) -> (AuthenticationConfig);
  set_automation_config : (SetAutomationConfig) -> (AutomationConfig);
  set_controllers : (SetControllersArgs) -> (
      vec record { principal; AccessKey },
    );
  set_custom_domain : (text, opt text) -> ();
  set_db_config : (SetDbConfig) -> (DbConfig);
  set_doc : (text, text, SetDoc) -> (Doc);
  set_many_docs : (vec record { text; text; SetDoc }) -> (
      vec record { text; Doc },
    );
  set_rule : (CollectionType, text, SetRule) -> (Rule);
  set_storage_config : (SetStorageConfig) -> (StorageConfig);
  set_storage_config_with_options : (SetStorageConfigWithOptions) -> (
      StorageConfig,
    );
  submit_proposal : (nat) -> (nat, Proposal);
  switch_storage_system_memory : () -> ();
  upload_asset_chunk : (UploadChunk) -> (UploadChunkResult);
  upload_proposal_asset_chunk : (UploadChunk) -> (UploadChunkResult);
}
