Class: Appwrite::Sites

Inherits:
Service show all
Defined in:
lib/appwrite/services/sites.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Sites

Returns a new instance of Sites.



6
7
8
# File 'lib/appwrite/services/sites.rb', line 6

def initialize(client)
    @client = client
end

Instance Method Details

#create(site_id:, name:, framework:, build_runtime:, enabled: nil, logging: nil, timeout: nil, install_command: nil, build_command: nil, start_command: nil, output_directory: nil, adapter: nil, installation_id: nil, fallback_file: nil, provider_repository_id: nil, provider_branch: nil, provider_silent_mode: nil, provider_root_directory: nil, provider_branches: nil, provider_paths: nil, build_specification: nil, runtime_specification: nil, deployment_retention: nil) ⇒ Site

Create a new site.

Parameters:

  • site_id (String)

    Site ID. Choose a custom ID or generate a random ID with ID.unique(). Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.

  • name (String)

    Site name. Max length: 128 chars.

  • framework (Framework)

    Sites framework.

  • build_runtime (BuildRuntime)

    Runtime to use during build step.

  • []

    enabled Is site enabled? When set to 'disabled', users cannot access the site but Server SDKs with and API key can still access the site. No data is lost when this is toggled.

  • []

    logging When disabled, request logs will exclude logs and errors, and site responses will be slightly faster.

  • timeout (Integer) (defaults to: nil)

    Maximum request time in seconds.

  • install_command (String) (defaults to: nil)

    Install Command.

  • build_command (String) (defaults to: nil)

    Build Command.

  • start_command (String) (defaults to: nil)

    Custom start command. Leave empty to use default.

  • output_directory (String) (defaults to: nil)

    Output Directory for site.

  • adapter (Adapter) (defaults to: nil)

    Framework adapter defining rendering strategy. Allowed values are: static, ssr

  • installation_id (String) (defaults to: nil)

    Appwrite Installation ID for VCS (Version Control System) deployment.

  • fallback_file (String) (defaults to: nil)

    Fallback file for single page application sites.

  • provider_repository_id (String) (defaults to: nil)

    Repository ID of the repo linked to the site.

  • provider_branch (String) (defaults to: nil)

    Production branch for the repo linked to the site.

  • []

    provider_silent_mode Is the VCS (Version Control System) connection in silent mode for the repo linked to the site? In silent mode, comments will not be made on commits and pull requests.

  • provider_root_directory (String) (defaults to: nil)

    Path to site code in the linked repo.

  • provider_branches (Array) (defaults to: nil)

    List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches.

  • provider_paths (Array) (defaults to: nil)

    List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes.

  • build_specification (String) (defaults to: nil)

    Build specification for the site deployments.

  • runtime_specification (String) (defaults to: nil)

    Runtime specification for the SSR executions.

  • deployment_retention (Integer) (defaults to: nil)

    Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept.

Returns:

  • (Site)


69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/appwrite/services/sites.rb', line 69

