22
33from __future__ import annotations
44
5- from typing import Type , Optional , cast
5+ from typing import Type , Mapping , Optional , cast
66from typing_extensions import Literal
77
88import httpx
99
10- from ....._types import Body , Omit , Query , Headers , NotGiven , omit , not_given
11- from ....._utils import maybe_transform , async_maybe_transform
10+ from ....._types import Body , Omit , Query , Headers , NotGiven , FileTypes , omit , not_given
11+ from ....._utils import extract_files , maybe_transform , deepcopy_minimal , async_maybe_transform
1212from ....._compat import cached_property
1313from ....._resource import SyncAPIResource , AsyncAPIResource
1414from ....._response import (
@@ -68,7 +68,19 @@ def create(
6868 project_name : str ,
6969 * ,
7070 account_id : str ,
71+ _headers : FileTypes | Omit = omit ,
72+ _redirects : FileTypes | Omit = omit ,
73+ _routes_json : FileTypes | Omit = omit ,
74+ _worker_bundle : FileTypes | Omit = omit ,
75+ _worker_js : FileTypes | Omit = omit ,
7176 branch : str | Omit = omit ,
77+ commit_dirty : Literal ["true" , "false" ] | Omit = omit ,
78+ commit_hash : str | Omit = omit ,
79+ commit_message : str | Omit = omit ,
80+ functions_filepath_routing_config_json : FileTypes | Omit = omit ,
81+ manifest : str | Omit = omit ,
82+ pages_build_output_dir : str | Omit = omit ,
83+ wrangler_config_hash : str | Omit = omit ,
7284 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
7385 # The extra values given here take precedence over values defined on the client or passed to this method.
7486 extra_headers : Headers | None = None ,
@@ -86,9 +98,37 @@ def create(
8698
8799 project_name: Name of the project.
88100
101+ _headers: Headers configuration file for the deployment.
102+
103+ _redirects: Redirects configuration file for the deployment.
104+
105+ _routes_json: Routes configuration file defining routing rules.
106+
107+ _worker_bundle: Worker bundle file in multipart/form-data format. Mutually exclusive with
108+ `_worker.js`. Cannot specify both `_worker.js` and `_worker.bundle` in the same
109+ request. Maximum size: 25 MiB.
110+
111+ _worker_js: Worker JavaScript file. Mutually exclusive with `_worker.bundle`. Cannot specify
112+ both `_worker.js` and `_worker.bundle` in the same request.
113+
89114 branch: The branch to build the new deployment from. The `HEAD` of the branch will be
90115 used. If omitted, the production branch will be used by default.
91116
117+ commit_dirty: Boolean string indicating if the working directory has uncommitted changes.
118+
119+ commit_hash: Git commit SHA associated with this deployment.
120+
121+ commit_message: Git commit message associated with this deployment.
122+
123+ functions_filepath_routing_config_json: Functions routing configuration file.
124+
125+ manifest: JSON string containing a manifest of files to deploy. Maps file paths to their
126+ content hashes. Required for direct upload deployments. Maximum 20,000 entries.
127+
128+ pages_build_output_dir: The build output directory path.
129+
130+ wrangler_config_hash: Hash of the Wrangler configuration file used for this deployment.
131+
92132 extra_headers: Send extra headers
93133
94134 extra_query: Add additional query parameters to the request
@@ -101,13 +141,42 @@ def create(
101141 raise ValueError (f"Expected a non-empty value for `account_id` but received { account_id !r} " )
102142 if not project_name :
103143 raise ValueError (f"Expected a non-empty value for `project_name` but received { project_name !r} " )
144+ body = deepcopy_minimal (
145+ {
146+ "_headers" : _headers ,
147+ "_redirects" : _redirects ,
148+ "_routes_json" : _routes_json ,
149+ "_worker_bundle" : _worker_bundle ,
150+ "_worker_js" : _worker_js ,
151+ "branch" : branch ,
152+ "commit_dirty" : commit_dirty ,
153+ "commit_hash" : commit_hash ,
154+ "commit_message" : commit_message ,
155+ "functions_filepath_routing_config_json" : functions_filepath_routing_config_json ,
156+ "manifest" : manifest ,
157+ "pages_build_output_dir" : pages_build_output_dir ,
158+ "wrangler_config_hash" : wrangler_config_hash ,
159+ }
160+ )
161+ files = extract_files (
162+ cast (Mapping [str , object ], body ),
163+ paths = [
164+ ["_headers" ],
165+ ["_redirects" ],
166+ ["_routes.json" ],
167+ ["_worker.bundle" ],
168+ ["_worker.js" ],
169+ ["functions-filepath-routing-config.json" ],
170+ ],
171+ )
104172 # It should be noted that the actual Content-Type header that will be
105173 # sent to the server will contain a `boundary` parameter, e.g.
106174 # multipart/form-data; boundary=---abc--
107175 extra_headers = {"Content-Type" : "multipart/form-data" , ** (extra_headers or {})}
108176 return self ._post (
109177 f"/accounts/{ account_id } /pages/projects/{ project_name } /deployments" ,
110- body = maybe_transform ({"branch" : branch }, deployment_create_params .DeploymentCreateParams ),
178+ body = maybe_transform (body , deployment_create_params .DeploymentCreateParams ),
179+ files = files ,
111180 options = make_request_options (
112181 extra_headers = extra_headers ,
113182 extra_query = extra_query ,
@@ -398,7 +467,19 @@ async def create(
398467 project_name : str ,
399468 * ,
400469 account_id : str ,
470+ _headers : FileTypes | Omit = omit ,
471+ _redirects : FileTypes | Omit = omit ,
472+ _routes_json : FileTypes | Omit = omit ,
473+ _worker_bundle : FileTypes | Omit = omit ,
474+ _worker_js : FileTypes | Omit = omit ,
401475 branch : str | Omit = omit ,
476+ commit_dirty : Literal ["true" , "false" ] | Omit = omit ,
477+ commit_hash : str | Omit = omit ,
478+ commit_message : str | Omit = omit ,
479+ functions_filepath_routing_config_json : FileTypes | Omit = omit ,
480+ manifest : str | Omit = omit ,
481+ pages_build_output_dir : str | Omit = omit ,
482+ wrangler_config_hash : str | Omit = omit ,
402483 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
403484 # The extra values given here take precedence over values defined on the client or passed to this method.
404485 extra_headers : Headers | None = None ,
@@ -416,9 +497,37 @@ async def create(
416497
417498 project_name: Name of the project.
418499
500+ _headers: Headers configuration file for the deployment.
501+
502+ _redirects: Redirects configuration file for the deployment.
503+
504+ _routes_json: Routes configuration file defining routing rules.
505+
506+ _worker_bundle: Worker bundle file in multipart/form-data format. Mutually exclusive with
507+ `_worker.js`. Cannot specify both `_worker.js` and `_worker.bundle` in the same
508+ request. Maximum size: 25 MiB.
509+
510+ _worker_js: Worker JavaScript file. Mutually exclusive with `_worker.bundle`. Cannot specify
511+ both `_worker.js` and `_worker.bundle` in the same request.
512+
419513 branch: The branch to build the new deployment from. The `HEAD` of the branch will be
420514 used. If omitted, the production branch will be used by default.
421515
516+ commit_dirty: Boolean string indicating if the working directory has uncommitted changes.
517+
518+ commit_hash: Git commit SHA associated with this deployment.
519+
520+ commit_message: Git commit message associated with this deployment.
521+
522+ functions_filepath_routing_config_json: Functions routing configuration file.
523+
524+ manifest: JSON string containing a manifest of files to deploy. Maps file paths to their
525+ content hashes. Required for direct upload deployments. Maximum 20,000 entries.
526+
527+ pages_build_output_dir: The build output directory path.
528+
529+ wrangler_config_hash: Hash of the Wrangler configuration file used for this deployment.
530+
422531 extra_headers: Send extra headers
423532
424533 extra_query: Add additional query parameters to the request
@@ -431,13 +540,42 @@ async def create(
431540 raise ValueError (f"Expected a non-empty value for `account_id` but received { account_id !r} " )
432541 if not project_name :
433542 raise ValueError (f"Expected a non-empty value for `project_name` but received { project_name !r} " )
543+ body = deepcopy_minimal (
544+ {
545+ "_headers" : _headers ,
546+ "_redirects" : _redirects ,
547+ "_routes_json" : _routes_json ,
548+ "_worker_bundle" : _worker_bundle ,
549+ "_worker_js" : _worker_js ,
550+ "branch" : branch ,
551+ "commit_dirty" : commit_dirty ,
552+ "commit_hash" : commit_hash ,
553+ "commit_message" : commit_message ,
554+ "functions_filepath_routing_config_json" : functions_filepath_routing_config_json ,
555+ "manifest" : manifest ,
556+ "pages_build_output_dir" : pages_build_output_dir ,
557+ "wrangler_config_hash" : wrangler_config_hash ,
558+ }
559+ )
560+ files = extract_files (
561+ cast (Mapping [str , object ], body ),
562+ paths = [
563+ ["_headers" ],
564+ ["_redirects" ],
565+ ["_routes.json" ],
566+ ["_worker.bundle" ],
567+ ["_worker.js" ],
568+ ["functions-filepath-routing-config.json" ],
569+ ],
570+ )
434571 # It should be noted that the actual Content-Type header that will be
435572 # sent to the server will contain a `boundary` parameter, e.g.
436573 # multipart/form-data; boundary=---abc--
437574 extra_headers = {"Content-Type" : "multipart/form-data" , ** (extra_headers or {})}
438575 return await self ._post (
439576 f"/accounts/{ account_id } /pages/projects/{ project_name } /deployments" ,
440- body = await async_maybe_transform ({"branch" : branch }, deployment_create_params .DeploymentCreateParams ),
577+ body = await async_maybe_transform (body , deployment_create_params .DeploymentCreateParams ),
578+ files = files ,
441579 options = make_request_options (
442580 extra_headers = extra_headers ,
443581 extra_query = extra_query ,
0 commit comments