def create(site_id:, name:, framework:, build_runtime:, enabled: nil, logging: nil, timeout: nil, install_command: nil, build_command: nil, start_command: nil, output_directory: nil, adapter: nil, installation_id: nil, fallback_file: nil, provider_repository_id: nil, provider_branch: nil, provider_silent_mode: nil, provider_root_directory: nil, provider_branches: nil, provider_paths: nil, build_specification: nil, runtime_specification: nil, deployment_retention: nil)
    api_path = '/sites'

    if site_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "siteId"')
    end

    if name.nil?
      raise Appwrite::Exception.new('Missing required parameter: "name"')
    end

    if framework.nil?
      raise Appwrite::Exception.new('Missing required parameter: "framework"')
    end

    if build_runtime.nil?
      raise Appwrite::Exception.new('Missing required parameter: "buildRuntime"')
    end

    api_params = {
        siteId: site_id,
        name: name,
        framework: framework,
        enabled: enabled,
        logging: logging,
        timeout: timeout,
        installCommand: install_command,
        buildCommand: build_command,
        startCommand: start_command,
        outputDirectory: output_directory,
        buildRuntime: build_runtime,
        adapter: adapter,
        installationId: installation_id,
        fallbackFile: fallback_file,
        providerRepositoryId: provider_repository_id,
        providerBranch: provider_branch,
        providerSilentMode: provider_silent_mode,
        providerRootDirectory: provider_root_directory,
        providerBranches: provider_branches,
        providerPaths: provider_paths,
        buildSpecification: build_specification,
        runtimeSpecification: runtime_specification,
        deploymentRetention: deployment_retention,
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

    @client.call(
        method: 'POST',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::Site
    )

end

#create_deployment(site_id:, code:, install_command: nil, build_command: nil, output_directory: nil, activate: nil, on_progress: nil) ⇒ Deployment

Create a new site code deployment. Use this endpoint to upload a new version of your site code. To activate your newly uploaded code, you'll need to update the site's deployment to use your new deployment ID.

Parameters:

  • site_id (String)

    Site ID.

  • code (file)

    Gzip file with your code package. When used with the Appwrite CLI, pass the path to your code directory, and the CLI will automatically package your code. Use a path that is within the current directory.

  • install_command (String) (defaults to: nil)

    Install Commands.

  • build_command (String) (defaults to: nil)

    Build Commands.

  • output_directory (String) (defaults to: nil)

    Output Directory.

  • []

    activate Automatically activate the deployment when it is finished building.

Returns:

  • (Deployment)


417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
# File 'lib/appwrite/services/sites.rb', line 417

def create_deployment(site_id:, code:, install_command: nil, build_command: nil, output_directory: nil, activate: nil, on_progress: nil)
    api_path = '/sites/{siteId}/deployments'
        .gsub('{siteId}', site_id)

    if site_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "siteId"')
    end

    if code.nil?
      raise Appwrite::Exception.new('Missing required parameter: "code"')
    end

    api_params = {
        installCommand: install_command,
        buildCommand: build_command,
        outputDirectory: output_directory,
        code: code,
        activate: activate,
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'multipart/form-data',
        "accept": 'application/json',
    }

    id_param_name = nil
    param_name = 'code'

    @client.chunked_upload(
        path: api_path,
        headers: api_headers,
        params: api_params,
        param_name: param_name,
        id_param_name: id_param_name,
        on_progress: on_progress,
        response_type: Models::Deployment
    )

end

#create_duplicate_deployment(site_id:, deployment_id:) ⇒ Deployment

Create a new build for an existing site deployment. This endpoint allows you to rebuild a deployment with the updated site configuration, including its commands and output directory if they have been modified. The build process will be queued and executed asynchronously. The original deployment's code will be preserved and used for the new build.

Parameters:

  • site_id (String)

    Site ID.

  • deployment_id (String)

    Deployment ID.

Returns:

  • (Deployment)


468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
# File 'lib/appwrite/services/sites.rb', line 468

def create_duplicate_deployment(site_id:, deployment_id:)
    api_path = '/sites/{siteId}/deployments/duplicate'
        .gsub('{siteId}', site_id)

    if site_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "siteId"')
    end

    if deployment_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "deploymentId"')
    end

    api_params = {
        deploymentId: deployment_id,
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

    @client.call(
        method: 'POST',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::Deployment
    )

end

#create_template_deployment(site_id:, repository:, owner:, root_directory:, type:, reference:, activate: nil) ⇒ Deployment

Create a deployment based on a template.

Use this endpoint with combination of listTemplates to find the template details.

Parameters:

  • site_id (String)

    Site ID.

  • repository (String)

    Repository name of the template.

  • owner (String)

    The name of the owner of the template.

  • root_directory (String)

    Path to site code in the template repo.

  • type (TemplateReferenceType)

    Type for the reference provided. Can be commit, branch, or tag

  • reference (String)

    Reference value, can be a commit hash, branch name, or release tag

  • []

    activate Automatically activate the deployment when it is finished building.

Returns:

  • (Deployment)


515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
# File 'lib/appwrite/services/sites.rb', line 515

def create_template_deployment(site_id:, repository:, owner:, root_directory:, type:, reference:, activate: nil)
    api_path = '/sites/{siteId}/deployments/template'
        .gsub('{siteId}', site_id)

    if site_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "siteId"')
    end

    if repository.nil?
      raise Appwrite::Exception.new('Missing required parameter: "repository"')
    end

    if owner.nil?
      raise Appwrite::Exception.new('Missing required parameter: "owner"')
    end

    if root_directory.nil?
      raise Appwrite::Exception.new('Missing required parameter: "rootDirectory"')
    end

    if type.nil?
      raise Appwrite::Exception.new('Missing required parameter: "type"')
    end

    if reference.nil?
      raise Appwrite::Exception.new('Missing required parameter: "reference"')
    end

    api_params = {
        repository: repository,
        owner: owner,
        rootDirectory: root_directory,
        type: type,
        reference: reference,
        activate: activate,
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

    @client.call(
        method: 'POST',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::Deployment
    )

end

#create_variable(site_id:, variable_id:, key:, value:, secret: nil) ⇒ Variable

Create a new site variable. These variables can be accessed during build and runtime (server-side rendering) as environment variables.

Parameters:

  • site_id (String)

    Site unique ID.

  • variable_id (String)

    Variable ID. Choose a custom ID or generate a random ID with ID.unique(). Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.

  • key (String)

    Variable key. Max length: 255 chars.

  • value (String)

    Variable value. Max length: 8192 chars.

  • []

    secret Secret variables can be updated or deleted, but only sites can read them during build and runtime.

Returns:

  • (Variable)


926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
# File 'lib/appwrite/services/sites.rb', line 926

def create_variable(site_id:, variable_id:, key:, value:, secret: nil)
    api_path = '/sites/{siteId}/variables'
        .gsub('{siteId}', site_id)

    if site_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "siteId"')
    end

    if variable_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "variableId"')
    end

    if key.nil?
      raise Appwrite::Exception.new('Missing required parameter: "key"')
    end

    if value.nil?
      raise Appwrite::Exception.new('Missing required parameter: "value"')
    end

    api_params = {
        variableId: variable_id,
        key: key,
        value: value,
        secret: secret,
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

    @client.call(
        method: 'POST',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::Variable
    )

end

#create_vcs_deployment(site_id:, type:, reference:, activate: nil) ⇒ Deployment

Create a deployment when a site is connected to VCS.

This endpoint lets you create deployment from a branch, commit, or a tag.

Parameters:

  • site_id (String)

    Site ID.

  • type (VCSReferenceType)

    Type of reference passed. Allowed values are: branch, commit

  • reference (String)

    VCS reference to create deployment from. Depending on type this can be: branch name, commit hash

  • []

    activate Automatically activate the deployment when it is finished building.

Returns:

  • (Deployment)


578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
# File 'lib/appwrite/services/sites.rb', line 578

def create_vcs_deployment(site_id:, type:, reference:, activate: nil)
    api_path = '/sites/{siteId}/deployments/vcs'
        .gsub('{siteId}', site_id)

    if site_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "siteId"')
    end

    if type.nil?
      raise Appwrite::Exception.new('Missing required parameter: "type"')
    end

    if reference.nil?
      raise Appwrite::Exception.new('Missing required parameter: "reference"')
    end

    api_params = {
        type: type,
        reference: reference,
        activate: activate,
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

    @client.call(
        method: 'POST',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::Deployment
    )

end

#delete(site_id:) ⇒ Object

Delete a site by its unique ID.

Parameters:

  • site_id (String)

    Site ID.

Returns:

  • []



303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
# File 'lib/appwrite/services/sites.rb', line 303

def delete(site_id:)
    api_path = '/sites/{siteId}'
        .gsub('{siteId}', site_id)

    if site_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "siteId"')
    end

    api_params = {
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
    }

    @client.call(
        method: 'DELETE',
        path: api_path,
        headers: api_headers,
        params: api_params,
    )

end

#delete_deployment(site_id:, deployment_id:) ⇒ Object

Delete a site deployment by its unique ID.

Parameters:

  • site_id (String)

    Site ID.

  • deployment_id (String)

    Deployment ID.

Returns:

  • []



659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
# File 'lib/appwrite/services/sites.rb', line 659

def delete_deployment(site_id:, deployment_id:)
    api_path = '/sites/{siteId}/deployments/{deploymentId}'
        .gsub('{siteId}', site_id)
        .gsub('{deploymentId}', deployment_id)

    if site_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "siteId"')
    end

    if deployment_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "deploymentId"')
    end

    api_params = {
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
    }

    @client.call(
        method: 'DELETE',
        path: api_path,
        headers: api_headers,
        params: api_params,
    )

end

#delete_log(site_id:, log_id:) ⇒ Object

Delete a site log by its unique ID.

Parameters:

  • site_id (String)

    Site ID.

  • log_id (String)

    Log ID.

Returns:

  • []



850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
# File 'lib/appwrite/services/sites.rb', line 850

def delete_log(site_id:, log_id:)
    api_path = '/sites/{siteId}/logs/{logId}'
        .gsub('{siteId}', site_id)
        .gsub('{logId}', log_id)

    if site_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "siteId"')
    end

    if log_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "logId"')
    end

    api_params = {
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

    @client.call(
        method: 'DELETE',
        path: api_path,
        headers: api_headers,
        params: api_params,
    )

end

#delete_variable(site_id:, variable_id:) ⇒ Object

Delete a variable by its unique ID.

Parameters:

  • site_id (String)

    Site unique ID.

  • variable_id (String)

    Variable unique ID.

Returns:

  • []



1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
# File 'lib/appwrite/services/sites.rb', line 1056

def delete_variable(site_id:, variable_id:)
    api_path = '/sites/{siteId}/variables/{variableId}'
        .gsub('{siteId}', site_id)
        .gsub('{variableId}', variable_id)

    if site_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "siteId"')
    end

    if variable_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "variableId"')
    end

    api_params = {
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
    }

    @client.call(
        method: 'DELETE',
        path: api_path,
        headers: api_headers,
        params: api_params,
    )

end

#get(site_id:) ⇒ Site

Get a site by its unique ID.

Parameters:

  • site_id (String)

    Site ID.

Returns:

  • (Site)


188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
# File 'lib/appwrite/services/sites.rb', line 188

def get(site_id:)
    api_path = '/sites/{siteId}'
        .gsub('{siteId}', site_id)

    if site_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "siteId"')
    end

    api_params = {
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "accept": 'application/json',
    }

    @client.call(
        method: 'GET',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::Site
    )

end

#get_deployment(site_id:, deployment_id:) ⇒ Deployment

Get a site deployment by its unique ID.

Parameters:

  • site_id (String)

    Site ID.

  • deployment_id (String)

    Deployment ID.

Returns:

  • (Deployment)


622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
# File 'lib/appwrite/services/sites.rb', line 622

def get_deployment(site_id:, deployment_id:)
    api_path = '/sites/{siteId}/deployments/{deploymentId}'
        .gsub('{siteId}', site_id)
        .gsub('{deploymentId}', deployment_id)

    if site_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "siteId"')
    end

    if deployment_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "deploymentId"')
    end

    api_params = {
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "accept": 'application/json',
    }

    @client.call(
        method: 'GET',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::Deployment
    )

end

#get_deployment_download(site_id:, deployment_id:, type: nil) ⇒ Object

Get a site deployment content by its unique ID. The endpoint response return with a 'Content-Disposition: attachment' header that tells the browser to start downloading the file to user downloads directory.

Parameters:

  • site_id (String)

    Site ID.

  • deployment_id (String)

    Deployment ID.

  • type (DeploymentDownloadType) (defaults to: nil)

    Deployment file to download. Can be: "source", "output".

Returns:

  • []



698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
# File 'lib/appwrite/services/sites.rb', line 698

def get_deployment_download(site_id:, deployment_id:, type: nil)
    api_path = '/sites/{siteId}/deployments/{deploymentId}/download'
        .gsub('{siteId}', site_id)
        .gsub('{deploymentId}', deployment_id)

    if site_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "siteId"')
    end

    if deployment_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "deploymentId"')
    end

    api_params = {
        type: type,
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "accept": '*/*',
    }

    @client.call(
        method: 'GET',
        path: api_path,
        headers: api_headers,
        params: api_params,
    )

end

#get_log(site_id:, log_id:) ⇒ Execution

Get a site request log by its unique ID.

Parameters:

  • site_id (String)

    Site ID.

  • log_id (String)

    Log ID.

Returns:

  • (Execution)


813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
# File 'lib/appwrite/services/sites.rb', line 813

def get_log(site_id:, log_id:)
    api_path = '/sites/{siteId}/logs/{logId}'
        .gsub('{siteId}', site_id)
        .gsub('{logId}', log_id)

    if site_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "siteId"')
    end

    if log_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "logId"')
    end

    api_params = {
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "accept": 'application/json',
    }

    @client.call(
        method: 'GET',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::Execution
    )

end

#get_variable(site_id:, variable_id:) ⇒ Variable

Get a variable by its unique ID.

Parameters:

  • site_id (String)

    Site unique ID.

  • variable_id (String)

    Variable unique ID.

Returns:

  • (Variable)


975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
# File 'lib/appwrite/services/sites.rb', line 975

def get_variable(site_id:, variable_id:)
    api_path = '/sites/{siteId}/variables/{variableId}'
        .gsub('{siteId}', site_id)
        .gsub('{variableId}', variable_id)

    if site_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "siteId"')
    end

    if variable_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "variableId"')
    end

    api_params = {
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "accept": 'application/json',
    }

    @client.call(
        method: 'GET',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::Variable
    )

end

#list(queries: nil, search: nil, total: nil) ⇒ SiteList

Get a list of all the project's sites. You can use the query params to filter your results.

Parameters:

  • queries (Array) (defaults to: nil)

    Array of query strings generated using the Query class provided by the SDK. Learn more about queries. Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, enabled, framework, deploymentId, buildCommand, installCommand, outputDirectory, installationId

  • search (String) (defaults to: nil)

    Search term to filter your list results. Max length: 256 chars.

  • []

    total When set to false, the total count returned will be 0 and will not be calculated.

Returns:

  • (SiteList)


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/appwrite/services/sites.rb', line 18

def list(queries: nil, search: nil, total: nil)
    api_path = '/sites'

    api_params = {
        queries: queries,
        search: search,
        total: total,
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "accept": 'application/json',
    }

    @client.call(
        method: 'GET',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::SiteList
    )

end

#list_deployments(site_id:, queries: nil, search: nil, total: nil) ⇒ DeploymentList

Get a list of all the site's code deployments. You can use the query params to filter your results.

Parameters:

  • site_id (String)

    Site ID.

  • queries (Array) (defaults to: nil)

    Array of query strings generated using the Query class provided by the SDK. Learn more about queries. Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: buildSize, sourceSize, totalSize, buildDuration, status, activate, type

  • search (String) (defaults to: nil)

    Search term to filter your list results. Max length: 256 chars.

  • []

    total When set to false, the total count returned will be 0 and will not be calculated.

Returns:

  • (DeploymentList)


376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
# File 'lib/appwrite/services/sites.rb', line 376

def list_deployments(site_id:, queries: nil, search: nil, total: nil)
    api_path = '/sites/{siteId}/deployments'
        .gsub('{siteId}', site_id)

    if site_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "siteId"')
    end

    api_params = {
        queries: queries,
        search: search,
        total: total,
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "accept": 'application/json',
    }

    @client.call(
        method: 'GET',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::DeploymentList
    )

end

#list_frameworksFrameworkList

Get a list of all frameworks that are currently available on the server instance.

Returns:

  • (FrameworkList)


135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/appwrite/services/sites.rb', line 135

def list_frameworks()
    api_path = '/sites/frameworks'

    api_params = {
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "accept": 'application/json',
    }

    @client.call(
        method: 'GET',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::FrameworkList
    )

end

#list_logs(site_id:, queries: nil, total: nil) ⇒ ExecutionList

Get a list of all site logs. You can use the query params to filter your results.

Parameters:

  • site_id (String)

    Site ID.

  • queries (Array) (defaults to: nil)

    Array of query strings generated using the Query class provided by the SDK. Learn more about queries. Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: trigger, status, responseStatusCode, duration, requestMethod, requestPath, deploymentId

  • []

    total When set to false, the total count returned will be 0 and will not be calculated.

Returns:

  • (ExecutionList)


779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
# File 'lib/appwrite/services/sites.rb', line 779

def list_logs(site_id:, queries: nil, total: nil)
    api_path = '/sites/{siteId}/logs'
        .gsub('{siteId}', site_id)

    if site_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "siteId"')
    end

    api_params = {
        queries: queries,
        total: total,
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "accept": 'application/json',
    }

    @client.call(
        method: 'GET',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::ExecutionList
    )

end

#list_specifications(type: nil) ⇒ SpecificationList

List allowed site specifications for this instance.

Parameters:

  • type (String) (defaults to: nil)

    Specification type to list. Can be one of: runtimes, builds.

Returns:

  • (SpecificationList)


161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/appwrite/services/sites.rb', line 161

def list_specifications(type: nil)
    api_path = '/sites/specifications'

    api_params = {
        type: type,
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "accept": 'application/json',
    }

    @client.call(
        method: 'GET',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::SpecificationList
    )

end

#list_variables(site_id:, queries: nil, total: nil) ⇒ VariableList

Get a list of all variables of a specific site.

Parameters:

  • site_id (String)

    Site unique ID.

  • queries (Array) (defaults to: nil)

    Array of query strings generated using the Query class provided by the SDK. Learn more about queries. Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key, resourceType, resourceId, secret

  • []

    total When set to false, the total count returned will be 0 and will not be calculated.

Returns:

  • (VariableList)


888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
# File 'lib/appwrite/services/sites.rb', line 888

def list_variables(site_id:, queries: nil, total: nil)
    api_path = '/sites/{siteId}/variables'
        .gsub('{siteId}', site_id)

    if site_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "siteId"')
    end

    api_params = {
        queries: queries,
        total: total,
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "accept": 'application/json',
    }

    @client.call(
        method: 'GET',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::VariableList
    )

end

#update(site_id:, name:, framework:, enabled: nil, logging: nil, timeout: nil, install_command: nil, build_command: nil, start_command: nil, output_directory: nil, build_runtime: nil, adapter: nil, fallback_file: nil, installation_id: nil, provider_repository_id: nil, provider_branch: nil, provider_silent_mode: nil, provider_root_directory: nil, provider_branches: nil, provider_paths: nil, build_specification: nil, runtime_specification: nil, deployment_retention: nil) ⇒ Site

Update site by its unique ID.

Parameters:

  • site_id (String)

    Site ID.

  • name (String)

    Site name. Max length: 128 chars.

  • framework (Framework)

    Sites framework.

  • []

    enabled Is site enabled? When set to 'disabled', users cannot access the site but Server SDKs with and API key can still access the site. No data is lost when this is toggled.

  • []

    logging When disabled, request logs will exclude logs and errors, and site responses will be slightly faster.

  • timeout (Integer) (defaults to: nil)

    Maximum request time in seconds.

  • install_command (String) (defaults to: nil)

    Install Command.

  • build_command (String) (defaults to: nil)

    Build Command.

  • start_command (String) (defaults to: nil)

    Custom start command. Leave empty to use default.

  • output_directory (String) (defaults to: nil)

    Output Directory for site.

  • build_runtime (BuildRuntime) (defaults to: nil)

    Runtime to use during build step.

  • adapter (Adapter) (defaults to: nil)

    Framework adapter defining rendering strategy. Allowed values are: static, ssr

  • fallback_file (String) (defaults to: nil)

    Fallback file for single page application sites.

  • installation_id (String) (defaults to: nil)

    Appwrite Installation ID for VCS (Version Control System) deployment.

  • provider_repository_id (String) (defaults to: nil)

    Repository ID of the repo linked to the site.

  • provider_branch (String) (defaults to: nil)

    Production branch for the repo linked to the site.

  • []

    provider_silent_mode Is the VCS (Version Control System) connection in silent mode for the repo linked to the site? In silent mode, comments will not be made on commits and pull requests.

  • provider_root_directory (String) (defaults to: nil)

    Path to site code in the linked repo.

  • provider_branches (Array) (defaults to: nil)

    List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches.

  • provider_paths (Array) (defaults to: nil)

    List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes.

  • build_specification (String) (defaults to: nil)

    Build specification for the site deployments.

  • runtime_specification (String) (defaults to: nil)

    Runtime specification for the SSR executions.

  • deployment_retention (Integer) (defaults to: nil)

    Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept.

Returns:

  • (Site)


241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
# File 'lib/appwrite/services/sites.rb', line 241

def update(site_id:, name:, framework:, enabled: nil, logging: nil, timeout: nil, install_command: nil, build_command: nil, start_command: nil, output_directory: nil, build_runtime: nil, adapter: nil, fallback_file: nil, installation_id: nil, provider_repository_id: nil, provider_branch: nil, provider_silent_mode: nil, provider_root_directory: nil, provider_branches: nil, provider_paths: nil, build_specification: nil, runtime_specification: nil, deployment_retention: nil)
    api_path = '/sites/{siteId}'
        .gsub('{siteId}', site_id)

    if site_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "siteId"')
    end

    if name.nil?
      raise Appwrite::Exception.new('Missing required parameter: "name"')
    end

    if framework.nil?
      raise Appwrite::Exception.new('Missing required parameter: "framework"')
    end

    api_params = {
        name: name,
        framework: framework,
        enabled: enabled,
        logging: logging,
        timeout: timeout,
        installCommand: install_command,
        buildCommand: build_command,
        startCommand: start_command,
        outputDirectory: output_directory,
        buildRuntime: build_runtime,
        adapter: adapter,
        fallbackFile: fallback_file,
        installationId: installation_id,
        providerRepositoryId: provider_repository_id,
        providerBranch: provider_branch,
        providerSilentMode: provider_silent_mode,
        providerRootDirectory: provider_root_directory,
        providerBranches: provider_branches,
        providerPaths: provider_paths,
        buildSpecification: build_specification,
        runtimeSpecification: runtime_specification,
        deploymentRetention: deployment_retention,
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

    @client.call(
        method: 'PUT',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::Site
    )

end

#update_deployment_status(site_id:, deployment_id:) ⇒ Deployment

Cancel an ongoing site deployment build. If the build is already in progress, it will be stopped and marked as canceled. If the build hasn't started yet, it will be marked as canceled without executing. You cannot cancel builds that have already completed (status 'ready') or failed. The response includes the final build status and details.

Parameters:

  • site_id (String)

    Site ID.

  • deployment_id (String)

    Deployment ID.

Returns:

  • (Deployment)


739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
# File 'lib/appwrite/services/sites.rb', line 739

def update_deployment_status(site_id:, deployment_id:)
    api_path = '/sites/{siteId}/deployments/{deploymentId}/status'
        .gsub('{siteId}', site_id)
        .gsub('{deploymentId}', deployment_id)

    if site_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "siteId"')
    end

    if deployment_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "deploymentId"')
    end

    api_params = {
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

    @client.call(
        method: 'PATCH',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::Deployment
    )

end

#update_site_deployment(site_id:, deployment_id:) ⇒ Site

Update the site active deployment. Use this endpoint to switch the code deployment that should be used when visitor opens your site.

Parameters:

  • site_id (String)

    Site ID.

  • deployment_id (String)

    Deployment ID.

Returns:

  • (Site)


335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
# File 'lib/appwrite/services/sites.rb', line 335

def update_site_deployment(site_id:, deployment_id:)
    api_path = '/sites/{siteId}/deployment'
        .gsub('{siteId}', site_id)

    if site_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "siteId"')
    end

    if deployment_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "deploymentId"')
    end

    api_params = {
        deploymentId: deployment_id,
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

    @client.call(
        method: 'PATCH',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::Site
    )

end

#update_variable(site_id:, variable_id:, key: nil, value: nil, secret: nil) ⇒ Variable

Update variable by its unique ID.

Parameters:

  • site_id (String)

    Site unique ID.

  • variable_id (String)

    Variable unique ID.

  • key (String) (defaults to: nil)

    Variable key. Max length: 255 chars.

  • value (String) (defaults to: nil)

    Variable value. Max length: 8192 chars.

  • []

    secret Secret variables can be updated or deleted, but only sites can read them during build and runtime.

Returns:

  • (Variable)


1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
# File 'lib/appwrite/services/sites.rb', line 1015

def update_variable(site_id:, variable_id:, key: nil, value: nil, secret: nil)
    api_path = '/sites/{siteId}/variables/{variableId}'
        .gsub('{siteId}', site_id)
        .gsub('{variableId}', variable_id)

    if site_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "siteId"')
    end

    if variable_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "variableId"')
    end

    api_params = {
        key: key,
        value: value,
        secret: secret,
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

    @client.call(
        method: 'PUT',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::Variable
    )

end